Class WorkerFactory | Barracuda | 1.0.4
docs.unity3d.com
    Show / Hide Table of Contents

    Class 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.

    Inheritance
    Object
    WorkerFactory
    BarracudaWorkerFactory
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.Barracuda
    Syntax
    public class WorkerFactory

    Methods

    CreateComputeWorker(Model, Boolean)

    Create a worker using the precompiled GPU backend for the given model. model is the associated model. See ModelLoader.cs. verbose will log scheduling of layers execution to the console (default == false).

    Declaration
    public static IWorker CreateComputeWorker(Model model, bool verbose = false)
    Parameters
    Type Name Description
    Model model
    Boolean verbose
    Returns
    Type Description
    IWorker

    CreateReferenceComputeWorker(Model, Boolean)

    Create a worker using the reference GPU backend for the given model. model is the associated model. See ModelLoader.cs. verbose will log scheduling of layers execution to the console (default == false).

    Declaration
    public static IWorker CreateReferenceComputeWorker(Model model, bool verbose = false)
    Parameters
    Type Name Description
    Model model
    Boolean verbose
    Returns
    Type Description
    IWorker

    CreateReferenceCPUWorker(Model, Boolean)

    Create a worker using the reference CPU backend for the given model. model is the associated model. See ModelLoader.cs. verbose will log scheduling of layers execution to the console (default == false).

    Declaration
    public static IWorker CreateReferenceCPUWorker(Model model, bool verbose = false)
    Parameters
    Type Name Description
    Model model
    Boolean verbose
    Returns
    Type Description
    IWorker

    CreateWorker(Model, Boolean)

    Create a worker that will execute model using the best backend that is available for a given device type. model is the associated model. See ModelLoader.cs. verbose will log scheduling of layers execution to the console.

    Declaration
    public static IWorker CreateWorker(Model model, bool verbose = false)
    Parameters
    Type Name Description
    Model model
    Boolean verbose
    Returns
    Type Description
    IWorker

    CreateWorker(Model, String[], String[], WorkerFactory.Device, Boolean)

    Create a worker that will execute model using the best backend that is available for a given device type. model is the associated model. See ModelLoader.cs. additionalOutputs are the additional outputs to track but not directly specified by the model. trimOutputs are the outputs not discard even if they are specified by the model. device is the device type to run worker on. For example WorkerFactory.Device.GPU specifies the fast GPU path. verbose will log scheduling of layers execution to the console (default == false).

    Declaration
    public static IWorker CreateWorker(Model model, string[] additionalOutputs, string[] trimOutputs, WorkerFactory.Device device = WorkerFactory.Device.Auto, bool verbose = false)
    Parameters
    Type Name Description
    Model model
    String[] additionalOutputs
    String[] trimOutputs
    WorkerFactory.Device device
    Boolean verbose
    Returns
    Type Description
    IWorker

    CreateWorker(Model, String[], WorkerFactory.Device, Boolean)

    Create a worker that will execute model using the best backend that is available for a given device type. model is the associated model. See ModelLoader.cs. additionalOutputs are the additional outputs to track but not directly specified by the model. device is the device type to run worker on. For example WorkerFactory.Device.GPU specifies the fast GPU path. verbose will log scheduling of layers execution to the console (default == false).

    Declaration
    public static IWorker CreateWorker(Model model, string[] additionalOutputs, WorkerFactory.Device device = WorkerFactory.Device.Auto, bool verbose = false)
    Parameters
    Type Name Description
    Model model
    String[] additionalOutputs
    WorkerFactory.Device device
    Boolean verbose
    Returns
    Type Description
    IWorker

    CreateWorker(Model, WorkerFactory.Device, Boolean)

    Create a worker that will execute model using the best backend that is available for a given device type. model is the associated model. See ModelLoader.cs. device is the preferred device for execution. For example WorkerFactory.Device.GPU specifies the fast GPU path. verbose will log scheduling of layers execution to the console.

    Declaration
    public static IWorker CreateWorker(Model model, WorkerFactory.Device device, bool verbose = false)
    Parameters
    Type Name Description
    Model model
    WorkerFactory.Device device
    Boolean verbose
    Returns
    Type Description
    IWorker

    CreateWorker(WorkerFactory.Type, Model, Boolean)

    Create a worker with explicitly specified backend type to execute the given model. type is backend type to use. For example WorkerFactory.Type.Compute specifies the fast GPU path. model is the associated model. See ModelLoader.cs. verbose will log scheduling of layers execution to the console.

    Declaration
    public static IWorker CreateWorker(WorkerFactory.Type type, Model model, bool verbose)
    Parameters
    Type Name Description
    WorkerFactory.Type type
    Model model
    Boolean verbose
    Returns
    Type Description
    IWorker

    CreateWorker(WorkerFactory.Type, Model, Boolean, WorkerFactory.Type, CompareOpsUtils.LogLevel)

    Create a worker with explicitly specified backend type to execute the given model. type is backend type to use. For example WorkerFactory.Type.Compute specifies the fast GPU path. model is the associated model. See ModelLoader.cs. verbose will log scheduling of layers execution to the console. compareAgainstType if different than type model will be run on those two backend and result of every layer will be compared, checking for divergence. Great for debugging, but very slow because of the sync needed. differenceAsError if compareAgainstType is used difference will be reported as error is this is true or warning otherwise.

    Declaration
    public static IWorker CreateWorker(WorkerFactory.Type type, Model model, bool verbose, WorkerFactory.Type compareAgainstType, CompareOpsUtils.LogLevel differenceLogLevel = CompareOpsUtils.LogLevel.Warning)
    Parameters
    Type Name Description
    WorkerFactory.Type type
    Model model
    Boolean verbose
    WorkerFactory.Type compareAgainstType
    CompareOpsUtils.LogLevel differenceLogLevel
    Returns
    Type Description
    IWorker

    CreateWorker(WorkerFactory.Type, Model, String[], Boolean)

    Create a worker with explicitly specified backend type to execute the given model. type is backend type to use. For example WorkerFactory.Type.Compute specifies the fast GPU path. model is the associated model. See ModelLoader.cs. additionalOutputs are the additional outputs to track but not directly specified by the model. verbose will log scheduling of layers execution to the console (default == false).

    Declaration
    public static IWorker CreateWorker(WorkerFactory.Type type, Model model, string[] additionalOutputs, bool verbose = false)
    Parameters
    Type Name Description
    WorkerFactory.Type type
    Model model
    String[] additionalOutputs
    Boolean verbose
    Returns
    Type Description
    IWorker

    CreateWorker(WorkerFactory.Type, Model, String[], String[], Boolean)

    Create a worker with explicitly specified backend type to execute the given model. type is backend type to use. For example WorkerFactory.Type.Compute specifies the fast GPU path. model is the associated model. See ModelLoader.cs. additionalOutputs are the additional outputs to track but not directly specified by the model. trimOutputs are the outputs not discard even if they are specified by the model. verbose will log scheduling of layers execution to the console (default == false).

    Declaration
    public static IWorker CreateWorker(WorkerFactory.Type type, Model model, string[] additionalOutputs = null, string[] trimOutputs = null, bool verbose = false)
    Parameters
    Type Name Description
    WorkerFactory.Type type
    Model model
    String[] additionalOutputs
    String[] trimOutputs
    Boolean verbose
    Returns
    Type Description
    IWorker

    CreateWorker(WorkerFactory.Type, Model, String[], String[], Boolean, WorkerFactory.Type, CompareOpsUtils.LogLevel)

    Create a worker with explicitly specified backend type to execute the given model. type is backend type to use. For example WorkerFactory.Type.Compute specifies the fast GPU path. model is the associated model. See ModelLoader.cs. additionalOutputs are the additional outputs to track but not directly specified by the model. trimOutputs are the outputs not discard even if they are specified by the model. verbose will log scheduling of layers execution to the console. compareAgainstType if different than type model will be run on those two backend and result of every layer will be compared, checking for divergence. Great for debugging, but very slow because of the sync needed. differenceAsError if compareAgainstType is used difference will be reported as error is this is true or warning otherwise.

    Declaration
    public static IWorker CreateWorker(WorkerFactory.Type type, Model model, string[] additionalOutputs, string[] trimOutputs, bool verbose, WorkerFactory.Type compareAgainstType, CompareOpsUtils.LogLevel differenceLogLevel = CompareOpsUtils.LogLevel.Warning)
    Parameters
    Type Name Description
    WorkerFactory.Type type
    Model model
    String[] additionalOutputs
    String[] trimOutputs
    Boolean verbose
    WorkerFactory.Type compareAgainstType
    CompareOpsUtils.LogLevel differenceLogLevel
    Returns
    Type Description
    IWorker

    CreateWorker(WorkerFactory.Type, Model, String[], String[], WorkerFactory.WorkerConfiguration)

    Create a worker with explicitly specified backend type to execute the given model. type is backend type to use. For example WorkerFactory.Type.Compute specifies the fast GPU path. model is the associated model. See ModelLoader.cs. additionalOutputs are the additional outputs to track but not directly specified by the model. trimOutputs are the outputs not discard even if they are specified by the model. workerConfiguration define configurations such as logging and comparison backend, see WorkerConfiguration API docs.

    Declaration
    public static IWorker CreateWorker(WorkerFactory.Type type, Model model, string[] additionalOutputs, string[] trimOutputs, WorkerFactory.WorkerConfiguration workerConfiguration)
    Parameters
    Type Name Description
    WorkerFactory.Type type
    Model model
    String[] additionalOutputs
    String[] trimOutputs
    WorkerFactory.WorkerConfiguration workerConfiguration
    Returns
    Type Description
    IWorker

    CreateWorker(WorkerFactory.Type, Model, WorkerFactory.WorkerConfiguration)

    Create a worker with explicitly specified backend type to execute the given model. type is backend type to use. For example WorkerFactory.Type.Compute specifies the fast GPU path. model is the associated model. See ModelLoader.cs. workerConfiguration define configurations such as logging and comparison backend, see WorkerConfiguration API docs.

    Declaration
    public static IWorker CreateWorker(WorkerFactory.Type type, Model model, WorkerFactory.WorkerConfiguration workerConfiguration)
    Parameters
    Type Name Description
    WorkerFactory.Type type
    Model model
    WorkerFactory.WorkerConfiguration workerConfiguration
    Returns
    Type Description
    IWorker

    GetBestTypeForDevice(WorkerFactory.Device)

    Returns the best backend type that can run on a device given the model.

    Declaration
    public static WorkerFactory.Type GetBestTypeForDevice(WorkerFactory.Device device)
    Parameters
    Type Name Description
    WorkerFactory.Device device
    Returns
    Type Description
    WorkerFactory.Type

    IsType(WorkerFactory.Type, WorkerFactory.Device)

    Check if a backend is of a given type. For example: IsType(Type.CSharpRef, Device.GPU) == true

    Declaration
    public static bool IsType(WorkerFactory.Type type, WorkerFactory.Device device)
    Parameters
    Type Name Description
    WorkerFactory.Type type
    WorkerFactory.Device device
    Returns
    Type Description
    Boolean

    ValidateType(WorkerFactory.Type)

    Validate if a backend of type is supported, otherwise return a fallback type.

    Declaration
    public static WorkerFactory.Type ValidateType(WorkerFactory.Type type)
    Parameters
    Type Name Description
    WorkerFactory.Type type
    Returns
    Type Description
    WorkerFactory.Type
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023