Skip to content

Commit f29cd78

Browse files
lucylqfacebook-github-bot
authored andcommitted
Expect at least one value in the tensor, to extract scalar from
Summary: local scalar dense extracts a scalar from a tensor. Check that the tensor has at least one value Differential Revision: D86363818
1 parent 2bb8055 commit f29cd78

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)