40 for (
int idx = 0;
idx < input->shape().num_dims();
idx++)
47 throw std::runtime_error(
"Invalid size.");
55 throw std::runtime_error(
"Invalid begin and size.");
65 std::vector<int> *
begins, std::vector<int> *sizes)
67 for (
int idx = dimensions - 1;
idx >= 0; --
idx)
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.");
101 std::vector<int> sizes;
103 if (
begin()->element_type() == DataType::S32)
107 else if (
begin()->element_type() == DataType::S64)
113 throw std::runtime_error(
"Unsupported begin type.");
121 assert(
begins.size() == 4);
122 assert(sizes.size() == 4);
126 for (
int i = 0;
i < 4;
i++)
131 switch (
input()->element_type())
133 case DataType::FLOAT32:
148 throw std::runtime_error(
"Unsupported input type.");
void resize(const Shape &new_shape)
const Tensor * begin() const
void configure() override
Slice(const Tensor *input, const Tensor *begin, const Tensor *size, Tensor *output)
const Tensor * input() const
void execute() const override
const Tensor * size() const
const luci_interpreter::RuntimeShape output_shape
Shape calculateOutputShape(const Tensor *input, const Tensor *begin, const Tensor *size)
tflite::RuntimeShape getTensorShape(const Tensor *tensor)
void getBeginAndSizeVectors(int dimensions, const Tensor *begin, const Tensor *size, std::vector< int > *begins, std::vector< int > *sizes)
T must_cast(loco::Node *node)