Skip to content

Commit 28ab306

Browse files
Matthias Cremonfacebook-github-bot
authored andcommitted
Update name from xtensa to cadence (#2982)
Summary: Pull Request resolved: #2982 As titled. Differential Revision: D55998135
1 parent d761f99 commit 28ab306

33 files changed

+49
-49
lines changed

docs/source/build-run-xtensa.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Step 2. Make sure you have completed the ExecuTorch setup tutorials linked to at
6464
The working tree is:
6565

6666
```
67-
examples/xtensa/
67+
examples/cadence/
6868
├── aot
6969
├── kernels
7070
├── ops
@@ -75,7 +75,7 @@ examples/xtensa/
7575

7676
***AoT (Ahead-of-Time) Components***:
7777

78-
The AoT folder contains all of the python scripts and functions needed to export the model to an ExecuTorch `.pte` file. In our case, [export_example.py](https://github.com/pytorch/executorch/blob/main/examples/xtensa/aot/export_example.py) is an API that takes a model (nn.Module) and representative inputs and runs it through the quantizer (from [quantizer.py](https://github.com/pytorch/executorch/blob/main/examples/xtensa/aot/quantizer.py)). Then a few compiler passes, also defined in [quantizer.py](https://github.com/pytorch/executorch/blob/main/examples/xtensa/aot/quantizer.py), will replace operators with custom ones that are supported and optimized on the chip. Any operator needed to compute things should be defined in [meta_registrations.py](https://github.com/pytorch/executorch/blob/main/examples/xtensa/aot/meta_registrations.py) and have corresponding implemetations in the other folders.
78+
The AoT folder contains all of the python scripts and functions needed to export the model to an ExecuTorch `.pte` file. In our case, [export_example.py](https://github.com/pytorch/executorch/blob/main/examples/cadence/aot/export_example.py) is an API that takes a model (nn.Module) and representative inputs and runs it through the quantizer (from [quantizer.py](https://github.com/pytorch/executorch/blob/main/examples/cadence/aot/quantizer.py)). Then a few compiler passes, also defined in [quantizer.py](https://github.com/pytorch/executorch/blob/main/examples/cadence/aot/quantizer.py), will replace operators with custom ones that are supported and optimized on the chip. Any operator needed to compute things should be defined in [meta_registrations.py](https://github.com/pytorch/executorch/blob/main/examples/cadence/aot/meta_registrations.py) and have corresponding implemetations in the other folders.
7979

8080
***Operators***:
8181

@@ -101,14 +101,14 @@ python3 -m examples.portable.scripts.export --model_name="add"
101101
***Quantized Operators***:
102102

103103
The other, more complex model are custom operators, including:
104-
- a quantized [linear](https://pytorch.org/docs/stable/generated/torch.nn.Linear.html) operation. The model is defined [here](https://github.com/pytorch/executorch/blob/main/examples/xtensa/tests/quantized_linear_example.py#L28). Linear is the backbone of most Automatic Speech Recognition (ASR) models.
105-
- a quantized [conv1d](https://pytorch.org/docs/stable/generated/torch.nn.Conv1d.html) operation. The model is defined [here](https://github.com/pytorch/executorch/blob/main/examples/xtensa/tests/quantized_conv1d_example.py#L36). Convolutions are important in wake word and many denoising models.
104+
- a quantized [linear](https://pytorch.org/docs/stable/generated/torch.nn.Linear.html) operation. The model is defined [here](https://github.com/pytorch/executorch/blob/main/examples/cadence/tests/quantized_linear_example.py#L28). Linear is the backbone of most Automatic Speech Recognition (ASR) models.
105+
- a quantized [conv1d](https://pytorch.org/docs/stable/generated/torch.nn.Conv1d.html) operation. The model is defined [here](https://github.com/pytorch/executorch/blob/main/examples/cadence/tests/quantized_conv1d_example.py#L36). Convolutions are important in wake word and many denoising models.
106106

107107
In both cases the generated file is called `XtensaDemoModel.pte`.
108108

109109
```bash
110110
cd executorch
111-
python3 -m examples.xtensa.tests.quantized_<linear,conv1d>_example
111+
python3 -m examples.cadence.tests.quantized_<linear,conv1d>_example
112112
```
113113

114114
***Small Model: RNNT predictor***:
@@ -118,7 +118,7 @@ The predictor is a sequence of basic ops (embedding, ReLU, linear, layer norm) a
118118

119119
```bash
120120
cd executorch
121-
python3 -m examples.xtensa.tests.rnnt_predictor_quantized_example
121+
python3 -m examples.cadence.tests.rnnt_predictor_quantized_example
122122
```
123123

124124
The generated file is called `XtensaDemoModel.pte`.
@@ -131,7 +131,7 @@ In this step, you'll be building the DSP firmware image that consists of the sam
131131
***Step 1***. Configure the environment variables needed to point to the Xtensa toolchain that you have installed in the previous step. The three environment variables that need to be set include:
132132
```bash
133133
# Directory in which the Xtensa toolchain was installed
134-
export XTENSA_TOOLCHAIN=/home/user_name/xtensa/XtDevTools/install/tools
134+
export XTENSA_TOOLCHAIN=/home/user_name/cadence/XtDevTools/install/tools
135135
# The version of the toolchain that was installed. This is essentially the name of the directory
136136
# that is present in the XTENSA_TOOLCHAIN directory from above.
137137
export TOOLCHAIN_VER=RI-2021.8-linux
@@ -151,7 +151,7 @@ cd executorch
151151
rm -rf cmake-out
152152
# prebuild and install executorch library
153153
cmake -DBUCK2=buck2 \
154-
-DCMAKE_TOOLCHAIN_FILE=<path_to_executorch>/examples/xtensa/xtensa.cmake \
154+
-DCMAKE_TOOLCHAIN_FILE=<path_to_executorch>/examples/cadence/cadence.cmake \
155155
-DCMAKE_INSTALL_PREFIX=cmake-out \
156156
-DCMAKE_BUILD_TYPE=Debug \
157157
-DPYTHON_EXECUTABLE=python3 \
@@ -165,18 +165,18 @@ cmake -DBUCK2=buck2 \
165165
-Bcmake-out .
166166

167167
cmake --build cmake-out -j8 --target install --config Debug
168-
# build xtensa runner
168+
# build cadence runner
169169
cmake -DCMAKE_BUILD_TYPE=Debug \
170-
-DCMAKE_TOOLCHAIN_FILE=<path_to_executorch>/examples/xtensa/xtensa.cmake \
170+
-DCMAKE_TOOLCHAIN_FILE=<path_to_executorch>/examples/cadence/cadence.cmake \
171171
-DCMAKE_PREFIX_PATH=<path_to_executorch>/cmake-out \
172172
-DMODEL_PATH=<path_to_program_file_generated_in_previous_step> \
173173
-DNXP_SDK_ROOT_DIR=<path_to_nxp_sdk_root> -DEXECUTORCH_BUILD_FLATC=0 \
174174
-DFLATC_EXECUTABLE="$(which flatc)" \
175175
-DNN_LIB_BASE_DIR=<path_to_nnlib_cloned_in_step_2> \
176-
-Bcmake-out/examples/xtensa \
177-
examples/xtensa
176+
-Bcmake-out/examples/cadence \
177+
examples/cadence
178178

179-
cmake --build cmake-out/examples/xtensa -j8 -t xtensa_executorch_example
179+
cmake --build cmake-out/examples/cadence -j8 -t cadence_executorch_example
180180
```
181181

182182
After having succesfully run the above step you should see two binary files in their CMake output directory.
@@ -213,6 +213,6 @@ First 20 elements of output 0
213213

214214
In this tutorial, you have learned how to export a quantized operation, build the ExecuTorch runtime and run this model on the Xtensa HiFi4 DSP chip.
215215

216-
The (quantized linear) model in this tutorial is a typical operation appearing in ASR models, and can be extended to a complete ASR model by creating the model as a new test and adding the needed operators/kernels to [operators](https://github.com/pytorch/executorch/blob/main/examples/xtensa/ops) and [kernels](https://github.com/pytorch/executorch/blob/main/examples/xtensa/kernels).
216+
The (quantized linear) model in this tutorial is a typical operation appearing in ASR models, and can be extended to a complete ASR model by creating the model as a new test and adding the needed operators/kernels to [operators](https://github.com/pytorch/executorch/blob/main/examples/cadence/ops) and [kernels](https://github.com/pytorch/executorch/blob/main/examples/cadence/kernels).
217217

218218
Other models can be created following the same structure, always assuming that operators and kernels are available.
File renamed without changes.
File renamed without changes.

examples/xtensa/aot/export_example.py renamed to examples/cadence/aot/export_example.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
logging.basicConfig(level=logging.INFO, format=FORMAT)
2929

3030

31-
def export_xtensa_model(model, example_inputs):
31+
def export_model(model, example_inputs):
3232
# Quantizer
3333
quantizer = XtensaBaseQuantizer()
3434

@@ -46,20 +46,20 @@ def export_xtensa_model(model, example_inputs):
4646
patterns = [q.pattern for q in quantizer.quantizers]
4747
QuantFusion(patterns)(converted_model)
4848

49-
# Get edge program (note: the name will change to export_to_xtensa in future PRs)
49+
# Get edge program (note: the name will change to export_to_cadence in future PRs)
5050
edge_prog_manager = export_to_edge(converted_model, example_inputs, pt2_quant=True)
5151

5252
# Run a couple required passes for quant/dequant ops
53-
xtensa_prog_manager = edge_prog_manager.transform(
53+
cadence_prog_manager = edge_prog_manager.transform(
5454
[ReplacePT2QuantWithXtensaQuant(), ReplacePT2DequantWithXtensaDequant()],
5555
check_ir_validity=False,
5656
)
5757

58-
exec_prog = xtensa_prog_manager.to_executorch()
58+
exec_prog = cadence_prog_manager.to_executorch()
5959

6060
logging.info(
6161
f"Final exported graph module:\n{exec_prog.exported_program().graph_module}"
6262
)
6363

64-
# Save the program as XtensaDemoModel.pte
65-
save_pte_program(exec_prog, "XtensaDemoModel")
64+
# Save the program as CadenceDemoModel.pte
65+
save_pte_program(exec_prog, "CadenceDemoModel")

examples/xtensa/aot/quantizer.py renamed to examples/cadence/aot/quantizer.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ def get_anchors(
437437
)
438438

439439
def replacement_op(self):
440-
return torch.ops.xtensa.quantized_linear.default
440+
return torch.ops.cadence.quantized_linear.default
441441

442442

443443
class LinearFunctionalPattern(QuantizationPattern):
@@ -457,7 +457,7 @@ def get_anchors(
457457
)
458458

459459
def replacement_op(self):
460-
return torch.ops.xtensa.quantized_linear.default
460+
return torch.ops.cadence.quantized_linear.default
461461

462462

463463
class LayerNormPattern(QuantizationPattern):
@@ -476,7 +476,7 @@ def get_anchors(self, gm, fused_partition) -> PartitionAnchors:
476476
)
477477

478478
def replacement_op(self):
479-
return torch.ops.xtensa.quantized_layer_norm.default
479+
return torch.ops.cadence.quantized_layer_norm.default
480480

481481

482482
class Conv1dPattern(QuantizationPattern):
@@ -503,7 +503,7 @@ def get_anchors(
503503
)
504504

505505
def replacement_op(self):
506-
return torch.ops.xtensa.quantized_conv.default
506+
return torch.ops.cadence.quantized_conv.default
507507

508508

509509
class Conv2dPattern(QuantizationPattern):
@@ -530,7 +530,7 @@ def get_anchors(
530530
)
531531

532532
def replacement_op(self):
533-
return torch.ops.xtensa.quantized_conv.default
533+
return torch.ops.cadence.quantized_conv.default
534534

535535

536536
class AddmmPattern(QuantizationPattern):
@@ -550,7 +550,7 @@ def get_anchors(
550550
)
551551

552552
def replacement_op(self):
553-
return torch.ops.xtensa.quantized_linear.default
553+
return torch.ops.cadence.quantized_linear.default
554554

555555

556556
class ReluPattern(QuantizationPattern):
@@ -573,7 +573,7 @@ def get_anchors(
573573
)
574574

575575
def replacement_op(self):
576-
return torch.ops.xtensa.quantized_relu.default
576+
return torch.ops.cadence.quantized_relu.default
577577

578578

579579
class GenericQuantizer(Quantizer):
@@ -823,15 +823,15 @@ def mark_fused(cls, nodes) -> bool:
823823

824824
class ReplacePT2QuantWithXtensaQuant(ExportPass):
825825
"""
826-
Replace the pt2 quantization ops with custom xtensa quantization ops.
826+
Replace the pt2 quantization ops with custom cadence quantization ops.
827827
"""
828828

829829
def call_operator(self, op, args, kwargs, meta):
830830
if op not in {exir_ops.edge.quantized_decomposed.quantize_per_tensor.default}:
831831
return super().call_operator(op, args, kwargs, meta)
832832

833833
return super().call_operator(
834-
exir_ops.edge.xtensa.quantize_per_tensor.default,
834+
exir_ops.edge.cadence.quantize_per_tensor.default,
835835
args,
836836
kwargs,
837837
meta,
@@ -840,15 +840,15 @@ def call_operator(self, op, args, kwargs, meta):
840840

841841
class ReplacePT2DequantWithXtensaDequant(ExportPass):
842842
"""
843-
Replace the pt2 dequantization ops with custom xtensa dequantization ops.
843+
Replace the pt2 dequantization ops with custom cadence dequantization ops.
844844
"""
845845

846846
def call_operator(self, op, args, kwargs, meta):
847847
if op not in {exir_ops.edge.quantized_decomposed.dequantize_per_tensor.default}:
848848
return super().call_operator(op, args, kwargs, meta)
849849

850850
return super().call_operator(
851-
exir_ops.edge.xtensa.dequantize_per_tensor.default,
851+
exir_ops.edge.cadence.dequantize_per_tensor.default,
852852
args,
853853
kwargs,
854854
meta,
File renamed without changes.
File renamed without changes.

examples/xtensa/ops/CMakeLists.txt renamed to examples/cadence/ops/CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ set(_aten_ops__srcs
3131
"${CMAKE_CURRENT_SOURCE_DIR}/op_view_copy.cpp"
3232
"${EXECUTORCH_ROOT}/kernels/portable/cpu/util/broadcast_util.cpp"
3333
"${EXECUTORCH_ROOT}/kernels/portable/cpu/util/repeat_util.cpp")
34-
add_library(aten_ops_xtensa ${_aten_ops__srcs})
35-
target_link_libraries(aten_ops_xtensa PUBLIC executorch)
36-
target_link_libraries(aten_ops_xtensa PRIVATE xtensa_kernels)
34+
add_library(aten_ops_cadence ${_aten_ops__srcs})
35+
target_link_libraries(aten_ops_cadence PUBLIC executorch)
36+
target_link_libraries(aten_ops_cadence PRIVATE cadence_kernels)
3737

3838
# Let files say "include <executorch/path/to/header.h>".
3939
set(_common_include_directories ${EXECUTORCH_ROOT}/..)
4040

41-
target_include_directories(aten_ops_xtensa PUBLIC ${ROOT_DIR}/..
41+
target_include_directories(aten_ops_cadence PUBLIC ${ROOT_DIR}/..
4242
${CMAKE_BINARY_DIR}
4343
${_common_include_directories})
4444

@@ -52,7 +52,7 @@ target_include_directories(custom_ops PUBLIC ${ROOT_DIR}/..
5252
${_common_include_directories})
5353

5454
target_link_libraries(custom_ops PUBLIC executorch)
55-
target_link_libraries(custom_ops PRIVATE xtensa_kernels)
55+
target_link_libraries(custom_ops PRIVATE cadence_kernels)
5656

5757
# Generate C++ bindings to register kernels into both PyTorch (for AOT) and
5858
# Executorch (for runtime). Here select all ops in functions.yaml
@@ -62,6 +62,6 @@ generate_bindings_for_kernels(
6262
message("Generated files ${gen_command_sources}")
6363

6464
gen_operators_lib(
65-
"xtensa_ops_lib"
65+
"cadence_ops_lib"
6666
KERNEL_LIBS custom_ops
67-
DEPS aten_ops_xtensa)
67+
DEPS aten_ops_cadence)

examples/xtensa/ops/functions.yaml renamed to examples/cadence/ops/functions.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,29 @@
3333
kernel_name: torch::executor::view_copy_out
3434

3535
# custom ops
36-
- func: xtensa::quantize_per_tensor.out(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype, *, Tensor(a!) out) -> Tensor(a!)
36+
- func: cadence::quantize_per_tensor.out(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype, *, Tensor(a!) out) -> Tensor(a!)
3737
variants: function
3838
kernels:
3939
- arg_meta: null
4040
kernel_name: impl::HiFi::quantize_per_tensor_out
4141

42-
- func: xtensa::dequantize_per_tensor.out(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype, *, Tensor(a!) out) -> Tensor(a!)
42+
- func: cadence::dequantize_per_tensor.out(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype, *, Tensor(a!) out) -> Tensor(a!)
4343
variants: function
4444
kernels:
4545
- arg_meta: null
4646
kernel_name: impl::HiFi::dequantize_per_tensor_out
4747

48-
- func: xtensa::quantized_conv.out(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, int[] dilation, int groups, int input_zero_point, Tensor weight_zero_point, Tensor bias_scale, float out_scale, int out_zero_point, Tensor out_multiplier, Tensor out_shift, bool channel_last=False, *, Tensor(a!) out) -> Tensor(a!)
48+
- func: cadence::quantized_conv.out(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, int[] dilation, int groups, int input_zero_point, Tensor weight_zero_point, Tensor bias_scale, float out_scale, int out_zero_point, Tensor out_multiplier, Tensor out_shift, bool channel_last=False, *, Tensor(a!) out) -> Tensor(a!)
4949
kernels:
5050
- arg_meta: null
5151
kernel_name: impl::HiFi::quantized_conv_out
5252

53-
- func: xtensa::quantized_linear.out(Tensor src, Tensor weight, Tensor bias, float src_scale, int src_zero_point, float weight_scale, int weight_zero_point, Tensor out_multiplier, Tensor out_shift, int out_zero_point, *, Tensor(a!) out) -> Tensor(a!)
53+
- func: cadence::quantized_linear.out(Tensor src, Tensor weight, Tensor bias, float src_scale, int src_zero_point, float weight_scale, int weight_zero_point, Tensor out_multiplier, Tensor out_shift, int out_zero_point, *, Tensor(a!) out) -> Tensor(a!)
5454
kernels:
5555
- arg_meta: null
5656
kernel_name: impl::HiFi::quantized_linear_out
5757

58-
- func: xtensa::quantized_relu.out(Tensor X, Tensor X_zero_point, *, Tensor(a!) out) -> Tensor(a!)
58+
- func: cadence::quantized_relu.out(Tensor X, Tensor X_zero_point, *, Tensor(a!) out) -> Tensor(a!)
5959
kernels:
6060
- arg_meta: null
6161
kernel_name: impl::HiFi::quantized_relu_out
File renamed without changes.
File renamed without changes.

examples/xtensa/tests/quantized_conv1d_example.py renamed to examples/cadence/tests/quantized_conv1d_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import torch
1414

15-
from ..aot.export_example import export_xtensa_model
15+
from ..aot.export_example import export_model
1616

1717

1818
FORMAT = "[%(levelname)s %(asctime)s %(filename)s:%(lineno)s] %(message)s"
@@ -55,4 +55,4 @@ def forward(self, x: torch.Tensor):
5555

5656
example_inputs = (torch.randn(shape),)
5757

58-
export_xtensa_model(model, example_inputs)
58+
export_model(model, example_inputs)

examples/xtensa/tests/quantized_linear_example.py renamed to examples/cadence/tests/quantized_linear_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import torch
1414

15-
from ..aot.export_example import export_xtensa_model
15+
from ..aot.export_example import export_model
1616

1717

1818
FORMAT = "[%(levelname)s %(asctime)s %(filename)s:%(lineno)s] %(message)s"
@@ -39,4 +39,4 @@ def forward(self, x: torch.Tensor):
3939

4040
example_inputs = (torch.ones(shape),)
4141

42-
export_xtensa_model(model, example_inputs)
42+
export_model(model, example_inputs)

examples/xtensa/tests/rnnt_predictor_quantized_example.py renamed to examples/cadence/tests/rnnt_predictor_quantized_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from typing import Tuple
1616

17-
from ..aot.export_example import export_xtensa_model
17+
from ..aot.export_example import export_model
1818

1919

2020
FORMAT = "[%(levelname)s %(asctime)s %(filename)s:%(lineno)s] %(message)s"
@@ -66,4 +66,4 @@ def forward(
6666
predictor_lengths,
6767
)
6868

69-
export_xtensa_model(model, example_inputs)
69+
export_model(model, example_inputs)

0 commit comments

Comments
 (0)