docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class GenericWorker

    Represents a generic implementation of an IWorker.

    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.Sentis
    Assembly: Unity.Sentis.dll
    Syntax
    public class GenericWorker : IWorker, IDisposable

    Constructors

    GenericWorker(Model, IBackend, IModelStorage, bool)

    Initializes and returns an instance of GenericWorker for the specified model and ops.

    Declaration
    public GenericWorker(Model model, IBackend backend, IModelStorage storage, bool takeoverWeights = false)
    Parameters
    Type Name Description
    Model model

    The model to execute.

    IBackend backend

    The backend to use for execution.

    IModelStorage storage

    The stored tensor variables to use for execution.

    bool takeoverWeights

    Whether to allow the worker to take ownership of the model weights during execution.

    Properties

    scheduleProgress

    Returns the proportion of the model scheduled for execution since the last call to ExecuteLayerByLayer.

    Returns 0.0 after you call ExecuteLayerByLayer. Returns 1.0 when the model is fully scheduled.

    The value increases each time you iterate on the IEnumerator that ExecuteLayerByLayer returns.

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

    Methods

    Dispose()

    Disposes of the worker and any associated memory.

    Declaration
    public void Dispose()

    Execute()

    Schedules the execution of the model on the worker. This is non-blocking.

    Declaration
    public IWorker Execute()
    Returns
    Type Description
    IWorker

    The IWorker.

    Execute(IDictionary<string, Tensor>)

    Sets multiple tensors as the inputs of the model and schedules execution of the model. This is non-blocking.

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

    The IWorker.

    Execute(Tensor)

    Sets a tensor as the default input of the model and schedules the execution of the model on the worker. This is non-blocking. For models with more than one input this sets the first input.

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

    The IWorker.

    ExecuteLayerByLayer()

    Schedules the execution of the model one layer at a time. This is non-blocking.

    To schedule the execution of the next layer of the model, call MoveNext on the IEnumerator object this method returns.

    Declaration
    public IEnumerator ExecuteLayerByLayer()
    Returns
    Type Description
    IEnumerator

    The IEnumerator for scheduling manual execution.

    ExecuteLayerByLayer(IDictionary<string, Tensor>)

    Sets multiple tensors as the inputs of the model and schedules execution of the model one layer at a time. This is non-blocking.

    To schedule execution of the next layer of the model, call MoveNext on the IEnumerator object this method returns.

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

    The IEnumerator for scheduling manual execution.

    ExecuteLayerByLayer(Tensor)

    Sets a tensor as the default input of the model and schedules execution of the model one layer at a time. This is non-blocking. For models with more than one input this sets the first input.

    To schedule execution of the next layer of the model, call MoveNext on the IEnumerator object this method returns.

    Declaration
    public IEnumerator ExecuteLayerByLayer(Tensor input)
    Parameters
    Type Name Description
    Tensor input
    Returns
    Type Description
    IEnumerator

    The IEnumerator for scheduling manual execution.

    ~GenericWorker()

    Finalizes the GenericWorker.

    Declaration
    protected ~GenericWorker()

    GetBackend()

    Gets the backend used by the worker for execution.

    Declaration
    public IBackend GetBackend()
    Returns
    Type Description
    IBackend

    The backend used for execution.

    PeekOutput()

    Returns a reference to the default output tensor. This is non-blocking.

    For models with more than one output this returns a reference to the first output tensor.

    The reference is valid only until you call Execute() or Dispose() on the worker.

    Declaration
    public Tensor PeekOutput()
    Returns
    Type Description
    Tensor

    The output tensor reference.

    PeekOutput(string)

    Returns a reference to the default output tensor. This is non-blocking.

    For models with more than one output this returns a reference to the first output tensor.

    The reference is valid only until you call Execute() or Dispose() on the worker.

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

    The name of the output tensor to peek.

    Returns
    Type Description
    Tensor

    The output tensor reference.

    SetInput(string, Tensor)

    Sets a tensor as a named input of the model.

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

    The name of the input to set.

    Tensor x

    TakeOutputOwnership()

    Takes ownership of the default output tensor. This is non-blocking.

    For models with more than one output this returns a reference to the first output tensor.

    Declaration
    public Tensor TakeOutputOwnership()
    Returns
    Type Description
    Tensor

    The output tensor.

    TakeOutputOwnership(string)

    Takes ownership of an output tensor with a given name. This is non-blocking.

    Declaration
    public Tensor TakeOutputOwnership(string name)
    Parameters
    Type Name Description
    string name

    The name of the output tensor to take ownership of.

    Returns
    Type Description
    Tensor

    The output tensor.

    Implements

    IWorker
    IDisposable
    In This Article
    Back to top
    Copyright © 2024 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)