Skip to content

Commit 7b8343b

Browse files
mcremon-metafacebook-github-bot
authored andcommitted
Update name from xtensa to cadence (#2982)
Summary: Pull Request resolved: #2982 As titled. Reviewed By: cccclai Differential Revision: D55998135 fbshipit-source-id: a57bd233afe170290c7def4406d6d6e769d467ed
1 parent c7fd394 commit 7b8343b

33 files changed

+73
-73
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.

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if(NOT CMAKE_CXX_STANDARD)
1212
endif()
1313

1414
# Set the project name.
15-
project(xtensa_executorch_example)
15+
project(cadence_executorch_example)
1616

1717
# Source root directory for executorch.
1818
if(NOT EXECUTORCH_ROOT)
@@ -100,21 +100,21 @@ add_custom_command(
100100

101101
add_custom_target(gen_model_header DEPENDS ${CMAKE_BINARY_DIR}/model_pte.h)
102102

103-
add_executable(xtensa_executorch_example executor_runner.cpp)
104-
add_dependencies(xtensa_executorch_example gen_model_header)
103+
add_executable(cadence_executorch_example executor_runner.cpp)
104+
add_dependencies(cadence_executorch_example gen_model_header)
105105

106106
# lint_cmake: -linelength
107-
target_include_directories(xtensa_executorch_example PUBLIC ${ROOT_DIR}/..
107+
target_include_directories(cadence_executorch_example PUBLIC ${ROOT_DIR}/..
108108
${CMAKE_BINARY_DIR}
109109
${_common_include_directories})
110110

111-
target_link_options(xtensa_executorch_example PRIVATE
111+
target_link_options(cadence_executorch_example PRIVATE
112112
-mlsp=${NXP_SDK_ROOT_DIR}/devices/MIMXRT685S/xtensa/min-rt)
113-
target_link_libraries(xtensa_executorch_example dsp_mu_polling_libs
114-
xtensa_ops_lib extension_runner_util executorch)
113+
target_link_libraries(cadence_executorch_example dsp_mu_polling_libs
114+
cadence_ops_lib extension_runner_util executorch)
115115

116116
add_custom_command(
117-
TARGET xtensa_executorch_example
117+
TARGET cadence_executorch_example
118118
POST_BUILD
119119
COMMAND
120120
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/utils/post_compilation.py
File renamed without changes.

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@
1717

1818
from .compiler import export_to_edge
1919
from .quantizer import (
20+
CadenceBaseQuantizer,
2021
QuantFusion,
21-
ReplacePT2DequantWithXtensaDequant,
22-
ReplacePT2QuantWithXtensaQuant,
23-
XtensaBaseQuantizer,
22+
ReplacePT2DequantWithCadenceDequant,
23+
ReplacePT2QuantWithCadenceQuant,
2424
)
2525

2626

2727
FORMAT = "[%(levelname)s %(asctime)s %(filename)s:%(lineno)s] %(message)s"
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
33-
quantizer = XtensaBaseQuantizer()
33+
quantizer = CadenceBaseQuantizer()
3434

3535
# Export
3636
model_exp = capture_pre_autograd_graph(model, example_inputs)
@@ -42,24 +42,24 @@ def export_xtensa_model(model, example_inputs):
4242
# Convert
4343
converted_model = convert_pt2e(prepared_model)
4444

45-
# pyre-fixme[16]: Pyre doesn't get that XtensaQuantizer has a patterns attribute
45+
# pyre-fixme[16]: Pyre doesn't get that CadenceQuantizer has a patterns attribute
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(
54-
[ReplacePT2QuantWithXtensaQuant(), ReplacePT2DequantWithXtensaDequant()],
53+
cadence_prog_manager = edge_prog_manager.transform(
54+
[ReplacePT2QuantWithCadenceQuant(), ReplacePT2DequantWithCadenceDequant()],
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/meta_registrations.py renamed to examples/cadence/aot/meta_registrations.py

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

1313
from .utils import get_conv1d_output_size
1414

15-
lib = Library("xtensa", "DEF")
15+
lib = Library("cadence", "DEF")
1616

1717
lib.define(
1818
"quantize_per_tensor(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype) -> (Tensor Z)"
@@ -56,7 +56,7 @@
5656
"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!)"
5757
)
5858

59-
m = Library("xtensa", "IMPL", "Meta")
59+
m = Library("cadence", "IMPL", "Meta")
6060

6161

6262
@impl(m, "quantize_per_tensor")

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

Lines changed: 14 additions & 14 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):
@@ -657,7 +657,7 @@ def get_supported_operators(cls) -> List[OperatorConfig]:
657657
)
658658

659659

660-
class XtensaBaseQuantizer(ComposableQuantizer):
660+
class CadenceBaseQuantizer(ComposableQuantizer):
661661
def __init__(self):
662662
static_qconfig = QuantizationConfig(
663663
act_qspec,
@@ -821,34 +821,34 @@ def mark_fused(cls, nodes) -> bool:
821821
n.meta["QuantFusion"] = True
822822

823823

824-
class ReplacePT2QuantWithXtensaQuant(ExportPass):
824+
class ReplacePT2QuantWithCadenceQuant(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,
838838
)
839839

840840

841-
class ReplacePT2DequantWithXtensaDequant(ExportPass):
841+
class ReplacePT2DequantWithCadenceDequant(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/executor_runner.cpp renamed to examples/cadence/executor_runner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* This is a simple executor_runner that boots up the DSP, configures the serial
1313
* port, sends a bunch of test messages to the M33 core and then loads the model
1414
* defined in model_pte.h. It runs this model using the ops available in
15-
* xtensa/ops directory.
15+
* cadence/ops directory.
1616
*/
1717

1818
#include <fsl_debug_console.h>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
# LICENSE file in the root directory of this source tree.
66

77
# lint_cmake: -linelength
8-
add_library(xtensa_kernels kernels.cpp ${EXECUTORCH_ROOT}/examples/xtensa/third-party/nnlib-hifi4/matmul_asym8uxasym8u_asym8u.cpp)
8+
add_library(cadence_kernels kernels.cpp ${EXECUTORCH_ROOT}/examples/cadence/third-party/nnlib-hifi4/matmul_asym8uxasym8u_asym8u.cpp)
99

1010
target_include_directories(
11-
xtensa_kernels
11+
cadence_kernels
1212
PUBLIC .
1313
${NN_LIB_BASE_DIR}/xa_nnlib/algo/common/include/
1414
${NN_LIB_BASE_DIR}/xa_nnlib/include/nnlib

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ 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}/..
42-
${CMAKE_BINARY_DIR}
43-
${_common_include_directories})
41+
target_include_directories(aten_ops_cadence PUBLIC ${ROOT_DIR}/..
42+
${CMAKE_BINARY_DIR}
43+
${_common_include_directories})
4444

4545
# Custom ops that are needed to run the test model.
4646
add_library(
@@ -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)

0 commit comments

Comments
 (0)