From ce5241dda89ef386e69c6f34e08c7bc43840428c Mon Sep 17 00:00:00 2001 From: luochao Date: Tue, 17 Jan 2023 16:45:11 +0800 Subject: [PATCH] fix_set_inputs_problem --- mindspore/python/mindspore/common/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mindspore/python/mindspore/common/api.py b/mindspore/python/mindspore/common/api.py index 3c9591ffc37..4b51ed2547d 100644 --- a/mindspore/python/mindspore/common/api.py +++ b/mindspore/python/mindspore/common/api.py @@ -410,7 +410,7 @@ class _MindsporeFunctionExecutor: # Case: If the shape of input args is dynamic, get dynamic shape tensor from context and use it to compile. compile_args = args_list # Case: The `set_inputs()` of Cell object has been set, using these dynamic shape args as compile args. - if isinstance(self.obj, ms.nn.Cell) and self.obj.get_inputs(): + if self.fn.__name__ == 'construct' and isinstance(self.obj, ms.nn.Cell) and self.obj.get_inputs(): compile_args = self.obj.get_inputs() for args in compile_args: Validator.check_isinstance("args set in `set_inputs()` of Cell", args, PythonTensor)