Skip to content

Commit

Permalink
[Dynamo] Do not crash if numpy is not installed (#112175)
Browse files Browse the repository at this point in the history
`s/isinstance(value, np.generic)/np is not None and isinstance(value, np.generic)/`

Found while looking at #110512

Pull Request resolved: #112175
Approved by: https://github.com/ev-br, https://github.com/kit1980
  • Loading branch information
malfet authored and pytorchmergebot committed Oct 27, 2023
1 parent 22221c6 commit ac4cc5d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion torch/_dynamo/variables/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def index_source(key):
source=self.source,
guards=make_guards(GuardBuilder.ID_MATCH),
)
elif isinstance(value, np.generic):
elif np is not None and isinstance(value, np.generic):
# numpy array scalars: convert to 0D arrays
return self.wrap_numpy_ndarray(np.asarray(value))
elif is_numpy(value):
Expand Down

0 comments on commit ac4cc5d

Please sign in to comment.