Skip to content

Commit 4567478

Browse files
lucylqpytorchbot
authored andcommitted
Expect at least one value in the tensor, to extract scalar from
Differential Revision: D86363818 Pull Request resolved: #15627 (cherry picked from commit 47aca69)
1 parent 8deae88 commit 4567478

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

kernels/prim_ops/register_prim_ops.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ static Kernel prim_ops[] = {
124124
EValue& out = *stack[1];
125125
executorch::aten::Tensor self_tensor =
126126
self.to<executorch::aten::Tensor>();
127+
ET_KERNEL_CHECK_MSG(
128+
context,
129+
self_tensor.numel() >= 1,
130+
InvalidArgument,
131+
/* void */,
132+
"Expected tensor with at least 1 element");
127133
ET_SWITCH_REAL_TYPES_AND(
128134
Bool,
129135
self_tensor.scalar_type(),

0 commit comments

Comments
 (0)