99 Tensor::element_type(kernel.
output()));
101 Tensor::element_type(kernel.
input2()) == DataType::S64);
103 Tensor::element_type(kernel.
input3()) == DataType::S64);
113 bool is_dynamic_shapes =
false;
115 const circle::Tensor *input = kernel.
input1();
117 const circle::Tensor *size_tensor = kernel.
input3();
118 const circle::Tensor *output = kernel.
output();
121 if (input_data ==
nullptr)
126 if (begin_data ==
nullptr)
129 is_dynamic_shapes =
true;
134 if (size_data ==
nullptr)
137 is_dynamic_shapes =
true;
144 SliceParams op_params{};
145 op_params.begin_count = max_dim;
146 op_params.size_count = max_dim;
147 for (
int i = 0; i < max_dim; i++)
149 op_params.begin[i] = 0;
150 op_params.size[i] = 1;
152 auto num_dim = Tensor::num_dims(input);
154 if (Tensor::element_type(
begin) == DataType::S32)
156 getBeginAndSizeVectors<int32_t>(num_dim, begin_data, size_data, op_params.begin,
159 else if (Tensor::element_type(
begin) == DataType::S64)
161 getBeginAndSizeVectors<int64_t>(num_dim, begin_data, size_data, op_params.begin,
166 assert(
false &&
"Unsupported type");
169#ifndef DIS_DYN_SHAPES
170 if (is_dynamic_shapes)
172 int32_t data_size = 1;
174 int offset = max_dim - Tensor::num_dims(input);
175 for (
int i = 0; i <= max_dim - num_dim; ++i)
179 auto cur_size = op_params.size[i +
offset] != -1
180 ? op_params.size[i +
offset]
182 data_size *= cur_size;
184 dynamic_shapes.
setDim(i, cur_size);
186 data_size *=
size(Tensor::element_type(output));
196 auto new_output_data =
new uint8_t[data_size];
197 output_data = new_output_data;
201 assert(is_dynamic_shapes ==
false);
204 switch (Tensor::element_type(input))
207 case DataType::FLOAT32:
210 kernels::getTensorData<float>(output_data));
217 kernels::getTensorData<uint8_t>(output_data));
222 kernels::getTensorData<int8_t>(output_data));
227 kernels::getTensorData<int16_t>(output_data));
231 assert(
false &&
"Unsupported input type.");