Skip to content
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

Add new_empty_strided op #8217

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 experimental/torch_xla2/test/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
"lu_unpack",
"masked.median",
"max_pool2d_with_indices_backward",
"new_empty_strided",
"nextafter",
"nn.functional.adaptive_avg_pool3d",
"nn.functional.adaptive_max_pool1d",
Expand Down Expand Up @@ -159,6 +158,7 @@
'empty_strided',
'bernoulli',
"new_empty",
"new_empty_strided",
'randint_like',
'randn',
'randn_like',
Expand Down
9 changes: 7 additions & 2 deletions experimental/torch_xla2/torch_xla2/ops/jaten.py
Original file line number Diff line number Diff line change
Expand Up @@ -3990,8 +3990,13 @@ def _new_empty(self, size, **kwargs):


@op(torch.ops.aten.new_empty_strided)
def _new_empty_strided(self, size, stride, **kwargs):
return jnp.empty(size)
def _new_empty_strided(self, size, stride, dtype=None, **kwargs):
# Ignore stride, since JAX and torch tensor doesn't share the same memory.
if not dtype:
return jnp.empty(size, dtype=self.dtype)
else:
jax_dtype = mappings.t2j_dtype(dtype)
return jnp.empty(size, dtype=jax_dtype)


@op(torch.ops.aten._unsafe_index_put, is_jax_function=False)
Expand Down
Loading