-
Notifications
You must be signed in to change notification settings - Fork 233
Integrate Automated QDQ placement tool - Part 2 #702
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
base: main
Are you sure you want to change the base?
Integrate Automated QDQ placement tool - Part 2 #702
Conversation
|
Hi @ajrasane , could you help me review this PR, thanks! |
3f7ff31 to
d3a6765
Compare
|
|
||
| return scheme | ||
|
|
||
| def format_tree(self, region: Region, graph: gs.Graph, indent: int = 0) -> str: |
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.
Could you provide a small example of how this tree looks?
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 added tests for region search to print tree structure, below is an example:
tests/unit/onnx/quantization/autotune/test_region_search.py::TestPrintTree::test_print_tree_top_down_builder
============================================================
Region Tree Structure:
============================================================
├─ Region 0 (Level 0, Type: LEAF)
│ ├─ Direct nodes: 2
│ ├─ Total nodes (recursive): 2
│ ├─ Children: 0
│ ├─ Inputs: 1 tensors
│ │ - input
│ └─ Outputs: 1 tensors
│ - output
│
│ Nodes in this region:
│ - Node 0: Conv (name: conv)
│ - Node 1: Relu (name: relu)
|
├─ <child region if exists>
============================================================
Currently, the 2 stage region partitioner only creates regions with depth <= 2.
| Signature formats: | ||
| - Empty region: "EMPTY" | ||
| - Leaf region: "Op1->Op2->Op3" or "Op1[params]->Op2[params]" |
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 this be saved as LEAF(ops)
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 additional LEAF is needed? I think op1->op2->...opn is okay to represent op sequence. Adding LEAF would make complex region too long.
| region_node_indices: Set of node indices in the current region | ||
| Returns: | ||
| Signature string examples: |
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.
How will the signatures of custom ops look? Could you provide an example?
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.
example res-block signature:
COMPOSITE(Conv[kernel_shape=3x3]->BatchNormalization->Relu->Conv[kernel_shape=3x3]->BatchNormalization+Conv[kernel_shape=1x1]->BatchNormalization+Add->Relu)
graph structure:
Input
│
┌──────────────┴──────────────┐
│ │
▼ ▼
┌───────────────┐ ┌───────────────┐
│ Conv (3x3) │ │ Conv (1x1) │ (projection)
└───────────────┘ └───────────────┘
│ │
▼ ▼
┌───────────────┐ ┌───────────────┐
│ BatchNorm │ │ BatchNorm │
└───────────────┘ └───────────────┘
│ │
▼ │
┌───────────────┐ │
│ Relu │ │
└───────────────┘ │
│ │
▼ │
┌───────────────┐ │
│ Conv (3x3) │ │
└───────────────┘ │
│ │
▼ │
┌───────────────┐ │
│ BatchNorm │ │
└───────────────┘ │
│ │
└──────────────┬──────────────┘
▼
┌─────────┐
│ Add │
└─────────┘
│
▼
┌─────────┐
│ Relu │
└─────────┘
For custom plugin node, thier name will also be added to the signature.
616285d to
c95939a
Compare
| quantized_tensors = set() | ||
|
|
||
| for node in onnx_model.graph.node: | ||
| if node.op_type == "QuantizeLinear": |
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 --dq_only is enabled, there may only be the DQ node indicating that a tensor is being quantized. Please verify that those cases are supporting with this function.
See
| "--dq_only", |
0c4f114 to
4468ca2
Compare
Signed-off-by: Will Guo <[email protected]>
4468ca2 to
bc87ca7
Compare
What does this PR do?
Type of change: new feature
Overview: This PR integrate automated Q/DQ placement tool to ModelOpt. This PR is 2/4 parts of the cahnges.
Part 1: #701
Part 2: #702
Part 3: #703
Part 4: #704
This PR contains the following changes:
Usage
Example output:
Testing
Implemented unit tests for new classes. All unit tests could get pass locally.
Before your PR is "Ready for review"
Additional Information