mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-28 20:11:22 +00:00
Fix Comments (#16513)
### Description Address comments in #14040 ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> --------- Co-authored-by: Edward Chen <18449977+edgchen1@users.noreply.github.com>
This commit is contained in:
parent
05c4566fe9
commit
0051497055
1 changed files with 9 additions and 7 deletions
|
|
@ -183,22 +183,24 @@ NnapiExecutionProvider::GetCapability(const onnxruntime::GraphViewer& graph_view
|
|||
result = utils::CreateSupportedPartitions(graph_viewer, is_node_supported, on_group_closed,
|
||||
gen_metadef_name, NNAPI, kNnapiExecutionProvider);
|
||||
|
||||
// Generally, NNAPI support graph with inputs and outputs except constant initializer.
|
||||
// So far, we have a few cases that sub-graph has zero inputs,
|
||||
// Generally, NNAPI supports sub-graphs with at least one non-constant initializer input and one output.
|
||||
// So far, we have a few cases that sub-graph has zero valid inputs, like `CastLike`
|
||||
// a) A sub-graph has only initializer as inputs
|
||||
// b) A sub-graph has zero inputs
|
||||
// b) A sub-graph has zero inputs, like a `Constant` node
|
||||
// So we just remove these sub-graph which is captured by NNAPI.
|
||||
// A existing example is CastLike, as which can't be fold in constant folding pass.
|
||||
// CastLike Op will be inlined into Cast after Pass transform.
|
||||
// Can we remove it if support CastLike in CF or support Pass transform after InlineNodes?
|
||||
// CastLike Op will be inlined into Cast after constant folding optimizer.
|
||||
// Can we remove it if support CastLike in constant folding
|
||||
// or support doing constant folding optimizer after InlineNodes?
|
||||
std::for_each(result.begin(), result.end(), [&graph_viewer](auto& capability) {
|
||||
if (capability && capability->sub_graph && capability->sub_graph->GetMetaDef()) {
|
||||
const auto* meta_def = capability->sub_graph->GetMetaDef();
|
||||
bool not_empty_inputs = std::any_of(meta_def->inputs.begin(), meta_def->inputs.end(), [&graph_viewer](const auto& input) {
|
||||
bool has_any_non_constant_inputs = std::any_of(meta_def->inputs.begin(), meta_def->inputs.end(), [&graph_viewer](const auto& input) {
|
||||
return !graph_viewer.IsConstantInitializer(input, true);
|
||||
});
|
||||
|
||||
if (!not_empty_inputs || meta_def->outputs.empty()) {
|
||||
// ALL inputs are constant
|
||||
if (!has_any_non_constant_inputs) {
|
||||
capability.reset();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue