Giter VIP home page Giter VIP logo

Comments (3)

justinchuby avatar justinchuby commented on June 27, 2024 1

I will create a patch today

from onnxscript.

borisfom avatar borisfom commented on June 27, 2024

This is a repro, just in case. You have to install NVIDIA NeMo toolkit first :
pip install --extra-index-url https://pypi.ngc.nvidia.com/ nemo_toolkit[all]

import torch
from nemo.core.classes import typecheck
from nemo.utils.export_utils import wrap_forward_method
from nemo.collections.asr.models import EncDecCTCModelBPE
import onnxscript

model = EncDecCTCModelBPE.from_pretrained(model_name="stt_en_conformer_ctc_small")

model = model.eval()
wrap_forward_method(model)
model._prepare_for_export()

typecheck.set_typecheck_enabled(enabled=False)

with torch.no_grad():
    input_example = model.input_module.input_example(max_batch=4, max_dim=256)
    # This has to have min=2                                                                                                              
    batch = torch.export.Dim("batch", min=2, max=64)
    dynamic_shapes={'audio_signal': { 0: batch,
                                      # 2: torch.export.Dim("audio_signal__2")                                                            
                              },
                    'length': {0: batch}
                    }

    ex_model = torch.export.export(
        model, tuple(input_example),
        dynamic_shapes=dynamic_shapes,
        strict=False
    )

    ex_model = ex_model.run_decompositions()
    ex_module=ex_model.module()

    print("Running torch.onnx.dynamo_export ...")
    options = torch.onnx.ExportOptions(dynamic_shapes=True)
    ex = torch.onnx.dynamo_export(ex_module, *input_example, export_options=options)
    ex.save("ctc.onnx")

from onnxscript.

justinchuby avatar justinchuby commented on June 27, 2024

Thank you!

from onnxscript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.