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

description of softmax operation. More...

#include <SoftmaxOp.h>

Collaboration diagram for mir::ops::SoftmaxOp:

Public Member Functions

 SoftmaxOp (Output *arg, int32_t axis)
 
OperationcopyWithInputs (const std::vector< Output * > &inputs) override
 
int32_t getAxis () const
 
- 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

description of softmax operation.

Definition at line 30 of file SoftmaxOp.h.

Constructor & Destructor Documentation

◆ SoftmaxOp()

mir::ops::SoftmaxOp::SoftmaxOp ( Output arg,
int32_t  axis 
)
inline

Definition at line 33 of file SoftmaxOp.h.

33 : Operation(Type::softmax, {arg}), _axis(axis)
34 {
35 setOutputType(0, {arg->getElementType(), arg->getShape()});
36 }
void setOutputType(std::size_t index, const TensorType &type)
Definition Operation.h:172

Member Function Documentation

◆ copyWithInputs()

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

Implements mir::Operation.

Definition at line 38 of file SoftmaxOp.h.

39 {
40 return new SoftmaxOp(inputs[0], _axis);
41 }
SoftmaxOp(Output *arg, int32_t axis)
Definition SoftmaxOp.h:33

◆ getAxis()

int32_t mir::ops::SoftmaxOp::getAxis ( ) const
inline

Definition at line 43 of file SoftmaxOp.h.

44 {
45 if (_axis < 0)
46 {
47 // Negative axis is used to index starting from the last element of the shape
48 // -1 means last element, -2 means second from end, like in python
49 int32_t res = _axis + getInputShape(0).rank();
50 assert(res >= 0);
51 return res;
52 }
53 return _axis;
54 }
const Shape & getInputShape(std::size_t index) const
Definition Operation.h:161
int32_t rank() const
Definition Shape.h:43

References mir::Operation::getInputShape(), and mir::Shape::rank().

Referenced by TEST(), mir_interpreter::MIRInterpreter::visit(), mir2loco::Transformer::visit(), nnc::AclCppOpGenerator::visit(), nnc::Serializer::visit(), and mir::DotNodeBuilder::visit().


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