ncGraphCreate()
Info | Value |
---|---|
Header | mvnc.h |
Library | libmvnc.so |
Version | 2.0 |
See also | struct ncGraphHandle_t, ncGraphAllocateWithFifos(), ncGraphAllocateWithFifosEx(), ncGraphAllocate(), ncGraphDestroy() |
Overview
This function initializes a ncGraphHandle_t struct.
Create a graph handle for each network graph. A neural compute device can have more than one graph allocated to it, but each graph can only be allocated to a single device.
ncGraphDestroy() frees the memory that is allocated for the ncGraphHandle_t struct.
Prototype
ncStatus_t ncGraphCreate(const char* name, struct ncGraphHandle_t** graphHandle);
Parameters
Name | Type | Description |
---|---|---|
name | const char* | A null-terminated array of characters that specify a name for the graph; 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 ncGraphGetOption(). |
graphHandle | struct ncGraphHandle_t** | The address of a pointer to the ncGraphHandle_t struct that will be created and initialized by this function. |
Return
An appropriate value from the ncStatus_t enumeration.
Notes
- The ncGraphHandle_t struct must be created and initialized with this function before being passed to any other API functions. When the graph handle is properly initialized, the graph state will be NC_GRAPH_CREATED.
- After initialization, the ncGraphHandle_t struct must be passed to ncGraphAllocateWithFifos()/ncGraphAllocateWithFifosEx() or ncGraphAllocate() before being passed to any API functions other than ncGraphGetOption() or ncGraphSetOption().
Example
#include <stdio.h>
#include <mvnc.h>
int main(int argc, char** argv)
{
ncStatus_t retCode;
struct ncDeviceHandle_t* deviceHandlePtr;
struct ncGraphHandle_t* graphHandlePtr;
ncDeviceCreate(0, &deviceHandlePtr);
ncDeviceOpen(deviceHandlePtr);
// Initialize the graph and give it a name.
retCode = ncGraphCreate("My Graph", &graphHandlePtr);
if (retCode != NC_OK)
{
printf("Error creating graph[%d]\n", retCode);
}
else
{
// Graph is initialized. User can now call ncGraphAllocate and then
// other API functions with the graph handle.
printf("Graph created OK!\n");
}
// clean up the graph and device
ncGraphDestroy(&graphHandlePtr);
ncDeviceClose(deviceHandlePtr);
ncDeviceDestroy(&deviceHandlePtr);
}