-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[Relay] Add pass for getting calibration data from a relay module #5997
Conversation
def get_calibration_data(mod, data): | ||
"""Get the calibration data of a given relay graph | ||
|
||
This pass use the graph runtime to get the calibration data of a module, which |
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.
We may need to think of the semantic for the module with control flows, which has to use VM instead of graph runtime.
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 pass use the graph runtime to get the calibration data of a module, which | |
This pass uses the graph runtime to get the calibration data of a module, which |
Per offline discussion, please mention that this pass only works for the graph without control flow.
def get_calibration_data(mod, data): | ||
"""Get the calibration data of a given relay graph | ||
|
||
This pass use the graph runtime to get the calibration data of a module, which |
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 pass use the graph runtime to get the calibration data of a module, which | |
This pass uses the graph runtime to get the calibration data of a module, which |
Per offline discussion, please mention that this pass only works for the graph without control flow.
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.
LGTM
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.
LGTM
Thanks @seanlatias @comaniac |
…ache#5997) * add simple pass to extract outputs * complete pass that collects all function inputs/outputs * add analysis pass for collecting outputs * reorganize the files * add the first test * update test with tuples * clean up Python code * merge with upstream * clean up transform.py * add comments for cpp files * fix lint issues * update submodules * modify files according to the review * fix style and typo * fix lint error * add checks for repeated function calls * fix lint error * merge review comments * small simplification * revise the code according to the review comments * add username in TODO * use IRModule directly * use better APIs according to the review * apply comments from the reviewer * retrigger ci
…ache#5997) * add simple pass to extract outputs * complete pass that collects all function inputs/outputs * add analysis pass for collecting outputs * reorganize the files * add the first test * update test with tuples * clean up Python code * merge with upstream * clean up transform.py * add comments for cpp files * fix lint issues * update submodules * modify files according to the review * fix style and typo * fix lint error * add checks for repeated function calls * fix lint error * merge review comments * small simplification * revise the code according to the review comments * add username in TODO * use IRModule directly * use better APIs according to the review * apply comments from the reviewer * retrigger ci
RFC discussion: https://discuss.tvm.ai/t/rfc-byoc-data-calibration-flow/7099/15
This PR implements the analysis pass
get_calibration_data
mentioned in the RFC. The main functionality of this analysis pass is allowing users to easily get the calibration data from any Relay module. The calibration data includes the input and output tensor values of each subgraph in the module. Following is an example.The input relay graph that contains two subgraphs:
The Python API
The expected output
As can be seen, the output calibration data is a two-level dictionary. The first level takes in the GlobalVar of a subgraph as a key and the value is the second-level dictionary. The second level always has two keys: inputs and outputs, which map to the real tensor values of each subgraph. For more complex example please refer to the test.
@comaniac @zhiics