docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Namespace Unity.Barracuda

    Classes

    ArrayTensorData

    Internal Tensor data backed by managed array

    BarracudaArray

    A BarracudaArray exposes a buffer of native memory to managed code.

    BarracudaArrayFromManagedArray

    A BarracudaArrayFromManagedArray exposes a buffer of managed memory as if it was native memory (by pinning it).

    BarracudaTextureUtils

    Deprecated. Use Tensor.ToRenderTexture method instead

    BarracudaWorkerFactory

    Deprecated. Use WorkerFactory class instead

    BurstBLAS

    Burst specific BLAS implementation

    BurstCPUOps

    Burst specific implementation of IOps

    BurstTensorData

    Burst specific internal Tensor data storage

    CompareOps

    Compares output of two different implementations of IOps. Useful for debugging purposes

    CompareOpsUtils

    CompareOps utilities

    ComputeInfo

    GPU compute info

    ComputeOps

    GPU compute implementation of IOps

    ComputeShaderSingleton

    Stores compute kernel cache for GPU compute backends

    ComputeTensorData

    Tensor data storage for GPU backends

    D

    Barracuda debug logging utility

    DeprecatedTensorDataExtensions

    Deprecated ITensorData extensions

    DeprecatedTensorExtensions

    Deprecated APIs, left here only for backwards compatibility

    DeprecatedTestSetExtensions

    Deprecated TestSet extensions

    DeprecatedWorkerExtensions

    Deprecated IWorker extensions

    GenericWorker

    Generic IWorker implementation

    JSONTensor

    JSON tensor

    JSONTensorShape

    JSON tensor shape

    JSONTestSet

    JSON test structure

    Layer

    Barracuda Model Layer

    Model

    Neural Net Model data structure

    Model.ImporterWarning

    Importer warning data structure

    ModelBuilder

    Class responsible for run-time model building from Neural Net primitives.

    ModelExtensions

    Extensions for Model class

    ModelLoader

    Barracuda Model loader

    ModelMetadataExtensions

    Model metadata extensions

    ModelWriter

    Serializes model to binary stream

    NNModel

    Barracuda Model asset

    NNModelData

    Barracuda Model data storage

    NNModelExtensions

    Extensions for NNModel class

    NNModelImporter

    Asset Importer of barracuda models.

    ONNXModelImporter

    Asset Importer for Open Neural Network Exchange (ONNX) files. For more information about ONNX file format see: https://github.com/onnx/onnx

    PixelShaderOps

    PixelShaderSingleton

    Stores compute kernel cache for GPU pixel shader backends

    PrecompiledComputeOps

    Precompiled GPU compute IOps implementation

    RawTestSet

    Raw test structure

    RecurrentState

    Object that represent memory (recurrent state) between the executions of a given model.

    ReferenceCPUOps

    Reference CPU implementation of IOps

    ReferenceComputeOps

    Reference GPU compute IOps implementation

    SharedArrayTensorData

    Internal Tensor data backed by managed array that is shared between multiple tensors

    StatsOps

    Proxy IOps implementation for tracking computational expenses for specific model

    Tensor

    Multidimensional array-like data storage

    TensorExtensions

    Tensor extension methods

    TestSet

    Test set loading utility

    TestSetLoader

    Test set loader

    TextureAsTensorData

    Texture based Tensor storage

    TextureTensorData

    UniqueResourceId

    Base class to track unique resource by an id.

    UnsafeArrayCPUOps

    Unsafe array based IOps implementation

    UnsafeArrayTensorData

    Tensor data storage based on unsafe array

    VerboseOps

    Verbose proxy to other IOps implementation

    WaitForCompletion

    Suspends the coroutine execution until worker has completed execution on a device and contents of the specified tensor are downloaded to the main CPU memory. WaitForCompletion is not necessary and should NOT be used, unless tensor contents are accessed on CPU! WaitForCompletion can only be used with a yield statement in coroutines.

    WorkerExtensions

    IWorker interface extensions

    WorkerFactory

    Factory to create worker that executes specified model on a particular device (GPU, CPU, etc) using particular backend. See IWorker for usage of the worker itself.

    Structs

    Layer.DataSet

    Layer param data structure

    MemoryPeakSummary

    High level model execution peak memory usage information

    Model.Input

    Input data structure

    Model.Memory

    Memory data structure. Used by recurrent models to store information about recurrent inputs/outputs

    TensorIterator

    Helper structure to iterate over tensor shape

    TensorShape

    TensorShape are immutable representation of a Tensor dimensions and rank. Depending on which constructor is used, the TensorShape will either be rank 8 and channels last (ie NHWC) or actual rank with unnamed tensor dimensions when using the constructor that takes int[]. With legacy use (explicit named constructors) of TensorShape an axis can be of size 1. For example, a tensor without spatial information will be N,1,1,C. With the use of TensorShape via the int[] constructor, then axes can have values of 0.

    WorkerFactory.WorkerConfiguration

    Worker configuration compareAgainstType if different than the worker type, the model will be run on both backend and result of every layer will be compared, checking for divergence. Great for debugging, but very slow because of the sync needed. verbose will log scheduling of layers execution to the console (default == false). compareLogLevel define how difference will be reported (default == Warning). compareEpsilon the maximum tolerance before a difference is reported (default == 0.0001f).

    Interfaces

    BLASPlugin

    BLAS plugin interface, allows to supply platform specific implementation of matrix multiplication

    IAllocatorStatistics

    IDependableMemoryResource

    Job system dependency fences for the memory resource

    IDependableTensorData

    Interface for device dependent representation of Tensor data that provides fences for scheduling data job.

    IModelExecutionsReporter

    Interfaces for model execution reporter

    IOps

    Interfaces for backend implementers see ModelBuilder.cs for detail on layers.

    IOpsStatistics

    ITensorAllocator

    Interfaces for tensor allocator

    ITensorData

    Interface for device dependent representation of Tensor data.

    ITensorDataStatistics

    ITensorStatistics

    IUniqueResource

    IVars

    Interfaces for variables

    IVarsStatistics

    IWorker

    The main interface to execute neural networks (a.k.a models). IWorker abstracts implementation details associated with various hardware devices (CPU, GPU and NPU in the future) that can execute neural networks and provides clean and simple interface to:

    1. specify inputs, 2) schedule the work and 3) retrieve outputs. Internally IWorker translates description of the neural network provided by Model instance into the set of operations that are sent to hardware device for execution in a non-blocking (asynchronous) manner.

    The following is a simple example of image classification using pretrained neural network:

    using UnityEngine; using Unity.Barracuda; public class ImageRecognitionSample : MonoBehaviour { // small ready to use image classification neural network in ONNX format can be obtained from https://github.com/onnx/models/tree/master/vision/classification/mobilenet public NNModel onnxAsset; public Texture2D imageToRecognise; private IWorker worker; void Start() { worker = onnxAsset.CreateWorker(); } void Update() { // convert texture into Tensor of shape [1, imageToRecognise.height, imageToRecognise.width, 3] using (var input = new Tensor(imageToRecognise, channels:3)) { // execute neural network with specific input and get results back var output = worker.Execute(input).PeekOutput(); // the following line will access values of the output tensor causing the main thread to block until neural network execution is done var indexWithHighestProbability = output.ArgMax()[0]; UnityEngine.Debug.Log($"Image was recognised as class number: {indexWithHighestProbability}"); } } void OnDisable() { worker.Dispose(); } }

    The following example demonstrates the use of coroutine to continue smooth app execution while neural network executes in the background:

    using UnityEngine; using Unity.Barracuda; using System.Collections; public class CoroutineImageRecognitionSample : MonoBehaviour { // small ready to use image classification neural network in ONNX format can be obtained from https://github.com/onnx/models/tree/master/vision/classification/mobilenet public NNModel onnxAsset; public Texture2D imageToRecognise; private IWorker worker; void Start() { worker = onnxAsset.CreateWorker(); StartCoroutine(ImageRecognitionCoroutine()); } IEnumerator ImageRecognitionCoroutine() { while (true) { // convert texture into Tensor of shape [1, imageToRecognise.height, imageToRecognise.width, 3] using (var input = new Tensor(imageToRecognise, channels:3)) { // execute neural network with specific input and get results back var output = worker.Execute(input).PeekOutput(); // allow main thread to run until neural network execution has finished yield return new WaitForCompletion(output); var indexWithHighestProbability = output.ArgMax()[0]; UnityEngine.Debug.Log($"Image was recognised as class number: {indexWithHighestProbability}"); } // wait until a new image is provided var previousImage = imageToRecognise; while (imageToRecognise == previousImage) yield return null; } } void OnDisable() { worker.Dispose(); } }

    Use WorkerFactory.CreateWorker or Model.CreateWorker to create new worker instance.

    Enums

    AllocScope

    Enum to describe life time of a given allocation

    BarracudaWorkerFactory.Flags

    Device type enum

    BurstCPUOps.BLAS

    CompareOpsUtils.LogLevel

    CompareOps log level enum

    ComputeInfo.ChannelsOrder

    Channel order enum

    DataType

    Layer.Activation

    Activation enum

    Layer.AutoPad

    Auto padding enum

    Layer.DepthToSpaceMode

    Depth to space mode enum

    Layer.Flags

    Layer preservation flags

    Layer.FusedActivation

    Fused activations enum

    Layer.PadMode

    Layer.ScatterNDReductionMode

    ScatterND reduction mode

    Layer.Type

    Layer Type

    TextureAsTensorData.Flip

    Flip flag enum

    TextureAsTensorData.InterpretColorAs

    Interpret color enum

    TextureAsTensorData.InterpretDepthAs

    Interpret depth as enum

    WorkerFactory.Device

    Supported device type

    WorkerFactory.Type

    Backend type


    Did you find this page useful? Please give it a rating:

    Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • Classes
    • Structs
    • Interfaces
    • Enums
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)