Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
46f56a7d
提交
46f56a7d
authored
10月 17, 2011
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Run cpu Join test on gpu and transform cpu join to gpu join when input are constant.
上级
724df23d
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
25 行增加
和
7 行删除
+25
-7
opt.py
theano/sandbox/cuda/opt.py
+2
-2
test_basic_ops.py
theano/sandbox/cuda/tests/test_basic_ops.py
+14
-0
test_basic.py
theano/tensor/tests/test_basic.py
+9
-5
没有找到文件。
theano/sandbox/cuda/opt.py
浏览文件 @
46f56a7d
...
@@ -881,8 +881,8 @@ def local_gpu_join(node):
...
@@ -881,8 +881,8 @@ def local_gpu_join(node):
#print "OPT: axis_and_tensors=", axis_and_tensors
#print "OPT: axis_and_tensors=", axis_and_tensors
matches
=
[
not
t
.
owner
is
None
and
t
.
owner
.
op
==
host_from_gpu
for
t
in
axis_and_tensors
[
1
:]]
matches
=
[
(
not
t
.
owner
is
None
and
t
.
owner
.
op
==
host_from_gpu
)
or
isinstance
(
t
,
gof
.
Constant
)
for
t
in
axis_and_tensors
[
1
:]]
#print "OPT: matches =", matches
#print "OPT: matches =", matches
# if all input tensors are host_from_gpu'ified
# if all input tensors are host_from_gpu'ified
...
...
theano/sandbox/cuda/tests/test_basic_ops.py
浏览文件 @
46f56a7d
...
@@ -792,6 +792,20 @@ def test_gpualloc_output_to_gpu():
...
@@ -792,6 +792,20 @@ def test_gpualloc_output_to_gpu():
assert
numpy
.
allclose
(
f
(
5
),
f_gpu
(
5
))
assert
numpy
.
allclose
(
f
(
5
),
f_gpu
(
5
))
import
theano.tensor.tests.test_basic
import
theano.tensor.tests.test_basic
class
T_Join_and_Split
(
theano
.
tensor
.
tests
.
test_basic
.
T_Join_and_Split
):
def
setUp
(
self
):
utt
.
seed_rng
()
self
.
mode
=
mode_with_gpu
.
excluding
(
'constant_folding'
)
self
.
join_op
=
cuda
.
GpuJoin
self
.
split_op
=
tensor
.
Split
# No Make vector on the gpu, Join used instead
self
.
make_vector_op
=
cuda
.
GpuJoin
self
.
floatX
=
"float32"
# In FAST_COMPILE mode, we force the FAST_RUN mode for optimization.
self
.
hide_error
=
not
theano
.
config
.
mode
in
[
'DebugMode'
,
'DEBUG_MODE'
]
self
.
shared
=
cuda
.
shared_constructor
# This is to don't duplicate test.
# This is to don't duplicate test.
class
T_subtensor
(
theano
.
tensor
.
tests
.
test_basic
.
T_subtensor
):
class
T_subtensor
(
theano
.
tensor
.
tests
.
test_basic
.
T_subtensor
):
shared
=
staticmethod
(
cuda
.
shared_constructor
)
shared
=
staticmethod
(
cuda
.
shared_constructor
)
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
46f56a7d
...
@@ -2539,11 +2539,11 @@ class T_Join_and_Split(unittest.TestCase):
...
@@ -2539,11 +2539,11 @@ class T_Join_and_Split(unittest.TestCase):
self
.
mode
=
theano
.
compile
.
get_default_mode
()
.
excluding
(
'constant_folding'
)
self
.
mode
=
theano
.
compile
.
get_default_mode
()
.
excluding
(
'constant_folding'
)
self
.
join_op
=
Join
self
.
join_op
=
Join
self
.
split_op
=
Split
self
.
split_op
=
Split
self
.
make_vector_op
=
opt
.
MakeVector
self
.
floatX
=
config
.
floatX
self
.
floatX
=
config
.
floatX
self
.
hide_error
=
not
theano
.
config
.
mode
in
[
'DebugMode'
,
'DEBUG_MODE'
,
'FAST_COMPILE'
]
self
.
hide_error
=
not
theano
.
config
.
mode
in
[
'DebugMode'
,
'DEBUG_MODE'
,
'FAST_COMPILE'
]
self
.
shared
=
shared
self
.
shared
=
shared
def
eval_outputs_and_check_join
(
self
,
outputs
):
def
eval_outputs_and_check_join
(
self
,
outputs
):
f
=
theano
.
function
([],
outputs
,
self
.
mode
)
f
=
theano
.
function
([],
outputs
,
self
.
mode
)
topo
=
f
.
maker
.
env
.
toposort
()
topo
=
f
.
maker
.
env
.
toposort
()
...
@@ -2553,10 +2553,13 @@ class T_Join_and_Split(unittest.TestCase):
...
@@ -2553,10 +2553,13 @@ class T_Join_and_Split(unittest.TestCase):
return
variables
[
0
]
return
variables
[
0
]
return
variables
return
variables
def
eval_outputs_and_check_vector
(
self
,
outputs
):
def
eval_outputs_and_check_vector
(
self
,
outputs
,
make_vector_op
=
None
):
if
make_vector_op
is
None
:
make_vector_op
=
self
.
make_vector_op
f
=
theano
.
function
([],
outputs
,
self
.
mode
)
f
=
theano
.
function
([],
outputs
,
self
.
mode
)
topo
=
f
.
maker
.
env
.
toposort
()
topo
=
f
.
maker
.
env
.
toposort
()
assert
[
True
for
node
in
topo
if
isinstance
(
node
.
op
,
opt
.
MakeVector
)]
assert
[
True
for
node
in
topo
if
isinstance
(
node
.
op
,
make_vector_op
)]
variables
=
f
()
variables
=
f
()
if
isinstance
(
variables
,(
tuple
,
list
))
and
len
(
variables
)
==
1
:
if
isinstance
(
variables
,(
tuple
,
list
))
and
len
(
variables
)
==
1
:
return
variables
[
0
]
return
variables
[
0
]
...
@@ -2572,14 +2575,15 @@ class T_Join_and_Split(unittest.TestCase):
...
@@ -2572,14 +2575,15 @@ class T_Join_and_Split(unittest.TestCase):
self
.
fail
()
self
.
fail
()
def
test_stack_mixed_type_constants
(
self
):
def
test_stack_mixed_type_constants
(
self
):
# tested only on cpu as gpu support only float32
a
=
as_tensor_variable
(
1
)
a
=
as_tensor_variable
(
1
)
b
=
as_tensor_variable
(
2.0
)
b
=
as_tensor_variable
(
2.0
)
c
=
shared
(
numpy
.
asarray
(
3.0
))
c
=
shared
(
numpy
.
asarray
(
3.0
)
.
astype
(
self
.
floatX
)
)
s
=
stack
(
a
,
b
,
c
)
s
=
stack
(
a
,
b
,
c
)
want
=
numpy
.
array
([
1
,
2
,
3
])
want
=
numpy
.
array
([
1
,
2
,
3
])
out
=
self
.
eval_outputs_and_check_vector
([
s
])
out
=
self
.
eval_outputs_and_check_vector
([
s
]
,
opt
.
MakeVector
)
self
.
assertTrue
((
out
==
want
)
.
all
())
self
.
assertTrue
((
out
==
want
)
.
all
())
def
test_stack_scalar
(
self
):
def
test_stack_scalar
(
self
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论