limbus icon indicating copy to clipboard operation
limbus copied to clipboard

New pipeline save/load features

Open shijianjian opened this issue 1 year ago • 3 comments

An ideal feature but not sure if it is better for app or pipeline. A proper save/load can make the limbus serve as ONNX.

1. Save and Load

Requesting a feature to export/save and import/load a built Pipeline.

Format Candidates:

  • joblib, recommended by scikit-learn. https://scikit-learn.org/stable/model_persistence.html
MyPipeline().save("myapp.someformat")

Then one can load and use with

Load("myapp.someformat").run(1)

2. Input/Output Information

In order to integrate the exported app/pipeline to other applications, it is better to include the input and output information like pipeline.graph.input and pipeline.graph.output.

3. Accepts I/O

Accepting input and output for the built app/pipeline.

4. A flag with if packaging models into the output or not.

We support a very big xxx.pipeline file.

Or a file structure like:

  • XXX.pipeline
    • model_a.onnx
    • model_b.tensorrt

A Proposal

Maybe having Input and Output Component.

For example:

self.c1 = Input("c1", shape=(B,))
self.t1 = Input("t1", shape=(B, 3))
self.t2 = Input("t2", shape=(B, 3))
self.stack = stack("stack")
self.out = Output("o", shape=None)

self.c1 >> self.stack.inputs.dim
self.t1>> self.stack.inputs.tensors.select(0)
self.t2>> self.stack.inputs.tensors.select(1)
self.stack.outputs.out >> self.out

pipeline = Pipeline()
pipeline.add_nodes([c1, t1, t2, stack, show])

pipeline.save("mypipeline.pipeline")

# Adding some ONNX-ish APIs
pipeline.graph.input  # returns [c1, t1, t2] and their shapes
pipeline.graph.output  # returns [o] and its shape

out = pipeline.exec([torch.tensor([0.]), np.array([[1, 2, 3.]]), ...])

shijianjian avatar Apr 12 '23 16:04 shijianjian