Skip to content

Commit 5db5142

Browse files
GregoryComerfacebook-github-bot
authored andcommitted
Log dtype names on input dtype mismatch (#7537)
Summary: Update the error message when input tensor scalar type is incorrect. We've seen this get hit a few times and it should be easier to debug than it is. New Message: ``` [method.cpp:834] Input 0 has unexpected scalar type: expected Float but was Byte. ``` Old Message: ``` [method.cpp:826] The 0-th input tensor's scalartype does not meet requirement: found 0 but expected 6 ``` Test Plan: Built executorch bento kernel locally and tested with an incorrect scalar type to view the new error message. ``` [method.cpp:834] Input 0 has unexpected scalar type: expected Float but was Byte. ``` I also locally patched and built the bento kernel with ET_ENABLE_ENUM_STRINGS=0. ``` [method.cpp:834] Input 0 has unexpected scalar type: expected 6 but was 0. ``` Differential Revision: D67887770 Pulled By: GregoryComer
1 parent cf8d0cf commit 5db5142

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

runtime/executor/method.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -830,14 +830,14 @@ Method::set_input(const EValue& input_evalue, size_t input_idx) {
830830
if (e.isTensor()) {
831831
const auto& t_dst = e.toTensor();
832832
const auto& t_src = input_evalue.toTensor();
833+
833834
ET_CHECK_OR_RETURN_ERROR(
834835
t_dst.scalar_type() == t_src.scalar_type(),
835836
InvalidArgument,
836-
"The %zu-th input tensor's scalartype does not meet requirement: found %" PRId8
837-
" but expected %" PRId8,
837+
"Input %zu has unexpected scalar type: expected %s but was %s.",
838838
input_idx,
839-
static_cast<int8_t>(t_src.scalar_type()),
840-
static_cast<int8_t>(t_dst.scalar_type()));
839+
executorch::runtime::toString(t_dst.scalar_type()),
840+
executorch::runtime::toString(t_src.scalar_type()));
841841
// Reset the shape for the Method's input as the size of forwarded input
842842
// tensor for shape dynamism. Also is a safety check if need memcpy.
843843
Error err = resize_tensor(t_dst, t_src.sizes());

runtime/executor/targets.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def define_common_targets():
8282
"//executorch/runtime/core:evalue" + aten_suffix,
8383
"//executorch/runtime/core:event_tracer" + aten_suffix,
8484
"//executorch/runtime/core/exec_aten:lib" + aten_suffix,
85+
"//executorch/runtime/core/exec_aten/util:scalar_type_util" + aten_suffix,
8586
"//executorch/runtime/core/exec_aten/util:tensor_util" + aten_suffix,
8687
"//executorch/runtime/kernel:kernel_runtime_context" + aten_suffix,
8788
"//executorch/runtime/kernel:operator_registry",

0 commit comments

Comments
 (0)