|  | 
|  | 1 | +# Samsung Exynos Backend | 
|  | 2 | + | 
|  | 3 | +ExecuTorch's Samsung Exynos backend enables the execution of ExecuTorch models on | 
|  | 4 | +Samsung SoCs via the NPU/DSP. The delegate is built on top of the | 
|  | 5 | +[Samsung Exynos AI Litecore SDK]((https://soc-developer.semiconductor.samsung.com/global/development/ai-litecore)). | 
|  | 6 | + | 
|  | 7 | +## Features | 
|  | 8 | + | 
|  | 9 | +- Wide range of operator support | 
|  | 10 | +- Supported inference precisions: | 
|  | 11 | +  - FP16 | 
|  | 12 | +  - 8-bit statically quantized (int8/uint8) | 
|  | 13 | +  - 16-bit statically quantized (int16/uint16) | 
|  | 14 | + | 
|  | 15 | +## Target Requirements | 
|  | 16 | + | 
|  | 17 | +Currently, the Samsung Exynos backend is supported only for devices with the | 
|  | 18 | +following chipsets: | 
|  | 19 | + | 
|  | 20 | +- Exynos 2500 (E9955) | 
|  | 21 | + | 
|  | 22 | +## Development Requirements | 
|  | 23 | + | 
|  | 24 | +The [Samsung Exynos AI Litecore SDK](https://soc-developer.semiconductor.samsung.com/global/development/ai-litecore) | 
|  | 25 | +is required to build the Exynos backend from source, and is also required to | 
|  | 26 | +export models to the Exynos delegate. | 
|  | 27 | + | 
|  | 28 | +---- | 
|  | 29 | + | 
|  | 30 | +## Using the Samsung Exynos Backend | 
|  | 31 | + | 
|  | 32 | +To target the Exynos backend during the export and lowering process, pass an instance of | 
|  | 33 | +the `EnnPartitioner` to `to_edge_transform_and_lower`. The example below | 
|  | 34 | +demonstrates this process using the MobileNet V2 model from torchvision. | 
|  | 35 | + | 
|  | 36 | +```python | 
|  | 37 | +import torch | 
|  | 38 | +import torchvision.models as models | 
|  | 39 | +from torchvision.models.mobilenetv2 import MobileNet_V2_Weights | 
|  | 40 | +from executorch.backends.samsung.partition.enn_partitioner import EnnPartitioner | 
|  | 41 | +from executorch.backends.samsung.serialization.compile_options import ( | 
|  | 42 | +    gen_samsung_backend_compile_spec, | 
|  | 43 | +) | 
|  | 44 | +from executorch.exir import to_edge_transform_and_lower | 
|  | 45 | + | 
|  | 46 | +mobilenet_v2 = models.mobilenetv2.mobilenet_v2(weights=MobileNet_V2_Weights.DEFAULT).eval() | 
|  | 47 | +sample_inputs = (torch.randn(1, 3, 224, 224), ) | 
|  | 48 | + | 
|  | 49 | +chipset = "E9955" | 
|  | 50 | +compile_specs = [gen_samsung_backend_compile_spec(chipset)] | 
|  | 51 | + | 
|  | 52 | +et_program = to_edge_transform_and_lower( | 
|  | 53 | +    torch.export.export(mobilenet_v2, sample_inputs), | 
|  | 54 | +    partitioner=[EnnPartitioner(compile_specs)], | 
|  | 55 | +).to_executorch() | 
|  | 56 | + | 
|  | 57 | +with open("mv2_xnnpack.pte", "wb") as file: | 
|  | 58 | +    et_program.write_to_file(file) | 
|  | 59 | +``` | 
|  | 60 | + | 
|  | 61 | +See [Partitioner API](/backends/samsung/samsung-partitioner) for a reference on available partitioner options. | 
|  | 62 | + | 
|  | 63 | +---- | 
|  | 64 | + | 
|  | 65 | +## Quantization | 
|  | 66 | + | 
|  | 67 | +The Samsung Exynos backend support statically quantized models with 8-bit and 16-bit | 
|  | 68 | +integral types. | 
|  | 69 | + | 
|  | 70 | +See [Samsung Exynos Quantization](/backends/samsung/samsung-quantization) for more | 
|  | 71 | +information on available quantization schemes and APIs. | 
|  | 72 | + | 
|  | 73 | +---- | 
|  | 74 | + | 
|  | 75 | +## Runtime Integration | 
|  | 76 | + | 
|  | 77 | +To run the model on-device, use the standard ExecuTorch runtime APIs. | 
|  | 78 | + | 
|  | 79 | +The Exynos backend is currently not available in any of ExecuTorch's published packages. | 
|  | 80 | +To access it, build ExecuTorch from source. When building from source, pass | 
|  | 81 | +`-DEXECUTORCH_BUILD_EXYNOS=ON` when configuring the CMake build. See [Running on Device](/getting-started.md#running-on-device) | 
|  | 82 | +for more information. | 
|  | 83 | + | 
|  | 84 | +Then, to link against the backend, add the `executorch_backends` CMake target as a build | 
|  | 85 | +dependency. | 
|  | 86 | + | 
|  | 87 | +``` | 
|  | 88 | +# CMakeLists.txt | 
|  | 89 | +add_subdirectory("executorch") | 
|  | 90 | +... | 
|  | 91 | +target_link_libraries( | 
|  | 92 | +    my_target | 
|  | 93 | +    PRIVATE executorch | 
|  | 94 | +    executorch_backends | 
|  | 95 | +    ... | 
|  | 96 | +) | 
|  | 97 | +``` | 
|  | 98 | + | 
|  | 99 | +No additional steps are necessary to use the backend beyond linking the target. Any | 
|  | 100 | +Exynos delegated .pte file will automatically run on the registered backend. | 
|  | 101 | + | 
|  | 102 | +## Reference | 
|  | 103 | + | 
|  | 104 | +**→{doc}`exynos-partitioner` — Partitioner options.** | 
|  | 105 | + | 
|  | 106 | +**→{doc}`exynos-quantization` — Supported quantization schemes.** | 
|  | 107 | + | 
|  | 108 | +**→{doc}`exynos-op-support` — Supported operators.** | 
|  | 109 | + | 
|  | 110 | +```{toctree} | 
|  | 111 | +:maxdepth: 2 | 
|  | 112 | +:hidden: | 
|  | 113 | +:caption: Exynos Backend | 
|  | 114 | +
 | 
|  | 115 | +exynos-partitioner | 
|  | 116 | +exynos-quantization | 
|  | 117 | +exynos-op-support | 
0 commit comments