Fifo.allocate()

Info Value
Package mvnc
Module mvncapi
Version 2.0
See also Fifo, Fifo.destroy()

Overview

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

Syntax

fifo.allocate(device, tensor_desc, n_elem)

Parameters

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 that a Graph will read from this Fifo (for an input Fifo) or write to this Fifo (for an output Fifo). You should use Graph.get_option() to get lists of input or output TensorDescriptors that are appropriate for the associated Graph.
n_elem int The maximum number of elements that the Fifo will be able to contain.

Return

None

Raises

Exception with a status code from Status if underlying function calls return a status other than Status.OK.

Notes

Example

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