39 const int num_dims = input_shape.
num_dims();
42 throw std::runtime_error(
"Unsupported number of dimensions.");
44 assert(
output()->element_type() ==
input()->element_type());
45 assert(
paddings()->element_type() == DataType::S32);
48 assert(
paddings()->shape().num_dims() == 2);
49 assert(
paddings()->shape().dim(0) == num_dims);
50 assert(
paddings()->shape().dim(1) == 2);
55 const auto *paddings_data = getTensorData<int32_t>(
paddings());
56 for (
int i = 0; i < num_dims; ++i)
58 const int32_t padding_before = paddings_data[i * 2];
59 const int32_t padding_after = paddings_data[i * 2 + 1];
60 assert(padding_before >= 0 && padding_after >= 0);
61 output_shape.dim(i) = input_shape.
dim(i) + padding_before + padding_after;
71 tflite::PadParams params{};
72 params.left_padding_count = num_dims;
73 params.right_padding_count = num_dims;
75 const auto *paddings_data = getTensorData<int32_t>(
paddings());
76 for (
int i = num_dims - 1; i >= 0; --i)
78 params.left_padding[i] = paddings_data[i * 2];
79 params.right_padding[i] = paddings_data[i * 2 + 1];
82 switch (
input()->element_type())
84 case DataType::FLOAT32:
89 getTensorData<float>(
output()));
94 assert(
output()->zero_point() >= std::numeric_limits<uint8_t>::min());
95 assert(
output()->zero_point() <= std::numeric_limits<uint8_t>::max());
99 getTensorData<uint8_t>(
output()));
103 throw std::runtime_error(
"luci-intp PadV2 Unsupported type.");