ONE - On-device Neural Engine
Loading...
Searching...
No Matches
mir::ops::ReshapeOp Class Reference

#include <ReshapeOp.h>

Collaboration diagram for mir::ops::ReshapeOp:

Public Member Functions

 ReshapeOp (Output *arg, const Shape &shape)
 
OperationcopyWithInputs (const std::vector< Output * > &inputs) override
 
- Public Member Functions inherited from mir::Operation
virtual ~Operation ()=default
 
Type getType () const
 
std::size_t getId () const
 
void setId (std::size_t id)
 
std::size_t getNumInputs () const
 
std::size_t getNumOutputs () const
 
std::deque< Output * > & getInputs ()
 
const std::deque< Output * > & getInputs () const
 
std::deque< Output > & getOutputs ()
 
const std::deque< Output > & getOutputs () const
 
OutputgetInput (std::size_t index)
 
const OutputgetInput (std::size_t index) const
 
OutputgetOutput (std::size_t index)
 
const OutputgetOutput (std::size_t index) const
 
const ShapegetInputShape (std::size_t index) const
 
const ShapegetOutputShape (std::size_t index) const
 
void accept (IVisitor *v)
 

Additional Inherited Members

- Public Types inherited from mir::Operation
enum class  Type { HANDLE_OP }
 
- Protected Member Functions inherited from mir::Operation
 Operation (Type type, const std::vector< Output * > &inputs, std::size_t num_outputs=1)
 
void setOutputType (std::size_t index, const TensorType &type)
 

Detailed Description

Definition at line 27 of file ReshapeOp.h.

Constructor & Destructor Documentation

◆ ReshapeOp()

mir::ops::ReshapeOp::ReshapeOp ( Output arg,
const Shape shape 
)
inline

Definition at line 30 of file ReshapeOp.h.

30 : Operation(Type::reshape, {arg})
31 {
32 const Shape &input_shape = getInputShape(0);
33 auto output_shape = shape;
34
35 auto in_elements_num = input_shape.numElements();
36 int32_t out_elements_num = 1;
37 // Can't use num_elements due to -1 in input shape and Shape using unsigned ints for dimensions.
38 for (int32_t d = 0; d < output_shape.rank(); ++d)
39 {
40 auto dim = output_shape.dim(d);
41 if (dim != Shape::autoDim)
42 out_elements_num *= dim;
43 }
44
45 for (int32_t d = 0; d < output_shape.rank(); ++d)
46 {
47 auto &dim = output_shape.dim(d);
48 if (dim == Shape::autoDim)
49 dim = static_cast<int32_t>(in_elements_num / out_elements_num);
50 }
51
52 setOutputType(0, {arg->getElementType(), output_shape});
53 }
const Shape & getInputShape(std::size_t index) const
Definition Operation.h:161
void setOutputType(std::size_t index, const TensorType &type)
Definition Operation.h:172
const luci_interpreter::RuntimeShape output_shape
Definition Shape.h:28

Member Function Documentation

◆ copyWithInputs()

Operation * mir::ops::ReshapeOp::copyWithInputs ( const std::vector< Output * > &  inputs)
inlineoverridevirtual

Implements mir::Operation.

Definition at line 55 of file ReshapeOp.h.

56 {
57 return new ReshapeOp(inputs[0], getOutputShape(0));
58 }
const Shape & getOutputShape(std::size_t index) const
Definition Operation.h:163
ReshapeOp(Output *arg, const Shape &shape)
Definition ReshapeOp.h:30

References mir::Operation::getOutputShape().


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