Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions torch_xla/csrc/aten_xla_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1241,13 +1241,18 @@ at::Tensor XLANativeFunctions::empty_symint(
sym_size, 0, GetXlaDeviceOrCurrent(device), at::dtype_or_default(dtype)));
}

// When the test `TestDynamicShapes.test_fill_` is called, `torch.fill_` calls
// into this function. sym_size is dynamic with value [<=6, 1], stride is static
// with value [1, 1].
at::Tensor XLANativeFunctions::empty_strided_symint(
at::SymIntArrayRef sym_size, at::SymIntArrayRef sym_stride,
c10::optional<at::ScalarType> dtype, c10::optional<at::Layout> layout,
c10::optional<at::Device> device, c10::optional<bool> pin_memory) {
TORCH_LAZY_FN_COUNTER("xla::");
auto size = C10_AS_INTARRAYREF_SLOW(sym_size);
auto stride = C10_AS_INTARRAYREF_SLOW(sym_stride);
// auto size = C10_AS_INTARRAYREF_SLOW(sym_size);
// auto stride = C10_AS_INTARRAYREF_SLOW(sym_stride);
at::IntArrayRef size = c10::asIntArrayRefUnchecked(sym_size);
at::IntArrayRef stride = c10::asIntArrayRefUnchecked(sym_stride);
at::Tensor t =
empty_symint(sym_size, dtype, layout, device, pin_memory, c10::nullopt);
return torch_xla::XLANativeFunctions::as_strided_copy(t, size, stride,
Expand Down
4 changes: 4 additions & 0 deletions torch_xla/csrc/tensor_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ XLATensorImpl::XLATensorImpl(XLATensor&& tensor)
bridge::XlaDeviceToAtenDevice(tensor.GetDevice())),
tensor_(c10::make_intrusive<XLATensor>(std::move(tensor))) {
is_non_overlapping_and_dense_ = false;
const_cast<XLATensorImpl*>(this)->SetupSizeProperties();
set_sizes_and_strides(
c10::SymIntArrayRef(sym_sizes_.data(), sym_sizes_.size()),
c10::fromIntArrayRefSlow(strides_default()));
set_custom_sizes_strides(SizesStridesPolicy::CustomSizes);
}

Expand Down