pytorch / pytorch/executorch

I am trying to use export custom model to a executorch

Open
#7,428 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

module: exir triaged
Dominant language
Python
Stars
5k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
581

Description

Hi I am trying to export a customer model to executorch, I was able to convert the model to a graph representation using the following code

import torch
from torch.export import export, ExportedProgram
from executorch.exir import EdgeProgramManager, to_edge

variant='edgeface_xxs_q'
model = torch.hub.load('otroshi/edgeface', variant, source='github', pretrained=True)
model.eval()

example_args = (torch.randn(1, 3, 112, 112),)
aten_dialect: ExportedProgram = export(model, example_args)
print(aten_dialect)

But getting an error while lowering to the Edge Dialect

edge_program: EdgeProgramManager = to_edge(aten_dialect)
print("Edge Dialect Graph")
print(edge_program.exported_program())

Error:

Traceback (most recent call last):
  File "/my-disk/bob.paper.tbiom2023_edgeface/test.py", line 51, in <module>
    edge_program: EdgeProgramManager = to_edge(aten_dialect)
  File "/home/dinusha/anaconda3/envs/executorch/lib/python3.10/site-packages/executorch/exir/program/_program.py", line 1142, in to_edge
    program = program.run_decompositions(_default_decomposition_table())
  File "/home/dinusha/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/exported_program.py", line 114, in wrapper
    return fn(*args, **kwargs)
  File "/home/dinusha/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/exported_program.py", line 1003, in run_decompositions
    return _decompose_exported_program(
  File "/home/dinusha/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/exported_program.py", line 617, in _decompose_exported_program
    gm, new_graph_signature = _decompose_and_get_gm_with_new_signature_constants(
  File "/home/dinusha/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/export/exported_program.py", line 410, in _decompose_and_get_gm_with_new_signature_constants
    gm, graph_signature = aot_export_module(
  File "/home/dinusha/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/_functorch/aot_autograd.py", line 1246, in aot_export_module
    fx_g, metadata, in_spec, out_spec = _aot_export_function(
  File "/home/dinusha/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/_functorch/aot_autograd.py", line 1480, in _aot_export_function
    fx_g, meta = create_aot_dispatcher_function(
  File "/home/dinusha/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/_functorch/aot_autograd.py", line 522, in create_aot_dispatcher_function
    return _create_aot_dispatcher_function(
  File "/home/dinusha/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/_functorch/aot_autograd.py", line 623, in _create_aot_dispatcher_function
    fw_metadata = run_functionalized_fw_and_collect_metadata(
  File "/home/dinusha/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/collect_metadata_analysis.py", line 150, in inner
    assert all(isinstance(a, tuple(KNOWN_TYPES)) for a in flat_args)
AssertionError

any help on this would be highly appreciated

Thank you

cc @JacobSzwejbka @angelayi

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided test.py reproduction at the to_edge call on line 51, then trace torch.export.ExportedProgram.run_decompositions through executorch.exir.to_edge to the shown assertion. Reproduce the failure with the edgeface_xxs_q model and determine whether the model can be lowered; done means documenting a validated resolution or compatibility limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
embedded-iot, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.