EsCreateGraphInputWithDetails

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product

Atlas training product

Header File/Library File

  • Header file: #include <ge/esb_funcs.h>
  • Library files: libeager_style_graph_builder_base.so and libeager_style_graph_builder_base_static.a

Function Usage

Creates an input on a graph.

Prototype

1
EsCTensorHolder *EsCreateGraphInputWithDetails(EsCGraphBuilder *graph, int64_t index, const char *name, const char *type, C_DataType data_type, C_Format format, const int64_t *shape, int64_t dim_num);

Parameters

Parameter

Input/Output

Description

graph

Input

Pointer to the graph builder.

index

Input

Index of the input graph, starting from 0.

name

Input

Input name. If this parameter is left blank, the default value input_{index} is used.

type

Input

Input type. If this parameter is left blank, the default value Data is used.

data_type

Input

Data type.

format

Input

Format type.

shape

Input

Shape information. If this parameter is left blank, the value is a scalar.

dim_num

Input

Number of dimensions.

Returns

Parameter

Type

Description

-

EsCTensorHolder *

Tensor resources managed by the graph builder.

Restrictions

None

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "c_types.h" // Includes the enumeration type definition in C.
// 1. Create a graph builder (EsCGraphBuilder).
EsCGraphBuilder *builder = EsCreateGraphBuilder("graph_name");
// 2. Prepare the shape (dimension information).
// Example: Batch=1, Channel=3, Height=224, Width=224
int64_t input_shape[] = {1, 3, 224, 224};

// Compute the number of dimensions (dim_num).
int64_t dim_num = sizeof(input_shape) / sizeof(input_shape[0]); // The result is 4.

// 3. Prepare other parameters.
int64_t input_index = 0;           // Input 0
const char *input_name = "data";   // Input node name
const char *node_type = "Data";   // Input node type
C_DataType dtype = C_DT_FLOAT;   // The data type is float.
C_Format fmt = C_FORMAT_NCHW;         // The data layout is NCHW.

// 4. Call the function.
EsCTensorHolder *input_tensor = EsCreateGraphInputWithDetails(
    builder,      // graph: graph builder pointer
    input_index,  // index: input index
    input_name,   // name: input name
    node_type,    // type: node type string
    dtype,        // data_type: data type enum
    fmt,          // format: format enum
    input_shape,  // shape: dimension array pointer
    dim_num       // dim_num: length of the dimension array
);