Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
6052f90f
提交
6052f90f
authored
1月 18, 2017
作者:
Frédéric Bastien
提交者:
GitHub
1月 18, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5417 from ReyhaneAskari/4897
make tensor.join() return the input when there is only 1 variable to join.
上级
e345e095
965366d8
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
38 行增加
和
11 行删除
+38
-11
opt.py
theano/gpuarray/opt.py
+1
-1
test_basic_ops.py
theano/gpuarray/tests/test_basic_ops.py
+1
-1
opt.py
theano/sandbox/cuda/opt.py
+1
-1
test_basic_ops.py
theano/sandbox/cuda/tests/test_basic_ops.py
+1
-1
basic.py
theano/tensor/basic.py
+15
-7
test_basic.py
theano/tensor/tests/test_basic.py
+19
-0
没有找到文件。
theano/gpuarray/opt.py
浏览文件 @
6052f90f
...
@@ -591,7 +591,7 @@ def local_gpua_alloc2(node):
...
@@ -591,7 +591,7 @@ def local_gpua_alloc2(node):
return
return
if
(
isinstance
(
node
.
op
,
tensor
.
Alloc
)
and
if
(
isinstance
(
node
.
op
,
tensor
.
Alloc
)
and
all
(
c
!=
'output'
and
all
(
c
!=
'output'
and
c
.
op
==
tensor
.
join
and
isinstance
(
c
.
op
,
tensor
.
Join
)
and
all
(
i
.
owner
and
all
(
i
.
owner
and
i
.
owner
.
op
in
[
host_from_gpu
,
tensor
.
alloc
]
i
.
owner
.
op
in
[
host_from_gpu
,
tensor
.
alloc
]
for
i
in
c
.
inputs
[
1
:])
for
i
in
c
.
inputs
[
1
:])
...
...
theano/gpuarray/tests/test_basic_ops.py
浏览文件 @
6052f90f
...
@@ -378,7 +378,7 @@ def test_gpujoin_gpualloc():
...
@@ -378,7 +378,7 @@ def test_gpujoin_gpualloc():
T
.
ones_like
(
b
))
+
4
,
T
.
ones_like
(
b
))
+
4
,
mode
=
mode_with_gpu
)
mode
=
mode_with_gpu
)
assert
sum
([
node
.
op
==
T
.
alloc
for
node
in
f
.
maker
.
fgraph
.
toposort
()])
==
2
assert
sum
([
node
.
op
==
T
.
alloc
for
node
in
f
.
maker
.
fgraph
.
toposort
()])
==
2
assert
sum
([
node
.
op
==
T
.
join
for
node
in
f
.
maker
.
fgraph
.
toposort
()])
==
1
assert
sum
([
node
.
op
==
T
.
join
_
for
node
in
f
.
maker
.
fgraph
.
toposort
()])
==
1
assert
sum
([
isinstance
(
node
.
op
,
GpuAlloc
)
assert
sum
([
isinstance
(
node
.
op
,
GpuAlloc
)
for
node
in
f_gpu
.
maker
.
fgraph
.
toposort
()])
==
2
for
node
in
f_gpu
.
maker
.
fgraph
.
toposort
()])
==
2
assert
sum
([
node
.
op
==
gpu_join
assert
sum
([
node
.
op
==
gpu_join
...
...
theano/sandbox/cuda/opt.py
浏览文件 @
6052f90f
...
@@ -2207,7 +2207,7 @@ def local_gpualloc(node):
...
@@ -2207,7 +2207,7 @@ def local_gpualloc(node):
# if all clients are on gpu
# if all clients are on gpu
replace
=
True
replace
=
True
elif
all
([
c
!=
'output'
and
elif
all
([
c
!=
'output'
and
c
.
op
==
tensor
.
join
and
isinstance
(
c
.
op
,
tensor
.
Join
)
and
all
(
i
.
owner
and
all
(
i
.
owner
and
i
.
owner
.
op
in
[
host_from_gpu
,
tensor
.
alloc
]
i
.
owner
.
op
in
[
host_from_gpu
,
tensor
.
alloc
]
for
i
in
c
.
inputs
[
1
:])
for
i
in
c
.
inputs
[
1
:])
...
...
theano/sandbox/cuda/tests/test_basic_ops.py
浏览文件 @
6052f90f
...
@@ -945,7 +945,7 @@ def test_gpujoin_gpualloc():
...
@@ -945,7 +945,7 @@ def test_gpujoin_gpualloc():
mode
=
mode_with_gpu
)
mode
=
mode_with_gpu
)
assert
sum
([
node
.
op
==
T
.
alloc
for
node
in
f
.
maker
.
fgraph
.
toposort
()])
==
2
assert
sum
([
node
.
op
==
T
.
alloc
for
node
in
f
.
maker
.
fgraph
.
toposort
()])
==
2
assert
sum
([
node
.
op
==
T
.
join
for
node
in
f
.
maker
.
fgraph
.
toposort
()])
==
1
assert
sum
([
isinstance
(
node
.
op
,
T
.
Join
)
for
node
in
f
.
maker
.
fgraph
.
toposort
()])
==
1
assert
sum
([
isinstance
(
node
.
op
,
B
.
GpuAlloc
)
assert
sum
([
isinstance
(
node
.
op
,
B
.
GpuAlloc
)
for
node
in
f_gpu
.
maker
.
fgraph
.
toposort
()])
==
2
for
node
in
f_gpu
.
maker
.
fgraph
.
toposort
()])
==
2
assert
sum
([
node
.
op
==
B
.
gpu_join
assert
sum
([
node
.
op
==
B
.
gpu_join
...
...
theano/tensor/basic.py
浏览文件 @
6052f90f
...
@@ -4174,9 +4174,18 @@ class Join(Op):
...
@@ -4174,9 +4174,18 @@ class Join(Op):
return
[
tuple
(
out_shapes
)]
return
[
tuple
(
out_shapes
)]
"""
join_
=
Join
()
pprint
.
assign
(
Join
,
printing
.
FunctionPrinter
(
'join'
))
def
join
(
axis
,
*
tensors_list
):
"""
Convenience function to concatenate `TensorType`s along the given axis.
Convenience function to concatenate `TensorType`s along the given axis.
This function will not add the op in the graph when it is not useful.
For example, in the case that the list of tensors to be concatenated
is one, it will just return the tensor.
Parameters
Parameters
----------
----------
tensors : list of tensors (or list-like)
tensors : list of tensors (or list-like)
...
@@ -4193,12 +4202,11 @@ class Join(Op):
...
@@ -4193,12 +4202,11 @@ class Join(Op):
former case, the axis is fixed at construction, while in the
former case, the axis is fixed at construction, while in the
latter it may vary over time depending on the value of the
latter it may vary over time depending on the value of the
`axis` variable.
`axis` variable.
"""
"""
if
len
(
tensors_list
)
==
1
:
return
tensors_list
[
0
]
join
=
Join
()
else
:
return
join_
(
axis
,
*
tensors_list
)
pprint
.
assign
(
Join
,
printing
.
FunctionPrinter
(
'join'
))
def
roll
(
x
,
shift
,
axis
=
None
):
def
roll
(
x
,
shift
,
axis
=
None
):
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
6052f90f
...
@@ -4372,6 +4372,25 @@ def test_join_inplace():
...
@@ -4372,6 +4372,25 @@ def test_join_inplace():
assert
numpy
.
allclose
(
f
(
data
,
0
),
[
3
,
4
,
5
])
assert
numpy
.
allclose
(
f
(
data
,
0
),
[
3
,
4
,
5
])
def
test_join_oneInput
():
"""Test join when only 1 input is given.
This functions tests the case when concatenate is called
on an array of tensors but the array has only one element.
In this case, we would like to avoid the computational
overhead of concatenation of one element.
"""
x_0
=
theano
.
tensor
.
fmatrix
()
x_1
=
theano
.
tensor
.
fmatrix
()
x_2
=
theano
.
tensor
.
fvector
()
join_0
=
theano
.
tensor
.
concatenate
([
x_0
],
axis
=
1
)
join_1
=
theano
.
tensor
.
concatenate
([
x_0
,
x_1
,
theano
.
tensor
.
shape_padright
(
x_2
)],
axis
=
1
)
assert
join_0
is
x_0
assert
join_1
is
not
x_0
class
test_comparison
(
unittest
.
TestCase
):
class
test_comparison
(
unittest
.
TestCase
):
"""Test <, >, <=, >=, == and !=
"""Test <, >, <=, >=, == and !=
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论