Skip to content

Commit 24f0d34

Browse files
authored
Log dtype names on input dtype mismatch (#7537)
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 d999204 commit 24f0d34

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
@@ -840,14 +840,14 @@ Method::set_input(const EValue& input_evalue, size_t input_idx) {
840840
if (e.isTensor()) {
841841
const auto& t_dst = e.toTensor();
842842
const auto& t_src = input_evalue.toTensor();
843+
843844
ET_CHECK_OR_RETURN_ERROR(
844845
t_dst.scalar_type() == t_src.scalar_type(),
845846
InvalidArgument,
846-
"The %zu-th input tensor's scalartype does not meet requirement: found %" PRId8
847-
" but expected %" PRId8,
847+
"Input %zu has unexpected scalar type: expected %s but was %s.",
848848
input_idx,
849-
static_cast<int8_t>(t_src.scalar_type()),
850-
static_cast<int8_t>(t_dst.scalar_type()));
849+
executorch::runtime::toString(t_dst.scalar_type()),
850+
executorch::runtime::toString(t_src.scalar_type()));
851851
// Reset the shape for the Method's input as the size of forwarded input
852852
// tensor for shape dynamism. Also is a safety check if need memcpy.
853853
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)