-
Notifications
You must be signed in to change notification settings - Fork 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
Enable transpose optimizer in minimal extended build #10349
Conversation
…optimizer_minimal_build
…optimizer_minimal_build
…RUNTIME_OPTIMIZATIONS_IN_MINIMAL_BUILD.
…optimizer_minimal_build
if (node.ContainsSubgraph()) { | ||
const auto subgraphs = node.GetSubgraphs(); | ||
for (const auto& subgraph : subgraphs) { | ||
const auto status = VerifyEachNodeIsAssignedToAnEpImpl(*subgraph, is_verbose, node_placements); |
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, ORT_RETURN_IF_ERROR #Resolved
|
||
/** Returns the attribute of a Node with a given name. */ | ||
const ONNX_NAMESPACE::AttributeProto* GetNodeAttribute(const Node& node, const std::string& attr_name); | ||
|
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, can be moved below with AddInitializer to reduce number of #ifdef? #Resolved
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 one is unfortunately used by the template GetRepeatedNodeAttributeValues(), which is above the other ifdef
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.
Can we move the other 2 functions up here in the same #ifdef
?
"${ONNX_SOURCE_ROOT}/onnx/defs/data_type_utils.h" | ||
"${ONNX_SOURCE_ROOT}/onnx/defs/data_type_utils.cc" | ||
"${ONNX_SOURCE_ROOT}/onnx/defs/shape_inference.h" | ||
"${ONNX_SOURCE_ROOT}/onnx/defs/shape_inference.cc" | ||
) |
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 do we need the shape inference code?
I would have expected this causes a large hit to binary size but maybe most of it can be thrown away. #Closed
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.
graph.cc:MergeShapeInfo():
static Status MergeShapeInfo(const std::string& output_name, |
NodeArg::UpdateTypeAndShape()
api_impl.cc:ApiGraph::CopyValueInfo()
ORT_THROW_IF_ERROR(dst_arg.UpdateTypeAndShape(*src_arg, /*strict*/ false, /*override_types*/ false, logger_)); |
the reason is ApiGraph::CopyValueInfo()
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.
removed the dependency on shape inference code
Does this need to be enabled? I think in training they have scenarios when the type gets overridden, but for our usages I wouldn't expect that to ever happen. In reply to: 1020851523 In reply to: 1020851523 #Closed Refers to: include/onnxruntime/core/graph/node_arg.h:86 in 16c7768. [](commit_id = 16c7768, deletion_comment = False) |
Actually taking a step up, do we need to use UpdateTypeAndShape? I could only see a call to that in ApiGraph::CopyValueInfo, and given that's a straight copy we shouldn't need any of the merge/override logic. Not sure what isn't populated by the call to GetOrCreateNodeArg with the source NodeArg - if that include type and shape we don't need a call to UpdateTypeAndShape at all. In reply to: 1020851523 Refers to: include/onnxruntime/core/graph/node_arg.h:86 in 16c7768. [](commit_id = 16c7768, deletion_comment = False) |
|
||
for (const auto& node : Nodes()) { | ||
node.ForEachDef([&](const NodeArg& node_arg, bool is_input) { | ||
if (is_input) { |
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.
nice! way simpler than the old code :) #Closed
…optimizer_minimal_build
yeah, modifying ApiGraph::CopyValueInfo might be better In reply to: 1020858991 Refers to: include/onnxruntime/core/graph/node_arg.h:86 in 16c7768. [](commit_id = 16c7768, deletion_comment = False) |
NodeArg& dst_arg = graph_.GetOrCreateNodeArg(std::string(dst_name), nullptr); | ||
|
||
if (auto* dst_type = dst_arg.TypeAsProto(); dst_type != nullptr) { | ||
int32_t src_data_element_type; |
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 caller guarantees this so you don't have to do the check if you don't want to.
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 good to know. Will leave the check to make debugging easier.
/// in the ValueInfo class (like symbolic shape information). Destination dtype must be compatible with source dtype | ||
/// if known. | ||
/// in the ValueInfo class (like symbolic shape information). If already set, the destination dtype should be equal | ||
/// to the source dtype. |
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 correct, and if the caller fails to do this, the behavior is undefined.
NodeArg& dst_arg = graph_.GetOrCreateNodeArg(std::string(dst_name), nullptr); | ||
|
||
if (auto* dst_type = dst_arg.TypeAsProto(); dst_type != nullptr) { | ||
int32_t src_data_element_type; |
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 the dst_type init have to be in the 'if'? just wondering what the benefit of that is given it slightly complicates reading the code.
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 benefit in my opinion is that the scope of dst_type can be more limited
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.
🕐
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.
Description
Enable transpose optimizer and infrastructure it depends on in a minimal extended build.
Motivation and Context
Enable the transpose optimizer to run as part of runtime optimization of ORT format models.