aclnnInit

Function Usage

Initializes aclnnXxx in the single-operator API execution framework. Before calling such APIs, you must initialize aclnn resources (such as reading environment variables, parsing configuration files, and loading the resource library). Otherwise, an internal system error occurs, affecting service running.

Either aclnnInit or aclInit can be called to initialize resources. The difference is that aclnnInit initializes only aclnn-related resources, while aclInit initializes aclnn and other resources in the acl API. Therefore, aclnnInit is more lightweight than aclInit. If both APIs are called, no failure message is returned.

Prototype

aclnnStatus aclnnInit(const char *configPath)

Parameters

Parameter

Input/Output

Description

configPath

Input

Path (including the file name) of the aclnn initialization configuration file. Developers can enable the debugging capability of the aclnn API through this configuration. The default value is NULL.

The configuration file must be in JSON format. For example, if the value of configPath is /home/acl.json, the configuration example of acl.json is as follows:

1
2
3
4
5
{
   "op_debug_config":{
           "enable_debug_kernel":"on"
    }
}

The values of enable_debug_kernel are as follows:

  • on: The debugging capability of the aclnn API is enabled. That is, during operator execution, the system checks whether memory overwriting occurs in the global memory and whether the internal pipeline is synchronized.
  • off: The debugging capability of the aclnn API is disabled. Defaults to off.

Returns

0 on success; else, failure. For details about the return codes, see Common APIs and Return Codes.

Constraints

  • This API must be used together with aclnnFinalize to initialize and deinitialize aclnn resources.
  • aclnnInit can be called only once in a process.

Examples

The following code examples are for reference only and are not intended for direct copying and execution:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
// Initialize resources.
auto ret = aclnnInit("/home/acl.json");
...
// Create an operator API parameter object.
ret = aclCreate***(...);
...
// Call the two-phase operator APIs.
ret = aclnnXxxGetWorkspaceSize(...);
ret = aclnnXxx(...);
...
// Destroy an operator API parameter object.
ret = aclDestroy***();
...
// Deinitialize resources.
ret = aclnnFinalize();