Skip to content

How to let executorch export intput output int8 #16244

@kris-himax

Description

@kris-himax

Hi,

I use https://github.com/pytorch/executorch/blob/main/examples/arm/ethos_u_minimal_example.ipynb to export example model and run on FVP.
The output is 2.0(float).

But I modify the code and that it output and intput to be int8. But the output at FVP show 1(char).
I think that it is wrong. How can I fix it?

Image

from executorch.backends.arm.ethosu import EthosUPartitioner
from executorch.exir import (
    EdgeCompileConfig,
    ExecutorchBackendConfig,
    to_edge_transform_and_lower,
)
from executorch.extension.export_util.utils import save_pte_program
from executorch.exir.passes.quantize_io_pass import QuantizeInputs, QuantizeOutputs



# Create partitioner from compile spec
partitioner = EthosUPartitioner(compile_spec)

# Lower the exported program to the Ethos-U backend
edge_program_manager = to_edge_transform_and_lower(
            quantized_exported_program,
            partitioner=[partitioner],
            compile_config=EdgeCompileConfig(
                _check_ir_validity=False,
            ),
        )
edge_program_manager.transform(passes=[QuantizeInputs(edge_program_manager, [0, 1]), QuantizeOutputs(edge_program_manager, [0])])
# Convert edge program to executorch
executorch_program_manager = edge_program_manager.to_executorch(
            config=ExecutorchBackendConfig(extract_delegate_segments=False)
        )

_ = executorch_program_manager.exported_program().graph_module.print_readable()

# Save pte file
save_pte_program(executorch_program_manager, "ethos_u_minimal_example_test_inout_int8.pte")

By the way, according to #7590
How can the embedded application access the quantisation scale & zero point finally?

Thanks,
Kris

cc @freddan80 @per @zingo @oscarandersson8218 @digantdesai

Metadata

Metadata

Assignees

Labels

partner: armFor backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions