Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e9264ec6
提交
e9264ec6
authored
3月 15, 2012
作者:
Olivier Delalleau
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #534 from lamblin/fix_for_win64
Fix for win64
上级
263d7d26
d7a83e6c
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
54 行增加
和
42 行删除
+54
-42
test_pfunc.py
theano/compile/tests/test_pfunc.py
+1
-1
test_shared.py
theano/compile/tests/test_shared.py
+1
-1
cmodule.py
theano/gof/cmodule.py
+18
-7
scan_opt.py
theano/scan_module/scan_opt.py
+9
-8
basic.py
theano/tensor/basic.py
+24
-24
opt.py
theano/tensor/opt.py
+1
-1
没有找到文件。
theano/compile/tests/test_pfunc.py
浏览文件 @
e9264ec6
...
...
@@ -556,7 +556,7 @@ class Test_pfunc(unittest.TestCase):
def
test_default_updates_input
(
self
):
x
=
shared
(
0
)
y
=
shared
(
1
)
if
theano
.
gof
.
cmodule
.
local
_bitwidth
()
==
32
:
if
theano
.
gof
.
cmodule
.
python_int
_bitwidth
()
==
32
:
a
=
iscalar
(
'a'
)
else
:
a
=
lscalar
(
'a'
)
...
...
theano/compile/tests/test_shared.py
浏览文件 @
e9264ec6
...
...
@@ -16,7 +16,7 @@ class Test_SharedVariable(unittest.TestCase):
assert
shared
(
7
,
dtype
=
'float64'
)
.
type
==
Scalar
(
'float64'
)
else
:
if
theano
.
gof
.
cmodule
.
local_bitwidth
()
==
32
:
if
theano
.
gof
.
cmodule
.
python_int_bitwidth
()
==
32
:
assert
shared
(
7
)
.
type
==
theano
.
tensor
.
iscalar
,
shared
(
7
)
.
type
else
:
assert
shared
(
7
)
.
type
==
theano
.
tensor
.
lscalar
,
shared
(
7
)
.
type
...
...
theano/gof/cmodule.py
浏览文件 @
e9264ec6
...
...
@@ -5,6 +5,7 @@ import cPickle
import
logging
import
operator
import
os
import
platform
import
shutil
import
stat
import
StringIO
...
...
@@ -28,13 +29,23 @@ AddConfigVar('cmodule.mac_framework_link',
BoolParam
(
False
))
def
local_bitwidth
():
"""Return 32 for 32bit arch, 64 for 64bit arch"""
# Note - it seems from an informal survey of machines at scipy2010
# that platform.architecture is also a reliable way to get the bitwidth
try
:
maxint
=
sys
.
maxint
except
AttributeError
:
# python 3 compatibility
maxint
=
sys
.
maxsize
"""
Return 32 for 32bit arch, 64 for 64bit arch
By "architecture", we mean the size of memory pointers (size_t in C),
*not* the size of long int, as it can be different.
"""
# Platform.architecture is not reliable on OS X with universal binaries
maxsize
=
sys
.
maxsize
return
len
(
'
%
x'
%
maxsize
)
*
4
def
python_int_bitwidth
():
"""
Return the bit width of Python int (C long int).
Note that it can be different from the size of a memory pointer.
"""
maxint
=
sys
.
maxint
return
len
(
'
%
x'
%
maxint
)
*
4
_logger
=
logging
.
getLogger
(
"theano.gof.cmodule"
)
...
...
theano/scan_module/scan_opt.py
浏览文件 @
e9264ec6
...
...
@@ -497,7 +497,7 @@ class ScanSaveMem(gof.Optimizer):
stop
=
tensor
.
basic
.
extract_constant
(
cf_slice
[
0
]
.
stop
)
else
:
stop
=
tensor
.
basic
.
extract_constant
(
cf_slice
[
0
])
+
1
if
stop
==
sys
.
max
int
or
stop
==
length
:
if
stop
==
sys
.
max
size
or
stop
==
length
:
stop
=
None
else
:
# there is a **gotcha** here ! Namely, scan returns an
...
...
@@ -515,15 +515,16 @@ class ScanSaveMem(gof.Optimizer):
# yes if it is a tensor
if
isinstance
(
stop
,
tensor
.
Variable
):
global_nsteps
[
'sym'
]
+=
[
stop
]
# not if it is maxint
elif
(
type
(
stop
)
is
int
and
stop
==
sys
.
maxint
):
# not if it is maxsize
elif
(
type
(
stop
)
in
(
int
,
long
)
and
stop
==
sys
.
maxsize
):
global_nsteps
=
None
# yes if it is a int k, 0 < k < max
int
elif
(
type
(
stop
)
i
s
int
and
# yes if it is a int k, 0 < k < max
size
elif
(
type
(
stop
)
i
n
(
int
,
long
)
and
global_nsteps
[
'real'
]
<
stop
):
global_nsteps
[
'real'
]
=
stop
# yes if it is a int k, 0 < k < max
int
elif
(
type
(
stop
)
i
s
int
and
stop
>
0
):
# yes if it is a int k, 0 < k < max
size
elif
(
type
(
stop
)
i
n
(
int
,
long
)
and
stop
>
0
):
pass
# not otherwise
else
:
...
...
@@ -755,7 +756,7 @@ class ScanSaveMem(gof.Optimizer):
start
=
(
cnf_slice
[
0
]
.
start
-
nw_steps
-
init_l
[
pos
]
+
store_steps
[
pos
])
if
(
cnf_slice
[
0
]
.
stop
is
not
None
and
cnf_slice
[
0
]
.
stop
!=
sys
.
max
int
):
cnf_slice
[
0
]
.
stop
!=
sys
.
max
size
):
stop
=
(
cnf_slice
[
0
]
.
stop
-
nw_steps
-
init_l
[
pos
]
+
store_steps
[
pos
])
else
:
...
...
theano/tensor/basic.py
浏览文件 @
e9264ec6
...
...
@@ -3,7 +3,7 @@
__docformat__
=
"restructuredtext en"
import
__builtin__
import
sys
# for sys.max
int
import
sys
# for sys.max
size
from
theano.configparser
import
config
import
warnings
from
itertools
import
izip
...
...
@@ -1413,10 +1413,14 @@ class _tensor_py_operators:
return
cast
(
self
,
dtype
)
#SLICING
# def __getitem__(self, args): return Subtensor.from_idxs(self,
# args).outputs[0]
# def __getslice__(self, *args): return Subtensor.from_idxs(self,
# (slice(*args),)).outputs[0]
# Do not define __getslice__ here:
# When calling t[1:], for instance, the arguments passed to __getslice__
# are (1, sys.maxsize), which is a pain to deal with, and can even not be
# an int (but a long).
# If __getslice__ does not exist, __getitem__ is called instead, with
# argument slice(1, None, None), which is much more desirable.
# __getslice__ is deprecated in python 2.6 anyway.
def
__getitem__
(
self
,
args
):
if
not
isinstance
(
args
,
tuple
):
args
=
args
,
...
...
@@ -1445,10 +1449,6 @@ class _tensor_py_operators:
else
:
return
Subtensor
(
args
)(
self
,
*
Subtensor
.
collapse
(
args
,
lambda
entry
:
isinstance
(
entry
,
Variable
)))
def
__getslice__
(
self
,
*
args
):
args
=
slice
(
*
args
),
return
self
.
__getitem__
(
args
)
#COPYING
def
copy
(
self
):
return
tensor_copy
(
self
)
...
...
@@ -3124,7 +3124,10 @@ def get_canonical_form_slice(theslice, length):
start
=
switch
(
ge
(
start
,
length
)
,
switch
(
lt
(
step
,
0
),
length
-
1
,
length
)
,
start
)
if
stop
in
[
None
,
sys
.
maxint
]:
if
stop
in
[
None
,
sys
.
maxsize
]:
# The special "maxsize" case is probably not needed here,
# as slices containing maxsize are not generated by
# __getslice__ anymore.
stop
=
defstop
else
:
stop
=
switch
(
lt
(
stop
,
0
),
stop
+
length
,
stop
)
...
...
@@ -3246,7 +3249,10 @@ class Subtensor(Op):
else
:
slice_a
=
None
if
b
is
not
None
:
if
b
is
not
None
and
b
!=
sys
.
maxsize
:
# The special "maxsize" case is probably not needed here,
# as slices containing maxsize are not generated by
# __getslice__ anymore.
slice_b
=
Subtensor
.
convert
(
b
,
False
)
else
:
slice_b
=
None
...
...
@@ -3256,11 +3262,7 @@ class Subtensor(Op):
else
:
slice_c
=
None
return
slice
(
slice_a
,
slice_b
,
slice_c
)
#backport
#return slice(Subtensor.convert(a, False) if a is not None else None,
# Subtensor.convert(b, False) if b is not None else None,
# Subtensor.convert(c, False) if c is not None else None)
return
slice
(
slice_a
,
slice_b
,
slice_c
)
elif
isinstance
(
entry
,
int
):
return
entry
...
...
@@ -3348,7 +3350,7 @@ class Subtensor(Op):
# If it is the default (None, None, None) slice, or a variant,
# the shape will be xl
if
(
(
idx
.
start
in
[
None
,
0
])
and
(
idx
.
stop
in
[
None
,
sys
.
max
int
])
and
(
idx
.
stop
in
[
None
,
sys
.
max
size
])
and
(
idx
.
step
is
None
or
idx
.
step
==
1
)
):
outshp
.
append
(
xl
)
else
:
...
...
@@ -3420,7 +3422,9 @@ class Subtensor(Op):
fail
=
sub
[
'fail'
]
init_cmds
=
[]
# initialization for subtensor_spec
is_slice
=
[]
NONE_CODE
=
sys
.
maxint
-
1
#TODO: change that, it might lead to unexpected results,
# see assembla-#767
NONE_CODE
=
sys
.
maxsize
-
1
pos
=
[
0
,
1
]
#annoying version of global variable for init_entry
def
inc_spec_pos
(
amt
):
pos
[
0
]
+=
amt
...
...
@@ -3637,7 +3641,7 @@ class Subtensor(Op):
@staticmethod
def
helper_c_code_cache_version
():
return
(
3
,)
return
(
4
,)
def
c_code
(
self
,
node
,
name
,
inputs
,
outputs
,
sub
):
#DEBUG
part0
=
self
.
helper_c_code
(
node
,
name
,
inputs
,
outputs
,
sub
,
...
...
@@ -3694,7 +3698,7 @@ class SubtensorPrinter:
else
:
msg1
=
entry
.
start
if
entry
.
stop
is
None
or
entry
.
stop
==
sys
.
max
int
:
if
entry
.
stop
is
None
or
entry
.
stop
==
sys
.
max
size
:
msg2
=
""
else
:
msg2
=
entry
.
stop
...
...
@@ -3705,10 +3709,6 @@ class SubtensorPrinter:
msg3
=
":
%
s"
%
entry
.
step
sidxs
.
append
(
"
%
s:
%
s
%
s"
%
(
msg1
,
msg2
,
msg3
))
#backport
#sidxs.append("%s:%s%s" % ("" if entry.start is None or entry.start == 0 else entry.start,
# "" if entry.stop is None or entry.stop == sys.maxint else entry.stop,
# "" if entry.step is None else ":%s" % entry.step))
return
"
%
s[
%
s]"
%
(
pstate
.
pprinter
.
process
(
input
,
pstate
.
clone
(
precedence
=
1000
)),
", "
.
join
(
sidxs
))
else
:
raise
TypeError
(
"Can only print Subtensor."
)
...
...
theano/tensor/opt.py
浏览文件 @
e9264ec6
...
...
@@ -1507,7 +1507,7 @@ def local_useless_subtensor(node):
# is not a useless subtensor
return
False
length_pos_data
=
sys
.
max
int
length_pos_data
=
sys
.
max
size
length_pos
=
shape_of
[
node
.
inputs
[
0
]][
pos
]
try
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论