nebuly icon indicating copy to clipboard operation
nebuly copied to clipboard

APIs for non-Python programming languages

Open emanef13 opened this issue 3 years ago • 9 comments

Is there a c++ api of the library?

emanef13 avatar Feb 22 '22 16:02 emanef13

We currently only support DL Python frameworks (Tensorflow and Pytorch).

We are considering extending the library to other programming languages such as Julia, Swift, and C++, however it will take some time to realize nebullvm's full vision for a programming language & hardware agnostic inference accelerator.

I have renamed this issue to "APIs for non-Python programming languages" in order to allow other community members to specify their preferences on APIs. That way, we will have a way to prioritize the development of programming languages.

diegofiori avatar Feb 23 '22 12:02 diegofiori

My target environment is C++ and I dont think optimizing model in C++ would have any value in my development cycle. Portability matters. Normally I am exporting ONNX if I can and torchscript otherwise.

isgursoy avatar Nov 22 '22 09:11 isgursoy

I'm have the same issue than isgursoy. Is it possible to export the optimised network to Onnx?

bzisl avatar Feb 22 '23 16:02 bzisl

Basically the idea is to be able to import the optimised model into C++ (onnxruntime)

bzisl avatar Feb 22 '23 16:02 bzisl

Hi @bzisl, the optimised models are compiled and cannot be converted back to onnx, however it is possible to exclude all compilers except onnxruntime during the optimization(using the ignore_compilers parameter), so that you have an optimised model that is in fact an onnx. Keep in mind that in this way Speedster will only use onnxruntime and possibly quantization to speed up your model, so the results may not be as good as using all the compilers. After optimizing the model, you just have to save the optimized_model using the save_model() function, and you will get an onnx model.

valeriosofi avatar Feb 22 '23 17:02 valeriosofi

Thanks!

bzisl avatar Feb 22 '23 17:02 bzisl

One question more, please. optimized_model = speedster.optimize_model(onnx_path, input_data=input_data, optimization_time="unconstrained")

How we force optimisation for CPU?

Best regards!!!!

bzisl avatar Feb 22 '23 17:02 bzisl

You can use:

optimized_model = speedster.optimize_model(
    onnx_path, 
    input_data=input_data, 
    optimization_time="unconstrained", 
    device="cpu"
)

I can see that you are optimizing an onnx model, I would suggest that you enable quantization by setting metric_drop_ths=0.1 in the function.

valeriosofi avatar Feb 22 '23 17:02 valeriosofi

Thanks a lot!

bzisl avatar Feb 22 '23 17:02 bzisl