1 // clang-format off
2 // Generated file (from: depthwise_conv2d_float_2_relaxed.mod.py). Do not edit
CreateModel(Model * model)3 void CreateModel(Model *model) {
4 OperandType type0(Type::TENSOR_FLOAT32, {1, 3, 2, 2});
5 OperandType type1(Type::TENSOR_FLOAT32, {1, 2, 2, 4});
6 OperandType type2(Type::TENSOR_FLOAT32, {4});
7 OperandType type3(Type::INT32, {});
8 OperandType type4(Type::TENSOR_FLOAT32, {1, 2, 1, 4});
9 // Phase 1, operands
10 auto op1 = model->addOperand(&type0);
11 auto op2 = model->addOperand(&type1);
12 auto op3 = model->addOperand(&type2);
13 auto pad_valid = model->addOperand(&type3);
14 auto stride = model->addOperand(&type3);
15 auto channelMultiplier = model->addOperand(&type3);
16 auto act_none = model->addOperand(&type3);
17 auto op4 = model->addOperand(&type4);
18 // Phase 2, operations
19 static float op2_init[] = {1.0f, 2.0f, 3.0f, 4.0f, -9.0f, 10.0f, -11.0f, 12.0f, 5.0f, 6.0f, 7.0f, 8.0f, 13.0f, -14.0f, 15.0f, -16.0f};
20 model->setOperandValue(op2, op2_init, sizeof(float) * 16);
21 static float op3_init[] = {1.0f, 2.0f, 3.0f, 4.0f};
22 model->setOperandValue(op3, op3_init, sizeof(float) * 4);
23 static int32_t pad_valid_init[] = {2};
24 model->setOperandValue(pad_valid, pad_valid_init, sizeof(int32_t) * 1);
25 static int32_t stride_init[] = {1};
26 model->setOperandValue(stride, stride_init, sizeof(int32_t) * 1);
27 static int32_t channelMultiplier_init[] = {2};
28 model->setOperandValue(channelMultiplier, channelMultiplier_init, sizeof(int32_t) * 1);
29 static int32_t act_none_init[] = {0};
30 model->setOperandValue(act_none, act_none_init, sizeof(int32_t) * 1);
31 model->addOperation(ANEURALNETWORKS_DEPTHWISE_CONV_2D, {op1, op2, op3, pad_valid, stride, stride, channelMultiplier, act_none}, {op4});
32 // Phase 3, inputs and outputs
33 model->identifyInputsAndOutputs(
34 {op1},
35 {op4});
36 // Phase 4: set relaxed execution
37 model->relaxComputationFloat32toFloat16(true);
38 assert(model->isValid());
39 }
40
is_ignored(int i)41 inline bool is_ignored(int i) {
42 static std::set<int> ignore = {};
43 return ignore.find(i) != ignore.end();
44 }
45
CreateModel_dynamic_output_shape(Model * model)46 void CreateModel_dynamic_output_shape(Model *model) {
47 OperandType type0(Type::TENSOR_FLOAT32, {1, 3, 2, 2});
48 OperandType type1(Type::TENSOR_FLOAT32, {1, 2, 2, 4});
49 OperandType type2(Type::TENSOR_FLOAT32, {4});
50 OperandType type3(Type::INT32, {});
51 OperandType type5(Type::TENSOR_FLOAT32, {0, 0, 0, 0});
52 // Phase 1, operands
53 auto op1 = model->addOperand(&type0);
54 auto op2 = model->addOperand(&type1);
55 auto op3 = model->addOperand(&type2);
56 auto pad_valid = model->addOperand(&type3);
57 auto stride = model->addOperand(&type3);
58 auto channelMultiplier = model->addOperand(&type3);
59 auto act_none = model->addOperand(&type3);
60 auto op4 = model->addOperand(&type5);
61 // Phase 2, operations
62 static float op2_init[] = {1.0f, 2.0f, 3.0f, 4.0f, -9.0f, 10.0f, -11.0f, 12.0f, 5.0f, 6.0f, 7.0f, 8.0f, 13.0f, -14.0f, 15.0f, -16.0f};
63 model->setOperandValue(op2, op2_init, sizeof(float) * 16);
64 static float op3_init[] = {1.0f, 2.0f, 3.0f, 4.0f};
65 model->setOperandValue(op3, op3_init, sizeof(float) * 4);
66 static int32_t pad_valid_init[] = {2};
67 model->setOperandValue(pad_valid, pad_valid_init, sizeof(int32_t) * 1);
68 static int32_t stride_init[] = {1};
69 model->setOperandValue(stride, stride_init, sizeof(int32_t) * 1);
70 static int32_t channelMultiplier_init[] = {2};
71 model->setOperandValue(channelMultiplier, channelMultiplier_init, sizeof(int32_t) * 1);
72 static int32_t act_none_init[] = {0};
73 model->setOperandValue(act_none, act_none_init, sizeof(int32_t) * 1);
74 model->addOperation(ANEURALNETWORKS_DEPTHWISE_CONV_2D, {op1, op2, op3, pad_valid, stride, stride, channelMultiplier, act_none}, {op4});
75 // Phase 3, inputs and outputs
76 model->identifyInputsAndOutputs(
77 {op1},
78 {op4});
79 // Phase 4: set relaxed execution
80 model->relaxComputationFloat32toFloat16(true);
81 assert(model->isValid());
82 }
83
is_ignored_dynamic_output_shape(int i)84 inline bool is_ignored_dynamic_output_shape(int i) {
85 static std::set<int> ignore = {};
86 return ignore.find(i) != ignore.end();
87 }
88
89