提交 f175d4b8 authored 作者: Frédéric Bastien's avatar Frédéric Bastien

Merge pull request #3486 from nouiz/tests

Fix daily buildbot tests
...@@ -2403,13 +2403,15 @@ class _Maker(FunctionMaker): # inheritance buys a few helper functions ...@@ -2403,13 +2403,15 @@ class _Maker(FunctionMaker): # inheritance buys a few helper functions
""" """
def __init__(self, inputs, outputs, optimizer, mode, def __init__(self, inputs, outputs, mode,
accept_inplace=False, accept_inplace=False,
function_builder=Function, function_builder=Function,
profile=None, profile=None,
on_unused_input=None, on_unused_input=None,
fgraph=None, # If present the optimized graph. we ignore it.
output_keys=None): output_keys=None):
self.profile = profile self.profile = profile
optimizer = mode.optimizer
# Handle the case where inputs and/or outputs is a single # Handle the case where inputs and/or outputs is a single
# Variable (not in a list) # Variable (not in a list)
unpack_single = False unpack_single = False
...@@ -2523,6 +2525,7 @@ class _Maker(FunctionMaker): # inheritance buys a few helper functions ...@@ -2523,6 +2525,7 @@ class _Maker(FunctionMaker): # inheritance buys a few helper functions
self.accept_inplace = accept_inplace self.accept_inplace = accept_inplace
self.function_builder = function_builder self.function_builder = function_builder
self.mode = mode self.mode = mode
self.on_unused_input = on_unused_input # Used for the pickling/copy
self.output_keys = output_keys self.output_keys = output_keys
def create(self, defaults=None, trustme=False, storage_map=None): def create(self, defaults=None, trustme=False, storage_map=None):
...@@ -2744,7 +2747,7 @@ class DebugMode(Mode): ...@@ -2744,7 +2747,7 @@ class DebugMode(Mode):
""" """
assert m is self assert m is self
return _Maker(i, o, self.optimizer, self, *args, **kwargs) return _Maker(i, o, self, *args, **kwargs)
def __init__(self, def __init__(self,
optimizer='fast_run', optimizer='fast_run',
......
...@@ -711,7 +711,10 @@ class Function(object): ...@@ -711,7 +711,10 @@ class Function(object):
mode=maker.mode, profile=profile, mode=maker.mode, profile=profile,
on_unused_input=maker.on_unused_input, on_unused_input=maker.on_unused_input,
function_builder=maker.function_builder, function_builder=maker.function_builder,
accept_inplace=maker.accept_inplace # As this is an optimized graph, it
# can contain inplace. DebugMode check
# that.
accept_inplace=True,
).create(input_storage, ).create(input_storage,
storage_map=new_storage_map) storage_map=new_storage_map)
...@@ -1497,7 +1500,7 @@ class FunctionMaker(object): ...@@ -1497,7 +1500,7 @@ class FunctionMaker(object):
self.mode = mode self.mode = mode
self.accept_inplace = accept_inplace self.accept_inplace = accept_inplace
self.function_builder = function_builder self.function_builder = function_builder
self.on_unused_input = on_unused_input # Used only for the pickling self.on_unused_input = on_unused_input # Used for the pickling/copy
self.output_keys = output_keys self.output_keys = output_keys
self.required = [(i.value is None) for i in self.inputs] self.required = [(i.value is None) for i in self.inputs]
......
...@@ -29,9 +29,16 @@ class TestPyDotFormatter(unittest.TestCase): ...@@ -29,9 +29,16 @@ class TestPyDotFormatter(unittest.TestCase):
f = th.function(m.inputs, m.outputs) f = th.function(m.inputs, m.outputs)
pdf = PyDotFormatter() pdf = PyDotFormatter()
graph = pdf(f) graph = pdf(f)
self.assertEqual(len(graph.get_nodes()), 11) expected = 11
if th.config.mode == "FAST_COMPILE":
expected = 12
self.assertEqual(len(graph.get_nodes()), 12)
nc = self.node_counts(graph) nc = self.node_counts(graph)
assert nc['apply'] == 5
if th.config.mode == "FAST_COMPILE":
assert nc['apply'] == 6
else:
assert nc['apply'] == 5
assert nc['output'] == 1 assert nc['output'] == 1
def test_ofg(self): def test_ofg(self):
...@@ -43,7 +50,10 @@ class TestPyDotFormatter(unittest.TestCase): ...@@ -43,7 +50,10 @@ class TestPyDotFormatter(unittest.TestCase):
sub_graphs = graph.get_subgraph_list() sub_graphs = graph.get_subgraph_list()
assert len(sub_graphs) == 2 assert len(sub_graphs) == 2
ofg1, ofg2 = sub_graphs ofg1, ofg2 = sub_graphs
assert len(ofg1.get_nodes()) == 5 if th.config.mode == "FAST_COMPILE":
assert len(ofg1.get_nodes()) == 9
else:
assert len(ofg1.get_nodes()) == 5
assert len(ofg1.get_nodes()) == len(ofg2.get_nodes()) assert len(ofg1.get_nodes()) == len(ofg2.get_nodes())
def test_ofg_nested(self): def test_ofg_nested(self):
......
...@@ -15,8 +15,13 @@ def check_deterministic(iterable): ...@@ -15,8 +15,13 @@ def check_deterministic(iterable):
# So I must use an assert here. In the long term we should fix the rest of # So I must use an assert here. In the long term we should fix the rest of
# theano to use exceptions correctly, so that this can be a TypeError. # theano to use exceptions correctly, so that this can be a TypeError.
if iterable is not None: if iterable is not None:
assert isinstance(iterable, ( if not isinstance(iterable, (
list, tuple, OrderedSet, types.GeneratorType, string_types)) list, tuple, OrderedSet,
types.GeneratorType, string_types)):
if len(iterable) > 1:
# We need to accept length 1 size to allow unpickle in tests.
raise AssertionError(
"Get an not ordered iterable when one was expected")
# Copyright (C) 2009 Raymond Hettinger # Copyright (C) 2009 Raymond Hettinger
# Permission is hereby granted, free of charge, to any person obtaining a # Permission is hereby granted, free of charge, to any person obtaining a
......
...@@ -287,8 +287,8 @@ class PycudaElemwiseSourceModuleMakeThunkOp(Op): ...@@ -287,8 +287,8 @@ class PycudaElemwiseSourceModuleMakeThunkOp(Op):
# As we have a dict in props, we need to implement __hash__ # As we have a dict in props, we need to implement __hash__
def __hash__(self): def __hash__(self):
return hash(type(self), hash(self.scalar_op), return hash((type(self), hash(self.scalar_op),
hash_from_dict(self.inplace_pattern)) hash_from_dict(self.inplace_pattern)))
def __str__(self): def __str__(self):
if self.name is None: if self.name is None:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论