Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
3d41cfaa
提交
3d41cfaa
authored
7月 18, 2013
作者:
lamblin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1457 from nouiz/gpu_min_max
Gpu min max, more pattern implemented
上级
ae91b627
d7bad6de
全部展开
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
30 行增加
和
25 行删除
+30
-25
NEWS_DEV.txt
NEWS_DEV.txt
+0
-0
basic_ops.py
theano/sandbox/cuda/basic_ops.py
+0
-0
opt.py
theano/sandbox/cuda/opt.py
+1
-1
test_basic_ops.py
theano/sandbox/cuda/tests/test_basic_ops.py
+27
-22
test_basic.py
theano/sparse/tests/test_basic.py
+2
-2
没有找到文件。
NEWS_DEV.txt
0 → 100644
浏览文件 @
3d41cfaa
差异被折叠。
点击展开。
theano/sandbox/cuda/basic_ops.py
浏览文件 @
3d41cfaa
差异被折叠。
点击展开。
theano/sandbox/cuda/opt.py
浏览文件 @
3d41cfaa
...
@@ -602,7 +602,7 @@ def local_gpu_careduce(node):
...
@@ -602,7 +602,7 @@ def local_gpu_careduce(node):
scalar_op
=
node
.
op
.
scalar_op
scalar_op
=
node
.
op
.
scalar_op
# currently, only these two ops are supported at all,
# currently, only these two ops are supported at all,
# and max does not support all combinations of axes
# and max does not support all combinations of axes
if
node
.
op
.
scalar_op
in
[
scal
.
add
,
scal
.
maximum
,
scal
.
minimum
]:
if
node
.
op
.
scalar_op
in
[
scal
.
add
,
scal
.
m
ul
,
scal
.
m
aximum
,
scal
.
minimum
]:
x
,
=
node
.
inputs
x
,
=
node
.
inputs
if
x
.
owner
and
x
.
owner
.
op
==
host_from_gpu
:
if
x
.
owner
and
x
.
owner
.
op
==
host_from_gpu
:
if
node
.
op
.
axis
is
None
:
if
node
.
op
.
axis
is
None
:
...
...
theano/sandbox/cuda/tests/test_basic_ops.py
浏览文件 @
3d41cfaa
...
@@ -65,9 +65,16 @@ def test_careduce():
...
@@ -65,9 +65,16 @@ def test_careduce():
TODO: test with broadcast
TODO: test with broadcast
"""
"""
for
scalar_op
,
careduce_op
in
[
for
scalar_op
,
careduce_op
in
[
(
theano
.
scalar
.
mul
,
tensor
.
elemwise
.
CAReduceDtype
),
(
theano
.
scalar
.
add
,
tensor
.
elemwise
.
CAReduceDtype
),
(
theano
.
scalar
.
add
,
tensor
.
elemwise
.
CAReduceDtype
),
(
theano
.
scalar
.
maximum
,
tensor
.
CAReduce
),
(
theano
.
scalar
.
maximum
,
tensor
.
CAReduce
),
(
theano
.
scalar
.
minimum
,
tensor
.
CAReduce
)]:
(
theano
.
scalar
.
minimum
,
tensor
.
CAReduce
)
#The following 2 cases could work if the scalar_op.c_code work with float* dtype.
#Currently we have this error:
#error: invalid operands of types 'npy_float32' and 'npy_float32' to binary 'operator&'
#(theano.scalar.and_, tensor.elemwise.CAReduce),
#(theano.scalar.or_, tensor.elemwise.CAReduce),
]:
for
shape
,
pattern
in
[((
1
,
1
),(
1
,)),
for
shape
,
pattern
in
[((
1
,
1
),(
1
,)),
((
1
,
0
),(
1
,)),
((
1
,
0
),(
1
,)),
((
0
,
1
),(
1
,)),
((
0
,
1
),(
1
,)),
...
@@ -124,11 +131,6 @@ def test_careduce():
...
@@ -124,11 +131,6 @@ def test_careduce():
op
=
careduce_op
(
scalar_op
,
axis
=
pattern
)
op
=
careduce_op
(
scalar_op
,
axis
=
pattern
)
pat
=
tensor_pattern_to_gpu_pattern
(
shape
,
pattern
)
pat
=
tensor_pattern_to_gpu_pattern
(
shape
,
pattern
)
#GpuCAReduce{maximum/minimum} support only those patterns
if
scalar_op
in
[
theano
.
scalar
.
maximum
,
theano
.
scalar
.
minimum
]
and
pat
not
in
[
(
0
,
1
),
(
0
,
1
,
1
),
(
0
,
1
,
1
),
(
1
,
0
)]:
continue
a
=
tensor
.
TensorType
(
'float32'
,
(
False
,)
*
len
(
shape
))()
a
=
tensor
.
TensorType
(
'float32'
,
(
False
,)
*
len
(
shape
))()
b
=
op
(
a
)
b
=
op
(
a
)
...
@@ -139,15 +141,22 @@ def test_careduce():
...
@@ -139,15 +141,22 @@ def test_careduce():
f
=
theano
.
function
([
a
],
b
,
mode
=
mode_with_gpu
)
f
=
theano
.
function
([
a
],
b
,
mode
=
mode_with_gpu
)
f2
=
theano
.
function
([
a
],
b
,
mode
=
mode_without_gpu
)
f2
=
theano
.
function
([
a
],
b
,
mode
=
mode_without_gpu
)
assert
tcn
.
GpuCAReduce
in
[
x
.
op
.
__class__
assert
tcn
.
GpuCAReduce
in
[
x
.
op
.
__class__
for
x
in
f
.
maker
.
fgraph
.
toposort
()]
for
x
in
f
.
maker
.
fgraph
.
toposort
()],
(
scalar_op
,
shape
,
pattern
)
assert
op
.
__class__
in
[
x
.
op
.
__class__
assert
op
.
__class__
in
[
x
.
op
.
__class__
for
x
in
f2
.
maker
.
fgraph
.
toposort
()]
for
x
in
f2
.
maker
.
fgraph
.
toposort
()],
(
scalar_op
,
shape
,
pattern
)
f_caused_value_error
=
False
f_caused_value_error
=
False
try
:
try
:
f_out
=
f
(
val
)
f_out
=
f
(
val
)
except
ValueError
,
e
:
except
ValueError
,
e
:
exc
=
e
exc
=
e
f_caused_value_error
=
True
f_caused_value_error
=
True
except
NotImplementedError
:
if
(
numpy
.
prod
(
shape
)
==
0
and
getattr
(
scalar_op
,
'identity'
,
None
)
!=
0
):
continue
raise
f2_caused_value_error
=
False
f2_caused_value_error
=
False
try
:
try
:
...
@@ -179,6 +188,7 @@ def test_careduce():
...
@@ -179,6 +188,7 @@ def test_careduce():
theano
.
tensor
.
basic
.
float32_rtol
=
2e-5
theano
.
tensor
.
basic
.
float32_rtol
=
2e-5
assert
_allclose
(
f_out
,
f2_out
),
(
'shape'
,
shape
,
assert
_allclose
(
f_out
,
f2_out
),
(
'shape'
,
shape
,
'pattern'
,
pattern
,
'pattern'
,
pattern
,
scalar_op
,
sum
([
shape
[
i
]
for
i
in
pattern
]),
sum
([
shape
[
i
]
for
i
in
pattern
]),
f2
(
val
),
f
(
val
),
val
)
f2
(
val
),
f
(
val
),
val
)
finally
:
finally
:
...
@@ -193,11 +203,6 @@ def test_careduce():
...
@@ -193,11 +203,6 @@ def test_careduce():
((
5
,
4
,
3
,
2
),[
0
,
1
,
2
,
3
]),
((
5
,
4
,
3
,
2
),[
0
,
2
,
3
])]:
((
5
,
4
,
3
,
2
),[
0
,
1
,
2
,
3
]),
((
5
,
4
,
3
,
2
),[
0
,
2
,
3
])]:
op
=
careduce_op
(
scalar_op
,
axis
=
pattern
)
op
=
careduce_op
(
scalar_op
,
axis
=
pattern
)
pat
=
tensor_pattern_to_gpu_pattern
(
shape
,
pattern
)
pat
=
tensor_pattern_to_gpu_pattern
(
shape
,
pattern
)
#GpuCAReduce{maximum/minimum} support only those patterns
if
scalar_op
in
[
theano
.
scalar
.
maximum
,
theano
.
scalar
.
minimum
]
and
pat
not
in
[
(
0
,
1
),
(
0
,
1
,
1
),
(
0
,
1
,
1
),
(
1
,
0
)]:
continue
a
=
tensor
.
TensorType
(
'float32'
,
(
False
,)
*
len
(
shape
))()
a
=
tensor
.
TensorType
(
'float32'
,
(
False
,)
*
len
(
shape
))()
dim_pattern
=
range
(
len
(
shape
))
dim_pattern
=
range
(
len
(
shape
))
...
@@ -212,11 +217,14 @@ def test_careduce():
...
@@ -212,11 +217,14 @@ def test_careduce():
f
=
theano
.
function
([
a
],
b
,
mode
=
mode_with_gpu
)
f
=
theano
.
function
([
a
],
b
,
mode
=
mode_with_gpu
)
f2
=
theano
.
function
([
a
],
b
,
mode
=
mode_without_gpu
)
f2
=
theano
.
function
([
a
],
b
,
mode
=
mode_without_gpu
)
assert
tcn
.
GpuCAReduce
in
[
x
.
op
.
__class__
assert
tcn
.
GpuCAReduce
in
[
x
.
op
.
__class__
for
x
in
f
.
maker
.
fgraph
.
toposort
()]
for
x
in
f
.
maker
.
fgraph
.
toposort
()],
(
scalar_op
,
shape
,
pattern
)
assert
op
.
__class__
in
[
x
.
op
.
__class__
assert
op
.
__class__
in
[
x
.
op
.
__class__
for
x
in
f2
.
maker
.
fgraph
.
toposort
()]
for
x
in
f2
.
maker
.
fgraph
.
toposort
()],
(
scalar_op
,
shape
,
pattern
)
assert
_allclose
(
f2
(
val
),
f
(
val
)),
(
'shape'
,
shape
,
assert
_allclose
(
f2
(
val
),
f
(
val
)),
(
'shape'
,
shape
,
'pattern'
,
pattern
,
'pattern'
,
pattern
,
scalar_op
,
sum
([
shape
[
i
]
for
i
in
pattern
]))
sum
([
shape
[
i
]
for
i
in
pattern
]))
#test with broadcast
#test with broadcast
...
@@ -227,11 +235,6 @@ def test_careduce():
...
@@ -227,11 +235,6 @@ def test_careduce():
((
5
,
4
,
3
,
2
),[
0
,
1
,
2
,
3
]),
((
5
,
4
,
3
,
2
),[
0
,
2
,
3
])]:
((
5
,
4
,
3
,
2
),[
0
,
1
,
2
,
3
]),
((
5
,
4
,
3
,
2
),[
0
,
2
,
3
])]:
op
=
careduce_op
(
scalar_op
,
axis
=
pattern
)
op
=
careduce_op
(
scalar_op
,
axis
=
pattern
)
pat
=
tensor_pattern_to_gpu_pattern
(
shape
,
pattern
)
pat
=
tensor_pattern_to_gpu_pattern
(
shape
,
pattern
)
#GpuCAReduce{maximum/minimum} support only those patterns
if
scalar_op
in
[
theano
.
scalar
.
maximum
,
theano
.
scalar
.
minimum
]
and
pat
not
in
[
(
0
,
1
),
(
0
,
1
,
1
),
(
0
,
1
,
1
),
(
1
,
0
)]:
continue
shape
=
numpy
.
asarray
(
shape
)
*
2
shape
=
numpy
.
asarray
(
shape
)
*
2
a
=
tensor
.
TensorType
(
'float32'
,
(
False
,)
*
len
(
shape
))()
a
=
tensor
.
TensorType
(
'float32'
,
(
False
,)
*
len
(
shape
))()
...
@@ -258,9 +261,11 @@ def test_careduce():
...
@@ -258,9 +261,11 @@ def test_careduce():
f
=
theano
.
function
([
a
],
b
,
mode
=
mode_without_gpu
)
f
=
theano
.
function
([
a
],
b
,
mode
=
mode_without_gpu
)
f2
=
theano
.
function
([
a2
],
b2
,
mode
=
mode_with_gpu
)
f2
=
theano
.
function
([
a2
],
b2
,
mode
=
mode_with_gpu
)
assert
tcn
.
GpuCAReduce
in
[
x
.
op
.
__class__
assert
tcn
.
GpuCAReduce
in
[
x
.
op
.
__class__
for
x
in
f2
.
maker
.
fgraph
.
toposort
()]
for
x
in
f2
.
maker
.
fgraph
.
toposort
()],
(
scalar_op
,
shape
,
pattern
)
assert
op
.
__class__
in
[
x
.
op
.
__class__
assert
op
.
__class__
in
[
x
.
op
.
__class__
for
x
in
f
.
maker
.
fgraph
.
toposort
()]
for
x
in
f
.
maker
.
fgraph
.
toposort
()],
(
scalar_op
,
shape
,
pattern
)
assert
_allclose
(
f2
(
val2
),
f
(
val
)),
(
'shape'
,
shape
,
assert
_allclose
(
f2
(
val2
),
f
(
val
)),
(
'shape'
,
shape
,
'pattern'
,
pattern
,
'pattern'
,
pattern
,
sum
([
shape
[
i
]
for
i
in
pattern
]))
sum
([
shape
[
i
]
for
i
in
pattern
]))
...
...
theano/sparse/tests/test_basic.py
浏览文件 @
3d41cfaa
...
@@ -2721,7 +2721,7 @@ class TrueDotTester(utt.InferShapeTester):
...
@@ -2721,7 +2721,7 @@ class TrueDotTester(utt.InferShapeTester):
assert
tested
.
format
==
format
assert
tested
.
format
==
format
assert
tested
.
dtype
==
expected
.
dtype
assert
tested
.
dtype
==
expected
.
dtype
tested
=
tested
.
toarray
()
tested
=
tested
.
toarray
()
assert
numpy
.
allclose
(
tested
,
expected
)
utt
.
assert_
allclose
(
tested
,
expected
)
def
test_op_sd
(
self
):
def
test_op_sd
(
self
):
for
format
in
sparse
.
sparse_formats
:
for
format
in
sparse
.
sparse_formats
:
...
@@ -2743,7 +2743,7 @@ class TrueDotTester(utt.InferShapeTester):
...
@@ -2743,7 +2743,7 @@ class TrueDotTester(utt.InferShapeTester):
assert
tested
.
format
==
format
assert
tested
.
format
==
format
assert
tested
.
dtype
==
expected
.
dtype
assert
tested
.
dtype
==
expected
.
dtype
tested
=
tested
.
toarray
()
tested
=
tested
.
toarray
()
assert
numpy
.
allclose
(
tested
,
expected
)
utt
.
assert_
allclose
(
tested
,
expected
)
def
test_infer_shape
(
self
):
def
test_infer_shape
(
self
):
for
format
in
sparse
.
sparse_formats
:
for
format
in
sparse
.
sparse_formats
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论