IMPORTANT! This feature is only available for the Python based frameworks.

Since SOL v0.4.2 you can cross execute SOL models. For this just use sol.optimize(..., framework='?'). I.e. you can load an ONNX Model and run it within PyTorch using:

import sol

# Run Model with Numpy (def func(...))
import numpy as np
np_model  = sol.optimize('mymodel.onnx', framework='numpy')
np_input  = np.random.rand(1, 3, 224, 224).astype(np.float32)
np_output = np_model(np_input)

# Run Model with PyTorch (torch.nn.Module)
import torch 
py_model = sol.optimize('mymodel.onnx', framework='pytorch')
py_input = torch.from_numpy(np_input)
with torch.no_grad():
	py_output = py_model(py_input)

# Run Model with TensorFlow (tf.Module)
import tensorflow as tf
tf_model = sol.optimize('mymodel.onnx', framework='tensorflow')
tf_output = tf_model(np_input)

# Run Model with Keras (tf.keras.model.Model)
import tensorflow as tf
keras_model = sol.optimize('mymodel.onnx', framework='keras')
keras_output = keras_model.predict(np_input)

There is one special case. As we use lazy initialization for PyTorch models, these need to be compiled with example inputs before they have the correct type.

pytorch_model = ...
keras_model = sol.optimize(pytorch_model, framework='keras')
# at this point it's not yet a Keras model
keras_output = keras_model.predict(np_input)