Skip to content

Commit

Permalink
Fix resize matrix_power.out dynamic shapes (pytorch#113695)
Browse files Browse the repository at this point in the history
Fixes pytorch#113003

Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: pytorch#113695
Approved by: https://github.com/bdhirsh, https://github.com/lezcano
  • Loading branch information
ezyang authored and pytorchmergebot committed Nov 16, 2023
1 parent 8a183bf commit c4c45ab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aten/src/ATen/native/LinearAlgebra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ Tensor linalg_matrix_power_impl(
if (_out.has_value()) {
checkSameDevice("matrix_power", out, self);
checkLinalgCompatibleDtype("matrix_power", out, self);
at::native::resize_output(out, self.sizes());
at::native::resize_output_symint(out, self.sym_sizes());
}

// For n=0 we return the identity matrix of the same shape as input.
Expand Down
5 changes: 5 additions & 0 deletions aten/src/ATen/native/Resize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ static void _maybe_resize_storage(TensorImpl* self, int64_t new_size_bytes) {
}

static void _maybe_resize_storage(TensorImpl* self, c10::SymInt new_size_bytes) {
if (self->is_cpu()) {
maybe_resize_storage_cpu(self, new_size_bytes.expect_int());
return;
}
TORCH_INTERNAL_ASSERT(self->is_meta());
maybe_resize_storage_meta(self, std::move(new_size_bytes));
}

Expand Down

0 comments on commit c4c45ab

Please sign in to comment.