!33539 Update check tensor logic

Merge pull request !33539 from zichun_ye/graph_mode_check_tensor
This commit is contained in:
i-robot 2022-04-26 06:50:55 +00:00 committed by Gitee
commit 851a1fc9e5
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 3 additions and 1 deletions

View File

@ -329,7 +329,9 @@ class CheckTensor(PrimitiveWithInfer):
return out
def __call__(self, x, name):
if isinstance(x, Tensor) or x is None:
# we skip this check in graph mode as it is checked in the infer stage
# and in the graph mode x is None if x is not const in the graph
if context.get_context("mode") == 0 or isinstance(x, Tensor):
return x
raise TypeError(
f"For {name}, input type should be a Tensor or Parameter.")