-
Notifications
You must be signed in to change notification settings - Fork 424
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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. ``` Reviewed By: digantdesai, SS-JIA Differential Revision: D67887770 Pulled By: GregoryComer
- Loading branch information
1 parent
39e8538
commit 4563528
Showing
7 changed files
with
90 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <executorch/runtime/core/exec_aten/util/scalar_type_util.h> | ||
#include <executorch/runtime/platform/log.h> | ||
|
||
namespace executorch { | ||
namespace runtime { | ||
|
||
/** | ||
* Convert a scalar type value to a string representation. If | ||
* ET_ENABLE_ENUM_STRINGS is set (it is on bby default), this will return a | ||
* string name (for example, "Float"). Otherwise, it will return a string | ||
* representation of the index value ("6"). | ||
* | ||
* If the user buffer is not large enough to hold the string representation, the | ||
* string will be truncated. | ||
* | ||
* The return value is the number of characters written, or in the case of | ||
* truncation, the number of characters that would be written if the buffer was | ||
* large enough. | ||
*/ | ||
size_t scalar_type_to_string( | ||
::executorch::aten::ScalarType t, | ||
char* buffer, | ||
size_t buffer_size) { | ||
#if ET_ENABLE_ENUM_STRINGS | ||
const char* name_str; | ||
#define DEFINE_CASE(unused, name) \ | ||
case ::executorch::aten::ScalarType::name: \ | ||
name_str = #name; \ | ||
break; | ||
|
||
switch (t) { | ||
ET_FORALL_SCALAR_TYPES(DEFINE_CASE) | ||
default: | ||
name_str = "Unknown"; | ||
break; | ||
} | ||
|
||
return snprintf(buffer, buffer_size, "%s", name_str); | ||
#undef DEFINE_CASE | ||
#else | ||
return snprintf(buffer, buffer_size, "%d", static_cast<int>(t)); | ||
#endif // ET_ENABLE_ENUM_TO_STRING | ||
} | ||
|
||
} // namespace runtime | ||
} // namespace executorch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters