Info | Value |
---|---|
Package | mvnc |
Module | mvncapi |
Version | 2.0 |
See also | Fifo, Fifo.destroy() |
This method allocates memory for the Fifo for the specified Device based on the number of elements the Fifo will hold and a TensorDescriptor struct, which describes the expected shape of the Fifo’s elements. Each Fifo can only be allocated to a single device.
Upon successful return from this method, the Fifo will be ready for reading/writing.
The allocated memory is freed with Fifo.destroy().
fifo.allocate(device, tensor_desc, n_elem)
Parameter | Type | Description |
---|---|---|
device | Device | A Device that this Fifo will be associated with. The DeviceState must be OPENED. |
tensor_desc | TensorDescriptor | A TensorDescriptor structure that describes the elements of the Fifo. Graph.get_option() with GraphOption.RO_INPUT_TENSOR_DESCRIPTORS or GraphOption.RO_OUTPUT_TENSOR_DESCRIPTORS will return a list of TensorDescriptors for that Graph. |
n_elem | int | The maximum number of elements that the Fifo will be able to contain. |
None
Exception with a status code from Status if underlying function calls return a status other than Status.OK.
from mvnc import mvncapi
#
# Open a Device and allocate a Graph...
#
# Create an input Fifo
input_fifo = mvncapi.Fifo('input1', mvncapi.FifoType.HOST_WO)
# Get an input TensorDescriptor from a graph
input_descs = graph.get_option(mvncapi.GraphOption.RO_INPUT_TENSOR_DESCRIPTORS)
# Allocate the Fifo buffer with the graph input TensorDescriptor to the device
NUM_ELEMENTS = 2
input_fifo.allocate(device, input_descs[0], NUM_ELEMENTS)
#
# Write elements to the Fifo with Fifo.write_elem() and initiate inferences with Graph.queue_inference()
#
# Destroy the Fifo
input_fifo.destroy()
#
# Perform other clean up...
#