35 const auto input_index = cur_op->inputs()->operator[](0);
36 const auto shape_index = cur_op->inputs()->operator[](1);
37 const auto output_index = cur_op->outputs()->operator[](0);
39 assert(input_index != -1);
40 assert(shape_index != -1);
41 assert(output_index != -1);
57 assert(input_data !=
nullptr);
58 assert(output_data !=
nullptr);
60 int32_t data_size = Tensor::num_elements(output) *
getDataTypeSize(Tensor::element_type(output));
63 if (shape_data ==
nullptr)
66 assert(shape_data !=
nullptr);
68 assert(Tensor::element_type(shape) == DataType::S32);
70 const int32_t *shape_data_int = kernels::getTensorData<int32_t>(shape_data);
71 const auto num_dims = Tensor::num_dims(output);
75 for (
int i = 0; i < num_dims; ++i)
77 dynamic_shape.
setDim(i, shape_data_int[i]);
78 data_size *= shape_data_int[i];
80 data_size *=
size(Tensor::element_type(output));
90 auto new_output_data =
new uint8_t[data_size];
91 output_data = new_output_data;
95 assert(shape_data !=
nullptr);
98 std::memcpy(output_data, input_data, data_size);