Info Value
Header mvnc.h
Version 2.0
See also struct ncFifoHandle_t, ncFifoOption_t, ncFifoSetOption()


This function gets the value of an option for a FIFO. The available options and possible values can be found in the ncFifoOption_t enumeration.


ncStatus_t ncFifoGetOption(struct ncFifoHandle_t* fifoHandle, 
                           int option, void* data, 
                           unsigned int* dataLength);


Name Type Description
fifoHandle struct ncFifoHandle_t* A pointer to an ncFifoHandle_t struct for the FIFO for which the option value will be retrieved. The FIFO state must be NC_FIFO_CREATED or NC_FIFO_ALLOCATED.
option int A value from the ncFifoOption_t enumeration that specifies which option’s value will be retrieved.
data void* A pointer to a buffer where the value of the option will be copied. The size and type of data this points to will depend on the option that is specified. See ncFifoOption_t for option data types.
dataLength unsigned int* A pointer to an unsigned int which contains the size, in bytes, of the buffer allocated by the caller for the data parameter.

Upon normal return (status code NC_OK), dataLength will be set to the number of bytes copied to the data buffer. In the event that the data buffer was an insufficient size to hold the option value, the return status code will be NC_INVALID_DATA_LENGTH and dataLength will be set to the size required to hold the option value.


An appropriate value from the ncStatus_t enumeration.

If the data buffer was an insufficient size to hold the option value, the return status code will be NC_INVALID_DATA_LENGTH and dataLength will be set to the size required to hold the option value.


  • If you don’t know what value to use for dataLength, you can call this function once with a dataLength of 0 to have dataLength be set to the correct value and then allocate a correctly sized buffer and call this function again. See the example below.


Get an option value when you know the correct data length:

#include <mvnc.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char** argv)
    ncStatus_t retCode;
    struct ncDeviceHandle_t* deviceHandlePtr = NULL;
    struct ncGraphHandle_t* graphHandlePtr = NULL;
    struct ncFifoHandle_t* inFifoHandlePtr = NULL;
    struct ncFifoHandle_t* outFifoHandlePtr = NULL;
    struct ncTensorDescriptor_t inTensorDesc;
    struct ncTensorDescriptor_t outTensorDesc;
    float* imageInMemoryPtr = NULL;
    unsigned int optionSize;

    ncDeviceCreate(0, &deviceHandlePtr);
    ncGraphCreate("My Graph", &graphHandlePtr);
    unsigned int graphSizeInBytes = 0;
    void* graphInMemoryPtr = LoadGraphFile("./graph", &graphSizeInBytes);
    ncGraphAllocate(deviceHandlePtr, graphHandlePtr, graphInMemoryPtr, graphSizeInBytes);

    ncFifoCreate("MY Input FIFO", NC_FIFO_HOST_WO, &inFifoHandlePtr);
    optionSize = sizeof(ncTensorDescriptor_t);
    ncGraphGetOption(graphHandlePtr, NC_RO_GRAPH_INPUT_TENSOR_DESCRIPTORS, &inTensorDesc, &optionSize);
    ncFifoAllocate(inFifoHandlePtr, deviceHandlePtr, &inTensorDesc, 2);
    ncFifoCreate("MY Output FIFO", NC_FIFO_HOST_RO, &outFifoHandlePtr);
    optionSize = sizeof(ncTensorDescriptor_t);
    ncGraphGetOption(graphHandlePtr, NC_RO_GRAPH_OUTPUT_TENSOR_DESCRIPTORS, &outTensorDesc, &optionSize);
    ncFifoAllocate(outFifoHandlePtr, deviceHandlePtr, &outTensorDesc, 2);

    unsigned int fifoOutputSize = 0;
    unsigned int optionDataLen = sizeof(unsigned int);
    retCode = ncFifoGetOption(outFifoHandlePtr, NC_RO_FIFO_ELEMENT_DATA_SIZE, &fifoOutputSize, &optionDataLen);
    if (retCode != NC_OK)
    {   // Could not get FIFO option
        printf("Error getting FIFO option [%d]\n", retCode);
        printf("Got FIFO option NC_RO_FIFO_ELEMENT_DATA_SIZE, it is: %d\n", fifoOutputSize);

    // Use FIFOs, device, graph here

    // clean up the graph and device

Get an option value when you don’t know the correct data length:

#include <mvnc.h>
#include <stdio.h>
#include <stdlib.h>

int main(void) {
    ncStatus_t retCode;
    struct ncFifoHandle_t* fifoHandle;
    char* fifoName; 
    unsigned int dataLength;
    /* Initialize a fifo handle */
    retCode = ncFifoCreate("inputFifo", NC_FIFO_HOST_WO, &fifoHandle);
    /* retCode should be NC_OK unless there was a problem */
    if(retCode != NC_OK)
        printf("Error: %d\n", retCode);
    /* Call ncFifoGetOption once to get the correct dataLength */
    fifoName = NULL;
    dataLength = 0;
    retCode = ncFifoGetOption(fifoHandle, NC_RO_FIFO_NAME, fifoName, &dataLength);

    /* retCode should be NC_INVALID_DATA_LENGTH unless there was another problem */
    if(retCode != NC_INVALID_DATA_LENGTH)
        printf("Error: %d\n", retCode);
    /* Now the value of dataLength is correctly set */
    /* Allocate the array buffer */
    fifoName = (char*)malloc(dataLength);
    /* Get the fifo name option value */
    retCode = ncFifoGetOption(fifoHandle, NC_RO_FIFO_NAME, fifoName, &dataLength);
    /* Use the fifo name as needed */
    printf("The fifo name is %s.\n", fifoName);
    return 0;