提交 ef1b9f3a authored 作者: David Warde-Farley's avatar David Warde-Farley

Merge pull request #789 from nouiz/fix_test2

small stuff
......@@ -719,9 +719,11 @@ class CLinker(link.Linker):
pass
c_compiler = self.c_compiler()
ret += c_compiler.compile_args()
ret = list(set(ret)) # to remove duplicate
# The args set by the compiler include the user flags. We do not want
# to reorder them
ret += c_compiler.compile_args()
for x in [y.type for y in self.variables] + [
y.op for y in self.node_order]:
try:
......
......@@ -650,6 +650,12 @@ class ModuleCache(object):
msg='broken cache directory [EOF]',
level=logging.WARNING)
continue
except ValueError:
# This can happen when we have bad config value
# in the cuda.nvcc_compiler.py file.
# We should not hide it here, as this will cause
# an unrelated error to appear.
raise
except Exception:
unpickle_failure()
if delete_if_problem:
......
......@@ -11,11 +11,13 @@ from theano.gof.cc import hash_from_file
from theano.gof.cmodule import (std_libs, std_lib_dirs,
std_include_dirs, dlimport,
get_lib_extension, local_bitwidth)
from theano.gof.python25 import any
_logger = logging.getLogger("theano.sandbox.cuda.nvcc_compiler")
_logger.setLevel(logging.WARN)
from theano.configparser import config, AddConfigVar, StrParam, BoolParam
from theano.configparser import (config, AddConfigVar, StrParam,
BoolParam, ConfigParam)
AddConfigVar('nvcc.compiler_bindir',
"If defined, nvcc compiler driver will seek g++ and gcc"
......@@ -32,9 +34,21 @@ if config.cuda.nvccflags != '':
'Please use nvcc.flags instead. You provided value: %s'
% config.cuda.nvccflags)
def filter_nvcc_flags(s):
assert isinstance(s, str)
flags = [flag for flag in s.split(' ') if flag]
if any([f for f in flags if not f.startswith("-")]):
raise ValueError(
"Theano nvcc.flags support only parameter/value pairs without"
" space between them. e.g.: '--machine 64' is not supported,"
" but '--machine=64' is supported. Please add the '=' symbol."
" nvcc.flags value is '%s'" % s)
return ' '.join(flags)
AddConfigVar('nvcc.flags',
"Extra compiler flags for nvcc",
StrParam(config.cuda.nvccflags))
ConfigParam(config.cuda.nvccflags, filter_nvcc_flags))
AddConfigVar('nvcc.fastmath',
"",
......@@ -210,13 +224,10 @@ class NVCC_compiler(object):
preargs2.append('/Zi')
cmd.extend(['-Xlinker', '/DEBUG'])
if sys.platform != 'win32':
if local_bitwidth() == 64:
cmd.append('-m64')
preargs2.append('-m64')
else:
cmd.append('-m32')
preargs2.append('-m32')
if len(preargs2) > 0:
cmd.extend(['-Xcompiler', ','.join(preargs2)])
......
......@@ -365,7 +365,7 @@ class SparseType(gof.Type):
"""
format_cls = {'csr': scipy.sparse.csr_matrix,
'csc': scipy.sparse.csc_matrix}
dtype_set = set(['int', 'int8', 'int16', 'int32', 'int64', 'float32',
dtype_set = set(['int8', 'int16', 'int32', 'int64', 'float32',
'float64', 'complex64', 'complex128'])
ndim = 2
......
......@@ -1890,7 +1890,8 @@ class MultinomialTester(utt.InferShapeTester):
_p = sp.csr_matrix(numpy.asarray([[0.0, 0.5, 0.0, 0.5],
[0.1, 0.2, 0.3, 0.4],
[0.0, 1.0, 0.0, 0.0],
[0.3, 0.3, 0.0, 0.4]]))
[0.3, 0.3, 0.0, 0.4]],
dtype=config.floatX))
def setUp(self):
super(MultinomialTester, self).setUp()
......
......@@ -429,9 +429,9 @@ class test_CAReduce(unittest_tools.InferShapeTester):
x = TensorType(dtype, [(entry == 1) for entry in xsh])('x')
if tosum is None:
tosum = range(len(xsh))
xv = numpy.asarray(numpy.random.rand(*xsh))
xv = numpy.asarray(numpy.random.rand(*xsh), dtype=dtype)
self._compile_and_check([x],
[CAReduce(add, axis=tosum)(x)],
[CAReduce(scalar.add, axis=tosum)(x)],
[xv], CAReduce, ["local_cut_useless_reduce"])
......@@ -811,10 +811,10 @@ class TestElemwise(unittest_tools.InferShapeTester):
dtype = theano.config.floatX
t_left = TensorType(dtype, [(entry == 1) for entry in s_left])()
t_right = TensorType(dtype, [(entry == 1) for entry in s_right])()
t_left_val = numpy.zeros(s_left)
t_right_val = numpy.zeros(s_right)
t_left_val = numpy.zeros(s_left, dtype=dtype)
t_right_val = numpy.zeros(s_right, dtype=dtype)
self._compile_and_check([t_left, t_right],
[Elemwise(add)(t_left, t_right)],
[Elemwise(scalar.add)(t_left, t_right)],
[t_left_val, t_right_val], Elemwise)
......
......@@ -3442,7 +3442,7 @@ class TestMakeVector(utt.InferShapeTester):
def setUp(self):
super(TestMakeVector, self).setUp()
def test_make_vector():
def test_make_vector(self):
b = T.bscalar()
i = T.iscalar()
d = T.dscalar()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论