76 assert(
input()->element_type() ==
output()->element_type());
77 assert(
begin()->element_type() == DataType::S32 ||
begin()->element_type() == DataType::S64);
78 assert(
size()->element_type() == DataType::S32 ||
size()->element_type() == DataType::S64);
79 assert(
begin()->shape().num_dims() == 1);
80 assert(
size()->shape().num_dims() == 1);
83 if (
begin()->element_type() == DataType::S32)
87 else if (
begin()->element_type() == DataType::S64)
93 throw std::runtime_error(
"luci-intp Slice Unsupported type.");
99 std::vector<int> begins;
101 std::vector<int> sizes;
103 if (
begin()->element_type() == DataType::S32)
105 getBeginAndSizeVectors<int32_t>(
input()->shape().num_dims(),
begin(),
size(), &begins, &sizes);
107 else if (
begin()->element_type() == DataType::S64)
109 getBeginAndSizeVectors<int64_t>(
input()->shape().num_dims(),
begin(),
size(), &begins, &sizes);
113 throw std::runtime_error(
"Unsupported begin type.");
115 for (
int i =
input()->shape().num_dims(); i <
max_dim; ++i)
121 assert(begins.size() == 4);
122 assert(sizes.size() == 4);
123 tflite::SliceParams op_params{};
124 op_params.begin_count = 4;
125 op_params.size_count = 4;
126 for (
int i = 0; i < 4; i++)
128 op_params.begin[i] = begins[3 - i];
129 op_params.size[i] = sizes[3 - i];
131 switch (
input()->element_type())
133 case DataType::FLOAT32:
140 getTensorData<uint8_t>(
output()));
145 getTensorData<int8_t>(
output()));
148 throw std::runtime_error(
"Unsupported input type.");