Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
02101b23
提交
02101b23
authored
10月 11, 2011
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix compilation crash on Mac OS X Lion.
We should not try to access C array before index 0!
上级
5e6ce10a
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
10 行增加
和
3 行删除
+10
-3
elemwise.py
theano/tensor/elemwise.py
+3
-2
test_elemwise.py
theano/tensor/tests/test_elemwise.py
+7
-1
没有找到文件。
theano/tensor/elemwise.py
浏览文件 @
02101b23
...
@@ -277,7 +277,8 @@ class DimShuffle(Op):
...
@@ -277,7 +277,8 @@ class DimShuffle(Op):
# set the strides of the broadcasted dimensions
# set the strides of the broadcasted dimensions
# this algorithm is from numpy: PyArray_Newshape() in cvs/numpy/numpy/core/src/multiarraymodule.c
# this algorithm is from numpy: PyArray_Newshape() in cvs/numpy/numpy/core/src/multiarraymodule.c
strides_statements
.
append
(
'if (strides['
+
str
(
nd_out
)
+
'-1] == 0) strides['
+
str
(
nd_out
)
+
'-1] =
%(basename)
s->descr->elsize'
)
if
nd_out
>
0
:
strides_statements
.
append
(
'if (strides['
+
str
(
nd_out
)
+
'-1] == 0) strides['
+
str
(
nd_out
)
+
'-1] =
%(basename)
s->descr->elsize'
)
for
i
in
xrange
(
nd_out
-
2
,
-
1
,
-
1
):
for
i
in
xrange
(
nd_out
-
2
,
-
1
,
-
1
):
strides_statements
.
append
(
"if (strides[
%(i)
s] == 0) strides[
%(i)
s] = strides[
%(i)
s+1] * dimensions[
%(i)
s+1]"
%
dict
(
i
=
str
(
i
)))
strides_statements
.
append
(
"if (strides[
%(i)
s] == 0) strides[
%(i)
s] = strides[
%(i)
s+1] * dimensions[
%(i)
s+1]"
%
dict
(
i
=
str
(
i
)))
...
@@ -326,7 +327,7 @@ class DimShuffle(Op):
...
@@ -326,7 +327,7 @@ class DimShuffle(Op):
return
full_code
%
dict
(
locals
(),
**
sub
)
return
full_code
%
dict
(
locals
(),
**
sub
)
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
return
(
1
,)
return
(
2
,)
def
grad
(
self
,
inp
,
grads
):
def
grad
(
self
,
inp
,
grads
):
x
,
=
inp
x
,
=
inp
...
...
theano/tensor/tests/test_elemwise.py
浏览文件 @
02101b23
...
@@ -26,7 +26,9 @@ class test_DimShuffle(unittest.TestCase):
...
@@ -26,7 +26,9 @@ class test_DimShuffle(unittest.TestCase):
((
2
,
3
,
4
),
(
2
,
1
,
0
),
(
4
,
3
,
2
)),
((
2
,
3
,
4
),
(
2
,
1
,
0
),
(
4
,
3
,
2
)),
((
2
,
3
,
4
),
(
'x'
,
2
,
1
,
0
,
'x'
),
(
1
,
4
,
3
,
2
,
1
)),
((
2
,
3
,
4
),
(
'x'
,
2
,
1
,
0
,
'x'
),
(
1
,
4
,
3
,
2
,
1
)),
((
1
,
4
,
3
,
2
,
1
),
(
3
,
2
,
1
),
(
2
,
3
,
4
)),
((
1
,
4
,
3
,
2
,
1
),
(
3
,
2
,
1
),
(
2
,
3
,
4
)),
((
1
,
1
,
4
),
(
1
,
2
),
(
1
,
4
))]:
((
1
,
1
,
4
),
(
1
,
2
),
(
1
,
4
)),
((
1
,
1
,
1
),
(),
()),
((
1
,),
(
'x'
,
'x'
),
(
1
,
1
)),]:
ib
=
[(
entry
==
1
)
for
entry
in
xsh
]
ib
=
[(
entry
==
1
)
for
entry
in
xsh
]
x
=
TensorType
(
'float64'
,
ib
)(
'x'
)
x
=
TensorType
(
'float64'
,
ib
)(
'x'
)
e
=
DimShuffle
(
ib
,
shuffle
)(
x
)
e
=
DimShuffle
(
ib
,
shuffle
)(
x
)
...
@@ -59,6 +61,10 @@ class test_DimShuffle(unittest.TestCase):
...
@@ -59,6 +61,10 @@ class test_DimShuffle(unittest.TestCase):
def
test_perform
(
self
):
def
test_perform
(
self
):
self
.
with_linker
(
gof
.
PerformLinker
())
self
.
with_linker
(
gof
.
PerformLinker
())
def
test_c_or_py
(
self
):
# Shape op don't have C code.
# But This will test DimShuffle c code
self
.
with_linker
(
gof
.
OpWiseCLinker
())
class
test_Broadcast
(
unittest
.
TestCase
):
class
test_Broadcast
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论