ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Operation.cpp File Reference
#include "mir/Operation.h"
#include "mir/ops/ConcatOp.h"
#include "mir/ops/InputOp.h"
#include "mir/ops/ReshapeOp.h"
#include "mir/ops/SoftmaxOp.h"
#include <gtest/gtest.h>
#include "mir/Operations.inc"

Go to the source code of this file.

Macros

#define HANDLE_OP(OpType, OpClass)   ASSERT_EQ(getTypeName(Operation::Type::OpType), #OpType);
 

Functions

 TEST (Operation, ConnectionTest)
 
 TEST (Operation, InputOutputShapeTest)
 
 TEST (Operation, SoftmaxAxisTest)
 
 TEST (Operation, ConcatAxisTest)
 
 TEST (Operation, OpNameTest)
 

Macro Definition Documentation

◆ HANDLE_OP

#define HANDLE_OP (   OpType,
  OpClass 
)    ASSERT_EQ(getTypeName(Operation::Type::OpType), #OpType);

Function Documentation

◆ TEST() [1/5]

TEST ( Operation  ,
ConcatAxisTest   
)

Definition at line 71 of file Operation.cpp.

72{
73 Shape in_shape{1, 2, 3};
74
75 mir::TensorType in_type{mir::DataType::FLOAT32, in_shape};
76 ops::InputOp input1(in_type), input2(in_type);
77
78 ops::ConcatOp op_1({input1.getOutput(0), input2.getOutput(0)}, 1);
79 ASSERT_EQ(op_1.getAxis(), 1);
80
81 ops::ConcatOp op_n1({input1.getOutput(0), input2.getOutput(0)}, -1);
82 ASSERT_EQ(op_n1.getAxis(), 2);
83
84 ops::ConcatOp op_n3({input1.getOutput(0), input2.getOutput(0)}, -3);
85 ASSERT_EQ(op_n3.getAxis(), 0);
86}
Description of tensor concatenation operation.
Definition ConcatOp.h:31
Definition Shape.h:28

References mir::Operation::getOutput().

◆ TEST() [2/5]

TEST ( Operation  ,
ConnectionTest   
)

Definition at line 27 of file Operation.cpp.

28{
29
30 mir::TensorType input_type{mir::DataType::FLOAT32, Shape{}};
31 auto op1 = new ops::InputOp(input_type);
32 op1->setId(0);
33 auto op2 = new ops::ReshapeOp(op1->getOutput(0), Shape{});
34 op2->setId(1);
35
36 ASSERT_EQ(op1, op2->getInput(0)->getNode());
37
38 delete op1;
39 delete op2;
40}

◆ TEST() [3/5]

TEST ( Operation  ,
InputOutputShapeTest   
)

Definition at line 42 of file Operation.cpp.

43{
44 Shape input_shape{1, 2, 3};
45
46 mir::TensorType input_type{mir::DataType::FLOAT32, input_shape};
47 ops::InputOp input(input_type);
48 ops::SoftmaxOp op(input.getOutput(0), 0);
49
50 ASSERT_EQ(input_shape, input.getOutputShape(0));
51 ASSERT_EQ(input_shape, op.getInputShape(0));
52}
description of softmax operation.
Definition SoftmaxOp.h:31

References mir::Operation::getInputShape().

◆ TEST() [4/5]

TEST ( Operation  ,
OpNameTest   
)

Definition at line 88 of file Operation.cpp.

89{
90#define HANDLE_OP(OpType, OpClass) ASSERT_EQ(getTypeName(Operation::Type::OpType), #OpType);
91#include "mir/Operations.inc"
92#undef HANDLE_OP
93}

◆ TEST() [5/5]

TEST ( Operation  ,
SoftmaxAxisTest   
)

Definition at line 54 of file Operation.cpp.

55{
56 Shape input_shape{1, 2, 3};
57
58 mir::TensorType input_type{mir::DataType::FLOAT32, input_shape};
59 ops::InputOp input(input_type);
60
61 ops::SoftmaxOp op_1(input.getOutput(0), 1);
62 ASSERT_EQ(op_1.getAxis(), 1);
63
64 ops::SoftmaxOp op_n1(input.getOutput(0), -1);
65 ASSERT_EQ(op_n1.getAxis(), 2);
66
67 ops::SoftmaxOp op_n3(input.getOutput(0), -3);
68 ASSERT_EQ(op_n3.getAxis(), 0);
69}

References mir::ops::SoftmaxOp::getAxis().