-
Notifications
You must be signed in to change notification settings - Fork 512
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
etdumpfilter impl #9752
etdumpfilter impl #9752
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/9752
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit b8f8988 with merge base d6e14fc ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This pull request was exported from Phabricator. Differential Revision: D72025517 |
@pytorchbot label "topic: not user facing" |
Summary: Introduce ETDumpFilter for filtering logged delegation intermediate data. Details can be found in pytorch#9260 Differential Revision: D72025517
f0102da
to
53ea16f
Compare
This pull request was exported from Phabricator. Differential Revision: D72025517 |
Summary: Pull Request resolved: pytorch#9752 Introduce ETDumpFilter for filtering logged delegation intermediate data. Details can be found in pytorch#9260 Differential Revision: D72025517
53ea16f
to
afa0c62
Compare
Summary: Introduce ETDumpFilter for filtering logged delegation intermediate data. Details can be found in pytorch#9260 Differential Revision: D72025517
afa0c62
to
eeaa935
Compare
This pull request was exported from Phabricator. Differential Revision: D72025517 |
Summary: Pull Request resolved: pytorch#9752 Introduce ETDumpFilter for filtering logged delegation intermediate data. Details can be found in pytorch#9260 Differential Revision: D72025517
eeaa935
to
f3bb579
Compare
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.
just some C++ comments; leaving for reviewers with more context on the actual goals here
namespace executorch { | ||
namespace etdump { |
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.
we have C++17 -- namespace executorch::etdump {
devtools/etdump/etdump_filter.h
Outdated
size_t regex_count_; | ||
size_t range_start_; | ||
size_t range_end_; |
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.
nit: you don't need the explicit default constructor if you assign 0 to these here; you can then change the constructor implementation in the .cpp file to ETDumpFilter::ETDumpFilter() = default;
devtools/etdump/etdump_filter.cpp
Outdated
if (len >= MAX_PATTERN_LENGTH) { | ||
return Error::InvalidArgument; // Pattern too long | ||
} | ||
strcpy(regex_patterns_[regex_count_], pattern); |
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.
nit: you already have the length, so use it -- std::memcpy(regex_patterns_[regex_count_], pattern, len)
devtools/etdump/etdump_filter.cpp
Outdated
return Error::InvalidArgument; // Pattern too long | ||
} | ||
strcpy(regex_patterns_[regex_count_], pattern); | ||
regex_patterns_[regex_count_][len] = '\0'; |
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.
FYI strcpy already does this. however, if you take my memcpy advice above you'll need to leave it
return true; | ||
} | ||
|
||
Result<bool> ETDumpFilter::set_debug_handle_range(size_t start, size_t end) { |
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.
what does a successful result of false
mean? (does Result<void>
work?)
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.
false will not be use.
We can not use Result<void>
cuz Result class need to use reference for the T type and void does not have Reference.
devtools/etdump/etdump_filter.cpp
Outdated
|
||
Result<bool> ETDumpFilter::filter_name_(const char* name) { | ||
if (name == nullptr) { | ||
return Error::InvalidArgument; // Name is null |
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.
comment repeats the code, delete
devtools/etdump/etdump_filter.h
Outdated
size_t get_n_regex() const; | ||
|
||
private: | ||
char regex_patterns_[MAX_REGEX_PATTERNS][MAX_PATTERN_LENGTH]{}; |
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.
why the hardcoded limit on length instead of a std::vector<std::string>
? I don't see any particular guarantees from RE2 itself that it doesn't malloc, so isn't studiously avoiding malloc in our wrapper a lost cause?
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.
I don't want to use any memory allocation operation in etdump_filter; our user usually have their own memory allocation way and does not support anything like vector or malloc.
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.
does not support anything like vector or malloc
but that's my point -- RE2 mallocs! (for example https://github.com/google/re2/blob/main/re2/compile.cc#L1254)
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.
ahhh fair point didn't pay attention to RE internal impl
devtools/etdump/etdump_filter.h
Outdated
* - An error code if number of pattern has reached to cap, or any | ||
* error occurs during regex compilation. | ||
*/ | ||
Result<bool> add_regex(const char* pattern); |
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.
std::string_view is in C++17. why not use it instead? (if the user ever passes a literal, we won't need to check its length at runtime)
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.
thx didn't know we have that; migrating to that.
Summary: Introduce ETDumpFilter for filtering logged delegation intermediate data. Details can be found in pytorch#9260 Differential Revision: D72025517
f3bb579
to
92235a1
Compare
This pull request was exported from Phabricator. Differential Revision: D72025517 |
@@ -0,0 +1,100 @@ | |||
/* |
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.
Overall high level comment, i think it's reasonable that we can assume the etdump filter we provide based on regex will need malloc to be supported. If users want to use this malloc support will be required on their platform. Based on this i think it would be good to remove the limitations we have in this class such as max regex, max char len etc.
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.
If users do need a filter for their platform that isn't based on regex they can write their own one. (which will be only very few embedded users).
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.
which will be only very few embedded users
ok in this case i agree we can make our etdump_filter support regex + malloc, just as what swolchok mentioned RE use malloc internally. Let me make an update
92235a1
to
379d4e4
Compare
Summary: Introduce ETDumpFilter for filtering logged delegation intermediate data. Details can be found in pytorch#9260 Differential Revision: D72025517
This pull request was exported from Phabricator. Differential Revision: D72025517 |
379d4e4
to
504dede
Compare
Summary: Introduce ETDumpFilter for filtering logged delegation intermediate data. Details can be found in pytorch#9260 Reviewed By: tarun292 Differential Revision: D72025517
This pull request was exported from Phabricator. Differential Revision: D72025517 |
Summary: Introduce ETDumpFilter for filtering logged delegation intermediate data. Details can be found in pytorch#9260 Reviewed By: tarun292 Differential Revision: D72025517
504dede
to
4b6c76f
Compare
Summary: Pull Request resolved: pytorch#9752 Introduce ETDumpFilter for filtering logged delegation intermediate data. Details can be found in pytorch#9260 Reviewed By: tarun292 Differential Revision: D72025517
This pull request was exported from Phabricator. Differential Revision: D72025517 |
4b6c76f
to
b8f8988
Compare
Differential Revision: D72025517