docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class GenericWorker

    Generic IWorker implementation

    Inheritance
    object
    GenericWorker
    Implements
    IWorker
    IDisposable
    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 class GenericWorker : IWorker, IDisposable

    Constructors

    GenericWorker(Model, IOps, IVars, bool)

    Create GenericWorker for specified model and ops

    Declaration
    public GenericWorker(Model model, IOps ops, IVars vars, bool verbose = false)
    Parameters
    Type Name Description
    Model model

    Model

    IOps ops

    IOps

    IVars vars

    IVars

    bool verbose

    verbose execution flag

    Properties

    scheduleProgress

    Reports the fraction (from 0.0 to 1.0) of the model that was scheduled for the execution since the last call to StartManualSchedule. This property will return 0.0 immediately after calling StartManualSchedule and will return 1.0 once the complete model was scheduled. This property will monotonuosly increase with the every iteration of IEnumerator that was obtained by calling StartManualSchedule.

    Declaration
    public virtual float scheduleProgress { get; }
    Property Value
    Type Description
    float

    Methods

    Dispose()

    Dispose all internal storage structures

    Declaration
    public virtual void Dispose()

    Execute()

    Non-blocking API that schedules network execution in one go.

    Declaration
    public virtual IWorker Execute()
    Returns
    Type Description
    IWorker

    IWorker instance

    Execute(IDictionary<string, Tensor>)

    Non-blocking API that takes multiple input tensors and schedules network execution in one go.

    Declaration
    public virtual IWorker Execute(IDictionary<string, Tensor> inputs)
    Parameters
    Type Name Description
    IDictionary<string, Tensor> inputs

    input Tensor Dictionary: name -> Tensor

    Returns
    Type Description
    IWorker

    IWorker instance

    Execute(Tensor)

    Non-blocking API that takes single input tensor and schedules network execution in one go. Useful when network have only one input as input name is not needed.

    Declaration
    public virtual IWorker Execute(Tensor input)
    Parameters
    Type Name Description
    Tensor input

    input Tensor

    Returns
    Type Description
    IWorker

    IWorker instance

    ~GenericWorker()

    Finalizer

    Declaration
    protected ~GenericWorker()

    FlushSchedule(bool)

    Non-blocking API that starts immediate execution on the part of the network that was scheduled so far. Optional blocking flag can force this function to block until execution is complete.

    Declaration
    public virtual void FlushSchedule(bool blocking)
    Parameters
    Type Name Description
    bool blocking

    if blocking True, wait for completion

    PeekConstants(string)

    Returns references to constants tensors for a layer. This reference might be valid only until the next Execute() or Dispose() method is called on the worker. IMPORTANT: if you want tensor to outlive the worker, use CopyOutput() method or follow with TakeOwnership() call on the tensor, also worker Execute() or PrepareForInput() should have been called at least once for the tensors to exist.

    Declaration
    public virtual Tensor[] PeekConstants(string layerName)
    Parameters
    Type Name Description
    string layerName

    Layer name

    Returns
    Type Description
    Tensor[]

    array of constant Tensors

    PeekOutput()

    Non-blocking API that returns a reference to the main output tensor. This reference will be valid only until the next Execute() or Dispose() method is called on the worker. Useful when network has only one output. IMPORTANT: if you want tensor to outlive the worker, use CopyOutput() method or follow with TakeOwnership() call on the tensor.

    Declaration
    public virtual Tensor PeekOutput()
    Returns
    Type Description
    Tensor

    output Tensor

    PeekOutput(string)

    Non-blocking API that returns a reference to output tensor by specified name. This reference will be valid only until the next Execute() or Dispose() method is called on the worker. IMPORTANT: if you want tensor to outlive the worker, use CopyOutput() method or follow with TakeOwnership() call on the tensor.

    Declaration
    public virtual Tensor PeekOutput(string name)
    Parameters
    Type Name Description
    string name

    output name

    Returns
    Type Description
    Tensor

    output Tensor

    PrepareForInput(IDictionary<string, TensorShape>)

    Optional API to prepare network execution for inputs of particular shapes. Useful to initialize execution device ahead of the first call to Execute.

    Declaration
    public virtual void PrepareForInput(IDictionary<string, TensorShape> inputShapes)
    Parameters
    Type Name Description
    IDictionary<string, TensorShape> inputShapes

    Dictionary of tensor name -> input shapes

    SetInput(string, Tensor)

    Assign tensor x to the named input of the network. String name specifies the name of the input.

    Declaration
    public virtual void SetInput(string name, Tensor x)
    Parameters
    Type Name Description
    string name

    Tensor name

    Tensor x

    Tensor

    SetInput(Tensor)

    Specify single tensor x as the only input for the network. Useful when network has only one input and caller does not need to specify input's name.

    Declaration
    public virtual void SetInput(Tensor x)
    Parameters
    Type Name Description
    Tensor x

    input Tensor

    StartManualSchedule()

    Non-blocking API that allows manual scheduling of the model one layer at the time. Call MoveNext on the IEnumerator obtained from calling this function to schedule next layer of the model.

    Declaration
    public virtual IEnumerator StartManualSchedule()
    Returns
    Type Description
    IEnumerator

    Manual schedule iterator

    StartManualSchedule(IDictionary<string, Tensor>)

    Non-blocking API that takes mutliple input tensors and schedules network execution one layer at the time. Call MoveNext on the IEnumerator obtained from calling this function to schedule next layer of the model.

    Declaration
    public virtual IEnumerator StartManualSchedule(IDictionary<string, Tensor> inputs)
    Parameters
    Type Name Description
    IDictionary<string, Tensor> inputs

    input Tensor Dictionary: name -> Tensor

    Returns
    Type Description
    IEnumerator

    Manual schedule iterator

    StartManualSchedule(Tensor)

    Non-blocking API that takes single input tensor and schedules network execution one layer at the time. Call MoveNext on the IEnumerator obtained from calling this function to schedule next layer of the model.

    Declaration
    public virtual IEnumerator StartManualSchedule(Tensor input)
    Parameters
    Type Name Description
    Tensor input

    input Tensor

    Returns
    Type Description
    IEnumerator

    Manual schedule iterator

    Summary()

    Execution summary

    Declaration
    public virtual string Summary()
    Returns
    Type Description
    string

    execution summary

    Implements

    IWorker
    IDisposable

    Extension Methods

    DeprecatedWorkerExtensions.AddInput(IWorker, string, Tensor)
    DeprecatedWorkerExtensions.AddInput(IWorker, Tensor)
    DeprecatedWorkerExtensions.ExecuteAndWaitForCompletion(IWorker, IDictionary<string, Tensor>)
    DeprecatedWorkerExtensions.ExecuteAndWaitForCompletion(IWorker, Tensor)
    DeprecatedWorkerExtensions.ExecuteAsync(IWorker)
    DeprecatedWorkerExtensions.ExecuteAsync(IWorker, IDictionary<string, Tensor>)
    DeprecatedWorkerExtensions.ExecuteAsync(IWorker, Tensor)
    DeprecatedWorkerExtensions.Fetch(IWorker)
    DeprecatedWorkerExtensions.Fetch(IWorker, string)
    DeprecatedWorkerExtensions.FetchAndTakeOwnership(IWorker)
    DeprecatedWorkerExtensions.FetchAndTakeOwnership(IWorker, string)
    DeprecatedWorkerExtensions.GetAsyncProgress(IWorker)
    DeprecatedWorkerExtensions.Peek(IWorker)
    DeprecatedWorkerExtensions.Peek(IWorker, string)
    DeprecatedWorkerExtensions.WaitForCompletion(IWorker)
    WorkerExtensions.CopyOutput(IWorker)
    WorkerExtensions.CopyOutput(IWorker, string)
    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)