ncFifoCreate()
Info | Value |
---|---|
Header | mvnc.h |
Library | libmvnc.so |
Version | 2.0 |
See also | struct ncFifoHandle_t, ncFifoAllocate(), ncFifoDestroy() |
Overview
This function initializes a ncFifoHandle_t struct.
Typically, two FIFOs are created for each network graph - one for input and one for output.
ncFifoDestroy() frees the memory that is allocated with this function.
Prototype
ncStatus_t ncFifoCreate(const char* name, ncFifoType_t type, struct ncFifoHandle_t** fifoHandle);
Parameters
Name | Type | Description |
---|---|---|
name | const char* | A null-terminated array of characters that specify a name for the FIFO; this can be can be anything you like up to NC_MAX_NAME_SIZE characters, or just an empty string. The name can be retrieved later with ncFifoGetOption(). |
type | ncFifoType_t | A member of the ncFifoType_t enumeration that specifies the FIFO access type. The API should be able to write to input FIFOs and read from output FIFOs. |
fifoHandle | struct ncFifoHandle_t** | The address of a pointer to a ncFifoHandle_t struct that will be created and initialized by this function. |
Return
An appropriate value from the ncStatus_t enumeration.
Notes
- The ncFifoHandle_t struct must be created and initialized with this function before being passed to any API functions. When the FIFO handle is properly initialized, the FIFO state will be NC_FIFO_CREATED.
- After initialization, the ncFifoHandle_t struct must be passed to ncFifoAllocate() before being passed to any API function other than ncFifoGetOption() or ncFifoSetOption().
- ncGraphAllocateWithFifos() or ncGraphAllocateWithFifosEx() can be used to easily initialize and allocate an input and an output FIFO in addition to allocating a graph to a device; these internally call ncFifoCreate() and ncFifoAllocate() for both ncFifoHandle_t structs and ncGraphAllocate() for the graph.
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;
ncDeviceCreate(0, &deviceHandlePtr);
ncDeviceOpen(deviceHandlePtr);
ncGraphCreate("My Graph", &graphHandlePtr);
ncFifoCreate("MY Input FIFO", NC_FIFO_HOST_WO, &inFifoHandlePtr);
if (retCode != NC_OK)
{ // Could not create FIFO
printf("Error creating FIFO [%d]\n", retCode);
}
else
{
// FIFO created write only FIFO.
// Now allocate it and then Write graph input to it and then queue inferences.
printf("FIFO created OK!\n");
}
// clean up the graph and device
ncFifoDestroy(&inFifoHandlePtr);
ncGraphDestroy(&graphHandlePtr);
ncDeviceClose(deviceHandlePtr);
ncDeviceDestroy(&deviceHandlePtr);
}