Skip to content

Commit 87dc49d

Browse files
haowhsu-quicfacebook-github-bot
authored andcommitted
Qualcomm AI Engine Direct - add tutorial for op builder & quantizer (#5575)
Summary: Summary - tutorial for extending support of existent op builder & quantizer Pull Request resolved: #5575 Reviewed By: kirklandsign Differential Revision: D63505510 Pulled By: cccclai fbshipit-source-id: abc9a71e9aff704d3ccb9f34390931ccab761e28
1 parent 4ee0437 commit 87dc49d

File tree

3 files changed

+614
-0
lines changed

3 files changed

+614
-0
lines changed

backends/qualcomm/README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,67 @@ examples/qualcomm
7373
Please see this [README.md](../../examples/qualcomm/README.md).
7474

7575
Further, an example build script is provided as [build.sh](scripts/build.sh).
76+
77+
## Issues
78+
If you want to address the problem encountered, it would be great to have reproduction information for indicating maintainers. Please also follow the [policy](../../CONTRIBUTING.md#issues) to emit issues.
79+
80+
## Pull Requests
81+
PRs are always welcome to help improve the codebase in a comprehensive manner. Before submitting changes, please apply:
82+
83+
- **Check the Coding Style**:<br/>
84+
Make sure your code follows the [style guides](../../CONTRIBUTING.md#coding-style) and passes the [lint checks](../../CONTRIBUTING.md#lintrunner).
85+
86+
- **Add Unit Tests**:<br/>
87+
Following is an example of adding test case after [creating new operator builder](builders/README.md), please navigate to `backends/qualcomm/tests` folder and put minimum example module in `model.py`. e.g.:
88+
```python
89+
class IndexPut(torch.nn.Module):
90+
...
91+
92+
# please insert implementation in alphabetical order
93+
class LayerNorm(torch.nn.Module):
94+
def __init__(self):
95+
super().__init__()
96+
self.layer_norm = torch.nn.LayerNorm([768], eps=1e-6)
97+
98+
def forward(self, x):
99+
return self.layer_norm(x)
100+
101+
102+
class LeakyReLUDefault(torch.nn.Module):
103+
...
104+
```
105+
Also extend sections `TestQNNFloatingPointOperator`, `TestQNNQuantizedOperator` in `test_qnn_delegate.py`. e.g.:
106+
```python
107+
class TestQNNQuantizedOperator(TestQNN):
108+
def test_qnn_backend_interpolate_nearest_2d(self):
109+
...
110+
111+
# please insert it implementation alphabetical order
112+
def test_qnn_backend_layer_norm(self):
113+
module = LayerNorm() # noqa: F405
114+
sample_input = (torch.randn(196, 768),)
115+
module = self.get_qdq_module(module, sample_input)
116+
self.lower_module_and_test_output(module, sample_input)
117+
118+
def test_qnn_backend_leaky_relu(self):
119+
...
120+
```
121+
122+
- **Verify Unit Test Results**:<br/>
123+
```bash
124+
cd $PATH_TO_EXECUTORCH
125+
# example usage of performing unit test
126+
python backends/qualcomm/tests/test_qnn_delegate.py -k TestQNNQuantizedOperator.test_qnn_backend_layer_norm -s $DEVICE_SERIAL -m SM8650 -b build-android/ -a $PATH_TO_TEST_ARTIFACTS
127+
```
128+
The test graph is expected to have 1 delegated node with only placeholders / output nodes being left. Check the execution report for more information.
129+
130+
- **Code Reviews**:<br/>
131+
Please ping authors in Qualcomm AI Engine Direct related PRs for reviewing, possible candidates are listed below:
132+
- [chiwwang](https://github.com/chiwwang)
133+
- [shewu-quic](https://github.com/shewu-quic)
134+
- [chunit-quic](https://github.com/chunit-quic)
135+
- [winskuo-quic](https://github.com/winskuo-quic)
136+
- [chuntl](https://github.com/chuntl)
137+
- [haowhsu-quic](https://github.com/haowhsu-quic)
138+
139+
Thanks again for your contribution!

0 commit comments

Comments
 (0)