Skip to content

Commit 994a990

Browse files
authored
Merge branch 'main' into visualize-tosa-flatbuffer
2 parents 7adf77b + dfd7f2a commit 994a990

File tree

4 files changed

+23
-47
lines changed

4 files changed

+23
-47
lines changed

backends/arm/scripts/mlsdk_utils.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
set -euo pipefail
88

99
mlsdk_manifest_url="https://github.com/arm/ai-ml-sdk-manifest.git"
10-
mlsdk_manifest_tag="dev-snapshot-2025-09-12"
10+
mlsdk_manifest_tag="refs/tags/dev-snapshot-2025-09-12"
1111

1212
script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
1313

backends/nxp/backend/ir/converter/builder/model_builder.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,26 @@ def _make_outputs_channels_first(self):
412412

413413
self.get_sub_graph().outputs.tmp_outputs = new_outputs
414414

415+
def _keep_one_empty_buffer(self):
416+
"""Create a single empty `Buffer` object and assign it to all tensors in the model that don't have static data."""
417+
empty_buffer = self.get_first_empty_buffer()
418+
419+
for t in self.get_tensors().vector:
420+
if tensor_has_data(t):
421+
# The buffer of `t` is not empty.
422+
continue
423+
424+
if t.tmp_buffer == empty_buffer:
425+
# Already optimized.
426+
continue
427+
428+
if t.is_variable:
429+
# The data of the tensor will change at runtime, so it shouldn't share the buffer with other tensors.
430+
continue
431+
432+
# It's safe to replace the buffer.
433+
t.tmp_buffer = empty_buffer
434+
415435
def finish(self) -> tflite_model.Model:
416436
"""Finalize and optimize the converted TFLite model. Then return it.
417437
@@ -430,6 +450,8 @@ def finish(self) -> tflite_model.Model:
430450
self.conversion_config.optimization_blacklist,
431451
)
432452

453+
self._keep_one_empty_buffer()
454+
433455
# Remove outputs, which are not produced by any node. Otherwise, there would be errors after inference.
434456
operator_outputs = []
435457
for op in self.get_operators().vector:

backends/nxp/backend/ir/tflite_optimizer/optimizations/keep_one_empty_buffer.py

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

backends/nxp/backend/ir/tflite_optimizer/optimizer.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
from executorch.backends.nxp.backend.ir.tflite_optimizer.optimizations.fuse_fully_connected_and_add_operators import (
2121
FuseFullyConnectedAndAddOperators,
2222
)
23-
from executorch.backends.nxp.backend.ir.tflite_optimizer.optimizations.keep_one_empty_buffer import (
24-
KeepOneEmptyBuffer,
25-
)
2623
from executorch.backends.nxp.backend.ir.tflite_optimizer.optimizations.move_relu_before_concat import (
2724
MoveActivationBeforeConcatenation,
2825
)
@@ -36,7 +33,6 @@
3633

3734

3835
class Optimization(Enum):
39-
KEEP_ONE_EMPTY_BUFFER = 0
4036
FUSE_ACTIVATION_FUNCTIONS = 1
4137
FUSE_FULLY_CONNECTED_AND_ADD = 2
4238

@@ -76,9 +72,6 @@ def __init__(
7672
self._builder = builder
7773

7874
self.optimization_map = {
79-
Optimization.KEEP_ONE_EMPTY_BUFFER: KeepOneEmptyBuffer(
80-
builder, conversion_config
81-
),
8275
Optimization.FUSE_ACTIVATION_FUNCTIONS: FuseActivationFunctions(
8376
builder, conversion_config
8477
),

0 commit comments

Comments
 (0)