-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
NPUW: Introduce 'last' keyword for dump options #26841
NPUW: Introduce 'last' keyword for dump options #26841
Conversation
a34a1bc
to
975ef80
Compare
6ed03ee
to
1b95b6f
Compare
@AsyaPronina please review |
89c72f6
to
5fe82f9
Compare
@@ -307,7 +307,9 @@ static constexpr ov::Property<bool> full{"NPUW_DUMP_FULL"}; | |||
* Type: std::string. | |||
* Dump the specified subgraph(s) in OpenVINO IR form in the current directory. | |||
* Possible values: Comma-separated list of subgraph indices or "YES" for all | |||
* subgraphs, "NO" or just empty value to turn option off. E.g. "0,1" or "YES". | |||
* subgraphs, "NO" or just empty value to turn option off. Keyword "last" can | |||
* be used for dumping last subgraph without specifying it by specific indice. |
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.
Nitpick: indice
typo, but comment might be ignored
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.
that's fair to be index
, why should this comment be ignored
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.
It's just aligned with comment message above:
Possible values: Comma-separated list of subgraph indices or "YES" for all subgraphs
Should I change it too?
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 thought that plural form of index
is indices
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.
Fixed
@@ -307,7 +307,9 @@ static constexpr ov::Property<bool> full{"NPUW_DUMP_FULL"}; | |||
* Type: std::string. | |||
* Dump the specified subgraph(s) in OpenVINO IR form in the current directory. | |||
* Possible values: Comma-separated list of subgraph indices or "YES" for all | |||
* subgraphs, "NO" or just empty value to turn option off. E.g. "0,1" or "YES". | |||
* subgraphs, "NO" or just empty value to turn option off. Keyword "last" can | |||
* be used for dumping last subgraph without specifying it by specific indice. |
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.
that's fair to be index
, why should this comment be ignored
@@ -211,7 +211,8 @@ void ov::npuw::IBaseInferRequest::infer() { | |||
|
|||
void ov::npuw::IBaseInferRequest::dump_input_tensors(std::size_t idx) { | |||
const std::string dump_ios_opt = m_npuw_model->m_cfg.get<::intel_npu::NPUW_DUMP_IO>(); | |||
if (!ov::npuw::util::is_set(idx, dump_ios_opt)) { | |||
const std::size_t last_idx = m_npuw_model->m_compiled_submodels.size() - 1; |
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.
maybe it makes sense to make last_idx
be end_idx
- exclusive, like end()
iterator - so that you have -1
in just a single place.
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.
Do you mean to add method to CompiledModel class which return the index of the last submodel?
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.
Might be Dmitry means just to rename last_idx
to end_idx
and use it without -1
when passing to the ov::npuw::util::is_set(idx, dump_ios_opt, end_idx)
, where you can substract 1 right inside the is_set
function?
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.
Yes, exactly what @AsyaPronina says
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.
Fixed
@@ -695,8 +704,9 @@ ov::SoPtr<ov::ICompiledModel> ov::npuw::CompiledModel::compile_submodel(const st | |||
|
|||
void ov::npuw::CompiledModel::dump_on_fail(std::size_t id, const std::string& device_to_try, const char* extra) { | |||
const std::string dof_opt = m_cfg.get<::intel_npu::NPUW_DUMP_SUBS_ON_FAIL>(); | |||
const std::size_t last_idx = m_compiled_submodels.size() - 1; |
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.
surely, it should be end_idx
to avoid these recurring -1
s.
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.
Fixed
std::string fsd_opt = m_cfg.get<::intel_npu::NPUW_SUBMODEL_DEVICE>(); | ||
// Change "last" keyword to tail subgraph number | ||
std::size_t last_pos = fsd_opt.find("last"); | ||
if (last_pos != std::string::npos) { | ||
fsd_opt.erase(last_pos, 4); | ||
fsd_opt.insert(last_pos, std::to_string(last_sub_idx)); | ||
} | ||
|
||
forced_sub_devices = ::intel_npu ::OptionParser<std::map<std::size_t, std::string>>::parse(fsd_opt); |
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.
@AsyaPronina is this OptionParser
ours? Can we add extra parameters to parse
in this case? I'd prefer that code handle last
for all its users (assuming the end of the range is passed to parse()
).
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.
This is NPU OptionParser
, it is generic callable to parse from string to requested type. However, we can as it to parse to std::map<std::string, std::string>
instead of std::map<std::size_t, std::string>
, where key will be string, so it may accept "last". But then we need to parse other indices from string
to std::size_t
on our own.
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.
This is NPU
OptionParser
, it is generic callable to parse from string to requested type. However, we can as it to parse tostd::map<std::string, std::string>
instead ofstd::map<std::size_t, std::string>
, where key will be string, so it may accept "last". But then we need to parse other indices fromstring
tostd::size_t
on our own.
so it means we can also extend it with a new parse()
overload for this particular template instantiation, isn't it?
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.
Yes, you are right, thank you!
@@ -17,20 +17,28 @@ | |||
#include "openvino/runtime/make_tensor.hpp" // get_tensor_impl | |||
#include "util_xarch.hpp" | |||
|
|||
bool ov::npuw::util::is_set(const std::size_t sub_idx, const std::string& opt) { | |||
bool ov::npuw::util::is_set(const std::size_t sub_idx, const std::string& opt, const std::size_t last_idx) { |
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.
@AsyaPronina what tests can you recommend here to add?
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.
Something likes this one: https://github.com/openvinotoolkit/openvino/blob/master/src/plugins/intel_npu/tests/functional/behavior/npuw/behavior_tests.cpp#L672
It can be made parametrized for multiple options.
The problem is that for different networks the number of NPUW's detected block may be different and it is hard to tell what the last block number will be. Now 'last' option can be used to tell NPUW to dump tail block without setting specific number.
5fe82f9
to
8af1e7d
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.
Let's merge it now but please add tests as a follow-up. Thanks!
std::vector<std::size_t> sub_inds{}; | ||
sub_inds = ::intel_npu ::OptionParser<std::vector<std::size_t>>::parse(opt); | ||
sub_inds = ::intel_npu ::OptionParser<std::vector<std::size_t>>::parse(str); |
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.
It's better to cover ::parse() handle this case - it will be one place for all
### Details: - The problem is that for different networks the number of NPUW's detected block may be different and it is hard to tell what the last block number will be. Now 'last' option can be used to tell NPUW to dump tail block without setting specific number. ### Tickets: - E-139857
Details:
Tickets: