Skip to content

Commit

Permalink
Hard code known true contiguity settings for unbacked SymInts (pytorc…
Browse files Browse the repository at this point in the history
…h#95003)

Extracted from pytorch#94523 which has E2E test

Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: pytorch#95003
Approved by: https://github.com/voznesenskym, https://github.com/ngimel
ezyang authored and pytorchmergebot committed Feb 17, 2023
1 parent a2f44d8 commit d9950c5
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions c10/core/TensorImpl.cpp
Original file line number Diff line number Diff line change
@@ -1212,6 +1212,29 @@ void TensorImpl::empty_tensor_restride_symint(MemoryFormat memory_format) {
// recompute contiguous flag, as currently NHWC/NCHW flags are not mutually
// exclusive see #24090
refresh_contiguous();
// hard code some known true settings, for unbacked case
// TODO: avoid chundering into the guards for computing these
switch (memory_format) {
case MemoryFormat::Contiguous: {
extra_meta_->is_contiguous_ = true;
extra_meta_->is_non_overlapping_and_dense_ = true;
break;
}
case MemoryFormat::ChannelsLast: {
extra_meta_->is_channels_last_contiguous_ = true;
extra_meta_->is_channels_last_ = true;
extra_meta_->is_non_overlapping_and_dense_ = true;
break;
}
case MemoryFormat::ChannelsLast3d: {
extra_meta_->is_channels_last_3d_contiguous_ = true;
extra_meta_->is_channels_last_3d_ = true;
extra_meta_->is_non_overlapping_and_dense_ = true;
break;
}
default:
break;
}
}

namespace impl {

0 comments on commit d9950c5

Please sign in to comment.