Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
88c9397d
提交
88c9397d
authored
6月 12, 2017
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add c code to abs for uint* and bool
上级
14c79a2a
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
15 行增加
和
6 行删除
+15
-6
test_misc.py
theano/gpuarray/tests/test_misc.py
+10
-6
basic.py
theano/scalar/basic.py
+5
-0
没有找到文件。
theano/gpuarray/tests/test_misc.py
浏览文件 @
88c9397d
# Test that normaly could be outside gpuarray, to have all gpuarray
# Test that normaly could be outside gpuarray, to have all gpuarray
# tests in the same directory, we put them here.
# tests in the same directory, we put them here.
import
numpy
as
np
import
theano
import
theano
from
theano
import
tensor
from
theano
import
tensor
...
@@ -9,9 +10,12 @@ from .config import mode_with_gpu
...
@@ -9,9 +10,12 @@ from .config import mode_with_gpu
def
test_nan_guard_mode
():
def
test_nan_guard_mode
():
x
=
tensor
.
vector
(
dtype
=
'int64'
)
# Also test that abs uint* and bool have c code.
y
=
x
+
1
for
dtype
in
[
'uint8'
,
'int64'
,
'bool'
]:
mode
=
NanGuardMode
(
nan_is_error
=
True
,
optimizer
=
mode_with_gpu
.
optimizer
)
x
=
tensor
.
vector
(
dtype
=
dtype
)
f
=
theano
.
function
([
x
],
y
,
mode
=
mode
)
y
=
x
+
1
theano
.
printing
.
debugprint
(
f
)
mode
=
NanGuardMode
(
nan_is_error
=
True
,
f
([
23
,
7
])
optimizer
=
mode_with_gpu
.
optimizer
)
f
=
theano
.
function
([
x
],
y
,
mode
=
mode
)
d
=
np
.
asarray
([
23
,
7
])
.
astype
(
dtype
)
assert
np
.
allclose
(
f
(
d
),
d
+
1
)
theano/scalar/basic.py
浏览文件 @
88c9397d
...
@@ -2420,6 +2420,11 @@ class Abs(UnaryScalarOp):
...
@@ -2420,6 +2420,11 @@ class Abs(UnaryScalarOp):
return
"
%(z)
s = fabs(
%(x)
s);"
%
locals
()
return
"
%(z)
s = fabs(
%(x)
s);"
%
locals
()
if
type
in
complex_types
:
if
type
in
complex_types
:
return
"
%(z)
s = sqrt(
%(x)
s.real*
%(x)
s.real +
%(x)
s.imag*
%(x)
s.imag);"
%
locals
()
return
"
%(z)
s = sqrt(
%(x)
s.real*
%(x)
s.real +
%(x)
s.imag*
%(x)
s.imag);"
%
locals
()
if
node
.
outputs
[
0
]
.
type
==
bool
:
return
"
%(z)
s = (
%(x)
s) ? 1 : 0;"
%
locals
()
if
type
in
uint_types
:
# uint are always already absolute value.
return
"
%(z)
s =
%(x)
s;"
%
locals
()
raise
NotImplementedError
(
'type not supported'
,
type
)
raise
NotImplementedError
(
'type not supported'
,
type
)
abs_
=
Abs
(
same_out
)
abs_
=
Abs
(
same_out
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论