CreateModel(Model * model)1 void CreateModel(Model *model) {
2 OperandType type0(Type::INT32, {1});
3 OperandType type2(Type::TENSOR_FLOAT32, {1, 1, 1, 3});
4 OperandType type1(Type::TENSOR_FLOAT32, {1, 8, 8, 3});
5 OperandType type3(Type::TENSOR_FLOAT32, {3});
6 // Phase 1, operands
7 auto pad0 = model->addOperand(&type0);
8 auto b5 = model->addOperand(&type0);
9 auto b6 = model->addOperand(&type0);
10 auto b7 = model->addOperand(&type0);
11 auto b8 = model->addOperand(&type0);
12 auto op2 = model->addOperand(&type1);
13 auto op3 = model->addOperand(&type1);
14 auto op0 = model->addOperand(&type2);
15 auto op1 = model->addOperand(&type3);
16 // Phase 2, operations
17 int32_t pad0_init[] = {0};
18 model->setOperandValue(pad0, pad0_init, sizeof(int32_t) * 1);
19 int32_t b5_init[] = {1};
20 model->setOperandValue(b5, b5_init, sizeof(int32_t) * 1);
21 int32_t b6_init[] = {1};
22 model->setOperandValue(b6, b6_init, sizeof(int32_t) * 1);
23 int32_t b7_init[] = {1};
24 model->setOperandValue(b7, b7_init, sizeof(int32_t) * 1);
25 int32_t b8_init[] = {0};
26 model->setOperandValue(b8, b8_init, sizeof(int32_t) * 1);
27 float op0_init[] = {-0.966213, -0.467474, -0.82203};
28 model->setOperandValue(op0, op0_init, sizeof(float) * 3);
29 float op1_init[] = {0, 0, 0};
30 model->setOperandValue(op1, op1_init, sizeof(float) * 3);
31 model->addOperation(ANEURALNETWORKS_DEPTHWISE_CONV_2D, {op2, op0, op1, pad0, pad0, pad0, pad0, b5, b6, b7, b8}, {op3});
32 // Phase 3, inputs and outputs
33 model->identifyInputsAndOutputs(
34 {op2},
35 {op3});
36 assert(model->isValid());
37 }
38