Skip to content

Commit e3d9f0e

Browse files
committed
Update on "[executorch][flat_tensor] flat tensor header"
Parse a FlatTensor header. The FlatTensor header contains: - flatbuffer offset - flatbuffer size - segment base offset - segment data size (total size of all segments) Mostly taken from extended_header.cpp/.h Differential Revision: [D67064570](https://our.internmc.facebook.com/intern/diff/D67064570/) [ghstack-poisoned]
2 parents 8082419 + e73123c commit e3d9f0e

File tree

117 files changed

+1585
-3307
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+1585
-3307
lines changed

.ci/scripts/utils.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ retry () {
1717
}
1818

1919
clean_executorch_install_folders() {
20-
./install_requirements.sh --clean
20+
./install_executorch.sh --clean
2121
}
2222

2323
install_executorch() {
2424
which pip
2525
# Install executorch, this assumes that Executorch is checked out in the
2626
# current directory.
2727
if [[ "${1:-}" == "use-pt-pinned-commit" ]]; then
28-
./install_requirements.sh --pybind xnnpack --use-pt-pinned-commit
28+
./install_executorch.sh --pybind xnnpack --use-pt-pinned-commit
2929
else
30-
./install_requirements.sh --pybind xnnpack
30+
./install_executorch.sh --pybind xnnpack
3131
fi
3232
# Just print out the list of packages for debugging
3333
pip list

.github/workflows/apple.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
paths:
1010
- .ci/scripts/setup-ios.sh
1111
- .github/workflows/apple.yml
12-
- install_requirements.sh
12+
- install_executorch.sh
1313
- backends/apple/**
1414
- build/build_apple_frameworks.sh
1515
- build/build_apple_llm_demo.sh

.github/workflows/pull.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ jobs:
200200
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"
201201
202202
# install pybind
203-
bash install_requirements.sh --pybind xnnpack
203+
bash install_executorch.sh --pybind xnnpack
204204
205205
# install Llava requirements
206206
bash examples/models/llama/install_requirements.sh
@@ -436,7 +436,7 @@ jobs:
436436
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"
437437
438438
# install pybind
439-
bash install_requirements.sh --pybind xnnpack
439+
bash install_executorch.sh --pybind xnnpack
440440
441441
# install phi-3-mini requirements
442442
bash examples/models/phi-3-mini/install_requirements.sh
@@ -463,7 +463,7 @@ jobs:
463463
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"
464464
465465
# install pybind
466-
bash install_requirements.sh --pybind xnnpack
466+
bash install_executorch.sh --pybind xnnpack
467467
468468
# install llama requirements
469469
bash examples/models/llama/install_requirements.sh
@@ -490,7 +490,7 @@ jobs:
490490
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"
491491
492492
# install pybind
493-
bash install_requirements.sh --pybind xnnpack
493+
bash install_executorch.sh --pybind xnnpack
494494
495495
# install llama requirements
496496
bash examples/models/llama/install_requirements.sh
@@ -517,7 +517,7 @@ jobs:
517517
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"
518518
519519
# install pybind
520-
bash install_requirements.sh --pybind xnnpack
520+
bash install_executorch.sh --pybind xnnpack
521521
522522
# install llama requirements
523523
bash examples/models/llama/install_requirements.sh

backends/apple/coreml/test/test_coreml_partitioner.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616

1717

1818
class TestCoreMLPartitioner(unittest.TestCase):
19-
# TODO(T182928844): Delegate dim order op to backend.
20-
edge_compile_config = executorch.exir.EdgeCompileConfig(_skip_dim_order=True)
19+
edge_compile_config = executorch.exir.EdgeCompileConfig()
2120

2221
def test_add_sub_skip_mm(self):
2322
class Model(torch.nn.Module):

backends/apple/mps/setup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ I 00:00:00.122615 executorch:mps_executor_runner.mm:501] Model verified successf
9797
### [Optional] Run the generated model directly using pybind
9898
1. Make sure `pybind` MPS support was installed:
9999
```bash
100-
./install_requirements.sh --pybind mps
100+
./install_executorch.sh --pybind mps
101101
```
102102
2. Run the `mps_example` script to trace the model and run it directly from python:
103103
```bash

backends/arm/_passes/annotate_channels_last_dim_order_pass.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 Arm Limited and/or its affiliates.
1+
# Copyright 2024-2025 Arm Limited and/or its affiliates.
22
# All rights reserved.
33
#
44
# This source code is licensed under the BSD-style license found in the
@@ -15,7 +15,7 @@
1515
get_node_arg,
1616
insert_q_dq_pair,
1717
)
18-
from executorch.backends.arm.tosa_quant_utils import dq_op, q_op, register_passable_op
18+
from executorch.backends.arm.tosa_quant_utils import dq_op, q_op
1919
from executorch.backends.arm.tosa_utils import is_consumer_node_depthwise_conv2d
2020
from executorch.exir.dialects._ops import ops as exir_ops
2121
from executorch.exir.pass_base import ExportPass, PassResult
@@ -43,9 +43,6 @@ def _transpose_impl(*args, **kwargs):
4343
return args[0]
4444

4545

46-
register_passable_op(torch.ops.passthrough_to_tosa._transpose)
47-
48-
4946
class AnnotateChannelsLastDimOrder(ExportPass):
5047
"""
5148
Annotates each node with a tosa_dim_order. tosa_dim_order can be seen as a channels-last dim-order

backends/arm/arm_backend.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def __init__(self):
5050
self.output_format = None
5151
self.path_for_intermediates = None
5252
self.tosa_version = None
53+
self.tosa_spec = None
5354
self.input_order = None
5455

5556
def ethosu_compile_spec(

backends/arm/operators/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
op_bmm,
1414
op_cat,
1515
op_conv2d,
16-
op_dequant,
1716
op_exp,
1817
op_full,
1918
op_get_item,
@@ -24,7 +23,6 @@
2423
op_min,
2524
op_mul,
2625
op_permute,
27-
op_quant,
2826
op_reciprocal,
2927
op_relu,
3028
op_repeat,

backends/arm/operators/op_dequant.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

backends/arm/operators/op_hardtanh.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023-2024 Arm Limited and/or its affiliates.
1+
# Copyright 2023-2025 Arm Limited and/or its affiliates.
22
#
33
# This source code is licensed under the BSD-style license found in the
44
# LICENSE file in the root directory of this source tree.
@@ -19,7 +19,6 @@
1919
)
2020
from executorch.backends.arm.tosa_mapping import TosaArg
2121

22-
from executorch.backends.arm.tosa_quant_utils import quantize_value
2322
from serializer.tosa_serializer import TosaOp
2423

2524

@@ -44,8 +43,8 @@ def define_node(
4443
input_qparams = get_input_qparams(node) # pyre-ignore[16]
4544
qargs = input_qparams[0]
4645
# Convert to quantized representation
47-
clamp_min_qs = quantize_value(inputs[1].number, qargs)
48-
clamp_max_qs = quantize_value(inputs[2].number, qargs)
46+
clamp_min_qs = qargs.quantize_value(inputs[1].number).item()
47+
clamp_max_qs = qargs.quantize_value(inputs[2].number).item()
4948
# Set fp values to 0.0 since they are not used
5049
clamp_min_fp = 0.0
5150
clamp_max_fp = 0.0

backends/arm/operators/op_quant.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

backends/arm/operators/op_relu.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
# Copyright 2024 Arm Limited and/or its affiliates.
1+
# Copyright 2024-2025 Arm Limited and/or its affiliates.
22
#
33
# This source code is licensed under the BSD-style license found in the
44
# LICENSE file in the root directory of this source tree.
55

66
# pyre-unsafe
77

8-
import executorch.backends.arm.tosa_quant_utils as tqutils
98
import serializer.tosa_serializer as ts
109
import torch.fx
1110

@@ -43,9 +42,8 @@ def define_node(
4342
clamp_max_qs = 0
4443
if inputs[0].dtype == ts.DType.INT8:
4544
out_qargs = get_output_qparams(node) # pyre-ignore[16]
46-
clamp_min_qs = tqutils.quantize_value(0, out_qargs[0])
47-
clamp_max_qs = tqutils.quantize_value(float("inf"), out_qargs[0])
48-
45+
clamp_min_qs = out_qargs[0].quantize_value(0).item()
46+
clamp_max_qs = out_qargs[0].quantize_value(float("inf")).item()
4947
else:
5048
clamp_min_fp = 0
5149
clamp_max_fp = float("inf")

backends/arm/process_node.py

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@
1212
import torch
1313
import torch.fx
1414
from executorch.backends.arm.operators.node_visitor import NodeVisitor
15-
from executorch.backends.arm.tosa_mapping import map_dtype, TosaArg
16-
from executorch.backends.arm.tosa_quant_utils import (
17-
dq_op,
18-
get_quantized_node_output_dtype,
19-
is_node_quantized,
20-
)
15+
from executorch.backends.arm.tosa_mapping import TosaArg
2116
from executorch.backends.arm.tosa_specification import TosaSpecification
2217
from executorch.backends.arm.tosa_utils import getNodeArgs, tosa_shape
2318
from torch.export.exported_program import ExportedProgram
@@ -35,15 +30,8 @@ def process_call_function(
3530
# Convert output (this node itself)
3631
output = TosaArg(node)
3732

38-
is_dq_node = node.target == dq_op
39-
if is_dq_node:
40-
output_dtype = ts.DType.INT8
41-
else:
42-
output_dtype = output.dtype
4333
tosa_graph.currRegion.currBasicBlock.addTensor(
44-
output.name,
45-
tosa_shape(output.shape, output.dim_order),
46-
output_dtype,
34+
output.name, tosa_shape(output.shape, output.dim_order), output.dtype
4735
)
4836

4937
# Visiting each Node
@@ -79,11 +67,7 @@ def process_inputs(
7967
tensor = ts.TosaSerializerTensor(
8068
inputs[0].name,
8169
tosa_shape(input_shape, input_dim_order),
82-
(
83-
map_dtype(get_quantized_node_output_dtype(node))
84-
if is_node_quantized(node)
85-
else inputs[0].dtype
86-
),
70+
inputs[0].dtype,
8771
data=None,
8872
placeholderFilename=inputs[0].name + ".npy",
8973
)

backends/arm/test/common.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,3 @@ def get_u85_compile_spec_unbuilt(
145145
.dump_intermediate_artifacts_to(artifact_path)
146146
)
147147
return compile_spec
148-
149-
150-
def get_target_board(compile_spec: list[CompileSpec]) -> str | None:
151-
for spec in compile_spec:
152-
if spec.key == "compile_flags":
153-
flags = spec.value.decode()
154-
if "u55" in flags:
155-
return "corstone-300"
156-
elif "u85" in flags:
157-
return "corstone-320"
158-
return None

backends/arm/test/models/test_mobilenet_v2_arm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def test_mv2_u55_BI(self):
9898
)
9999
if conftest.is_option_enabled("corstone_fvp"):
100100
tester.run_method_and_compare_outputs(
101-
atol=1.0, qtol=1, inputs=self.model_inputs, target_board="corstone-300"
101+
atol=1.0, qtol=1, inputs=self.model_inputs
102102
)
103103

104104
@pytest.mark.slow
@@ -118,5 +118,5 @@ def test_mv2_u85_BI(self):
118118
)
119119
if conftest.is_option_enabled("corstone_fvp"):
120120
tester.run_method_and_compare_outputs(
121-
atol=1.0, qtol=1, inputs=self.model_inputs, target_board="corstone-320"
121+
atol=1.0, qtol=1, inputs=self.model_inputs
122122
)

backends/arm/test/ops/test_max_pool.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,7 @@ def test_maxpool2d_tosa_u55_BI(
173173
(test_data,),
174174
)
175175
if conftest.is_option_enabled("corstone_fvp"):
176-
tester.run_method_and_compare_outputs(
177-
qtol=1, inputs=(test_data,), target_board="corstone-300"
178-
)
176+
tester.run_method_and_compare_outputs(qtol=1, inputs=(test_data,))
179177

180178
@parameterized.expand(test_data_suite)
181179
@pytest.mark.corstone_fvp
@@ -191,9 +189,7 @@ def test_maxpool2d_tosa_u85_BI(
191189
(test_data,),
192190
)
193191
if conftest.is_option_enabled("corstone_fvp"):
194-
tester.run_method_and_compare_outputs(
195-
qtol=1, inputs=(test_data,), target_board="corstone-320"
196-
)
192+
tester.run_method_and_compare_outputs(qtol=1, inputs=(test_data,))
197193

198194
@parameterized.expand(test_data_suite_mult_batches)
199195
def test_maxpool2d_tosa_MI_mult_batches(
@@ -232,9 +228,7 @@ def test_maxpool2d_tosa_u55_BI_mult_batches(
232228
(test_data,),
233229
)
234230
if conftest.is_option_enabled("corstone_fvp"):
235-
tester.run_method_and_compare_outputs(
236-
qtol=1, inputs=(test_data,), target_board="corstone-300"
237-
)
231+
tester.run_method_and_compare_outputs(qtol=1, inputs=(test_data,))
238232

239233
@parameterized.expand(test_data_suite_mult_batches)
240234
@pytest.mark.corstone_fvp
@@ -251,6 +245,4 @@ def test_maxpool2d_tosa_u85_BI_mult_batches(
251245
(test_data,),
252246
)
253247
if conftest.is_option_enabled("corstone_fvp"):
254-
tester.run_method_and_compare_outputs(
255-
qtol=1, inputs=(test_data,), target_board="corstone-320"
256-
)
248+
tester.run_method_and_compare_outputs(qtol=1, inputs=(test_data,))

backends/arm/test/ops/test_maximum.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@ def test_maximum_u55_BI(self, operand1: torch.Tensor, operand2: torch.Tensor):
121121
self.Maximum(), common.get_u55_compile_spec(), test_data
122122
)
123123
if conftest.is_option_enabled("corstone_fvp"):
124-
tester.run_method_and_compare_outputs(
125-
qtol=1, inputs=test_data, target_board="corstone-300"
126-
)
124+
tester.run_method_and_compare_outputs(qtol=1, inputs=test_data)
127125

128126
@parameterized.expand(Maximum.test_parameters)
129127
def test_maximum_u85_BI(self, operand1: torch.Tensor, operand2: torch.Tensor):
@@ -132,6 +130,4 @@ def test_maximum_u85_BI(self, operand1: torch.Tensor, operand2: torch.Tensor):
132130
self.Maximum(), common.get_u85_compile_spec(), test_data
133131
)
134132
if conftest.is_option_enabled("corstone_fvp"):
135-
tester.run_method_and_compare_outputs(
136-
qtol=1, inputs=test_data, target_board="corstone-320"
137-
)
133+
tester.run_method_and_compare_outputs(qtol=1, inputs=test_data)

0 commit comments

Comments
 (0)