提交 01325815 authored 作者: Ricardo's avatar Ricardo 提交者: Ricardo Vieira

Raise when SharedVariables are used as inputs of OpFromGraph

上级 16fce528
...@@ -334,8 +334,11 @@ class OpFromGraph(Op, HasInnerGraph): ...@@ -334,8 +334,11 @@ class OpFromGraph(Op, HasInnerGraph):
raise TypeError( raise TypeError(
f"Inputs and outputs must be Variable instances; got {i}" f"Inputs and outputs must be Variable instances; got {i}"
) )
if i in inputs and isinstance(i, Constant): if i in inputs:
raise TypeError(f"Constants not allowed as inputs; {i}") if isinstance(i, Constant):
raise TypeError(f"Constants not allowed as inputs; {i}")
if isinstance(i, SharedVariable):
raise TypeError(f"SharedVariables not allowed as inputs; {i}")
if "updates" in kwargs or "givens" in kwargs: if "updates" in kwargs or "givens" in kwargs:
raise NotImplementedError("Updates and givens are not allowed here") raise NotImplementedError("Updates and givens are not allowed here")
......
...@@ -38,6 +38,9 @@ class TestOpFromGraph(unittest_tools.InferShapeTester): ...@@ -38,6 +38,9 @@ class TestOpFromGraph(unittest_tools.InferShapeTester):
with pytest.raises(TypeError): with pytest.raises(TypeError):
OpFromGraph([x, as_tensor(1)], [x]) OpFromGraph([x, as_tensor(1)], [x])
with pytest.raises(TypeError):
OpFromGraph([shared(1)], [1])
with pytest.raises(NotImplementedError): with pytest.raises(NotImplementedError):
OpFromGraph([x], [x], updates={}) OpFromGraph([x], [x], updates={})
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论