Class GenericWorker
Generic IWorker implementation
Namespace: Unity.Barracuda
Syntax
public class GenericWorker : object, IWorker, IDisposable
Constructors
GenericWorker(Model, IOps, IVars, Boolean)
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 |
|
| IOps | ops |
|
| IVars | vars |
|
| Boolean | 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 |
|---|---|
| Single |
Implements
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 |
Implements
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 |
Implements
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 |
Implements
Finalize()
Finalizer
Declaration
protected void Finalize()
FlushSchedule(Boolean)
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 |
|---|---|---|
| Boolean | blocking | if blocking True, wait for completion |
Implements
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 |
Implements
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 |
Implements
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 |
Implements
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 |
Implements
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 |
Implements
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 |
Implements
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 |
Implements
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 |
Implements
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 |
Implements
Summary()
Execution summary
Declaration
public virtual string Summary()
Returns
| Type | Description |
|---|---|
| String | execution summary |