Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
3a0493c2
提交
3a0493c2
authored
1月 18, 2016
作者:
abergeron
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3875 from abergeron/fix_buildbot
Fix buildbot
上级
3dcba54d
534e040c
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
33 行增加
和
25 行删除
+33
-25
debugmode.py
theano/compile/debugmode.py
+5
-2
op.py
theano/gof/op.py
+15
-3
multinomial.py
theano/sandbox/multinomial.py
+2
-2
elemwise.py
theano/tensor/elemwise.py
+1
-18
test_conv.py
theano/tensor/nnet/tests/test_conv.py
+2
-0
test_corr.py
theano/tensor/nnet/tests/test_corr.py
+2
-0
test_basic.py
theano/tensor/tests/test_basic.py
+6
-0
没有找到文件。
theano/compile/debugmode.py
浏览文件 @
3a0493c2
...
@@ -1784,8 +1784,7 @@ class _VariableEquivalenceTracker(object):
...
@@ -1784,8 +1784,7 @@ class _VariableEquivalenceTracker(object):
# List of default version of make thunk.
# List of default version of make thunk.
# This is needed to know if the user overrided it.
# This is needed to know if the user overrided it.
# The GpuOp will be added here when theano.sandbox.cuda is imported.
# The GpuOp will be added here when theano.sandbox.cuda is imported.
default_make_thunk
=
[
get_unbound_function
(
theano
.
gof
.
Op
.
make_thunk
),
default_make_thunk
=
[
get_unbound_function
(
theano
.
gof
.
Op
.
make_thunk
)]
get_unbound_function
(
theano
.
gof
.
OpenMPOp
.
make_thunk
)]
# Debug mode cheats and initializes the linker in a different way in
# Debug mode cheats and initializes the linker in a different way in
...
@@ -1879,6 +1878,10 @@ class _Linker(gof.link.LocalLinker):
...
@@ -1879,6 +1878,10 @@ class _Linker(gof.link.LocalLinker):
thunk
.
inputs
=
[
storage_map
[
v
]
for
v
in
node
.
inputs
]
thunk
.
inputs
=
[
storage_map
[
v
]
for
v
in
node
.
inputs
]
thunk
.
outputs
=
[
storage_map
[
v
]
for
v
in
node
.
outputs
]
thunk
.
outputs
=
[
storage_map
[
v
]
for
v
in
node
.
outputs
]
thunk_other
=
thunk
thunk_other
=
thunk
else
:
new_node
=
node
.
op
.
prepare_node
(
node
)
if
new_node
is
not
None
:
node
=
new_node
try
:
try
:
if
not
self
.
maker
.
mode
.
check_c_code
:
if
not
self
.
maker
.
mode
.
check_c_code
:
...
...
theano/gof/op.py
浏览文件 @
3a0493c2
...
@@ -817,6 +817,16 @@ class Op(utils.object2, PureOp, CLinkerOp):
...
@@ -817,6 +817,16 @@ class Op(utils.object2, PureOp, CLinkerOp):
else
:
else
:
return
NotImplemented
return
NotImplemented
def
prepare_node
(
self
,
node
):
"""
Make any special modifications that the Op needs before doing
make_thunk().
This can either modify the node inplace or return a new one.
"""
pass
def
make_c_thunk
(
self
,
node
,
storage_map
,
compute_map
,
no_recycling
):
def
make_c_thunk
(
self
,
node
,
storage_map
,
compute_map
,
no_recycling
):
"""
"""
Like make_thunk, but will only try to make a C thunk.
Like make_thunk, but will only try to make a C thunk.
...
@@ -926,6 +936,10 @@ class Op(utils.object2, PureOp, CLinkerOp):
...
@@ -926,6 +936,10 @@ class Op(utils.object2, PureOp, CLinkerOp):
"""
"""
logger
=
logging
.
getLogger
(
'theano.gof.op.Op'
)
logger
=
logging
.
getLogger
(
'theano.gof.op.Op'
)
new_node
=
self
.
prepare_node
(
node
)
if
new_node
is
not
None
:
node
=
new_node
if
self
.
_op_use_c_code
:
if
self
.
_op_use_c_code
:
try
:
try
:
return
self
.
make_c_thunk
(
node
,
storage_map
,
compute_map
,
return
self
.
make_c_thunk
(
node
,
storage_map
,
compute_map
,
...
@@ -1162,10 +1176,8 @@ int main( int argc, const char* argv[] )
...
@@ -1162,10 +1176,8 @@ int main( int argc, const char* argv[] )
self
.
openmp
=
False
self
.
openmp
=
False
theano
.
config
.
openmp
=
False
theano
.
config
.
openmp
=
False
def
make_thunk
(
self
,
node
,
storage_map
,
compute_map
,
no_recycling
):
def
prepare_node
(
self
,
node
):
self
.
update_self_openmp
()
self
.
update_self_openmp
()
return
super
(
OpenMPOp
,
self
)
.
make_thunk
(
node
,
storage_map
,
compute_map
,
no_recycling
)
def
simple_meth
(
tag
):
def
simple_meth
(
tag
):
...
...
theano/sandbox/multinomial.py
浏览文件 @
3a0493c2
...
@@ -55,7 +55,7 @@ class MultinomialFromUniform(Op):
...
@@ -55,7 +55,7 @@ class MultinomialFromUniform(Op):
return
[
T
.
zeros_like
(
x
)
for
x
in
ins
]
return
[
T
.
zeros_like
(
x
)
for
x
in
ins
]
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
return
(
7
,)
return
(
8
,)
def
c_code
(
self
,
node
,
name
,
ins
,
outs
,
sub
):
def
c_code
(
self
,
node
,
name
,
ins
,
outs
,
sub
):
# support old pickled graphs
# support old pickled graphs
...
@@ -122,7 +122,7 @@ class MultinomialFromUniform(Op):
...
@@ -122,7 +122,7 @@ class MultinomialFromUniform(Op):
for (int n = 0; n < nb_multi; ++n)
for (int n = 0; n < nb_multi; ++n)
{
{
int waiting = 1;
int waiting = 1;
d
type_
%(pvals)
s
cummul = 0.;
d
ouble
cummul = 0.;
const dtype_
%(unis)
s* unis_n = (dtype_
%(unis)
s*)PyArray_GETPTR1(
%(unis)
s, c*nb_multi + n);
const dtype_
%(unis)
s* unis_n = (dtype_
%(unis)
s*)PyArray_GETPTR1(
%(unis)
s, c*nb_multi + n);
for (int m = 0; m < nb_outcomes; ++m)
for (int m = 0; m < nb_outcomes; ++m)
{
{
...
...
theano/tensor/elemwise.py
浏览文件 @
3a0493c2
...
@@ -7,7 +7,6 @@ import numpy
...
@@ -7,7 +7,6 @@ import numpy
import
theano
import
theano
from
theano
import
gof
from
theano
import
gof
from
theano.compat
import
izip
from
theano.compat
import
izip
from
theano.compat
import
get_unbound_function
from
six
import
iteritems
from
six
import
iteritems
from
six.moves
import
xrange
from
six.moves
import
xrange
from
theano.gof
import
Apply
,
Op
,
OpenMPOp
from
theano.gof
import
Apply
,
Op
,
OpenMPOp
...
@@ -793,8 +792,7 @@ class Elemwise(OpenMPOp):
...
@@ -793,8 +792,7 @@ class Elemwise(OpenMPOp):
return
ret
return
ret
def
make_thunk
(
self
,
node
,
storage_map
,
compute_map
,
no_recycling
):
def
prepare_node
(
self
,
node
):
node_
=
node
# Postpone the ufunc building to the last minutes
# Postpone the ufunc building to the last minutes
# NumPy ufunc support only up to 31 inputs.
# NumPy ufunc support only up to 31 inputs.
# But our c code support more.
# But our c code support more.
...
@@ -830,8 +828,6 @@ class Elemwise(OpenMPOp):
...
@@ -830,8 +828,6 @@ class Elemwise(OpenMPOp):
char
=
numpy
.
sctype2char
(
out_dtype
)
char
=
numpy
.
sctype2char
(
out_dtype
)
sig
=
char
*
node
.
nin
+
'->'
+
char
*
node
.
nout
sig
=
char
*
node
.
nin
+
'->'
+
char
*
node
.
nout
node
.
tag
.
sig
=
sig
node
.
tag
.
sig
=
sig
return
super
(
Elemwise
,
node_
.
op
)
.
make_thunk
(
node_
,
storage_map
,
compute_map
,
no_recycling
)
def
perform
(
self
,
node
,
inputs
,
output_storage
):
def
perform
(
self
,
node
,
inputs
,
output_storage
):
if
len
(
node
.
inputs
)
>=
32
:
if
len
(
node
.
inputs
)
>=
32
:
...
@@ -1273,19 +1269,6 @@ class Elemwise(OpenMPOp):
...
@@ -1273,19 +1269,6 @@ class Elemwise(OpenMPOp):
"""
"""
return
node
.
outputs
[
0
]
.
ndim
==
0
return
node
.
outputs
[
0
]
.
ndim
==
0
theano
.
compile
.
debugmode
.
default_make_thunk
.
append
(
get_unbound_function
(
Elemwise
.
make_thunk
))
# def elemwise_to_scal(fgraph):
# TODO: why is this commented out? should it be removed?
# it has needed maintenance despite being commented
# mapping = {}
# inputs = []
# outputs = []
# for node in fgraph.io_toposort():
# if not isinstance(node.op, Elemwise):
# raise TypeError('All ops in the graph must be Elemwise.')
################
################
# CAReduce #
# CAReduce #
...
...
theano/tensor/nnet/tests/test_conv.py
浏览文件 @
3a0493c2
...
@@ -99,6 +99,8 @@ class TestConv2D(utt.InferShapeTester):
...
@@ -99,6 +99,8 @@ class TestConv2D(utt.InferShapeTester):
out_shape2d
=
numpy
.
array
(
N_image_shape
[
-
2
:])
+
\
out_shape2d
=
numpy
.
array
(
N_image_shape
[
-
2
:])
+
\
s
*
numpy
.
array
(
N_filter_shape
[
-
2
:])
-
s
s
*
numpy
.
array
(
N_filter_shape
[
-
2
:])
-
s
out_shape2d
=
numpy
.
ceil
(
out_shape2d
/
numpy
.
array
(
subsample
))
out_shape2d
=
numpy
.
ceil
(
out_shape2d
/
numpy
.
array
(
subsample
))
# avoid numpy deprecation
out_shape2d
=
out_shape2d
.
astype
(
'int32'
)
out_shape
=
(
N_image_shape
[
0
],
N_filter_shape
[
0
])
+
tuple
(
out_shape2d
)
out_shape
=
(
N_image_shape
[
0
],
N_filter_shape
[
0
])
+
tuple
(
out_shape2d
)
ref_output
=
numpy
.
zeros
(
out_shape
)
ref_output
=
numpy
.
zeros
(
out_shape
)
...
...
theano/tensor/nnet/tests/test_corr.py
浏览文件 @
3a0493c2
...
@@ -97,6 +97,8 @@ class TestCorr2D(utt.InferShapeTester):
...
@@ -97,6 +97,8 @@ class TestCorr2D(utt.InferShapeTester):
else
:
else
:
raise
NotImplementedError
(
'Unsupported border_mode {}'
.
format
(
border_mode
))
raise
NotImplementedError
(
'Unsupported border_mode {}'
.
format
(
border_mode
))
out_shape2d
=
numpy
.
floor
((
img_shape2d
+
2
*
(
padHW
)
-
fil_shape2d
)
/
subsample2d
)
+
1
out_shape2d
=
numpy
.
floor
((
img_shape2d
+
2
*
(
padHW
)
-
fil_shape2d
)
/
subsample2d
)
+
1
# avoid numpy deprecation
out_shape2d
=
out_shape2d
.
astype
(
'int32'
)
out_shape
=
(
N_image_shape
[
0
],
N_filter_shape
[
0
])
+
tuple
(
out_shape2d
)
out_shape
=
(
N_image_shape
[
0
],
N_filter_shape
[
0
])
+
tuple
(
out_shape2d
)
ref_output
=
numpy
.
zeros
(
out_shape
)
ref_output
=
numpy
.
zeros
(
out_shape
)
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
3a0493c2
...
@@ -1493,6 +1493,12 @@ CosInplaceTester = makeBroadcastTester(
...
@@ -1493,6 +1493,12 @@ CosInplaceTester = makeBroadcastTester(
grad
=
_grad_broadcast_unary_wide
,
grad
=
_grad_broadcast_unary_wide
,
inplace
=
True
)
inplace
=
True
)
def
test_py_c_match
():
a
=
tensor
.
TensorType
(
dtype
=
'int8'
,
broadcastable
=
(
False
,))()
f
=
theano
.
function
([
a
],
tensor
.
arccos
(
a
),
mode
=
'DebugMode'
)
# This can fail in DebugMode
f
(
numpy
.
asarray
([
1
,
0
,
-
1
],
dtype
=
'int8'
))
ArccosTester
=
makeBroadcastTester
(
op
=
tensor
.
arccos
,
ArccosTester
=
makeBroadcastTester
(
op
=
tensor
.
arccos
,
expected
=
upcast_float16_ufunc
(
numpy
.
arccos
),
expected
=
upcast_float16_ufunc
(
numpy
.
arccos
),
good
=
_good_broadcast_unary_arcsin
,
good
=
_good_broadcast_unary_arcsin
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论