docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface IWorker

    An interface that allows you to execute neural networks (models).

    IWorker abstracts implementation details on different hardware devices such as the CPU and the GPU. IWorker lets you do the following:

    • Specify inputs.
    • Schedule the work.
    • Get outputs.

    Internally, IWorker translates the neural network from a Model into a set of operations, then sends the operations to the hardware device for asynchronous execution.

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

    Inherited Members
    IDisposable.Dispose()
    Namespace: Unity.Sentis
    Assembly: solution.dll
    Syntax
    public interface IWorker : IDisposable

    Properties

    Name Description
    scheduleProgress

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

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

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

    Methods

    Name Description
    Execute()

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

    Execute(IDictionary<string, Tensor>)

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

    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.

    FlushSchedule(bool)

    Schedules the execution of the part of the model that hasn't been scheduled yet. This is non-blocking.

    GetBackend()

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

    If you want to dispose of the worker but keep the tensor, use FinishExecutionAndDownloadOutput() instead, or use TakeOwnership() on the output tensor.

    PeekOutput(string)

    Returns a reference to an output tensor with a given name. This is non-blocking.

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

    If you want to dispose of the worker but keep the tensor, use FinishExecutionAndDownloadOutput() instead, or use TakeOwnership() on the output tensor.

    PrepareForInput(IDictionary<string, TensorShape>)

    Prepares the worker to execute the model using inputs of given shapes.

    SetInput(string, Tensor)

    Sets a tensor as a named input of the model.

    SetInput(Tensor)

    Sets a tensor as the default input of the model. For models with more than one input this sets the first input.

    StartManualSchedule()

    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.

    StartManualSchedule(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.

    StartManualSchedule(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.

    Summary()

    Returns a summary of the execution of the model.

    Extension Methods

    WorkerExtensions.ExecuteAndDownloadOutputsAsync(IWorker, Dictionary<string, Tensor>, List<string>)
    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)