ncFifoDestroy()

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

Overview

This function destroys a handle for a FIFO and frees associated resources. This function must be called for every FIFO handle that was initialized with ncFifoCreate().

Upon successful return, the ncFifoHandle_t struct pointer will be set to NULL.

Prototype

ncStatus_t ncFifoDestroy(struct ncFifoHandle_t** fifo);

Parameters

Name Type Description
fifoHandle struct ncFifoHandle_t** The address of a pointer to an initialized ncFifoHandle_t struct.

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

    // Use FIFOs here, write input and read output from inferences with them

    // Clean up and exit program
    retCode = ncFifoDestroy(&inFifoHandlePtr);
    if (retCode != NC_OK)
    {   // Could not destroy input FIFO
        printf("Error destroying input FIFO [%d]\n", retCode);
        exit(-1);
    }
    ncFifoDestroy(&outFifoHandlePtr);
    if (retCode != NC_OK)
    {   // Could not destroy FIFO
        printf("Error destroying output FIFO [%d]\n", retCode);
        exit(-1);
    }

    ncGraphDestroy(&graphHandlePtr);
    ncDeviceClose(deviceHandlePtr);
    ncDeviceDestroy(&deviceHandlePtr);
}