Class GenericWorker
Represents a generic implementation of an IWorker.
Inherited Members
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
Methods
Dispose()
Disposes of the worker and any associated memory.
Declaration
public virtual void Dispose()
Implements
Execute()
Schedules the execution of the model on the worker. This is non-blocking.
Declaration
public virtual IWorker Execute()
Returns
Type | Description |
---|---|
IWorker |
Implements
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
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
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 |
Implements
GetOps()
Declaration
public IOps GetOps()
Returns
Type | Description |
---|---|
IOps |
Implements
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
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
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
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
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
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
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
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
Summary()
Returns a summary of the execution as a string.
Declaration
public virtual string Summary()
Returns
Type | Description |
---|---|
String |