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

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