Skip to content

style: extend no-explicit-dtype check to xp and jnp #4247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deepmd/dpmodel/array_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def xp_take_along_axis(arr, indices, axis):
else:
indices = xp.reshape(indices, (0, 0))

offset = (xp.arange(indices.shape[0]) * m)[:, xp.newaxis]
offset = (xp.arange(indices.shape[0], dtype=indices.type) * m)[:, xp.newaxis]
indices = xp.reshape(offset + indices, (-1,))

out = xp.take(arr, indices)
Expand Down
2 changes: 1 addition & 1 deletion source/checker/deepmd_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def visit_call(self, node):
if (
isinstance(node.func, Attribute)
and isinstance(node.func.expr, Name)
and node.func.expr.name in {"np", "tf", "torch"}
and node.func.expr.name in {"np", "tf", "torch", "xp", "jnp"}
and node.func.attrname
in {
# https://pytorch.org/docs/stable/torch.html#creation-ops
Expand Down
Loading