Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
88b49770
提交
88b49770
authored
6月 13, 2017
作者:
Pascal Lamblin
提交者:
GitHub
6月 13, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6025 from nouiz/nanguardmode_int
[ENH] Speed up nanguardmode by not checking *int* dtype
上级
4e8eac00
0509589f
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
32 行增加
和
0 行删除
+32
-0
nanguardmode.py
theano/compile/nanguardmode.py
+4
-0
test_misc.py
theano/gpuarray/tests/test_misc.py
+23
-0
basic.py
theano/scalar/basic.py
+5
-0
没有找到文件。
theano/compile/nanguardmode.py
浏览文件 @
88b49770
...
@@ -106,6 +106,8 @@ def contains_nan(arr, node=None, var=None):
...
@@ -106,6 +106,8 @@ def contains_nan(arr, node=None, var=None):
"""
"""
if
not
_is_numeric_value
(
arr
,
var
):
if
not
_is_numeric_value
(
arr
,
var
):
return
False
return
False
elif
getattr
(
arr
,
'dtype'
,
''
)
in
T
.
discrete_dtypes
:
return
False
elif
pygpu_available
and
isinstance
(
arr
,
GpuArray
):
elif
pygpu_available
and
isinstance
(
arr
,
GpuArray
):
return
np
.
isnan
(
f_gpua_min
(
arr
.
reshape
(
arr
.
size
)))
return
np
.
isnan
(
f_gpua_min
(
arr
.
reshape
(
arr
.
size
)))
...
@@ -139,6 +141,8 @@ def contains_inf(arr, node=None, var=None):
...
@@ -139,6 +141,8 @@ def contains_inf(arr, node=None, var=None):
"""
"""
if
not
_is_numeric_value
(
arr
,
var
):
if
not
_is_numeric_value
(
arr
,
var
):
return
False
return
False
elif
getattr
(
arr
,
'dtype'
,
''
)
in
T
.
discrete_dtypes
:
return
False
elif
pygpu_available
and
isinstance
(
arr
,
GpuArray
):
elif
pygpu_available
and
isinstance
(
arr
,
GpuArray
):
return
(
np
.
isinf
(
f_gpua_min
(
arr
.
reshape
(
arr
.
size
)))
or
return
(
np
.
isinf
(
f_gpua_min
(
arr
.
reshape
(
arr
.
size
)))
or
np
.
isinf
(
f_gpua_max
(
arr
.
reshape
(
arr
.
size
))))
np
.
isinf
(
f_gpua_max
(
arr
.
reshape
(
arr
.
size
))))
...
...
theano/gpuarray/tests/test_misc.py
0 → 100644
浏览文件 @
88b49770
# Test that normaly could be outside gpuarray, to have all gpuarray
# tests in the same directory, we put them here.
from
__future__
import
absolute_import
,
print_function
,
division
import
numpy
as
np
import
theano
from
theano
import
tensor
from
theano.compile.nanguardmode
import
NanGuardMode
from
.config
import
mode_with_gpu
def
test_nan_guard_mode
():
# Also test that abs uint* and bool have c code.
for
dtype
in
[
'uint8'
,
'int64'
,
'bool'
]:
x
=
tensor
.
vector
(
dtype
=
dtype
)
y
=
x
+
1
mode
=
NanGuardMode
(
nan_is_error
=
True
,
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
浏览文件 @
88b49770
...
@@ -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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论