docs.unity3d.com
    Show / Hide Table of Contents

    Class GenericWorker

    Represents a generic implementation of an IWorker.

    Inheritance
    Object
    GenericWorker
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.Sentis
    Syntax
    public class GenericWorker : IWorker, IDisposable

    Constructors

    GenericWorker(Model, IOps, IVars, Boolean, Boolean)

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

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

    Properties

    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.

    Declaration
    public virtual float scheduleProgress { get; }
    Property Value
    Type Description
    Single
    Implements
    IWorker.scheduleProgress

    Methods

    Dispose()

    Disposes of the worker and any associated memory.

    Declaration
    public virtual void Dispose()
    Implements
    IDisposable.Dispose()

    Execute()

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

    Declaration
    public virtual IWorker Execute()
    Returns
    Type Description
    IWorker
    Implements
    IWorker.Execute()

    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 virtual IWorker Execute(IDictionary<string, Tensor> inputs)
    Parameters
    Type Name Description
    IDictionary<String, Tensor> inputs
    Returns
    Type Description
    IWorker
    Implements
    IWorker.Execute(IDictionary<String, Tensor>)

    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 virtual IWorker Execute(Tensor input)
    Parameters
    Type Name Description
    Tensor input
    Returns
    Type Description
    IWorker
    Implements
    IWorker.Execute(Tensor)

    Finalize()

    Finalizes the GenericWorker.

    Declaration
    protected void Finalize()

    FlushSchedule(Boolean)

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

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

    When the value is true, the method blocks further code until the model finishes executing.

    Implements
    IWorker.FlushSchedule(Boolean)

    GetOps()

    Declaration
    public IOps GetOps()
    Returns
    Type Description
    IOps
    Implements
    IWorker.GetOps()

    PeekOutput(Boolean)

    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 CopyOutput() instead, or use TakeOwnership() on the output tensor.

    Declaration
    public virtual Tensor PeekOutput(bool prepareCacheForAccess = false)
    Parameters
    Type Name Description
    Boolean prepareCacheForAccess

    Schedules a non-blocking download from the GPU to the CPU.

    Returns
    Type Description
    Tensor
    Implements
    IWorker.PeekOutput(Boolean)

    PeekOutput(String, Boolean)

    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 CopyOutput() instead, or use TakeOwnership() on the output tensor.

    Declaration
    public virtual Tensor PeekOutput(string name, bool prepareCacheForAccess = false)
    Parameters
    Type Name Description
    String name

    The name of the output tensor to peek.

    Boolean prepareCacheForAccess

    Whether to schedule a non-blocking download to the CPU.

    Returns
    Type Description
    Tensor
    Implements
    IWorker.PeekOutput(String, Boolean)

    PrepareForInput(IDictionary<String, TensorShape>)

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

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

    A dictionary mapping input names to tensor shapes.

    Implements
    IWorker.PrepareForInput(IDictionary<String, TensorShape>)

    SetInput(String, Tensor)

    Sets a tensor as a named input of the model.

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

    The name of the input to set.

    Tensor x
    Implements
    IWorker.SetInput(String, Tensor)

    SetInput(Tensor)

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

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

    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.

    Declaration
    public virtual IEnumerator StartManualSchedule()
    Returns
    Type Description
    IEnumerator
    Implements
    IWorker.StartManualSchedule()

    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.

    Declaration
    public virtual IEnumerator StartManualSchedule(IDictionary<string, Tensor> inputs)
    Parameters
    Type Name Description
    IDictionary<String, Tensor> inputs
    Returns
    Type Description
    IEnumerator
    Implements
    IWorker.StartManualSchedule(IDictionary<String, Tensor>)

    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.

    Declaration
    public virtual IEnumerator StartManualSchedule(Tensor input)
    Parameters
    Type Name Description
    Tensor input
    Returns
    Type Description
    IEnumerator
    Implements
    IWorker.StartManualSchedule(Tensor)

    Summary()

    Returns a summary of the execution as a string.

    Declaration
    public virtual string Summary()
    Returns
    Type Description
    String
    Implements
    IWorker.Summary()

    Extension Methods

    WorkerExtensions.CopyOutput(IWorker)
    WorkerExtensions.CopyOutput(IWorker, String)

    Did you find this page useful? Please give it a rating:

    Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • Constructors
      • GenericWorker(Model, IOps, IVars, Boolean, Boolean)
    • Properties
      • scheduleProgress
    • Methods
      • Dispose()
      • Execute()
      • Execute(IDictionary<String, Tensor>)
      • Execute(Tensor)
      • Finalize()
      • FlushSchedule(Boolean)
      • GetOps()
      • PeekOutput(Boolean)
      • PeekOutput(String, Boolean)
      • PrepareForInput(IDictionary<String, TensorShape>)
      • SetInput(String, Tensor)
      • SetInput(Tensor)
      • StartManualSchedule()
      • StartManualSchedule(IDictionary<String, Tensor>)
      • StartManualSchedule(Tensor)
      • Summary()
    • Extension Methods
    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