Updated on 2022-03-13 GMT+08:00

Protobuf Data Types

For details about how to use Protobuf, see https://developers.google.com/protocol-buffers/docs/reference/proto3-spec.

The Protobuf data types used by Matrix are as follows:

ai_types.proto
syntax = "proto3";IAITensor

package hiai;

// Tensor parameter description
message AITensorParaDescription
{
    string name = 1; // Parameter name
    string type = 2; // Parameter type
    string value = 3;  // Parameter value
    string desc = 4; // Parameter description
    repeated AITensorParaDescription sub_paras = 5; // Sub-parameter list
};

// Tensor description
message AITensorDescription
{
    string name = 1; // Tensor name
    string type = 2; // Tensor type
    repeated string compatible_type = 3; // Specifies all types of parent classes that are compatible.
   repeated AITensorParaDescription paras = 4; // Parameter list
};

// Tensor description list
message AITensorDescriptionList
{
    repeated AITensorDescription tensor_descs = 1; // Tensor list
}

// Common configuration items
// If sub_items exists, the current node is the parent node and the value is invalid.
message AIConfigItem
{
    string name = 1; // Configuration item name
    string value = 2;  // Configuration item value. When this parameter is set to the path of a model file, it contains the file name, supporting only digits, letters, underscores (_), and dots (.). You can set this parameter to the path of a single model file, for example, ./test_data/model/resnet18.om. You can also compress the model files into a tar package and set the parameter to the path of the tar package, for example, ./test_data/model/resnet18.tar. If there are multiple AIConfigItem, the files with the same name but in different formats cannot be in the same directory when you set the path of the tar package, for example, ./test_data/model/test and ./test_data/model/test.tar. The APIs for creating graphs include Graph::CreateGraph or HIAI_CreateGraph.
    repeated AIConfigItem sub_items = 3; // Configuration subitem
};

// Configuration parameter for running an NN node or API
message AIConfig
{
    repeated AIConfigItem items = 1; // Configuration item list
};

// Model description
message AIModelDescription
{
      string name = 1; // Model name
    int32 type = 2; // Model type. Currently, only the DAVINCI_OFFLINE_MODEL type is supported. The value is 0.
    string version = 3; // Model version
    int32 size = 4; // Model size
    string path = 5; // Model path
    string key = 8; // Model key
    bytes data = 100; // Model data
    repeated AITensorDescription inputs = 6; // Description of input tensors
    repeated AITensorDescription outputs = 7; // Description of output tensors
};

// NNNode description
message AINNNodeDescription
{
    string name = 1; // NN node name
    string desc = 2; // NN node description
   bool isPreAllocateOutputMem = 3; // Whether to pre-allocate the output memory
   AIConfig config = 4; // Configuration parameter
   repeated AIModelDescription model_list = 5;  // List of models required by an NN node
    repeated AITensorDescription inputs = 6; // Description of input tensors
    repeated AITensorDescription outputs = 7; // Description of output tensors
    bool need_verify = 8; // Whether to verify the tensor match during connection
    repeated string ignored_check_aitensor = 9; // Specifies the list of tensors for which the mechanism for verifying whether they match the tensors of the inputs is ignored during connection.
};

// NNNode description list
message AINNNodeDescriptionList
{
    repeated AINNNodeDescription nnnode_descs = 1; // NN node list
}

// API description
message AIAPIDescription
{
    string name = 1; // API name
    string desc = 2; // API description
    bool isPreAllocateOutputMem = 3; // Whether to pre-allocate the output memory
    AIConfig config = 4; // Configuration parameter
    repeated AITensorDescription inputs = 5; // Description of input tensors
    repeated AITensorDescription outputs = 6; // Description of output tensors
    bool need_verify = 7; // Whether to verify the tensor match during connection
    repeated string ignored_check_aitensor = 8; // Specifies the list of tensors for which the mechanism for verifying whether they match the tensors of the inputs is ignored during connection.
};

// API description list
message AIAPIDescriptionList
{
    repeated AIAPIDescription api_descs = 1; // API list
}

// AI operation description
message AIOPDescription
{
    enum OP_Type
    {
        AI_API = 0;
        AI_NNNODE = 1;
    }

    OP_Type type = 1;
    AINNNodeDescription nnnode_desc = 2;
    AIAPIDescription api_desc = 3;
};

// AI operation description list
message AIOPDescriptionList
{
   repeated AIOPDescription op_descs = 1; // AI operation list
}

// IDE passes parameters to Matrix APIs.

message NodeDesc
{
   string name=1; // IAINNNode or ALG_API name
   AIConfig config=2; // Initialization parameter required by IAINNNode or ALG_API
   repeated AIModelDescription mode_desc=3; // Initialization parameter required by IAINNNode
}

message EngineDesc
{
    enum RunSide
    {
        DEVICE=0;
        HOST=1;
    }
    enum EngineType
    {
        NORMAL=0;
        SOURCE=1;
        DEST=2;
    }
    uint32 id =1; // Engine ID (node)
    EngineType type=2; //
    string name =3; // Engine node name
    repeated string so_name=4; // The list of all DLL .so file names that need to be copied is loaded first according to the configuration sequence. If the loading fails, the system tries to load the list of files according to another loading sequence.
    RunSide side=5; // Run on the host side or device side.
    int32 priority=6; // Node priority
    uint32 instance_cnt=7; // Number of instances (equivalent to the number of threads)
    repeated uint32 next_node_id=8; // Next node list
    bool user_input_cb=9; // IDE can be ignored.
    bool user_output_cb=10; // IDE can be ignored.
    repeated NodeDesc oper=11; // Matrix node list
}

