Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f2608775
提交
f2608775
authored
10月 24, 2011
作者:
David Warde-Farley
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #126 from nouiz/join_test
Split/Join tests
上级
6bc14189
15cc9076
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
21 行增加
和
75 行删除
+21
-75
opt.py
theano/sandbox/cuda/opt.py
+2
-2
test_basic_ops.py
theano/sandbox/cuda/tests/test_basic_ops.py
+16
-71
basic.py
theano/tensor/basic.py
+3
-2
test_basic.py
theano/tensor/tests/test_basic.py
+0
-0
没有找到文件。
theano/sandbox/cuda/opt.py
浏览文件 @
f2608775
...
@@ -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
浏览文件 @
f2608775
...
@@ -646,76 +646,6 @@ def test_hostfromgpu_shape_i():
...
@@ -646,76 +646,6 @@ def test_hostfromgpu_shape_i():
# -----------------------------------------------------------------------
# -----------------------------------------------------------------------
import
theano.sandbox.cuda
as
cuda_ndarray
import
theano.sandbox.cuda
as
cuda_ndarray
from
theano.sandbox.cuda.basic_ops
import
gpu_join
,
GpuDimShuffle
def
test_gpujoin_concatenate_one_element
():
m
=
T
.
fmatrix
()
c
=
T
.
concatenate
([
m
])
f
=
theano
.
function
(
inputs
=
[
m
],
outputs
=
[
c
],
mode
=
mode_with_gpu
)
topo
=
f
.
maker
.
env
.
toposort
()
assert
len
(
topo
)
==
1
assert
isinstance
(
topo
[
0
]
.
op
,
theano
.
compile
.
DeepCopyOp
)
def
test_gpujoin_twomatrices_joincolumns
():
_a
=
numpy
.
asarray
([[
1
,
2
],[
3
,
4
]],
dtype
=
'float32'
)
_b
=
numpy
.
asarray
([[
5
,
6
,
7
],[
8
,
9
,
10
]],
dtype
=
'float32'
)
a
=
tcn
.
shared_constructor
(
_a
)
b
=
tcn
.
shared_constructor
(
_b
)
c
=
gpu_join
(
1
,
a
,
b
)
f
=
theano
.
function
([],
c
)
assert
numpy
.
all
(
f
()
==
numpy
.
concatenate
([
_a
,
_b
],
axis
=
1
))
def
test_gpujoin_twomatrices_badshapes
():
_a
=
numpy
.
asarray
([[
1
,
2
],[
3
,
4
]],
dtype
=
'float32'
)
_b
=
numpy
.
asarray
([[
5
,
6
,
7
],[
8
,
9
,
10
]],
dtype
=
'float32'
)
a
=
tcn
.
shared_constructor
(
_a
)
b
=
tcn
.
shared_constructor
(
_b
)
# try to join on dimension 0 where they don't agree (2!=3)
c
=
gpu_join
(
0
,
a
,
b
)
f
=
theano
.
function
([],
c
)
try
:
f
()
assert
False
except
ValueError
:
assert
True
def
test_gpujoin_preserves_broadcasting
():
_a
=
numpy
.
asarray
([[
1
,
2
],[
3
,
4
]],
dtype
=
'float32'
)
_b
=
numpy
.
asarray
([[
5
,
6
,
7
],[
8
,
9
,
10
]],
dtype
=
'float32'
)
a
=
tcn
.
shared_constructor
(
_a
)
b
=
tcn
.
shared_constructor
(
_b
)
# [0,0] : the two original dims were non-broadcastable
# [1,x,0]: new order and broadcastability
gpu_dimshuffle
=
GpuDimShuffle
([
0
,
0
],
[
1
,
'x'
,
0
])
a_shuffled
=
gpu_dimshuffle
(
a
)
b_shuffled
=
gpu_dimshuffle
(
b
)
c
=
gpu_join
(
0
,
a_shuffled
,
b_shuffled
)
assert
c
.
type
.
broadcastable
==
(
False
,
True
,
False
)
f
=
theano
.
function
([],
c
,
mode
=
mode_with_gpu
)
res
=
f
()
a_reshaped
=
numpy
.
asarray
([[[
1
,
3
]],[[
2
,
4
]]],
dtype
=
'float32'
)
b_reshaped
=
numpy
.
asarray
([[[
5
,
8
]],[[
6
,
9
]],[[
7
,
10
]]],
dtype
=
'float32'
)
concat
=
numpy
.
concatenate
([
a_reshaped
,
b_reshaped
],
axis
=
0
)
assert
numpy
.
all
(
res
==
concat
)
def
test_gpujoin_assert_cndas
():
def
test_gpujoin_assert_cndas
():
# this will end up being an ndarray, as it's float64
# this will end up being an ndarray, as it's float64
...
@@ -723,7 +653,7 @@ def test_gpujoin_assert_cndas():
...
@@ -723,7 +653,7 @@ def test_gpujoin_assert_cndas():
a
=
theano
.
shared
(
_a
)
a
=
theano
.
shared
(
_a
)
try
:
try
:
c
=
gpu_join
(
1
,
a
)
c
=
cuda
.
basic_ops
.
gpu_join
(
1
,
a
)
# can't "assert False" here, as we want the assertion
# can't "assert False" here, as we want the assertion
# error from gpu_join
# error from gpu_join
except
AssertionError
:
except
AssertionError
:
...
@@ -792,6 +722,21 @@ def test_gpualloc_output_to_gpu():
...
@@ -792,6 +722,21 @@ 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
# No gpu split.
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
=
theano
.
config
.
mode
not
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/basic.py
浏览文件 @
f2608775
...
@@ -2892,8 +2892,9 @@ def extract_constant(x):
...
@@ -2892,8 +2892,9 @@ def extract_constant(x):
This function is basically a call to tensor.get_constant_value. The
This function is basically a call to tensor.get_constant_value. The
main difference is the behaviour in case of failure. While
main difference is the behaviour in case of failure. While
get_constant_value raises an TypeError, this function returns x,
get_constant_value raises an TypeError, this function returns x,
as a tensor ( by removing the last scalar_from_tensor ) if needed
as a tensor if possible. If x is a ScalarVariable from a
or None if that is the value of x.
scalar_from_tensor, we remove the conversion. If x is just a
ScalarVariable, we convert it to a tensor with tensor_from_scalar.
'''
'''
try
:
try
:
x
=
get_constant_value
(
x
)
x
=
get_constant_value
(
x
)
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
f2608775
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论