Defining a Data Node (Data)
The Data operator implements the input node, or the data node, of a graph.
Data operator prototype definition is as follows.
1 2 3 4 5 | REG_OP(Data) .INPUT(x, TensorType::ALL()) .OUTPUT(y, TensorType::ALL()) .ATTR(index, Int, 0) .OP_END_FACTORY_REG(Data) |
Create a Data operator instance named data based on the operator prototype definition. The initial argument is desc_data. You need to set Shape, Format, and Dtype using the update_input_desc_inputName and update_output_desc_outputName APIs consistent with the data to be processed.
1 2 3 4 5 | auto shape_data = vector<int64_t>({1,17,2,2}); TensorDesc desc_data(ge::Shape(shape_data), FORMAT_ND, DT_FLOAT); auto data = op::Data("data"); // Create a Data operator. data.update_input_desc_x(desc_data); // Set the operator input description. data.update_output_desc_y(desc_data); // Set the operator output description. |
You need to set Shape, Format, and Dtype using the update_input_desc_inputName and update_output_desc_outputName APIs.
Parent topic: Operator Expression