message GraphInitDesc
{
    int32 priority=1; // Priority of the entire process for a graph
   //Runside side = 2; // Assume that the graph is deployed on the host and cannot be configured.
}

message GeneralFileBuffer
{
    bytes raw_data = 1;
    string file_name = 2;
}

graph_config.proto

syntax = "proto3";
import "ai_types.proto";
package hiai;

message DumpDef
{
    bytes model_name = 1; // Model name
    bytes is_dump_all = 2; // Whether to enable the dump function. This parameter is used to dump information about operators at all layers in the model.
    repeated bytes layer = 3;    // Determines the layers on which the operators need to be dumped in the model.
}
message OAMConfigDef
{
    repeated DumpDef dump_list = 1;
    bytes dump_path = 2;    // Path for storing dump files
}
message EngineConfig
{
    enum RunSide
    {
        DEVICE=0; // Run on the device side.
        HOST=1;     // Run on the host side.
    }

    uint32 id =1; // Engine ID (node)
    string engine_name =2; // Engine node name
    repeated string so_name=3; // The list of all DLL .so file names that need to be copied is loaded first according to the configuration sequence. If the loading fails, the system tries to load the list of files according to another loading sequence.
    RunSide side=4; // Run on the host side or device side.
    uint32 thread_num = 5;// Number of threads. If multi-channel decoding is used, you are advised to set this parameter to 1. If the value of "thread_num" is greater than 1, the decoding sequence between threads cannot be ensured.
    uint32 thread_priority = 6;// Thread priority
    uint32 queue_size = 7;// Queue size
    AIConfig ai_config = 8; // Aiconfig configuration file
    repeated AIModelDescription ai_model = 9; //AIModelDescription
    repeated string internal_so_name=10; // List of all DLL .so files that do not need to be copied
    uint32 wait_inputdata_max_time = 12; // Maximum timeout for waiting to receive the next data (in ms)
   uint32 holdModelFileFlag = 13; // Whether to retain the model file of this engine. 0: Not reserved; Other values: Reserved.
    OAMConfigDef oam_config = 14; // OAM configuration
    bool is_repeat_timeout_flag = 15; // Whether to perform timeout processing repeatedly when no data is received by an engine. 0: no; 1: yes. For example, if there is a large amount of multi-channel data to be analyzed, you are advised to set this parameter to 1. This parameter is used together with the wait_inputdata_max_time parameter. If "is_repeat_timeout_flag" is set to 0, the wait_inputdata_max_time parameter is used to set the timeout duration for a single time. If "is_repeat_timeout_flag" is set to 1, the wait_inputdata_max_time parameter is used to set the timeout duration of the entire period.
}
message ConnectConfig
{
    uint32 src_engine_id=1; // Engine ID of the transmit end
    uint32 src_port_id = 2; // Port ID of the transmit end
    uint32 target_graph_id=3; // Graph ID of the receive end
    uint32 target_engine_id=4; // Port ID of the receive end
    uint32 target_port_id=5; // Port ID of the receive end
     bool receive_memory_without_dvpp=6; // The default value is 0, indicating that the RX memory of the target engines running on the device side must meet the 4 GB address space limit. If this parameter is set to 1, the 4 GB address space limit does not need to be met. You can set the receive_memory_without_dvpp parameter (under the "connects" property) to 1 in the graph configuration file for all target engines running on the device side. You can also set the receive_memory_without_dvpp parameter under the "connects" property to 1 because the target engines running on the host side are not affected even if the parameter is set. In this way, the Matrix RX memory pool is not limited by the 4 GB address space, which improves the memory utilization. In the current DVPP, the input memory for the VPC, JPEGE, JPEGD, and PNGD must meet the 4 GB address space requirements, while that for the VDEC and VENC can either or not meet the 4 GB address space requirements.
}
message GraphConfig
{
    uint32 graph_id = 1;  //Graph ID
    int32 priority = 2; // Priority
    string device_id = 3;// Device ID, for example, "0"
   repeated EngineConfig engines = 3; // All engines. You are advised to configure multiple engines for multi-channel decoding. One engine corresponds to one thread. If one engine corresponds to multiple threads, the decoding sequence cannot be ensured.
    repeated ConnectConfig connects = 4; // Connection mode
}
message GraphConfigList
{
    repeated GraphConfig graphs = 1; // Configuration parameter for a single graph
}

message ProfileConfig
{
    string matrix_profiling = 1; //  Whether to enable profiling for Matrix. The value "on" indicates that the function is enabled.
    string ome_profiling = 2; // Whether to enable the performance statistics function of OME. The value "on" indicates that the function is enabled.
   string cce_profiling =3;  // Whether to enable the performance statistics function of CCE. The value "on" indicates that the function is enabled.
    string runtime_profiling = 4;  // Whether to enable the performance statistics function of Runtime. The value "on" indicates that the function is enabled.
    string PROFILER_TARGET = 5; //  Parameter for transparent transmission profiling
    string PROFILER_JOBCTX = 6;
    string src_path = 7;
    string dest_path = 8;
    string runtime_config = 9;
    string RTS_PATH = 10;
    string profiler_jobctx_path = 11;
    string profiler_target_path = 12;
}

message GraphUpdateConfig
{
    GraphConfig updataGraphConfig = 1;
    repeated uint32 del_engine_ids = 2;
    repeated ConnectConfig del_connects = 3;
}