Remove redundant Resolve() after each inlined function (#17556)

### Description
Remove `Resolve()` on the entire graph as each function is resolved.
We retain `Resolve()` after each inlining iteration.

### Motivation and Context
Poor performance for inlining the model and session initialization.

Original model before Resolve() removal
FunctionTest.Profiling (**65953 ms**)
After Resolve() Removal
FunctionTest.Profiling (**2911 ms**)

RelWithDebInfo pre-inlined model. Presumably because it runs Level1
optimizers
Non-inlined model consists of functions and Level1 optimizers have no
effect.
FunctionTest.Profiling (**9851 ms**)
This commit is contained in:
Dmitri Smirnov 2023-09-15 12:13:37 -07:00 committed by GitHub
parent adb0be45d3
commit fdb132643d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 3 deletions

View file

@ -1135,6 +1135,7 @@ class Graph {
/**
Directly insert the nodes in the function Node provided into this Graph.
The Graph needs to be Resolve()d after this call.
@param node Node with Node::Type of Node::Type::Fused
@returns Status indicating success or providing an error message.
*/

View file

@ -4145,8 +4145,6 @@ Status Graph::InlineFunction(Node& callnode) {
// std::cout << "Graph after inlining\n\n" << *this << std::endl << std::flush;
ORT_RETURN_IF_ERROR(this->Resolve());
return Status::OK();
}

View file

@ -25,8 +25,8 @@ void OpFunctionTester::RunFunctionBodyGraphOnCPU(TwoDArray& results) {
auto& node = *graph.Nodes().begin();
ASSERT_EQ(node.OpType(), op);
// Inline function will call Resolve itself
ASSERT_STATUS_OK(graph.InlineFunction(node));
ASSERT_STATUS_OK(graph.Resolve());
// Hookup the inputs and outputs
std::unordered_map<std::string, OrtValue> feeds;