Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c95f7e8b
提交
c95f7e8b
authored
3月 17, 2017
作者:
Frédéric Bastien
提交者:
GitHub
3月 17, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5717 from nouiz/careduce
crash fix of careduce with bool
上级
127ae529
f586678d
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
12 行增加
和
6 行删除
+12
-6
elemwise.py
theano/tensor/elemwise.py
+5
-2
test_elemwise.py
theano/tensor/tests/test_elemwise.py
+7
-4
没有找到文件。
theano/tensor/elemwise.py
浏览文件 @
c95f7e8b
...
...
@@ -1539,8 +1539,8 @@ class CAReduce(Op):
scal_name
=
'maximum'
if
input
.
type
.
dtype
in
[
"float32"
,
"float64"
]:
identity
=
"-__builtin_inf()"
elif
input
.
type
.
dtype
.
startswith
(
"uint"
):
# numpy does not define NPY_MIN_UINT*
elif
input
.
type
.
dtype
.
startswith
(
"uint"
)
or
input
.
type
.
dtype
==
'bool'
:
# numpy does not define NPY_MIN_UINT*
and NPY_MIN_BOOL
identity
=
"0"
else
:
identity
=
"NPY_MIN_"
+
str
(
input
.
type
.
dtype
)
.
upper
()
...
...
@@ -1548,6 +1548,9 @@ class CAReduce(Op):
scal_name
=
'minimum'
if
input
.
type
.
dtype
in
[
"float32"
,
"float64"
]:
identity
=
"__builtin_inf()"
elif
input
.
type
.
dtype
==
'bool'
:
# numpy does not define NPY_MAX_BOOL
identity
=
"1"
else
:
identity
=
"NPY_MAX_"
+
str
(
input
.
type
.
dtype
)
.
upper
()
fail
=
sub
[
"fail"
]
...
...
theano/tensor/tests/test_elemwise.py
浏览文件 @
c95f7e8b
...
...
@@ -426,6 +426,9 @@ class test_CAReduce(unittest_tools.InferShapeTester):
elif
scalar_op
==
scalar
.
add
:
for
axis
in
reversed
(
sorted
(
tosum
)):
zv
=
numpy
.
add
.
reduce
(
zv
,
axis
)
if
dtype
==
'bool'
:
# numpy.add of a bool upcast, while CAReduce don't
zv
=
zv
.
astype
(
dtype
)
elif
scalar_op
==
scalar
.
mul
:
for
axis
in
reversed
(
sorted
(
tosum
)):
zv
=
numpy
.
multiply
.
reduce
(
zv
,
axis
)
...
...
@@ -503,7 +506,7 @@ class test_CAReduce(unittest_tools.InferShapeTester):
assert
xv
.
size
==
0
def
test_perform
(
self
):
for
dtype
in
[
"floatX"
,
"complex64"
,
"complex128"
,
"int8"
,
"uint8"
]:
for
dtype
in
[
"
bool"
,
"
floatX"
,
"complex64"
,
"complex128"
,
"int8"
,
"uint8"
]:
self
.
with_linker
(
gof
.
PerformLinker
(),
scalar
.
add
,
dtype
=
dtype
)
self
.
with_linker
(
gof
.
PerformLinker
(),
scalar
.
mul
,
dtype
=
dtype
)
self
.
with_linker
(
gof
.
PerformLinker
(),
scalar
.
maximum
,
dtype
=
dtype
)
...
...
@@ -537,17 +540,17 @@ class test_CAReduce(unittest_tools.InferShapeTester):
if
not
theano
.
config
.
cxx
:
raise
SkipTest
(
"G++ not available, so we need to skip this test."
)
for
dtype
in
[
"floatX"
,
"complex64"
,
"complex128"
,
"int8"
,
"uint8"
]:
for
dtype
in
[
"
bool"
,
"
floatX"
,
"complex64"
,
"complex128"
,
"int8"
,
"uint8"
]:
self
.
with_linker
(
gof
.
CLinker
(),
scalar
.
add
,
dtype
=
dtype
)
self
.
with_linker
(
gof
.
CLinker
(),
scalar
.
mul
,
dtype
=
dtype
)
for
dtype
in
[
"floatX"
,
"int8"
,
"uint8"
]:
for
dtype
in
[
"
bool"
,
"
floatX"
,
"int8"
,
"uint8"
]:
self
.
with_linker
(
gof
.
CLinker
(),
scalar
.
minimum
,
dtype
=
dtype
)
self
.
with_linker
(
gof
.
CLinker
(),
scalar
.
maximum
,
dtype
=
dtype
)
self
.
with_linker
(
gof
.
CLinker
(),
scalar
.
and_
,
dtype
=
dtype
,
tensor_op
=
tensor
.
all
)
self
.
with_linker
(
gof
.
CLinker
(),
scalar
.
or_
,
dtype
=
dtype
,
tensor_op
=
tensor
.
any
)
for
dtype
in
[
"int8"
,
"uint8"
]:
for
dtype
in
[
"
bool"
,
"
int8"
,
"uint8"
]:
self
.
with_linker
(
gof
.
CLinker
(),
scalar
.
or_
,
dtype
=
dtype
)
self
.
with_linker
(
gof
.
CLinker
(),
scalar
.
and_
,
dtype
=
dtype
)
self
.
with_linker
(
gof
.
CLinker
(),
scalar
.
xor
,
dtype
=
dtype
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论