1*523fa7a6SAndroid Build Coastguard WorkerThis folder is an exmample backend to lower MobileNetV2. It covers the AOT side and showcase how to quantize and lower a MobileNetV2 to the example backend. The serialization format is purely string for demo purpose as it'll be up to backend's decision to choose serialization format. 2*523fa7a6SAndroid Build Coastguard Worker 3*523fa7a6SAndroid Build Coastguard WorkerThe folder structure incluces: 4*523fa7a6SAndroid Build Coastguard Worker- example_quantizer 5*523fa7a6SAndroid Build Coastguard Worker- example_partitioner 6*523fa7a6SAndroid Build Coastguard Worker- example_backend 7*523fa7a6SAndroid Build Coastguard Worker- examples_operators. Assuming all of them can run in the example backend. 8*523fa7a6SAndroid Build Coastguard Worker - The OpBase defined in op_base.py is just the draft idea, it can be defined more comprehensively depending example operator definitions 9*523fa7a6SAndroid Build Coastguard Worker- example_backend_delegate_passes. It includes passes that might be helpful in the backend. Right now there are two passes: merge_to_dim_pass.py and permute_memory_formats_pass.py. They are examples to show how to represent memory format permutation and how to represent operators with different memory format (like channel last) 10*523fa7a6SAndroid Build Coastguard Worker - merge_to_dim_pass.py only handles one merging cases. More cases need to be covered but should be straitforward. 11*523fa7a6SAndroid Build Coastguard Worker 12*523fa7a6SAndroid Build Coastguard Worker## High Level Flow 13*523fa7a6SAndroid Build Coastguard Worker 14*523fa7a6SAndroid Build Coastguard WorkerIn the following diagram, we show how to quantize a mobile net v2 model and lower it to ExampleBackend. 15*523fa7a6SAndroid Build Coastguard Worker 16*523fa7a6SAndroid Build Coastguard Worker### Quantize and Delegate 17*523fa7a6SAndroid Build Coastguard Worker 18*523fa7a6SAndroid Build Coastguard WorkerWe can define patterns based on the operators supported by the backend, which will be used by the quantizer and delegate. 19*523fa7a6SAndroid Build Coastguard Worker 20*523fa7a6SAndroid Build Coastguard Worker 21*523fa7a6SAndroid Build Coastguard Worker 22*523fa7a6SAndroid Build Coastguard Worker### Partitioner and Backend 23*523fa7a6SAndroid Build Coastguard Worker 24*523fa7a6SAndroid Build Coastguard WorkerThe way partitioner and backend is, partitioner will tag the nodes to lower to the backend and backend will will receive all tagged nodes and preprocess them as a delegate. 25*523fa7a6SAndroid Build Coastguard Worker 26*523fa7a6SAndroid Build Coastguard Worker 27*523fa7a6SAndroid Build Coastguard Worker 28*523fa7a6SAndroid Build Coastguard Worker### Memory format permute 29*523fa7a6SAndroid Build Coastguard Worker 30*523fa7a6SAndroid Build Coastguard WorkerSome operators may have better performance in the memory format other than contiguous. One way to do that is to insert `to_dim_op` to describe memory format permutation and merge if there two opposite one next to each other. 31*523fa7a6SAndroid Build Coastguard Worker 32*523fa7a6SAndroid Build Coastguard Worker 33