Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f09999ce
提交
f09999ce
authored
7月 09, 2015
作者:
Iban Harlouchet
提交者:
Iban Harlouchet
7月 23, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
flake8 for theano/misc/pycuda_example.py; 2 E left
上级
41e7e36a
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
16 行增加
和
20 行删除
+16
-20
pycuda_example.py
theano/misc/pycuda_example.py
+16
-19
test_flake8.py
theano/tests/test_flake8.py
+0
-1
没有找到文件。
theano/misc/pycuda_example.py
浏览文件 @
f09999ce
...
@@ -33,16 +33,14 @@ from theano.sandbox.cuda.basic_ops import (as_cuda_ndarray_variable,
...
@@ -33,16 +33,14 @@ from theano.sandbox.cuda.basic_ops import (as_cuda_ndarray_variable,
from
theano.sandbox.cuda.opt
import
gpu_seqopt
from
theano.sandbox.cuda.opt
import
gpu_seqopt
from
theano.tensor.utils
import
hash_from_dict
from
theano.tensor.utils
import
hash_from_dict
from
.
import
pycuda_init
if
not
pycuda_init
.
pycuda_available
:
raise
Exception
(
"No pycuda available. You can't load pycuda_example.py"
)
import
pycuda
import
pycuda
from
pycuda.elementwise
import
ElementwiseKernel
from
pycuda.compiler
import
SourceModule
from
pycuda.compiler
import
SourceModule
from
pycuda.tools
import
VectorArg
import
pycuda.gpuarray
import
pycuda.gpuarray
from
.
import
pycuda_init
if
not
pycuda_init
.
pycuda_available
:
raise
Exception
(
"No pycuda available. You can't load pycuda_example.py"
)
def
_replace_npy_types
(
c_arg
):
def
_replace_npy_types
(
c_arg
):
c_arg
=
c_arg
.
replace
(
'npy_float32'
,
'float'
)
c_arg
=
c_arg
.
replace
(
'npy_float32'
,
'float'
)
...
@@ -235,12 +233,11 @@ class PycudaElemwiseSourceModuleOp(GpuOp):
...
@@ -235,12 +233,11 @@ class PycudaElemwiseSourceModuleOp(GpuOp):
c_code
=
self
.
scalar_op
.
c_code
(
out_node
,
"some_name"
,
c_code
=
self
.
scalar_op
.
c_code
(
out_node
,
"some_name"
,
tuple
([
n
+
"[i]"
for
n
in
in_name
]),
tuple
([
n
+
"[i]"
for
n
in
in_name
]),
tuple
(
n
+
"[i]"
for
n
in
out_name
),
{})
tuple
(
n
+
"[i]"
for
n
in
out_name
),
{})
c_code_param
=
", "
.
join
([
c_code_param
=
", "
.
join
(
_replace_npy_types
(
var
.
type
.
dtype_specs
()[
1
])
+
" *"
+
name
[
_replace_npy_types
(
var
.
type
.
dtype_specs
()[
1
])
+
" *"
+
name
for
var
,
name
in
chain
(
izip
(
inputs
,
in_name
),
for
var
,
name
in
chain
(
izip
(
inputs
,
in_name
),
izip
(
out_node
.
outputs
,
izip
(
out_node
.
outputs
,
out_name
))]
+
out_name
))
[
"int size"
])
]
+
[
"int size"
])
mod
=
SourceModule
(
"""
mod
=
SourceModule
(
"""
__global__ void
%
s(
%
s)
__global__ void
%
s(
%
s)
{
{
...
@@ -259,8 +256,8 @@ class PycudaElemwiseSourceModuleOp(GpuOp):
...
@@ -259,8 +256,8 @@ class PycudaElemwiseSourceModuleOp(GpuOp):
# TODO assert all input have the same shape
# TODO assert all input have the same shape
z
,
=
out
z
,
=
out
if
(
z
[
0
]
is
None
or
if
(
z
[
0
]
is
None
or
z
[
0
]
.
shape
!=
inputs
[
0
]
.
shape
or
z
[
0
]
.
shape
!=
inputs
[
0
]
.
shape
or
not
z
[
0
]
.
is_c_contiguous
()):
not
z
[
0
]
.
is_c_contiguous
()):
z
[
0
]
=
theano
.
sandbox
.
cuda
.
CudaNdarray
.
zeros
(
inputs
[
0
]
.
shape
)
z
[
0
]
=
theano
.
sandbox
.
cuda
.
CudaNdarray
.
zeros
(
inputs
[
0
]
.
shape
)
if
inputs
[
0
]
.
shape
!=
inputs
[
1
]
.
shape
:
if
inputs
[
0
]
.
shape
!=
inputs
[
1
]
.
shape
:
raise
TypeError
(
"PycudaElemwiseSourceModuleOp:"
raise
TypeError
(
"PycudaElemwiseSourceModuleOp:"
...
@@ -329,8 +326,8 @@ class PycudaElemwiseSourceModuleMakeThunkOp(Op):
...
@@ -329,8 +326,8 @@ class PycudaElemwiseSourceModuleMakeThunkOp(Op):
c_code_param
=
", "
.
join
(
c_code_param
=
", "
.
join
(
[
_replace_npy_types
(
var
.
type
.
dtype_specs
()[
1
])
+
" *"
+
name
[
_replace_npy_types
(
var
.
type
.
dtype_specs
()[
1
])
+
" *"
+
name
for
var
,
name
in
chain
(
izip
(
node
.
inputs
,
in_name
),
for
var
,
name
in
chain
(
izip
(
node
.
inputs
,
in_name
),
izip
(
node
.
outputs
,
out_name
))]
izip
(
node
.
outputs
,
out_name
))]
+
+
[
"int size"
])
[
"int size"
])
mod
=
SourceModule
(
"""
mod
=
SourceModule
(
"""
__global__ void
%
s(
%
s)
__global__ void
%
s(
%
s)
...
@@ -349,8 +346,8 @@ class PycudaElemwiseSourceModuleMakeThunkOp(Op):
...
@@ -349,8 +346,8 @@ class PycudaElemwiseSourceModuleMakeThunkOp(Op):
def
thunk
():
def
thunk
():
z
=
outputs
[
0
]
z
=
outputs
[
0
]
if
(
z
[
0
]
is
None
or
if
(
z
[
0
]
is
None
or
z
[
0
]
.
shape
!=
inputs
[
0
][
0
]
.
shape
or
z
[
0
]
.
shape
!=
inputs
[
0
][
0
]
.
shape
or
not
z
[
0
]
.
is_c_contiguous
()):
not
z
[
0
]
.
is_c_contiguous
()):
z
[
0
]
=
theano
.
sandbox
.
cuda
.
CudaNdarray
.
zeros
(
z
[
0
]
=
theano
.
sandbox
.
cuda
.
CudaNdarray
.
zeros
(
inputs
[
0
][
0
]
.
shape
)
inputs
[
0
][
0
]
.
shape
)
if
inputs
[
0
][
0
]
.
shape
!=
inputs
[
1
][
0
]
.
shape
:
if
inputs
[
0
][
0
]
.
shape
!=
inputs
[
1
][
0
]
.
shape
:
...
@@ -384,7 +381,7 @@ def local_pycuda_gpu_elemwise(node):
...
@@ -384,7 +381,7 @@ def local_pycuda_gpu_elemwise(node):
"""
"""
if
isinstance
(
node
.
op
,
GpuElemwise
):
if
isinstance
(
node
.
op
,
GpuElemwise
):
if
(
not
any
([
any
(
i
.
type
.
broadcastable
)
for
i
in
node
.
inputs
])
and
if
(
not
any
([
any
(
i
.
type
.
broadcastable
)
for
i
in
node
.
inputs
])
and
all
([
i
.
ndim
<=
2
for
i
in
node
.
inputs
])):
all
([
i
.
ndim
<=
2
for
i
in
node
.
inputs
])):
new_op
=
PycudaElemwiseSourceModuleOp
(
node
.
op
.
scalar_op
,
new_op
=
PycudaElemwiseSourceModuleOp
(
node
.
op
.
scalar_op
,
node
.
op
.
inplace_pattern
)(
node
.
op
.
inplace_pattern
)(
*
node
.
inputs
)
*
node
.
inputs
)
...
...
theano/tests/test_flake8.py
浏览文件 @
f09999ce
...
@@ -184,7 +184,6 @@ whitelist_flake8 = [
...
@@ -184,7 +184,6 @@ whitelist_flake8 = [
"scan_module/scan_opt.py"
,
"scan_module/scan_opt.py"
,
"scan_module/tests/test_scan.py"
,
"scan_module/tests/test_scan.py"
,
"scan_module/tests/test_scan_opt.py"
,
"scan_module/tests/test_scan_opt.py"
,
"misc/pycuda_example.py"
,
"misc/ordered_set.py"
,
"misc/ordered_set.py"
,
"misc/strutil.py"
,
"misc/strutil.py"
,
"misc/gnumpy_utils.py"
,
"misc/gnumpy_utils.py"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论