Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b6f9a5bd
提交
b6f9a5bd
authored
9月 30, 2015
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Flake8 for basic_ops.py
上级
a81457e8
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
25 行增加
和
31 行删除
+25
-31
basic_ops.py
theano/sandbox/gpuarray/basic_ops.py
+25
-30
test_flake8.py
theano/tests/test_flake8.py
+0
-1
没有找到文件。
theano/sandbox/gpuarray/basic_ops.py
浏览文件 @
b6f9a5bd
...
@@ -2,11 +2,9 @@ import os
...
@@ -2,11 +2,9 @@ import os
import
numpy
import
numpy
import
theano
from
theano
import
Op
,
Apply
,
Type
,
Variable
from
theano
import
Op
,
Apply
from
theano
import
tensor
,
config
from
theano
import
tensor
,
scalar
,
config
from
theano.gradient
import
grad_undefined
from
theano.gradient
import
grad_undefined
from
theano.scalar
import
Scalar
from
theano.tensor.basic
import
Alloc
,
Join
,
Split
from
theano.tensor.basic
import
Alloc
,
Join
,
Split
from
theano.gof
import
HideC
from
theano.gof
import
HideC
...
@@ -17,7 +15,7 @@ from six.moves import xrange
...
@@ -17,7 +15,7 @@ from six.moves import xrange
try
:
try
:
import
pygpu
import
pygpu
from
pygpu
import
gpuarray
,
elemwise
from
pygpu
import
gpuarray
except
ImportError
:
except
ImportError
:
pass
pass
...
@@ -293,7 +291,6 @@ class GpuFromHost(Op):
...
@@ -293,7 +291,6 @@ class GpuFromHost(Op):
def
perform
(
self
,
node
,
inp
,
out
):
def
perform
(
self
,
node
,
inp
,
out
):
x
,
=
inp
x
,
=
inp
z
,
=
out
z
,
=
out
type
=
node
.
outputs
[
0
]
.
type
z
[
0
]
=
gpuarray
.
array
(
x
)
z
[
0
]
=
gpuarray
.
array
(
x
)
def
grad
(
self
,
inputs
,
grads
):
def
grad
(
self
,
inputs
,
grads
):
...
@@ -342,7 +339,7 @@ class GpuAlloc(HideC, Alloc):
...
@@ -342,7 +339,7 @@ class GpuAlloc(HideC, Alloc):
value is always 0, so the c code call memset as it is faster.
value is always 0, so the c code call memset as it is faster.
"""
"""
__props__
=
(
'memset_0'
,)
__props__
=
(
'memset_0'
,)
_f16_ok
=
True
_f16_ok
=
True
...
@@ -362,7 +359,7 @@ class GpuAlloc(HideC, Alloc):
...
@@ -362,7 +359,7 @@ class GpuAlloc(HideC, Alloc):
sh
,
bcast
=
self
.
validate_shape
(
shape
)
sh
,
bcast
=
self
.
validate_shape
(
shape
)
if
value
.
ndim
>
len
(
sh
):
if
value
.
ndim
>
len
(
sh
):
TypeError
(
"The GpuAlloc value to use has more dimensions "
TypeError
(
"The GpuAlloc value to use has more dimensions "
"than the specified shape"
,
v
.
ndim
,
len
(
sh
))
"than the specified shape"
,
v
alue
.
ndim
,
len
(
sh
))
otype
=
value
.
type
.
clone
(
broadcastable
=
bcast
)
otype
=
value
.
type
.
clone
(
broadcastable
=
bcast
)
return
Apply
(
self
,
[
value
]
+
sh
,
[
otype
()])
return
Apply
(
self
,
[
value
]
+
sh
,
[
otype
()])
...
@@ -456,29 +453,28 @@ class GpuAlloc(HideC, Alloc):
...
@@ -456,29 +453,28 @@ class GpuAlloc(HideC, Alloc):
return
(
2
,)
return
(
2
,)
def
do_constant_folding
(
self
,
node
):
def
do_constant_folding
(
self
,
node
):
from
.
import
subtensor
,
blas
for
client
in
node
.
outputs
[
0
]
.
clients
:
for
client
in
node
.
outputs
[
0
]
.
clients
:
if
client
[
0
]
==
'output'
:
if
client
[
0
]
==
'output'
:
# If the output is a constant, it will have to be deepcopied
# If the output is a constant, it will have to be deepcopied
# each time the function is called. So we do not fold.
# each time the function is called. So we do not fold.
return
False
return
False
elif
(
# The following ops work inplace of their input id 0.
# The following ops work inplace of their input id 0.
client
[
1
]
==
0
and
elif
(
client
[
1
]
==
0
and
isinstance
(
client
[
0
]
.
op
,
(
# Ops that will work inplace on the Alloc. So if they
# Ops that will work inplace on the Alloc. So if they
# get constant_folded, they would copy the
# get constant_folded, they would copy the
# constant and this is less efficients.
# constant and this is less efficients.
# Not doing the constant folding could also lower
# Not doing the constant folding could also lower
# the peak memory usage, as we the "constant" won't
# the peak memory usage, as we the "constant" won't
# always exists.
# always exists.
isinstance
(
client
[
0
]
.
op
,
# theano.tensor.subtensor.AdvancedIncSubtensor,
(
subtensor
.
GpuIncSubtensor
,
theano
.
sandbox
.
gpuarray
.
subtensor
.
GpuIncSubtensor
,
subtensor
.
GpuAdvancedIncSubtensor1
,
theano
.
sandbox
.
gpuarray
.
subtensor
.
GpuAdvancedIncSubtensor1
,
subtensor
.
GpuAdvancedIncSubtensor1_dev20
,
theano
.
sandbox
.
gpuarray
.
subtensor
.
GpuAdvancedIncSubtensor1_dev20
,
blas
.
GpuGemm
,
blas
.
GpuGemv
,
theano
.
sandbox
.
gpuarray
.
blas
.
GpuGemm
,
blas
.
GpuGer
)
theano
.
sandbox
.
gpuarray
.
blas
.
GpuGemv
,
)):
theano
.
sandbox
.
gpuarray
.
blas
.
GpuGer
,
))):
return
False
return
False
# If the clients is a transfer, we don't want to fold. We
# If the clients is a transfer, we don't want to fold. We
# let the moving opt finish before deciding what to do.
# let the moving opt finish before deciding what to do.
...
@@ -565,7 +561,7 @@ class GpuContiguous(Op):
...
@@ -565,7 +561,7 @@ class GpuContiguous(Op):
"""
"""
Always return a c contiguous output. Copy the input only if it is
Always return a c contiguous output. Copy the input only if it is
not already c contiguous.
not already c contiguous.
"""
"""
__props__
=
()
__props__
=
()
...
@@ -750,7 +746,7 @@ class GpuJoin(HideC, Join):
...
@@ -750,7 +746,7 @@ class GpuJoin(HideC, Join):
node
=
Join
.
make_node
(
self
,
axis
,
*
tensors
)
node
=
Join
.
make_node
(
self
,
axis
,
*
tensors
)
return
Apply
(
self
,
[
node
.
inputs
[
0
]]
+
list
(
map
(
as_gpuarray_variable
,
return
Apply
(
self
,
[
node
.
inputs
[
0
]]
+
list
(
map
(
as_gpuarray_variable
,
tensors
)),
tensors
)),
[
GpuArrayType
(
broadcastable
=
node
.
outputs
[
0
]
.
broadcastable
,
[
GpuArrayType
(
broadcastable
=
node
.
outputs
[
0
]
.
broadcastable
,
dtype
=
node
.
outputs
[
0
]
.
dtype
)()])
dtype
=
node
.
outputs
[
0
]
.
dtype
)()])
...
@@ -859,8 +855,7 @@ KERNEL void k(GLOBAL_MEM %(ctype)s *a, ga_size n, ga_size m) {
...
@@ -859,8 +855,7 @@ KERNEL void k(GLOBAL_MEM %(ctype)s *a, ga_size n, ga_size m) {
code
=
code
,
name
=
"k"
,
code
=
code
,
name
=
"k"
,
params
=
[
gpuarray
.
GpuArray
,
gpuarray
.
SIZE
,
gpuarray
.
SIZE
],
params
=
[
gpuarray
.
GpuArray
,
gpuarray
.
SIZE
,
gpuarray
.
SIZE
],
flags
=
Kernel
.
get_flags
(
self
.
dtype
),
flags
=
Kernel
.
get_flags
(
self
.
dtype
),
objvar
=
'k_eye_'
+
name
,
objvar
=
'k_eye_'
+
name
)]
)]
def
c_code
(
self
,
node
,
name
,
inp
,
out
,
sub
):
def
c_code
(
self
,
node
,
name
,
inp
,
out
,
sub
):
n
,
m
=
inp
n
,
m
=
inp
...
...
theano/tests/test_flake8.py
浏览文件 @
b6f9a5bd
...
@@ -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/basic_ops.py"
,
"sandbox/gpuarray/nnet.py"
,
"sandbox/gpuarray/nnet.py"
,
"sandbox/gpuarray/elemwise.py"
,
"sandbox/gpuarray/elemwise.py"
,
"sandbox/gpuarray/type.py"
,
"sandbox/gpuarray/type.py"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论