docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class NNModelExtensions

    Extensions for NNModel class

    Inheritance
    object
    NNModelExtensions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.Barracuda
    Assembly: Unity.Barracuda.dll
    Syntax
    public static class NNModelExtensions

    Methods

    CreateWorker(NNModel, string[], string[], Device, bool)

    Create a worker that will execute asset using the best backend that is available for a given device type. This is just a convenience function that internally calls ModelLoader.Load followed by ``WorkerFactory.CreateWorker`.

    Declaration
    public static IWorker CreateWorker(this NNModel asset, string[] additionalOutputs, string[] trimOutputs, WorkerFactory.Device device = Device.Auto, bool verbose = false)
    Parameters
    Type Name Description
    NNModel asset

    the associated NNModel asset

    string[] additionalOutputs

    the additional outputs to track but not directly specified by the model

    string[] trimOutputs

    by specifying this list of outputs, all other non-specified outputs will be discarded

    WorkerFactory.Device device

    the device type to run worker on. For example WorkerFactory.Device.GPU specifies the fast GPU path

    bool verbose

    will log scheduling of layers execution to the console (default == false)

    Returns
    Type Description
    IWorker

    Worker instance

    CreateWorker(NNModel, Device, bool)

    Create a worker that will execute asset using the best backend that is available for a given device type. This is just a convenience function that internally calls ModelLoader.Load followed by ``WorkerFactory.CreateWorker`.

    Declaration
    public static IWorker CreateWorker(this NNModel asset, WorkerFactory.Device device = Device.Auto, bool verbose = false)
    Parameters
    Type Name Description
    NNModel asset

    the associated NNModel asset

    WorkerFactory.Device device

    the preferred device for execution. For example WorkerFactory.Device.GPU specifies the fast GPU path

    bool verbose

    will log scheduling of layers execution to the console

    Returns
    Type Description
    IWorker

    Worker instance

    In This Article
    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)