Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0dd1ca98
提交
0dd1ca98
authored
3月 15, 2012
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make maxsize available for python < 2.6, use it
上级
0882b46a
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
30 行增加
和
12 行删除
+30
-12
python25.py
theano/gof/python25.py
+17
-0
scan_opt.py
theano/scan_module/scan_opt.py
+4
-4
basic.py
theano/tensor/basic.py
+7
-7
opt.py
theano/tensor/opt.py
+2
-1
没有找到文件。
theano/gof/python25.py
浏览文件 @
0dd1ca98
...
@@ -130,5 +130,22 @@ if sys.version_info[:2] < (2,6):
...
@@ -130,5 +130,22 @@ if sys.version_info[:2] < (2,6):
for
prod
in
result
:
for
prod
in
result
:
yield
tuple
(
prod
)
yield
tuple
(
prod
)
# For maxsize
class
__Dummy
(
object
):
"""
Dummy class used to know what is the max index of a slice.
This way, we do not have to rely on guesses for untested
architectures.
"""
def
__getslice__
(
self
,
*
args
):
return
args
# This "slice" should be a (1, maxsize) tuple
__dummy_slice
=
__Dummy
()[
1
:]
maxsize
=
__dummy_slice
[
1
]
del
__dummy_slice
,
__Dummy
else
:
else
:
from
itertools
import
combinations
,
product
from
itertools
import
combinations
,
product
from
sys
import
maxsize
theano/scan_module/scan_opt.py
浏览文件 @
0dd1ca98
...
@@ -14,12 +14,12 @@ __contact__ = "Razvan Pascanu <r.pascanu@gmail>"
...
@@ -14,12 +14,12 @@ __contact__ = "Razvan Pascanu <r.pascanu@gmail>"
import
logging
import
logging
import
numpy
import
numpy
import
sys
import
theano
import
theano
from
theano
import
tensor
from
theano
import
tensor
from
theano.tensor
import
opt
,
get_constant_value
from
theano.tensor
import
opt
,
get_constant_value
from
theano
import
gof
from
theano
import
gof
from
theano.gof.python25
import
maxsize
from
theano.compile
import
optdb
from
theano.compile
import
optdb
from
theano
import
config
from
theano
import
config
from
theano.compile.function_module
import
deep_copy_op
from
theano.compile.function_module
import
deep_copy_op
...
@@ -497,7 +497,7 @@ class ScanSaveMem(gof.Optimizer):
...
@@ -497,7 +497,7 @@ class ScanSaveMem(gof.Optimizer):
stop
=
tensor
.
basic
.
extract_constant
(
cf_slice
[
0
]
.
stop
)
stop
=
tensor
.
basic
.
extract_constant
(
cf_slice
[
0
]
.
stop
)
else
:
else
:
stop
=
tensor
.
basic
.
extract_constant
(
cf_slice
[
0
])
+
1
stop
=
tensor
.
basic
.
extract_constant
(
cf_slice
[
0
])
+
1
if
stop
==
sys
.
maxsize
or
stop
==
length
:
if
stop
==
maxsize
or
stop
==
length
:
stop
=
None
stop
=
None
else
:
else
:
# there is a **gotcha** here ! Namely, scan returns an
# there is a **gotcha** here ! Namely, scan returns an
...
@@ -517,7 +517,7 @@ class ScanSaveMem(gof.Optimizer):
...
@@ -517,7 +517,7 @@ class ScanSaveMem(gof.Optimizer):
global_nsteps
[
'sym'
]
+=
[
stop
]
global_nsteps
[
'sym'
]
+=
[
stop
]
# not if it is maxsize
# not if it is maxsize
elif
(
type
(
stop
)
in
(
int
,
long
)
and
elif
(
type
(
stop
)
in
(
int
,
long
)
and
stop
==
sys
.
maxsize
):
stop
==
maxsize
):
global_nsteps
=
None
global_nsteps
=
None
# yes if it is a int k, 0 < k < maxsize
# yes if it is a int k, 0 < k < maxsize
elif
(
type
(
stop
)
in
(
int
,
long
)
and
elif
(
type
(
stop
)
in
(
int
,
long
)
and
...
@@ -756,7 +756,7 @@ class ScanSaveMem(gof.Optimizer):
...
@@ -756,7 +756,7 @@ class ScanSaveMem(gof.Optimizer):
start
=
(
cnf_slice
[
0
]
.
start
-
nw_steps
-
start
=
(
cnf_slice
[
0
]
.
start
-
nw_steps
-
init_l
[
pos
]
+
store_steps
[
pos
])
init_l
[
pos
]
+
store_steps
[
pos
])
if
(
cnf_slice
[
0
]
.
stop
is
not
None
and
if
(
cnf_slice
[
0
]
.
stop
is
not
None
and
cnf_slice
[
0
]
.
stop
!=
sys
.
maxsize
):
cnf_slice
[
0
]
.
stop
!=
maxsize
):
stop
=
(
cnf_slice
[
0
]
.
stop
-
nw_steps
-
stop
=
(
cnf_slice
[
0
]
.
stop
-
nw_steps
-
init_l
[
pos
]
+
store_steps
[
pos
])
init_l
[
pos
]
+
store_steps
[
pos
])
else
:
else
:
...
...
theano/tensor/basic.py
浏览文件 @
0dd1ca98
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
__docformat__
=
"restructuredtext en"
__docformat__
=
"restructuredtext en"
import
__builtin__
import
__builtin__
import
sys
# for sys.maxsize
import
sys
from
theano.configparser
import
config
from
theano.configparser
import
config
import
warnings
import
warnings
from
itertools
import
izip
from
itertools
import
izip
...
@@ -17,7 +17,7 @@ from theano.gof import Apply, Constant, Op, Type, Value, Variable
...
@@ -17,7 +17,7 @@ from theano.gof import Apply, Constant, Op, Type, Value, Variable
import
elemwise
import
elemwise
from
theano
import
scalar
as
scal
from
theano
import
scalar
as
scal
from
theano.gof.python25
import
partial
,
any
,
all
from
theano.gof.python25
import
partial
,
any
,
all
,
maxsize
from
theano
import
compile
,
printing
from
theano
import
compile
,
printing
from
theano.printing
import
pprint
,
min_informative_str
from
theano.printing
import
pprint
,
min_informative_str
from
theano.tensor.utils
import
hash_from_ndarray
from
theano.tensor.utils
import
hash_from_ndarray
...
@@ -3124,7 +3124,7 @@ def get_canonical_form_slice(theslice, length):
...
@@ -3124,7 +3124,7 @@ def get_canonical_form_slice(theslice, length):
start
=
switch
(
ge
(
start
,
length
)
start
=
switch
(
ge
(
start
,
length
)
,
switch
(
lt
(
step
,
0
),
length
-
1
,
length
)
,
switch
(
lt
(
step
,
0
),
length
-
1
,
length
)
,
start
)
,
start
)
if
stop
in
[
None
,
sys
.
maxsize
]:
if
stop
in
[
None
,
maxsize
]:
# The special "maxsize" case is probably not needed here,
# The special "maxsize" case is probably not needed here,
# as slices containing maxsize are not generated by
# as slices containing maxsize are not generated by
# __getslice__ anymore.
# __getslice__ anymore.
...
@@ -3249,7 +3249,7 @@ class Subtensor(Op):
...
@@ -3249,7 +3249,7 @@ class Subtensor(Op):
else
:
else
:
slice_a
=
None
slice_a
=
None
if
b
is
not
None
and
b
!=
sys
.
maxsize
:
if
b
is
not
None
and
b
!=
maxsize
:
# The special "maxsize" case is probably not needed here,
# The special "maxsize" case is probably not needed here,
# as slices containing maxsize are not generated by
# as slices containing maxsize are not generated by
# __getslice__ anymore.
# __getslice__ anymore.
...
@@ -3350,7 +3350,7 @@ class Subtensor(Op):
...
@@ -3350,7 +3350,7 @@ class Subtensor(Op):
# If it is the default (None, None, None) slice, or a variant,
# If it is the default (None, None, None) slice, or a variant,
# the shape will be xl
# the shape will be xl
if
(
(
idx
.
start
in
[
None
,
0
])
if
(
(
idx
.
start
in
[
None
,
0
])
and
(
idx
.
stop
in
[
None
,
sys
.
maxsize
])
and
(
idx
.
stop
in
[
None
,
maxsize
])
and
(
idx
.
step
is
None
or
idx
.
step
==
1
)
):
and
(
idx
.
step
is
None
or
idx
.
step
==
1
)
):
outshp
.
append
(
xl
)
outshp
.
append
(
xl
)
else
:
else
:
...
@@ -3424,7 +3424,7 @@ class Subtensor(Op):
...
@@ -3424,7 +3424,7 @@ class Subtensor(Op):
is_slice
=
[]
is_slice
=
[]
#TODO: change that, it might lead to unexpected results,
#TODO: change that, it might lead to unexpected results,
# see assembla-#767
# see assembla-#767
NONE_CODE
=
sys
.
maxsize
-
1
NONE_CODE
=
maxsize
-
1
pos
=
[
0
,
1
]
#annoying version of global variable for init_entry
pos
=
[
0
,
1
]
#annoying version of global variable for init_entry
def
inc_spec_pos
(
amt
):
pos
[
0
]
+=
amt
def
inc_spec_pos
(
amt
):
pos
[
0
]
+=
amt
...
@@ -3698,7 +3698,7 @@ class SubtensorPrinter:
...
@@ -3698,7 +3698,7 @@ class SubtensorPrinter:
else
:
else
:
msg1
=
entry
.
start
msg1
=
entry
.
start
if
entry
.
stop
is
None
or
entry
.
stop
==
sys
.
maxsize
:
if
entry
.
stop
is
None
or
entry
.
stop
==
maxsize
:
msg2
=
""
msg2
=
""
else
:
else
:
msg2
=
entry
.
stop
msg2
=
entry
.
stop
...
...
theano/tensor/opt.py
浏览文件 @
0dd1ca98
...
@@ -20,6 +20,7 @@ import theano
...
@@ -20,6 +20,7 @@ import theano
from
theano
import
gof
from
theano
import
gof
from
theano.gof
import
opt
,
InconsistencyError
,
TopoOptimizer
,
graph
from
theano.gof
import
opt
,
InconsistencyError
,
TopoOptimizer
,
graph
from
theano.gof
import
Variable
,
Constant
from
theano.gof
import
Variable
,
Constant
from
theano.gof.python25
import
maxsize
from
theano.gof.utils
import
MethodNotDefined
from
theano.gof.utils
import
MethodNotDefined
from
theano.configparser
import
config
from
theano.configparser
import
config
from
elemwise
import
Elemwise
,
DimShuffle
from
elemwise
import
Elemwise
,
DimShuffle
...
@@ -1507,7 +1508,7 @@ def local_useless_subtensor(node):
...
@@ -1507,7 +1508,7 @@ def local_useless_subtensor(node):
# is not a useless subtensor
# is not a useless subtensor
return
False
return
False
length_pos_data
=
sys
.
maxsize
length_pos_data
=
maxsize
length_pos
=
shape_of
[
node
.
inputs
[
0
]][
pos
]
length_pos
=
shape_of
[
node
.
inputs
[
0
]][
pos
]
try
:
try
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论