apple / coremltools

Core ML tools contain supporting tools for Core ML model conversion, editing, and validation.
https://coremltools.readme.io
BSD 3-Clause "New" or "Revised" License
4.29k stars 623 forks source link

Interfacing converted models with MIL Builder #1785

Open gsigms opened 1 year ago

gsigms commented 1 year ago

❓Question

Is it possible to interface models converted to mlprogram with the mil builder? This would help with creating program with control flow without the hurdle of mixing scripted/traced torchscript models

TobyRoseman commented 1 year ago

You can get the MIL code for a Core ML model (wether converted to mlprogram or neuralnetwork) by calling ._get_mil_internal() on your MLModel.

Looks like there is no way to initialize a MIL Builder using MIL code. That functionality shouldn't be too hard to add.

I'll keep this issue open as a feature request.

@gsigms - can you tell us a little more about your use case?

gsigms commented 1 year ago

In the use case I am working on, I have alternative torch models and post processing code, that are traced/converted. I would like to write, say a beam search using a MIL Builder approach and compose its loop body using converted models.

The alternative approach I was contemplating is to write that beam search and export it via torch.jit.script with a traced model inside.