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
TF-TRT C++ conversion #52012
TF-TRT C++ conversion #52012
Conversation
e6d0699
to
45680b7
Compare
We can avoid the change to the utilities for freezing the graph by updating out SavedModelBundle with the converted GraphDef. Something like this:
|
afaa5af
to
d876eae
Compare
@bixia1 ready for review. |
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 am still working on reviewing trt_convert.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.
Still working on trt_convert.cc.
// We could set item_conifg.feed_nodes and item_config.fetch_nodes to the | ||
// nodes in the signature def. Alternatively, we could also set collection | ||
// 'train_op'. Grappler can use these to determine the input and outputs. | ||
// If none of these are set, then it will use the SignatereDef from | ||
// the MetaGraphDef. See grappler_item_builder.cc for details. |
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 we will go with the API where users provide input/output names, we should setup ItemConfig fetch_nodes/feed_nodes.
If we will go with the API where users provide SignatureDef, we need to clear the SignatureDef in the input meta_graph_def and keep only the one we need.
Also, if we will need to run grappler a few times, we probably want to avoid constructing GrapplerItem each time by somehow reusing the GrapplerItem, see TF code here.
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 have set up feed_nodes and fetch_nodes.
- If a previous conversion had
RunMetaOptimizer(item, ..., out_graph_def)
, can we just replace the item's graphitem.graph = out_graph_def
before the nextRunMetaOptimizer
call? For now we have only a single grappler pass, but it might matter in the follow up PR where we need to inline the graph before freezing 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.
Thanks @bixia1 for the review I have addressed most of the issues. Pleas have a look.
// We could set item_conifg.feed_nodes and item_config.fetch_nodes to the | ||
// nodes in the signature def. Alternatively, we could also set collection | ||
// 'train_op'. Grappler can use these to determine the input and outputs. | ||
// If none of these are set, then it will use the SignatereDef from | ||
// the MetaGraphDef. See grappler_item_builder.cc for details. |
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 have set up feed_nodes and fetch_nodes.
- If a previous conversion had
RunMetaOptimizer(item, ..., out_graph_def)
, can we just replace the item's graphitem.graph = out_graph_def
before the nextRunMetaOptimizer
call? For now we have only a single grappler pass, but it might matter in the follow up PR where we need to inline the graph before freezing it.
09cd906
to
b02e321
Compare
@bixia1 I have removed the circular dependency, and added trt_convert_api as a dependency of trt_op_libs. Let me know if there are other issues that we want to address in this PR. |
Can you fix the PR description, such as to remove the information that is obsolete? The PR description will become part of the commit message. |
b02e321
to
5cbde12
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.
Thanks @bixia1 for the review, I have addressed the issues.
TF-TRT C++ interface to convert models.
Differences compared to the Python API:
convert_to_static_engine
conversion param allows to convert dynamic engines to static engines.The steps for model conversion by
ConvertAndBuild
(On the Python side, steps 4-5 are done by a separate
build
function.)Related PRs: