Skip to content

Commit

Permalink
Fixed gradient GPU kernel defines in case of master-slave mode and ze…
Browse files Browse the repository at this point in the history
…ro moment

Change-Id: I0704efe2662ef835341fd7fae00405d9407aee88
  • Loading branch information
ajkxyz committed Apr 17, 2015
1 parent b3486b2 commit 92d8bf2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions gd.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,14 @@ def initialize(self, device, **kwargs):
raise ValueError("Some of the solvers need moment vectors")

def _gpu_init(self, defines):
dtype = self.err_output.mem.dtype
dtype = self.err_output.dtype
self.cl_const = numpy.zeros(9, dtype=dtype)

side = self.weights_shape[0]
other = self.weights.size // side
assert side == self.err_output.sample_size
assert other == self.input.sample_size
batch = self.input.mem.shape[0]
batch = self.input.shape[0]
defines.update({
"H": other,
"Y": side,
Expand All @@ -224,13 +224,13 @@ def _gpu_init(self, defines):

self.sources_["all2all/gradient_descent/weights_update"] = {
"USE_ORTHO": int(bool(self.factor_ortho)),
"USE_MOMENT": int(bool(self.gradient_moment))
"USE_MOMENT": int(bool(self.gradient_weights_with_moment))
}

self.sources_["all2all/gradient_descent/bias_update"] = {
"BIAS_SIZE": side,
"OUTPUT_SIZE": batch,
"USE_MOMENT": int(bool(self.gradient_moment_bias))
"USE_MOMENT": int(bool(self.gradient_bias_with_moment))
}

self.build_program(defines, "%s_%d_%d_%d" % (
Expand Down
4 changes: 2 additions & 2 deletions gd_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,15 @@ def ocl_init(self):
self.sources_["conv/gradient_descent/weights_update"] = {
"BLOCK_SIZE": block_size,
"USE_ORTHO": int(bool(self.factor_ortho)),
"USE_MOMENT": int(bool(self.gradient_moment))
"USE_MOMENT": int(bool(self.gradient_weights_with_moment))
}
self._global_size_weights = [
roundup(b_width, block_size),
roundup(a_width, block_size)]
self._local_size_weights = [block_size, block_size]

self.sources_["conv/gradient_descent/bias_update"] = {
"USE_MOMENT": int(bool(self.gradient_moment_bias))
"USE_MOMENT": int(bool(self.gradient_bias_with_moment))
}
self._global_size_bias = [self.n_kernels * self.reduce_size]
self._local_size_bias = [self.reduce_size]
Expand Down
2 changes: 1 addition & 1 deletion gd_deconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def ocl_init(self):
self.sources_["deconv/gradient_descent/weights_update"] = {
"BLOCK_SIZE": block_size_weights,
"USE_ORTHO": int(bool(self.factor_ortho)),
'USE_MOMENT': int(bool(self.gradient_moment))
'USE_MOMENT': int(bool(self.gradient_weights_with_moment))
}

self._gpu_init({})
Expand Down

0 comments on commit 92d8bf2

Please sign in to comment.