ONE - On-device Neural Engine
Loading...
Searching...
No Matches
mir_interpreter::TransposeImpl< T > Struct Template Reference

Static Public Member Functions

static void run (const mir::TensorVariant &input, const mir::ops::TransposeOp &op, mir::TensorVariant &output)
 

Detailed Description

template<typename T>
struct mir_interpreter::TransposeImpl< T >

Definition at line 27 of file Transpose.cpp.

Member Function Documentation

◆ run()

template<typename T >
void mir_interpreter::TransposeImpl< T >::run ( const mir::TensorVariant input,
const mir::ops::TransposeOp op,
mir::TensorVariant output 
)
static

Definition at line 34 of file Transpose.cpp.

36{
37 const auto &output_shape = op.getOutputShape(0);
38 const auto &axis_order = op.getAxisOrder();
39 const int32_t num_axis = static_cast<int32_t>(axis_order.size());
40 assert(num_axis == inputv.getShape().rank());
41 assert(num_axis == output_shape.rank());
42
43 mir::Index output_index;
44 output_index.resize(num_axis);
45
46 mir::Tensor<T> input(inputv);
47 mir::Tensor<T> output(outputv);
48
49 for (auto &input_index : mir::ShapeRange(input.getShape()))
50 {
51 for (int32_t i = 0; i < num_axis; i++)
52 output_index.at(i) = input_index.at(axis_order[i]);
53
54 output.at(output_index) = input.at(input_index);
55 }
56}
Index & resize(int32_t size)
resize index to given dimension number
Definition Index.cpp:24
int32_t & at(int32_t axis)
return position on given axis
Definition Index.h:64
const Shape & getOutputShape(std::size_t index) const
Definition Operation.h:163
const std::vector< std::size_t > & getAxisOrder() const
Definition TransposeOp.h:38
const luci_interpreter::RuntimeShape output_shape
nnfw::cker::Shape getShape(const IPortableTensor *tensor)

References mir::Index::at(), mir::ops::TransposeOp::getAxisOrder(), mir::Operation::getOutputShape(), mir::TensorVariant::getShape(), output_shape, mir::Shape::rank(), and mir::Index::resize().

Referenced by package.infer.session::inference().


The documentation for this struct was generated from the following file: