Skip to content

Commit b399007

Browse files
ezyangpytorchmergebot
authored andcommitted
Make TensorIterator give better error message for symbolic tensors (#92914)
This is one of the more common reasons to see "RuntimeError: Cannot call sizes() on tensor with symbolic sizes/strides" Signed-off-by: Edward Z. Yang <ezyang@meta.com> Pull Request resolved: #92914 Approved by: https://github.com/albanD, https://github.com/bdhirsh
1 parent c0ed0f2 commit b399007

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

aten/src/ATen/TensorIterator.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,9 @@ void TensorIteratorBase::compute_shape(const TensorIteratorConfig& config) {
12211221
// the destination tensor. If the output tensor is also an input, we'll
12221222
// pick it up later in the operands.
12231223
if (config.resize_outputs_ && op.is_output) continue;
1224+
TORCH_CHECK(!op.tensor_base().unsafeGetTensorImpl()->has_symbolic_sizes_strides(),
1225+
"TensorIterator does not support symbolic shapes; please implement this operator in torch/_refs "
1226+
"using the elementwise or reduction helpers (look at backtrace to find out what operator this is)");
12241227
auto shape = op.tensor_base().sizes();
12251228
if (shape.size() == 0) {
12261229
has_scalars = true;

0 commit comments

Comments
 (0)