提交 2e3d841e authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Flake8 for nnet.py

上级 b6f9a5bd
...@@ -5,9 +5,11 @@ import os ...@@ -5,9 +5,11 @@ import os
from theano import Op, Apply, config from theano import Op, Apply, config
from six import StringIO from six import StringIO
from theano.gof.util import MethodNotDefined
try: try:
import pygpu import pygpu
from pygpu import gpuarray, elemwise from pygpu import gpuarray
except ImportError: except ImportError:
pass pass
...@@ -665,15 +667,15 @@ class GpuSoftmax(GpuKernelBase, Op): ...@@ -665,15 +667,15 @@ class GpuSoftmax(GpuKernelBase, Op):
] ]
kernels = [] kernels = []
kname = "kSoftmax" kname = "kSoftmax"
k_var= "kSoftmax_" + nodename k_var = "kSoftmax_" + nodename
code = nvcc_kernel(kname, code = nvcc_kernel(
kname,
params=['const ga_size M', 'const ga_size N', params=['const ga_size M', 'const ga_size N',
'const %s * x' % type_x, 'const ga_size offset_x', 'const %s * x' % type_x, 'const ga_size offset_x',
'const ga_ssize sx0', 'const ga_ssize sx1', 'const ga_ssize sx0', 'const ga_ssize sx1',
'%s * sm' % type_sm, 'const ga_size offset_sm', '%s * sm' % type_sm, 'const ga_size offset_sm',
'const ga_ssize sm_s0', 'const ga_ssize sm_s1'], 'const ga_ssize sm_s0', 'const ga_ssize sm_s1'],
body=[ body=["extern __shared__ %s buf[]" % type_acc,
"extern __shared__ %s buf[]" % type_acc,
"%s * buf2 = buf + N" % type_acc, "%s * buf2 = buf + N" % type_acc,
"x = (const %s *)(((char *)x)+offset_x)" % type_x, "x = (const %s *)(((char *)x)+offset_x)" % type_x,
"sm = (%s *)(((char *)sm)+offset_sm)" % type_sm, "sm = (%s *)(((char *)sm)+offset_sm)" % type_sm,
...@@ -696,15 +698,15 @@ class GpuSoftmax(GpuKernelBase, Op): ...@@ -696,15 +698,15 @@ class GpuSoftmax(GpuKernelBase, Op):
kernels.append(Kernel(code=code, name=kname, params=params, kernels.append(Kernel(code=code, name=kname, params=params,
flags=flags, objvar=k_var)) flags=flags, objvar=k_var))
kname = "kSoftmax_fixed_shared" kname = "kSoftmax_fixed_shared"
k_var= "kSoftmax_fixed_shared" + nodename k_var = "kSoftmax_fixed_shared" + nodename
code = nvcc_kernel(kname, code = nvcc_kernel(
kname,
params=['const ga_size M', 'const ga_size N', params=['const ga_size M', 'const ga_size N',
'const %s * x' % type_x, 'const ga_size offset_x', 'const %s * x' % type_x, 'const ga_size offset_x',
'const ga_ssize sx0', 'const ga_ssize sx1', 'const ga_ssize sx0', 'const ga_ssize sx1',
'%s * sm' % type_sm, 'const ga_size offset_sm', '%s * sm' % type_sm, 'const ga_size offset_sm',
'const ga_ssize sm_s0', 'const ga_ssize sm_s1'], 'const ga_ssize sm_s0', 'const ga_ssize sm_s1'],
body=[ body=["extern __shared__ %s buf[]" % type_acc,
"extern __shared__ %s buf[]" % type_acc,
"x = (const %s *)(((char *)x)+offset_x)" % type_x, "x = (const %s *)(((char *)x)+offset_x)" % type_x,
"sm = (%s *)(((char *)sm)+offset_sm)" % type_sm, "sm = (%s *)(((char *)sm)+offset_sm)" % type_sm,
"for (int blockIDX = blockIdx.x; blockIDX < M;" "for (int blockIDX = blockIdx.x; blockIDX < M;"
...@@ -892,7 +894,8 @@ class GpuSoftmaxWithBias (GpuKernelBase, Op): ...@@ -892,7 +894,8 @@ class GpuSoftmaxWithBias (GpuKernelBase, Op):
kernels = [] kernels = []
kname = "kSoftmaxWithBias" kname = "kSoftmaxWithBias"
k_var = "kSoftmaxWithBias_" + nodename k_var = "kSoftmaxWithBias_" + nodename
code = nvcc_kernel(kname, code = nvcc_kernel(
kname,
params=['const ga_size M', 'const ga_size N', params=['const ga_size M', 'const ga_size N',
'const %s * x' % type_x, 'const ga_size offset_x', 'const %s * x' % type_x, 'const ga_size offset_x',
'const ga_ssize sx0', 'const ga_ssize sx1', 'const ga_ssize sx0', 'const ga_ssize sx1',
...@@ -900,8 +903,7 @@ class GpuSoftmaxWithBias (GpuKernelBase, Op): ...@@ -900,8 +903,7 @@ class GpuSoftmaxWithBias (GpuKernelBase, Op):
'const ga_ssize sb0', 'const ga_ssize sb0',
'%s * sm' % type_sm, 'const ga_size offset_sm', '%s * sm' % type_sm, 'const ga_size offset_sm',
'const ga_ssize sm_s0', 'const ga_ssize sm_s1'], 'const ga_ssize sm_s0', 'const ga_ssize sm_s1'],
body=[ body=["extern __shared__ %s buf[]" % type_acc,
"extern __shared__ %s buf[]" % type_acc,
"%s * buf2 = buf + N" % type_acc, "%s * buf2 = buf + N" % type_acc,
"x = (const %s *)(((char *)x)+offset_x)" % type_x, "x = (const %s *)(((char *)x)+offset_x)" % type_x,
"b = (const %s *)(((char *)b)+offset_b)" % type_b, "b = (const %s *)(((char *)b)+offset_b)" % type_b,
...@@ -926,7 +928,8 @@ class GpuSoftmaxWithBias (GpuKernelBase, Op): ...@@ -926,7 +928,8 @@ class GpuSoftmaxWithBias (GpuKernelBase, Op):
flags=flags, objvar=k_var)) flags=flags, objvar=k_var))
kname = "kSoftmaxWithBias_fixed_shared" kname = "kSoftmaxWithBias_fixed_shared"
k_var = "kSoftmaxWithBias_fixed_shared" + nodename k_var = "kSoftmaxWithBias_fixed_shared" + nodename
code = nvcc_kernel(kname, code = nvcc_kernel(
kname,
params=['const ga_size M', 'const ga_size N', params=['const ga_size M', 'const ga_size N',
'const %s * x' % type_x, 'const ga_size offset_x', 'const %s * x' % type_x, 'const ga_size offset_x',
'const ga_ssize sx0', 'const ga_ssize sx1', 'const ga_ssize sx0', 'const ga_ssize sx1',
...@@ -934,8 +937,7 @@ class GpuSoftmaxWithBias (GpuKernelBase, Op): ...@@ -934,8 +937,7 @@ class GpuSoftmaxWithBias (GpuKernelBase, Op):
'const ga_ssize sb0', 'const ga_ssize sb0',
'%s * sm' % type_sm, 'const ga_size offset_sm', '%s * sm' % type_sm, 'const ga_size offset_sm',
'const ga_ssize sm_s0', 'const ga_ssize sm_s1'], 'const ga_ssize sm_s0', 'const ga_ssize sm_s1'],
body=[ body=["extern __shared__ %s buf[]" % type_acc,
"extern __shared__ %s buf[]" % type_acc,
"x = (const %s *)(((char *)x)+offset_x)" % type_x, "x = (const %s *)(((char *)x)+offset_x)" % type_x,
"b = (const %s *)(((char *)b)+offset_b)" % type_b, "b = (const %s *)(((char *)b)+offset_b)" % type_b,
"sm = (%s *)(((char *)sm)+offset_sm)" % type_sm, "sm = (%s *)(((char *)sm)+offset_sm)" % type_sm,
......
...@@ -157,7 +157,6 @@ whitelist_flake8 = [ ...@@ -157,7 +157,6 @@ whitelist_flake8 = [
"sandbox/linalg/ops.py", "sandbox/linalg/ops.py",
"sandbox/linalg/__init__.py", "sandbox/linalg/__init__.py",
"sandbox/linalg/tests/test_linalg.py", "sandbox/linalg/tests/test_linalg.py",
"sandbox/gpuarray/nnet.py",
"sandbox/gpuarray/elemwise.py", "sandbox/gpuarray/elemwise.py",
"sandbox/gpuarray/type.py", "sandbox/gpuarray/type.py",
"sandbox/gpuarray/__init__.py", "sandbox/gpuarray/__init__.py",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论