Skip to content

Commit 47aca69

Browse files
authored
Expect at least one value in the tensor, to extract scalar from
Differential Revision: D86363818 Pull Request resolved: #15627
1 parent 652cc5a commit 47aca69

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
@@ -141,6 +141,12 @@ static Kernel prim_ops[] = {
141141
EValue& out = *stack[1];
142142
executorch::aten::Tensor self_tensor =
143143
self.to<executorch::aten::Tensor>();
144+
ET_KERNEL_CHECK_MSG(
145+
context,
146+
self_tensor.numel() >= 1,
147+
InvalidArgument,
148+
/* void */,
149+
"Expected tensor with at least 1 element");
144150
ET_SWITCH_REAL_TYPES_AND(
145151
Bool,
146152
self_tensor.scalar_type(),

0 commit comments

Comments
 (0)