-
Notifications
You must be signed in to change notification settings - Fork 749
Remove false positive error message in the executor_runner #7170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,8 @@ | |
| #include <cmath> | ||
| #include <cstddef> // size_t | ||
| #include <limits> | ||
| #include <sstream> | ||
| #include <vector> | ||
|
|
||
| #include <executorch/runtime/core/array_ref.h> | ||
| #include <executorch/runtime/core/error.h> | ||
|
|
@@ -484,6 +486,30 @@ inline bool tensor_is_type( | |
| return true; | ||
| } | ||
|
|
||
| inline bool tensor_is_type( | ||
| executorch::aten::Tensor t, | ||
| const std::vector<executorch::aten::ScalarType>& dtypes) { | ||
| if (std::find(dtypes.begin(), dtypes.end(), t.scalar_type()) != | ||
| dtypes.end()) { | ||
| return true; | ||
| } | ||
|
|
||
| std::stringstream dtype_ss; | ||
|
||
| for (size_t i = 0; i < dtypes.size(); i++) { | ||
| if (i != 0) { | ||
| dtype_ss << ", "; | ||
| } | ||
| dtype_ss << torch::executor::toString(dtypes[i]); | ||
| } | ||
|
|
||
| ET_LOG_MSG_AND_RETURN_IF_FALSE( | ||
| false, | ||
| "Expected to find one of %s types, but tensor has type %s", | ||
| dtype_ss.str().c_str(), | ||
| torch::executor::toString(t.scalar_type())); | ||
| return false; | ||
ykhrustalev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| inline bool tensor_is_integral_type( | ||
| executorch::aten::Tensor t, | ||
| bool includeBool = false) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The runtime must not use streams, vectors or any other type that allocates memory dynamically: see https://pytorch.org/executorch/main/portable-cpp-programming.html for some commentary on this.
In this case you may be able to use a
Span<ScalarType>since the container size is known at construction time.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noted, I will use the Span container