Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
816a83e3
提交
816a83e3
authored
3月 07, 2013
作者:
nouiz
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1271 from lamblin/arch_in_cache
Always put arch bitwidth in cache
上级
3805afa3
1d3ba7ec
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
97 行增加
和
88 行删除
+97
-88
config.txt
doc/library/config.txt
+1
-1
test_pfunc.py
theano/compile/tests/test_pfunc.py
+1
-1
test_shared.py
theano/compile/tests/test_shared.py
+1
-1
__init__.py
theano/gof/__init__.py
+3
-2
cmodule.py
theano/gof/cmodule.py
+40
-60
compiledir.py
theano/gof/compiledir.py
+38
-9
utils.py
theano/gof/utils.py
+0
-0
nvcc_compiler.py
theano/sandbox/cuda/nvcc_compiler.py
+2
-4
extra_ops.py
theano/tensor/extra_ops.py
+4
-4
test_extra_ops.py
theano/tensor/tests/test_extra_ops.py
+7
-6
没有找到文件。
doc/library/config.txt
浏览文件 @
816a83e3
...
@@ -364,7 +364,7 @@ import theano and print the config variable, as in:
...
@@ -364,7 +364,7 @@ import theano and print the config variable, as in:
.. attribute:: compiledir_format
.. attribute:: compiledir_format
Default: "compiledir_%(platform)s-%(processor)s-%(python_version)s"
Default: "compiledir_%(platform)s-%(processor)s-%(python_version)s
-%(python_bitwidth)s
"
This is a Python format string that specifies the subdirectory
This is a Python format string that specifies the subdirectory
of ``config.base_compiledir`` in which to store platform-dependent
of ``config.base_compiledir`` in which to store platform-dependent
...
...
theano/compile/tests/test_pfunc.py
浏览文件 @
816a83e3
...
@@ -548,7 +548,7 @@ class Test_pfunc(unittest.TestCase):
...
@@ -548,7 +548,7 @@ class Test_pfunc(unittest.TestCase):
def
test_default_updates_input
(
self
):
def
test_default_updates_input
(
self
):
x
=
shared
(
0
)
x
=
shared
(
0
)
y
=
shared
(
1
)
y
=
shared
(
1
)
if
theano
.
gof
.
cmodule
.
python_int_bitwidth
()
==
32
:
if
theano
.
gof
.
python_int_bitwidth
()
==
32
:
a
=
iscalar
(
'a'
)
a
=
iscalar
(
'a'
)
else
:
else
:
a
=
lscalar
(
'a'
)
a
=
lscalar
(
'a'
)
...
...
theano/compile/tests/test_shared.py
浏览文件 @
816a83e3
...
@@ -18,7 +18,7 @@ class Test_SharedVariable(unittest.TestCase):
...
@@ -18,7 +18,7 @@ class Test_SharedVariable(unittest.TestCase):
assert
shared
(
7
,
dtype
=
'float64'
)
.
type
==
Scalar
(
'float64'
)
assert
shared
(
7
,
dtype
=
'float64'
)
.
type
==
Scalar
(
'float64'
)
else
:
else
:
if
theano
.
gof
.
cmodule
.
python_int_bitwidth
()
==
32
:
if
theano
.
gof
.
python_int_bitwidth
()
==
32
:
assert
shared
(
7
)
.
type
==
theano
.
tensor
.
iscalar
,
shared
(
7
)
.
type
assert
shared
(
7
)
.
type
==
theano
.
tensor
.
iscalar
,
shared
(
7
)
.
type
else
:
else
:
assert
shared
(
7
)
.
type
==
theano
.
tensor
.
lscalar
,
shared
(
7
)
.
type
assert
shared
(
7
)
.
type
==
theano
.
tensor
.
lscalar
,
shared
(
7
)
.
type
...
...
theano/gof/__init__.py
浏览文件 @
816a83e3
...
@@ -38,7 +38,9 @@ e-mail thread "What is gof?"
...
@@ -38,7 +38,9 @@ e-mail thread "What is gof?"
from
theano.gof.cc
import
\
from
theano.gof.cc
import
\
CLinker
,
OpWiseCLinker
,
DualLinker
CLinker
,
OpWiseCLinker
,
DualLinker
import
theano.gof.compiledir
# adds config vars
# Also adds config vars
from
theano.gof.compiledir
import
\
local_bitwidth
,
python_int_bitwidth
from
theano.gof.fg
import
\
from
theano.gof.fg
import
\
InconsistencyError
,
MissingInputError
,
FunctionGraph
InconsistencyError
,
MissingInputError
,
FunctionGraph
...
@@ -77,4 +79,3 @@ from theano.gof.type import \
...
@@ -77,4 +79,3 @@ from theano.gof.type import \
from
theano.gof.utils
import
\
from
theano.gof.utils
import
\
object2
,
MethodNotDefined
object2
,
MethodNotDefined
theano/gof/cmodule.py
浏览文件 @
816a83e3
...
@@ -8,7 +8,6 @@ import os
...
@@ -8,7 +8,6 @@ import os
import
shutil
import
shutil
import
stat
import
stat
import
StringIO
import
StringIO
import
struct
import
subprocess
import
subprocess
import
sys
import
sys
import
tempfile
import
tempfile
...
@@ -27,7 +26,7 @@ from theano.misc.windows import call_subprocess_Popen
...
@@ -27,7 +26,7 @@ from theano.misc.windows import call_subprocess_Popen
# we will abuse the lockfile mechanism when reading and writing the registry
# we will abuse the lockfile mechanism when reading and writing the registry
from
theano.gof
import
compilelock
from
theano.gof
import
compilelock
from
theano.gof.compiledir
import
gcc_version_str
from
theano.gof.compiledir
import
gcc_version_str
,
local_bitwidth
from
theano.configparser
import
AddConfigVar
,
BoolParam
from
theano.configparser
import
AddConfigVar
,
BoolParam
...
@@ -55,29 +54,6 @@ AddConfigVar('cmodule.compilation_warning',
...
@@ -55,29 +54,6 @@ AddConfigVar('cmodule.compilation_warning',
BoolParam
(
False
))
BoolParam
(
False
))
def
local_bitwidth
():
"""
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.
"""
# Note that according to Python documentation, `platform.architecture()` is
# not reliable on OS X with universal binaries.
# Also, sys.maxsize does not exist in Python < 2.6.
# 'P' denotes a void*, and the size is expressed in bytes.
return
struct
.
calcsize
(
'P'
)
*
8
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.
"""
# 'l' denotes a C long int, and the size is expressed in bytes.
return
struct
.
calcsize
(
'l'
)
*
8
_logger
=
logging
.
getLogger
(
"theano.gof.cmodule"
)
_logger
=
logging
.
getLogger
(
"theano.gof.cmodule"
)
_logger
.
setLevel
(
logging
.
WARNING
)
_logger
.
setLevel
(
logging
.
WARNING
)
...
@@ -176,14 +152,14 @@ static struct PyModuleDef moduledef = {{
...
@@ -176,14 +152,14 @@ static struct PyModuleDef moduledef = {{
}};
}};
"""
.
format
(
name
=
self
.
name
)
"""
.
format
(
name
=
self
.
name
)
print
>>
stream
,
"PyMODINIT_FUNC PyInit_
%
s(void) {"
%
self
.
name
print
>>
stream
,
"PyMODINIT_FUNC PyInit_
%
s(void) {"
%
self
.
name
for
b
in
self
.
init_blocks
:
for
b
lock
in
self
.
init_blocks
:
print
>>
stream
,
' '
,
b
print
>>
stream
,
' '
,
b
lock
print
>>
stream
,
" PyObject *m = PyModule_Create(&moduledef);"
print
>>
stream
,
" PyObject *m = PyModule_Create(&moduledef);"
print
>>
stream
,
" return m;"
print
>>
stream
,
" return m;"
else
:
else
:
print
>>
stream
,
"PyMODINIT_FUNC init
%
s(void){"
%
self
.
name
print
>>
stream
,
"PyMODINIT_FUNC init
%
s(void){"
%
self
.
name
for
b
in
self
.
init_blocks
:
for
b
lock
in
self
.
init_blocks
:
print
>>
stream
,
' '
,
b
print
>>
stream
,
' '
,
b
lock
print
>>
stream
,
' '
,
(
'(void) Py_InitModule("
%
s", MyMethods);'
print
>>
stream
,
' '
,
(
'(void) Py_InitModule("
%
s", MyMethods);'
%
self
.
name
)
%
self
.
name
)
print
>>
stream
,
"}"
print
>>
stream
,
"}"
...
@@ -1564,7 +1540,8 @@ class GCC_compiler(object):
...
@@ -1564,7 +1540,8 @@ class GCC_compiler(object):
lines
=
stdout
+
stderr
lines
=
stdout
+
stderr
return
lines
return
lines
# The '-' at the end is needed. Otherwise, g++ do not output enough information.
# The '-' at the end is needed. Otherwise, g++ do not output
# enough information.
native_lines
=
get_lines
(
"g++ -march=native -E -v -"
)
native_lines
=
get_lines
(
"g++ -march=native -E -v -"
)
_logger
.
info
(
"g++ -march=native selected lines:
%
s"
,
native_lines
)
_logger
.
info
(
"g++ -march=native selected lines:
%
s"
,
native_lines
)
if
len
(
native_lines
)
!=
1
:
if
len
(
native_lines
)
!=
1
:
...
@@ -1619,6 +1596,39 @@ class GCC_compiler(object):
...
@@ -1619,6 +1596,39 @@ class GCC_compiler(object):
cxxflags
.
append
(
"-D NPY_ARRAY_UPDATE_ALL=NPY_UPDATE_ALL"
)
cxxflags
.
append
(
"-D NPY_ARRAY_UPDATE_ALL=NPY_UPDATE_ALL"
)
cxxflags
.
append
(
"-D NPY_ARRAY_C_CONTIGUOUS=NPY_C_CONTIGUOUS"
)
cxxflags
.
append
(
"-D NPY_ARRAY_C_CONTIGUOUS=NPY_C_CONTIGUOUS"
)
cxxflags
.
append
(
"-D NPY_ARRAY_F_CONTIGUOUS=NPY_F_CONTIGUOUS"
)
cxxflags
.
append
(
"-D NPY_ARRAY_F_CONTIGUOUS=NPY_F_CONTIGUOUS"
)
# Platform-specific flags.
# We put them here, rather than in compile_str(), so they en up
# in the key of the compiled module, avoiding potential conflicts.
# Figure out whether the current Python executable is 32
# or 64 bit and compile accordingly.
n_bits
=
local_bitwidth
()
cxxflags
.
append
(
'-m
%
d'
%
n_bits
)
_logger
.
debug
(
"Compiling for
%
s bit architecture"
,
n_bits
)
if
sys
.
platform
!=
'win32'
:
# Under Windows it looks like fPIC is useless. Compiler warning:
# '-fPIC ignored for target (all code is position independent)'
cxxflags
.
append
(
'-fPIC'
)
if
sys
.
platform
==
'win32'
and
local_bitwidth
()
==
64
:
# Under 64-bit Windows installation, sys.platform is 'win32'.
# We need to define MS_WIN64 for the preprocessor to be able to
# link with libpython.
cxxflags
.
append
(
'-DMS_WIN64'
)
#DSE Patch 1 for supporting OSX frameworks; add -framework Python
if
sys
.
platform
==
'darwin'
:
cxxflags
.
extend
([
'-undefined'
,
'dynamic_lookup'
])
python_inc
=
distutils
.
sysconfig
.
get_python_inc
()
# link with the framework library *if specifically requested*
# config.mac_framework_link is by default False, since on some mac
# installs linking with -framework causes a Bus Error
if
(
python_inc
.
count
(
'Python.framework'
)
>
0
and
config
.
cmodule
.
mac_framework_link
):
cxxflags
.
extend
([
'-framework'
,
'Python'
])
return
cxxflags
return
cxxflags
@staticmethod
@staticmethod
...
@@ -1744,40 +1754,10 @@ class GCC_compiler(object):
...
@@ -1744,40 +1754,10 @@ class GCC_compiler(object):
else
:
else
:
preargs
=
list
(
preargs
)
preargs
=
list
(
preargs
)
if
sys
.
platform
!=
'win32'
:
# Under Windows it looks like fPIC is useless. Compiler warning:
# '-fPIC ignored for target (all code is position independent)'
preargs
.
append
(
'-fPIC'
)
if
sys
.
platform
==
'win32'
and
local_bitwidth
()
==
64
:
# Under 64-bit Windows installation, sys.platform is 'win32'.
# We need to define MS_WIN64 for the preprocessor to be able to
# link with libpython.
preargs
.
append
(
'-DMS_WIN64'
)
# We also add "-m64", in case the installed gcc is 32-bit
preargs
.
append
(
'-m64'
)
include_dirs
=
include_dirs
+
std_include_dirs
()
include_dirs
=
include_dirs
+
std_include_dirs
()
libs
=
std_libs
()
+
libs
libs
=
std_libs
()
+
libs
lib_dirs
=
std_lib_dirs
()
+
lib_dirs
lib_dirs
=
std_lib_dirs
()
+
lib_dirs
#DSE Patch 1 for supporting OSX frameworks; add -framework Python
if
sys
.
platform
==
'darwin'
:
preargs
.
extend
([
'-undefined'
,
'dynamic_lookup'
])
python_inc
=
distutils
.
sysconfig
.
get_python_inc
()
# link with the framework library *if specifically requested*
# config.mac_framework_link is by default False, since on some mac
# installs linking with -framework causes a Bus Error
if
(
python_inc
.
count
(
'Python.framework'
)
>
0
and
config
.
cmodule
.
mac_framework_link
):
preargs
.
extend
([
'-framework'
,
'Python'
])
# Figure out whether the current Python executable is 32
# or 64 bit and compile accordingly.
n_bits
=
local_bitwidth
()
preargs
.
extend
([
'-m
%
s'
%
n_bits
])
_logger
.
debug
(
"OS X: compiling for
%
s bit architecture"
,
n_bits
)
# sometimes, the linker cannot find -lpython so we need to tell it
# sometimes, the linker cannot find -lpython so we need to tell it
# explicitly where it is located
# explicitly where it is located
# this returns somepath/lib/python2.x
# this returns somepath/lib/python2.x
...
...
theano/gof/compiledir.py
浏览文件 @
816a83e3
...
@@ -4,6 +4,7 @@ import os
...
@@ -4,6 +4,7 @@ import os
import
platform
import
platform
import
re
import
re
import
shutil
import
shutil
import
struct
import
subprocess
import
subprocess
import
sys
import
sys
import
textwrap
import
textwrap
...
@@ -32,16 +33,44 @@ except OSError:
...
@@ -32,16 +33,44 @@ except OSError:
del
p
del
p
del
dummy_err
del
dummy_err
compiledir_format_dict
=
{
"platform"
:
platform
.
platform
(),
"processor"
:
platform
.
processor
(),
def
local_bitwidth
():
"python_version"
:
platform
.
python_version
(),
"""
"theano_version"
:
theano
.
__version__
,
Return 32 for 32bit arch, 64 for 64bit arch
"numpy_version"
:
numpy
.
__version__
,
"gxx_version"
:
gcc_version_str
.
replace
(
" "
,
"_"
),
By "architecture", we mean the size of memory pointers (size_t in C),
}
*not* the size of long int, as it can be different.
"""
# Note that according to Python documentation, `platform.architecture()` is
# not reliable on OS X with universal binaries.
# Also, sys.maxsize does not exist in Python < 2.6.
# 'P' denotes a void*, and the size is expressed in bytes.
return
struct
.
calcsize
(
'P'
)
*
8
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.
"""
# 'l' denotes a C long int, and the size is expressed in bytes.
return
struct
.
calcsize
(
'l'
)
*
8
compiledir_format_dict
=
{
"platform"
:
platform
.
platform
(),
"processor"
:
platform
.
processor
(),
"python_version"
:
platform
.
python_version
(),
"python_bitwidth"
:
local_bitwidth
(),
"python_int_bitwidth"
:
python_int_bitwidth
(),
"theano_version"
:
theano
.
__version__
,
"numpy_version"
:
numpy
.
__version__
,
"gxx_version"
:
gcc_version_str
.
replace
(
" "
,
"_"
),
}
compiledir_format_keys
=
", "
.
join
(
sorted
(
compiledir_format_dict
.
keys
()))
compiledir_format_keys
=
", "
.
join
(
sorted
(
compiledir_format_dict
.
keys
()))
default_compiledir_format
=
\
default_compiledir_format
=
(
"compiledir_
%(platform)
s-
%(processor)
s-"
"compiledir_
%(platform)
s-
%(processor)
s-
%(python_version)
s"
"
%(python_version)
s-
%(python_bitwidth)
s"
)
AddConfigVar
(
"compiledir_format"
,
AddConfigVar
(
"compiledir_format"
,
textwrap
.
fill
(
textwrap
.
dedent
(
"""
\
textwrap
.
fill
(
textwrap
.
dedent
(
"""
\
...
...
theano/gof/utils.py
浏览文件 @
816a83e3
差异被折叠。
点击展开。
theano/sandbox/cuda/nvcc_compiler.py
浏览文件 @
816a83e3
...
@@ -9,11 +9,11 @@ import warnings
...
@@ -9,11 +9,11 @@ import warnings
import
numpy
import
numpy
import
theano
from
theano.gof
import
local_bitwidth
from
theano.gof.cc
import
hash_from_file
from
theano.gof.cc
import
hash_from_file
from
theano.gof.cmodule
import
(
std_libs
,
std_lib_dirs
,
from
theano.gof.cmodule
import
(
std_libs
,
std_lib_dirs
,
std_include_dirs
,
dlimport
,
std_include_dirs
,
dlimport
,
get_lib_extension
,
local_bitwidth
)
get_lib_extension
)
from
theano.gof.python25
import
any
from
theano.gof.python25
import
any
from
theano.misc.windows
import
call_subprocess_Popen
from
theano.misc.windows
import
call_subprocess_Popen
...
@@ -245,8 +245,6 @@ class NVCC_compiler(object):
...
@@ -245,8 +245,6 @@ class NVCC_compiler(object):
cppfile
=
file
(
cppfilename
,
'w'
)
cppfile
=
file
(
cppfilename
,
'w'
)
_logger
.
debug
(
'Writing module C++ code to
%
s'
,
cppfilename
)
_logger
.
debug
(
'Writing module C++ code to
%
s'
,
cppfilename
)
ofiles
=
[]
rval
=
None
cppfile
.
write
(
src_code
)
cppfile
.
write
(
src_code
)
cppfile
.
close
()
cppfile
.
close
()
...
...
theano/tensor/extra_ops.py
浏览文件 @
816a83e3
...
@@ -114,12 +114,12 @@ class BinCountOp(theano.Op):
...
@@ -114,12 +114,12 @@ class BinCountOp(theano.Op):
# Some dtypes are not supported by numpy's implementation of bincount.
# Some dtypes are not supported by numpy's implementation of bincount.
# Until another one is available, we should fail at graph construction
# Until another one is available, we should fail at graph construction
# time, not wait for execution.
# time, not wait for execution.
int_bitwidth
=
theano
.
gof
.
cmodule
.
python_int_bitwidth
()
int_bitwidth
=
theano
.
gof
.
python_int_bitwidth
()
if
int_bitwidth
==
64
:
if
int_bitwidth
==
64
:
numpy_unsupported_dtypes
=
(
'uint64'
,)
numpy_unsupported_dtypes
=
(
'uint64'
,)
if
int_bitwidth
==
32
:
if
int_bitwidth
==
32
:
numpy_unsupported_dtypes
=
(
'uint32'
,
'int64'
,
'uint64'
)
numpy_unsupported_dtypes
=
(
'uint32'
,
'int64'
,
'uint64'
)
intp_bitwidth
=
theano
.
gof
.
cmodule
.
local_bitwidth
()
intp_bitwidth
=
theano
.
gof
.
local_bitwidth
()
if
intp_bitwidth
==
32
:
if
intp_bitwidth
==
32
:
out_type
=
basic
.
ivector
()
out_type
=
basic
.
ivector
()
elif
intp_bitwidth
==
64
:
elif
intp_bitwidth
==
64
:
...
@@ -246,7 +246,7 @@ class RepeatOp(theano.Op):
...
@@ -246,7 +246,7 @@ class RepeatOp(theano.Op):
# Some dtypes are not supported by numpy's implementation of repeat.
# Some dtypes are not supported by numpy's implementation of repeat.
# Until another one is available, we should fail at graph construction
# Until another one is available, we should fail at graph construction
# time, not wait for execution.
# time, not wait for execution.
int_bitwidth
=
theano
.
gof
.
cmodule
.
python_int_bitwidth
()
int_bitwidth
=
theano
.
gof
.
python_int_bitwidth
()
if
int_bitwidth
==
64
:
if
int_bitwidth
==
64
:
numpy_unsupported_dtypes
=
(
'uint64'
,)
numpy_unsupported_dtypes
=
(
'uint64'
,)
if
int_bitwidth
==
32
:
if
int_bitwidth
==
32
:
...
@@ -259,7 +259,7 @@ class RepeatOp(theano.Op):
...
@@ -259,7 +259,7 @@ class RepeatOp(theano.Op):
%
numpy_unsupported_dtypes
),
repeats
.
dtype
)
%
numpy_unsupported_dtypes
),
repeats
.
dtype
)
if
self
.
axis
is
None
:
if
self
.
axis
is
None
:
broadcastable
=
[
False
]
broadcastable
=
[
False
]
else
:
else
:
try
:
try
:
const_reps
=
basic
.
get_scalar_constant_value
(
repeats
)
const_reps
=
basic
.
get_scalar_constant_value
(
repeats
)
...
...
theano/tensor/tests/test_extra_ops.py
浏览文件 @
816a83e3
...
@@ -13,6 +13,7 @@ from theano import config, tensor, function
...
@@ -13,6 +13,7 @@ from theano import config, tensor, function
numpy_ver
=
[
int
(
n
)
for
n
in
numpy
.
__version__
.
split
(
'.'
)[:
2
]]
numpy_ver
=
[
int
(
n
)
for
n
in
numpy
.
__version__
.
split
(
'.'
)[:
2
]]
numpy_16
=
bool
(
numpy_ver
>=
[
1
,
6
])
numpy_16
=
bool
(
numpy_ver
>=
[
1
,
6
])
class
TestBinCountOp
(
utt
.
InferShapeTester
):
class
TestBinCountOp
(
utt
.
InferShapeTester
):
def
setUp
(
self
):
def
setUp
(
self
):
super
(
TestBinCountOp
,
self
)
.
setUp
()
super
(
TestBinCountOp
,
self
)
.
setUp
()
...
@@ -25,7 +26,7 @@ class TestBinCountOp(utt.InferShapeTester):
...
@@ -25,7 +26,7 @@ class TestBinCountOp(utt.InferShapeTester):
'uint8'
,
'uint16'
,
'uint32'
,
'uint64'
):
'uint8'
,
'uint16'
,
'uint32'
,
'uint64'
):
# uint64 always fails
# uint64 always fails
# int64 and uint32 also fail if python int are 32-bit
# int64 and uint32 also fail if python int are 32-bit
int_bitwidth
=
theano
.
gof
.
cmodule
.
python_int_bitwidth
()
int_bitwidth
=
theano
.
gof
.
python_int_bitwidth
()
if
int_bitwidth
==
64
:
if
int_bitwidth
==
64
:
numpy_unsupported_dtypes
=
(
'uint64'
,)
numpy_unsupported_dtypes
=
(
'uint64'
,)
if
int_bitwidth
==
32
:
if
int_bitwidth
==
32
:
...
@@ -57,7 +58,7 @@ class TestBinCountOp(utt.InferShapeTester):
...
@@ -57,7 +58,7 @@ class TestBinCountOp(utt.InferShapeTester):
for
dtype
in
tensor
.
discrete_dtypes
:
for
dtype
in
tensor
.
discrete_dtypes
:
# uint64 always fails
# uint64 always fails
# int64 and uint32 also fail if python int are 32-bit
# int64 and uint32 also fail if python int are 32-bit
int_bitwidth
=
theano
.
gof
.
cmodule
.
python_int_bitwidth
()
int_bitwidth
=
theano
.
gof
.
python_int_bitwidth
()
if
int_bitwidth
==
64
:
if
int_bitwidth
==
64
:
numpy_unsupported_dtypes
=
(
'uint64'
,)
numpy_unsupported_dtypes
=
(
'uint64'
,)
if
int_bitwidth
==
32
:
if
int_bitwidth
==
32
:
...
@@ -188,7 +189,6 @@ class SqueezeTester(utt.InferShapeTester):
...
@@ -188,7 +189,6 @@ class SqueezeTester(utt.InferShapeTester):
def
test_grad
(
self
):
def
test_grad
(
self
):
for
shape
,
broadcast
in
zip
(
self
.
shape_list
,
self
.
broadcast_list
):
for
shape
,
broadcast
in
zip
(
self
.
shape_list
,
self
.
broadcast_list
):
data
=
numpy
.
random
.
random
(
size
=
shape
)
.
astype
(
theano
.
config
.
floatX
)
data
=
numpy
.
random
.
random
(
size
=
shape
)
.
astype
(
theano
.
config
.
floatX
)
variable
=
tensor
.
TensorType
(
theano
.
config
.
floatX
,
broadcast
)()
utt
.
verify_grad
(
self
.
op
,
[
data
])
utt
.
verify_grad
(
self
.
op
,
[
data
])
...
@@ -203,7 +203,7 @@ class TestRepeatOp(utt.InferShapeTester):
...
@@ -203,7 +203,7 @@ class TestRepeatOp(utt.InferShapeTester):
self
.
op
=
RepeatOp
()
self
.
op
=
RepeatOp
()
# uint64 always fails
# uint64 always fails
# int64 and uint32 also fail if python int are 32-bit
# int64 and uint32 also fail if python int are 32-bit
int_bitwidth
=
theano
.
gof
.
cmodule
.
python_int_bitwidth
()
int_bitwidth
=
theano
.
gof
.
python_int_bitwidth
()
if
int_bitwidth
==
64
:
if
int_bitwidth
==
64
:
self
.
numpy_unsupported_dtypes
=
(
'uint64'
,)
self
.
numpy_unsupported_dtypes
=
(
'uint64'
,)
if
int_bitwidth
==
32
:
if
int_bitwidth
==
32
:
...
@@ -287,11 +287,12 @@ class TestRepeatOp(utt.InferShapeTester):
...
@@ -287,11 +287,12 @@ class TestRepeatOp(utt.InferShapeTester):
x
=
T
.
TensorType
(
config
.
floatX
,
[
False
,
True
,
False
])()
x
=
T
.
TensorType
(
config
.
floatX
,
[
False
,
True
,
False
])()
r
=
RepeatOp
(
axis
=
1
)(
x
,
2
)
r
=
RepeatOp
(
axis
=
1
)(
x
,
2
)
self
.
assertEqual
(
r
.
broadcastable
,
(
False
,
False
,
False
))
self
.
assertEqual
(
r
.
broadcastable
,
(
False
,
False
,
False
))
r
=
RepeatOp
(
axis
=
1
)(
x
,
1
)
r
=
RepeatOp
(
axis
=
1
)(
x
,
1
)
self
.
assertEqual
(
r
.
broadcastable
,
(
False
,
True
,
False
))
self
.
assertEqual
(
r
.
broadcastable
,
(
False
,
True
,
False
))
r
=
RepeatOp
(
axis
=
0
)(
x
,
2
)
r
=
RepeatOp
(
axis
=
0
)(
x
,
2
)
self
.
assertEqual
(
r
.
broadcastable
,
(
False
,
True
,
False
))
self
.
assertEqual
(
r
.
broadcastable
,
(
False
,
True
,
False
))
class
TestBartlett
(
utt
.
InferShapeTester
):
class
TestBartlett
(
utt
.
InferShapeTester
):
def
setUp
(
self
):
def
setUp
(
self
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论