Search Unity

  1. Dismiss Notice
  2. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice

Help Wanted Tensor operations with Barracuda ?

Discussion in 'Barracuda' started by albanmdb, Aug 7, 2020.

  1. albanmdb

    albanmdb

    Joined:
    Jul 10, 2020
    Posts:
    3
    Hello,

    I come from a Python background and am very new to Unity/barracuda/c#. I would like to use a custom model inside Unity with Barracuda. The import goes well but I have to do some post-processing on the output tensors of the model. Is it possible to call some ONNX operators (eg. flatten, concat, max, etc.) after doing the inference with the model? If not, how would I go about implementing vectorized operations to still benefit from the GPU? Or am I forced to use the CPU to do the post-processing ?

    Thanks!
     
  2. amirebrahimi_unity

    amirebrahimi_unity

    Unity Technologies

    Joined:
    Aug 12, 2015
    Posts:
    379
    It is possible to create a model programmatically by adding to Layers:
    https://docs.unity3d.com/Packages/com.unity.barracuda@1.0/api/Unity.Barracuda.Model.html

    However, I think this will be cumbersome and error prone. My suggestion would be to create the other half of your post-processing network in one of the frameworks that supports exporting to ONNX and then import that as a separate network. You can feed the output of one to the input of the other. You are free to specify CPU/GPU when you create your IWorker.
     
unityunity