ncFifoSetOption()

Info Value
Header mvnc.h
Library libmvnc.so
Version 2.0
See also struct ncFifoHandle_t, ncFifoOption_t, ncFifoGetOption()

Overview

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

Prototype

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

Parameters

Name Type Description
fifoHandle struct ncFifoHandle_t* A pointer to an ncFifoHandle_t struct for the FIFO for which the option value will be set. The FIFO state must be NC_FIFO_CREATED.
option int A value from the ncFifoOption_t enumeration that specifies which option’s value will be set.
data const void* A pointer to a buffer containing the new value for the option.

The type of data this points to depends on the option that is specified. Check ncFifoOption_t for the data types that each option requires.
dataLength unsigned int An unsigned int that contains the length, in bytes, of the buffer that the data parameter points to.

Return

An appropriate value from the ncStatus_t enumeration.

Notes

Example

#include <stdio.h>
#include <stdlib.h>
#include <mvnc.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);
    ncDeviceOpen(deviceHandlePtr);
    ncGraphCreate("My Graph", &graphHandlePtr);

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

    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);

    /* crete fifo with WO type */
    ncFifoCreate("MY Output FIFO", NC_FIFO_HOST_WO, &outFifoHandlePtr);

    /* set the fifo option to change to RO type */
    ncFifoType_t newFifoType = NC_FIFO_HOST_RO;
    unsigned int dataLen = sizeof(ncFifoType_t);
    retCode = ncFifoSetOption(outFifoHandlePtr, NC_RW_FIFO_TYPE, &newFifoType, dataLen);
    if (retCode != NC_OK)
    {   // Could not get FIFO option
        printf("Error setting FIFO option [%d]\n", retCode);
    }
    else
    {
        printf("Set FIFO option NC_RW_FIFO_TYPE, it is: %d\n", newFifoType);
    }

    optionSize = sizeof(ncTensorDescriptor_t);
    ncGraphGetOption(graphHandlePtr, NC_RO_GRAPH_OUTPUT_TENSOR_DESCRIPTORS, &outTensorDesc, &optionSize);
    ncFifoAllocate(outFifoHandlePtr, deviceHandlePtr, &outTensorDesc, 2);

    // clean up the graph and device
    ncFifoDestroy(&inFifoHandlePtr);
    ncFifoDestroy(&outFifoHandlePtr);
    ncGraphDestroy(&graphHandlePtr);
    ncDeviceClose(deviceHandlePtr);
    ncDeviceDestroy(&deviceHandlePtr);
}