Skip to content

Commit 8083ce3

Browse files
committed
Fix TypeError: unhashable type
1 parent 3ed2faf commit 8083ce3

File tree

1 file changed

+6
-8
lines changed
  • python/paddle/jit/sot/opcode_translator/executor/variables

1 file changed

+6
-8
lines changed

python/paddle/jit/sot/opcode_translator/executor/variables/callable.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
from __future__ import annotations
1616

17-
import collections
1817
import dis
1918
import functools
2019
import inspect
@@ -422,18 +421,17 @@ def _get_numpy_ufuncs(cls):
422421
@VariableFactory.register_from_value(successor="BuiltinVariable")
423422
def from_value(value: Any, graph: FunctionGraph, tracker: Tracker):
424423
# TODO(wangmingkai02): support other numpy api.
425-
if (
426-
ENV_SOT_TRACE_NUMPY.get()
427-
and isinstance(value, collections.abc.Hashable)
428-
and (
424+
try:
425+
if ENV_SOT_TRACE_NUMPY.get() and (
429426
value in NUMPY_API_SUPPORTED_DICT
430427
or any(
431428
value in ufuncs
432429
for ufuncs in NumpyApiVariable._get_numpy_ufuncs()
433430
)
434-
)
435-
):
436-
return NumpyApiVariable(value, graph, tracker)
431+
):
432+
return NumpyApiVariable(value, graph, tracker)
433+
except Exception:
434+
return None
437435
return None
438436

439437
@property

0 commit comments

Comments
 (0)