Skip to content

Model quantization test exception when using LiteRT for MTK mobile phone deployment #825

@Bradywuli

Description

@Bradywuli

For specific quantitative issue content, please refer to the following link

google-ai-edge/litert-samples#53 (comment)
In addition, I also referred to Quantization in docs/pytorch_converter/README.md
content,

from torch.ao.quantization.quantize_pt2e import prepare_pt2e, convert_pt2e
from torch._export import capture_pre_autograd_graph

from ai_edge_torch.quantize.pt2e_quantizer import get_symmetric_quantization_config
from ai_edge_torch.quantize.pt2e_quantizer import PT2EQantizer
from ai_edge_torch.quantize.quant_config import QuantConfig

pt2e_quantizer = PT2EQantizer().set_global( 
get_symmetric_quantization_config(is_per_channel=True, is_dynamic=True)
)

pt2e_torch_model = capture_pre_autograd_graph(torch_model, sample_args)
pt2e_torch_model = prepare_pt2e(pt2e_torch_model, pt2e_quantizer)

# Run the prepared model with sample input data to ensure that internal observers are populated with correct values
pt2e_torch_model(*sample_args)

# Convert the prepared model to a quantized model
pt2e_torch_model = convert_pt2e(pt2e_torch_model, fold_quantize=False)

# Convert to an ai_edge_torch model
pt2e_drq_model = ai_edge_torch.convert(pt2e_torch_model, sample_args, quant_config=QuantConfig(pt2e_quantizer=pt2e_quantizer))

Found from torch.ao.quantization.quantize_pt2e import prepare_pt2e, convert_pt2e
prepare_pt2e in from torch._export import capture_pre_autograd_graph, convert_pt2e has been removed, and capture_pre_autograd_graph does not find this library

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions