50 bool index_on_padding(
false);
51 for (
const Index &ind : out_range)
53 index_on_padding =
false;
55 for (int32_t i = 0; i < rank; i++)
58 if (ind.at(i) >= padding_before[i] && ind.at(i) < out_shape.
dim(i) - padding_after[i])
60 temp_index.
at(i) = ind.at(i) - padding_before[i];
64 index_on_padding =
true;
74 result_accessor.
at(ind) = input.at(temp_index);
81 dispatch<PadImpl>(input.getElementType(), input, op, result);
Index & resize(int32_t size)
resize index to given dimension number
int32_t & at(int32_t axis)
return position on given axis
const Shape & getInputShape(std::size_t index) const
int32_t & dim(int32_t axis) noexcept
const Shape & getShape() const
T at(const Index &id) const
float getPaddingValue() const
const std::vector< std::int32_t > & getPaddingBefore() const
const std::vector< std::int32_t > & getPaddingAfter() const
void Pad(const mir::TensorVariant &input, const mir::ops::PadOp &op, mir::TensorVariant &result)
Implements PadOp for interpreter backend.
static void run(const mir::TensorVariant &inputv, const mir::ops::PadOp &op, mir::TensorVariant &result)