// Generated file (from: depthwise_conv2d_quant8.mod.py). Do not edit void CreateModel(Model *model) { OperandType type2(Type::INT32, {}); OperandType type1(Type::TENSOR_INT32, {2}, 0.25f, 0); OperandType type0(Type::TENSOR_QUANT8_ASYMM, {1, 2, 2, 2}, 0.5f, 0); OperandType type3(Type::TENSOR_QUANT8_ASYMM, {1,1,1,2}, 1.f, 0); // Phase 1, operands auto op1 = model->addOperand(&type0); auto op2 = model->addOperand(&type0); auto op3 = model->addOperand(&type1); auto pad0 = model->addOperand(&type2); auto act = model->addOperand(&type2); auto stride = model->addOperand(&type2); auto channelMultiplier = model->addOperand(&type2); auto op4 = model->addOperand(&type3); // Phase 2, operations static uint8_t op2_init[] = {2, 4, 2, 0, 2, 2, 2, 0}; model->setOperandValue(op2, op2_init, sizeof(uint8_t) * 8); static int32_t op3_init[] = {0, 0}; model->setOperandValue(op3, op3_init, sizeof(int32_t) * 2); static int32_t pad0_init[] = {0}; model->setOperandValue(pad0, pad0_init, sizeof(int32_t) * 1); static int32_t act_init[] = {0}; model->setOperandValue(act, act_init, sizeof(int32_t) * 1); static int32_t stride_init[] = {1}; model->setOperandValue(stride, stride_init, sizeof(int32_t) * 1); static int32_t channelMultiplier_init[] = {1}; model->setOperandValue(channelMultiplier, channelMultiplier_init, sizeof(int32_t) * 1); model->addOperation(ANEURALNETWORKS_DEPTHWISE_CONV_2D, {op1, op2, op3, pad0, pad0, pad0, pad0, stride, stride, channelMultiplier, act}, {op4}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {op1}, {op4}); assert(model->isValid()); }
// Generated file (from: depthwise_conv2d_quant8_2.mod.py). Do not edit void CreateModel(Model *model) { OperandType type3(Type::INT32, {}); OperandType type2(Type::TENSOR_INT32, {4}, 0.25f, 0); OperandType type4(Type::TENSOR_QUANT8_ASYMM, {1, 2, 1, 4}, 1.f, 127); OperandType type1(Type::TENSOR_QUANT8_ASYMM, {1, 2, 2, 4}, 0.5f, 127); OperandType type0(Type::TENSOR_QUANT8_ASYMM, {1, 3, 2, 2}, 0.5f, 127); // Phase 1, operands auto op1 = model->addOperand(&type0); auto op2 = model->addOperand(&type1); auto op3 = model->addOperand(&type2); auto pad_valid = model->addOperand(&type3); auto act_none = model->addOperand(&type3); auto stride = model->addOperand(&type3); auto channelMultiplier = model->addOperand(&type3); auto op4 = model->addOperand(&type4); // Phase 2, operations static uint8_t op2_init[] = {129, 131, 133, 135, 109, 147, 105, 151, 137, 139, 141, 143, 153, 99, 157, 95}; model->setOperandValue(op2, op2_init, sizeof(uint8_t) * 16); static int32_t op3_init[] = {4, 8, 12, 16}; model->setOperandValue(op3, op3_init, sizeof(int32_t) * 4); static int32_t pad_valid_init[] = {2}; model->setOperandValue(pad_valid, pad_valid_init, sizeof(int32_t) * 1); static int32_t act_none_init[] = {0}; model->setOperandValue(act_none, act_none_init, sizeof(int32_t) * 1); static int32_t stride_init[] = {1}; model->setOperandValue(stride, stride_init, sizeof(int32_t) * 1); static int32_t channelMultiplier_init[] = {2}; model->setOperandValue(channelMultiplier, channelMultiplier_init, sizeof(int32_t) * 1); model->addOperation(ANEURALNETWORKS_DEPTHWISE_CONV_2D, {op1, op2, op3, pad_valid, stride, stride, channelMultiplier, act_none}, {op4}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {op1}, {op4}); assert(model->isValid()); }
// Generated file (from: strided_slice_float_11.mod.py). Do not edit void CreateModel(Model *model) { OperandType type2(Type::INT32, {}); OperandType type0(Type::TENSOR_FLOAT32, {2, 3}); OperandType type3(Type::TENSOR_FLOAT32, {3}); OperandType type1(Type::TENSOR_INT32, {2}); // Phase 1, operands auto input = model->addOperand(&type0); auto begins = model->addOperand(&type1); auto ends = model->addOperand(&type1); auto strides = model->addOperand(&type1); auto beginMask = model->addOperand(&type2); auto endMask = model->addOperand(&type2); auto shrinkAxisMask = model->addOperand(&type2); auto output = model->addOperand(&type3); // Phase 2, operations static int32_t begins_init[] = {0, 0}; model->setOperandValue(begins, begins_init, sizeof(int32_t) * 2); static int32_t ends_init[] = {2, 3}; model->setOperandValue(ends, ends_init, sizeof(int32_t) * 2); static int32_t strides_init[] = {1, 1}; model->setOperandValue(strides, strides_init, sizeof(int32_t) * 2); static int32_t beginMask_init[] = {0}; model->setOperandValue(beginMask, beginMask_init, sizeof(int32_t) * 1); static int32_t endMask_init[] = {0}; model->setOperandValue(endMask, endMask_init, sizeof(int32_t) * 1); static int32_t shrinkAxisMask_init[] = {1}; model->setOperandValue(shrinkAxisMask, shrinkAxisMask_init, sizeof(int32_t) * 1); model->addOperation(ANEURALNETWORKS_STRIDED_SLICE, {input, begins, ends, strides, beginMask, endMask, shrinkAxisMask}, {output}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {input}, {output}); assert(model->isValid()); }
// Generated file (from: conv_3_h3_w2_SAME.mod.py). Do not edit void CreateModel(Model *model) { OperandType type0(Type::INT32, {}); OperandType type1(Type::TENSOR_FLOAT32, {1, 8, 8, 3}); OperandType type2(Type::TENSOR_FLOAT32, {3, 3, 2, 3}); OperandType type3(Type::TENSOR_FLOAT32, {3}); // Phase 1, operands auto b4 = model->addOperand(&type0); auto b5 = model->addOperand(&type0); auto b6 = model->addOperand(&type0); auto b7 = model->addOperand(&type0); auto op2 = model->addOperand(&type1); auto op3 = model->addOperand(&type1); auto op0 = model->addOperand(&type2); auto op1 = model->addOperand(&type3); // Phase 2, operations static int32_t b4_init[] = {1}; model->setOperandValue(b4, b4_init, sizeof(int32_t) * 1); static int32_t b5_init[] = {1}; model->setOperandValue(b5, b5_init, sizeof(int32_t) * 1); static int32_t b6_init[] = {1}; model->setOperandValue(b6, b6_init, sizeof(int32_t) * 1); static int32_t b7_init[] = {0}; model->setOperandValue(b7, b7_init, sizeof(int32_t) * 1); static float op0_init[] = {-0.966213f, -0.579455f, -0.684259f, 0.738216f, 0.184325f, 0.0973683f, -0.176863f, -0.23936f, -0.000233404f, 0.055546f, -0.232658f, -0.316404f, -0.012904f, 0.320705f, -0.326657f, -0.919674f, 0.868081f, -0.824608f, -0.467474f, 0.0278809f, 0.563238f, 0.386045f, -0.270568f, -0.941308f, -0.779227f, -0.261492f, -0.774804f, -0.79665f, 0.22473f, -0.414312f, 0.685897f, -0.327792f, 0.77395f, -0.714578f, -0.972365f, 0.0696099f, -0.82203f, -0.79946f, 0.37289f, -0.917775f, 0.82236f, -0.144706f, -0.167188f, 0.268062f, 0.702641f, -0.412223f, 0.755759f, 0.721547f, -0.43637f, -0.274905f, -0.269165f, 0.16102f, 0.819857f, -0.312008f}; model->setOperandValue(op0, op0_init, sizeof(float) * 54); static float op1_init[] = {0.0f, 0.0f, 0.0f}; model->setOperandValue(op1, op1_init, sizeof(float) * 3); model->addOperation(ANEURALNETWORKS_CONV_2D, {op2, op0, op1, b4, b5, b6, b7}, {op3}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {op2}, {op3}); assert(model->isValid()); }
// Generated file (from: conv_quant8_large_weights_as_inputs.mod.py). Do not edit void CreateModel(Model *model) { OperandType type3(Type::INT32, {}); OperandType type2(Type::TENSOR_INT32, {3}, 0.25, 0); OperandType type0(Type::TENSOR_QUANT8_ASYMM, {1, 2, 3, 3}, 0.5, 0); OperandType type4(Type::TENSOR_QUANT8_ASYMM, {1, 2, 3, 3}, 1.0, 0); OperandType type1(Type::TENSOR_QUANT8_ASYMM, {3, 1, 1, 3}, 0.5, 0); // Phase 1, operands auto op1 = model->addOperand(&type0); auto op2 = model->addOperand(&type1); auto op3 = model->addOperand(&type2); auto pad0 = model->addOperand(&type3); auto act = model->addOperand(&type3); auto stride = model->addOperand(&type3); auto op4 = model->addOperand(&type4); // Phase 2, operations static int32_t pad0_init[] = {0}; model->setOperandValue(pad0, pad0_init, sizeof(int32_t) * 1); static int32_t act_init[] = {0}; model->setOperandValue(act, act_init, sizeof(int32_t) * 1); static int32_t stride_init[] = {1}; model->setOperandValue(stride, stride_init, sizeof(int32_t) * 1); model->addOperation(ANEURALNETWORKS_CONV_2D, {op1, op2, op3, pad0, pad0, pad0, pad0, stride, stride, act}, {op4}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {op1, op2, op3}, {op4}); assert(model->isValid()); }
// Generated file (from: rnn_state_relaxed.mod.py). Do not edit void CreateModel(Model *model) { OperandType type5(Type::INT32, {}); OperandType type2(Type::TENSOR_FLOAT32, {16, 16}); OperandType type1(Type::TENSOR_FLOAT32, {16, 8}); OperandType type3(Type::TENSOR_FLOAT32, {16}); OperandType type4(Type::TENSOR_FLOAT32, {2, 16}); OperandType type0(Type::TENSOR_FLOAT32, {2, 8}); // Phase 1, operands auto input = model->addOperand(&type0); auto weights = model->addOperand(&type1); auto recurrent_weights = model->addOperand(&type2); auto bias = model->addOperand(&type3); auto hidden_state_in = model->addOperand(&type4); auto activation_param = model->addOperand(&type5); auto hidden_state_out = model->addOperand(&type4); auto output = model->addOperand(&type4); // Phase 2, operations static int32_t activation_param_init[] = {1}; model->setOperandValue(activation_param, activation_param_init, sizeof(int32_t) * 1); model->addOperation(ANEURALNETWORKS_RNN, {input, weights, recurrent_weights, bias, hidden_state_in, activation_param}, {hidden_state_out, output}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {input, weights, recurrent_weights, bias, hidden_state_in}, {hidden_state_out, output}); // Phase 4: set relaxed execution model->relaxComputationFloat32toFloat16(true); assert(model->isValid()); }
// Generated file (from: fully_connected_float_large.mod.py). Do not edit void CreateModel(Model *model) { OperandType type3(Type::INT32, {}); OperandType type2(Type::TENSOR_FLOAT32, {1, 1}); OperandType type0(Type::TENSOR_FLOAT32, {1, 5}); OperandType type1(Type::TENSOR_FLOAT32, {1}); // Phase 1, operands auto op1 = model->addOperand(&type0); auto op2 = model->addOperand(&type0); auto b0 = model->addOperand(&type1); auto op3 = model->addOperand(&type2); auto act = model->addOperand(&type3); // Phase 2, operations static float op2_init[] = {2.0f, 3.0f, 4.0f, 5.0f, 6.0f}; model->setOperandValue(op2, op2_init, sizeof(float) * 5); static float b0_init[] = {900000.0f}; model->setOperandValue(b0, b0_init, sizeof(float) * 1); static int32_t act_init[] = {0}; model->setOperandValue(act, act_init, sizeof(int32_t) * 1); model->addOperation(ANEURALNETWORKS_FULLY_CONNECTED, {op1, op2, b0, act}, {op3}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {op1}, {op3}); assert(model->isValid()); }
// Generated file (from: conv_1_h3_w2_SAME.mod.py). Do not edit void CreateModel(Model *model) { OperandType type0(Type::INT32, {}); OperandType type3(Type::TENSOR_FLOAT32, {1, 3, 2, 3}); OperandType type2(Type::TENSOR_FLOAT32, {1, 8, 8, 1}); OperandType type1(Type::TENSOR_FLOAT32, {1, 8, 8, 3}); OperandType type4(Type::TENSOR_FLOAT32, {1}); // Phase 1, operands auto b4 = model->addOperand(&type0); auto b5 = model->addOperand(&type0); auto b6 = model->addOperand(&type0); auto b7 = model->addOperand(&type0); auto op2 = model->addOperand(&type1); auto op3 = model->addOperand(&type2); auto op0 = model->addOperand(&type3); auto op1 = model->addOperand(&type4); // Phase 2, operations static int32_t b4_init[] = {1}; model->setOperandValue(b4, b4_init, sizeof(int32_t) * 1); static int32_t b5_init[] = {1}; model->setOperandValue(b5, b5_init, sizeof(int32_t) * 1); static int32_t b6_init[] = {1}; model->setOperandValue(b6, b6_init, sizeof(int32_t) * 1); static int32_t b7_init[] = {0}; model->setOperandValue(b7, b7_init, sizeof(int32_t) * 1); static float op0_init[] = {-0.966213f, -0.467474f, -0.82203f, -0.579455f, 0.0278809f, -0.79946f, -0.684259f, 0.563238f, 0.37289f, 0.738216f, 0.386045f, -0.917775f, 0.184325f, -0.270568f, 0.82236f, 0.0973683f, -0.941308f, -0.144706f}; model->setOperandValue(op0, op0_init, sizeof(float) * 18); static float op1_init[] = {0.0f}; model->setOperandValue(op1, op1_init, sizeof(float) * 1); model->addOperation(ANEURALNETWORKS_CONV_2D, {op2, op0, op1, b4, b5, b6, b7}, {op3}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {op2}, {op3}); assert(model->isValid()); }
// Generated file (from: svdf_state.mod.py). Do not edit void CreateModel(Model *model) { OperandType type5(Type::INT32, {}); OperandType type0(Type::TENSOR_FLOAT32, {2, 3}); OperandType type4(Type::TENSOR_FLOAT32, {2, 40}); OperandType type6(Type::TENSOR_FLOAT32, {2, 4}); OperandType type2(Type::TENSOR_FLOAT32, {4, 10}); OperandType type1(Type::TENSOR_FLOAT32, {4, 3}); OperandType type3(Type::TENSOR_FLOAT32, {4}); // Phase 1, operands auto input = model->addOperand(&type0); auto weights_feature = model->addOperand(&type1); auto weights_time = model->addOperand(&type2); auto bias = model->addOperand(&type3); auto state_in = model->addOperand(&type4); auto rank_param = model->addOperand(&type5); auto activation_param = model->addOperand(&type5); auto state_out = model->addOperand(&type4); auto output = model->addOperand(&type6); // Phase 2, operations static int32_t rank_param_init[] = {1}; model->setOperandValue(rank_param, rank_param_init, sizeof(int32_t) * 1); static int32_t activation_param_init[] = {0}; model->setOperandValue(activation_param, activation_param_init, sizeof(int32_t) * 1); model->addOperation(ANEURALNETWORKS_SVDF, {input, weights_feature, weights_time, bias, state_in, rank_param, activation_param}, {state_out, output}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {input, weights_feature, weights_time, bias, state_in}, {state_out, output}); assert(model->isValid()); }
// Generated file (from: fully_connected_quant8_2.mod.py). Do not edit void CreateModel(Model *model) { OperandType type4(Type::INT32, {}); OperandType type2(Type::TENSOR_INT32, {3}, 0.25f, 0); OperandType type3(Type::TENSOR_QUANT8_ASYMM, {2, 3}, 1.f, 127); OperandType type1(Type::TENSOR_QUANT8_ASYMM, {3, 10}, 0.5f, 127); OperandType type0(Type::TENSOR_QUANT8_ASYMM, {4, 1, 5, 1}, 0.5f, 127); // Phase 1, operands auto op1 = model->addOperand(&type0); auto op2 = model->addOperand(&type1); auto b0 = model->addOperand(&type2); auto op3 = model->addOperand(&type3); auto act_relu = model->addOperand(&type4); // Phase 2, operations static uint8_t op2_init[] = {129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147}; model->setOperandValue(op2, op2_init, sizeof(uint8_t) * 30); static int32_t b0_init[] = {4, 8, 12}; model->setOperandValue(b0, b0_init, sizeof(int32_t) * 3); static int32_t act_relu_init[] = {1}; model->setOperandValue(act_relu, act_relu_init, sizeof(int32_t) * 1); model->addOperation(ANEURALNETWORKS_FULLY_CONNECTED, {op1, op2, b0, act_relu}, {op3}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {op1}, {op3}); assert(model->isValid()); }
// Generated file (from: lstm2_relaxed.mod.py). Do not edit void CreateModel(Model *model) { OperandType type8(Type::FLOAT32, {}); OperandType type7(Type::INT32, {}); OperandType type5(Type::TENSOR_FLOAT32, {0,0}); OperandType type3(Type::TENSOR_FLOAT32, {0}); OperandType type9(Type::TENSOR_FLOAT32, {1, 12}); OperandType type0(Type::TENSOR_FLOAT32, {1, 2}); OperandType type6(Type::TENSOR_FLOAT32, {1, 4}); OperandType type1(Type::TENSOR_FLOAT32, {4, 2}); OperandType type2(Type::TENSOR_FLOAT32, {4, 4}); OperandType type4(Type::TENSOR_FLOAT32, {4}); // Phase 1, operands auto input = model->addOperand(&type0); auto input_to_input_weights = model->addOperand(&type1); auto input_to_forget_weights = model->addOperand(&type1); auto input_to_cell_weights = model->addOperand(&type1); auto input_to_output_weights = model->addOperand(&type1); auto recurrent_to_intput_weights = model->addOperand(&type2); auto recurrent_to_forget_weights = model->addOperand(&type2); auto recurrent_to_cell_weights = model->addOperand(&type2); auto recurrent_to_output_weights = model->addOperand(&type2); auto cell_to_input_weights = model->addOperand(&type3); auto cell_to_forget_weights = model->addOperand(&type4); auto cell_to_output_weights = model->addOperand(&type4); auto input_gate_bias = model->addOperand(&type4); auto forget_gate_bias = model->addOperand(&type4); auto cell_gate_bias = model->addOperand(&type4); auto output_gate_bias = model->addOperand(&type4); auto projection_weights = model->addOperand(&type5); auto projection_bias = model->addOperand(&type3); auto output_state_in = model->addOperand(&type6); auto cell_state_in = model->addOperand(&type6); auto activation_param = model->addOperand(&type7); auto cell_clip_param = model->addOperand(&type8); auto proj_clip_param = model->addOperand(&type8); auto scratch_buffer = model->addOperand(&type9); auto output_state_out = model->addOperand(&type6); auto cell_state_out = model->addOperand(&type6); auto output = model->addOperand(&type6); // Phase 2, operations static int32_t activation_param_init[] = {4}; model->setOperandValue(activation_param, activation_param_init, sizeof(int32_t) * 1); static float cell_clip_param_init[] = {0.0f}; model->setOperandValue(cell_clip_param, cell_clip_param_init, sizeof(float) * 1); static float proj_clip_param_init[] = {0.0f}; model->setOperandValue(proj_clip_param, proj_clip_param_init, sizeof(float) * 1); model->addOperation(ANEURALNETWORKS_LSTM, {input, input_to_input_weights, input_to_forget_weights, input_to_cell_weights, input_to_output_weights, recurrent_to_intput_weights, recurrent_to_forget_weights, recurrent_to_cell_weights, recurrent_to_output_weights, cell_to_input_weights, cell_to_forget_weights, cell_to_output_weights, input_gate_bias, forget_gate_bias, cell_gate_bias, output_gate_bias, projection_weights, projection_bias, output_state_in, cell_state_in, activation_param, cell_clip_param, proj_clip_param}, {scratch_buffer, output_state_out, cell_state_out, output}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {input, input_to_input_weights, input_to_forget_weights, input_to_cell_weights, input_to_output_weights, recurrent_to_intput_weights, recurrent_to_forget_weights, recurrent_to_cell_weights, recurrent_to_output_weights, cell_to_input_weights, cell_to_forget_weights, cell_to_output_weights, input_gate_bias, forget_gate_bias, cell_gate_bias, output_gate_bias, projection_weights, projection_bias, output_state_in, cell_state_in}, {scratch_buffer, output_state_out, cell_state_out, output}); // Phase 4: set relaxed execution model->relaxComputationFloat32toFloat16(true); assert(model->isValid()); }
int main() { type1(); printf("\n"); type2(); printf("\n"); type3(); printf("\n"); type4(); printf("\n"); type5(); printf("\n"); rectange_interview(); return 0; }
int area(int type) { int maxh, maxw; switch(type) { /*case 0 : maxw=dane[0].w+dane[1].w+dane[2].w+dane[3].w; maxh=max(dane[0].h,dane[1].h,dane[2].h,dane[3].h); return maxw*maxh;*/ case 0 : return type0(); case 1 : return type1(); case 2 : return type2(); case 3 : return type3(); case 4 : return type4(); } }
// Generated file (from: mul_broadcast_quant8.mod.py). Do not edit void CreateModel(Model *model) { OperandType type2(Type::INT32, {}); OperandType type0(Type::TENSOR_QUANT8_ASYMM, {1, 2}, 1.0, 0); OperandType type1(Type::TENSOR_QUANT8_ASYMM, {2, 2}, 1.0, 0); OperandType type3(Type::TENSOR_QUANT8_ASYMM, {2, 2}, 2.0, 0); // Phase 1, operands auto op1 = model->addOperand(&type0); auto op2 = model->addOperand(&type1); auto act = model->addOperand(&type2); auto op3 = model->addOperand(&type3); // Phase 2, operations static int32_t act_init[] = {0}; model->setOperandValue(act, act_init, sizeof(int32_t) * 1); model->addOperation(ANEURALNETWORKS_MUL, {op1, op2, act}, {op3}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {op1, op2}, {op3}); assert(model->isValid()); }
// Generated file (from: concat_float_2.mod.py). Do not edit void CreateModel(Model *model) { OperandType type2(Type::INT32, {}); OperandType type1(Type::TENSOR_FLOAT32, {40, 230}); OperandType type0(Type::TENSOR_FLOAT32, {52, 230}); OperandType type3(Type::TENSOR_FLOAT32, {92, 230}); // Phase 1, operands auto input1 = model->addOperand(&type0); auto input2 = model->addOperand(&type1); auto axis0 = model->addOperand(&type2); auto output = model->addOperand(&type3); // Phase 2, operations static int32_t axis0_init[] = {0}; model->setOperandValue(axis0, axis0_init, sizeof(int32_t) * 1); model->addOperation(ANEURALNETWORKS_CONCATENATION, {input1, input2, axis0}, {output}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {input1, input2}, {output}); assert(model->isValid()); }
// Generated file (from: space_to_batch_float_2.mod.py). Do not edit void CreateModel(Model *model) { OperandType type0(Type::TENSOR_FLOAT32, {1, 5, 2, 1}); OperandType type3(Type::TENSOR_FLOAT32, {6, 2, 2, 1}); OperandType type2(Type::TENSOR_INT32, {2, 2}); OperandType type1(Type::TENSOR_INT32, {2}); // Phase 1, operands auto input = model->addOperand(&type0); auto block_size = model->addOperand(&type1); auto paddings = model->addOperand(&type2); auto output = model->addOperand(&type3); // Phase 2, operations static int32_t block_size_init[] = {3, 2}; model->setOperandValue(block_size, block_size_init, sizeof(int32_t) * 2); static int32_t paddings_init[] = {1, 0, 2, 0}; model->setOperandValue(paddings, paddings_init, sizeof(int32_t) * 4); model->addOperation(ANEURALNETWORKS_SPACE_TO_BATCH_ND, {input, block_size, paddings}, {output}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {input}, {output}); assert(model->isValid()); }
/** Tests the dynamic typing utility * @param arg_id : The id of the test */ void test_dyntypes(const int arg_id) { bool flag = true; unsigned int test_id=0; try { //Initialize the buffers and the mem copier sutil::CDynamicType<std::string,SType1> type1(std::string("SType1")); sutil::CDynamicType<std::string,SType2> type2(std::string("SType2")); sutil::CDynamicType<std::string,SType3> type3(std::string("SType3")); //Test 1 : Register types. Should succeed. flag = type1.registerType(); if(false == flag) { throw(std::runtime_error("Failed to register type SType1")); } else { std::cout<<"\nTest Result ("<<test_id++<<") Registered type SType1"; } flag = type2.registerType(); if(false == flag) { throw(std::runtime_error("Failed to register type SType1")); } else { std::cout<<"\nTest Result ("<<test_id++<<") Registered type SType2"; } flag = type3.registerType(); if(false == flag) { throw(std::runtime_error("Failed to register type SType1")); } else { std::cout<<"\nTest Result ("<<test_id++<<") Registered type SType3"; } //Test 2 : Register types again. Should fail. flag = type1.registerType(); if(true == flag) { throw(std::runtime_error("Re-registered type SType1")); } else { std::cout<<"\nTest Result ("<<test_id++<<") Didn't re-register type SType1"; } flag = type2.registerType(); if(true == flag) { throw(std::runtime_error("Re-registered type SType1")); } else { std::cout<<"\nTest Result ("<<test_id++<<") Didn't re-register type SType2"; } flag = type3.registerType(); if(true == flag) { throw(std::runtime_error("Re-registered type SType1")); } else { std::cout<<"\nTest Result ("<<test_id++<<") Didn't re-register type SType3"; } //Test 2 : Test type functionality. typedef sutil::CRegisteredDynamicTypes<std::string> RegDynTypes; void* obj = NULL; SType1* t1; SType2* t2; SType3* t3; flag = RegDynTypes::getObjectForType(std::string("SType1"), obj); if(false == flag) { throw(std::runtime_error("Could not create dynamic object for type SType1")); } else { std::cout<<"\nTest Result ("<<test_id++<<") Created dynamic object for type SType1"; } t1 = reinterpret_cast<SType1*>(obj); t1->x = 10; std::cout<<"\nTest Result ("<<test_id++<<") Set data in type SType1 : "<<t1->x; delete t1; obj = NULL; flag = RegDynTypes::getObjectForType(std::string("SType2"), obj); if(false == flag) { throw(std::runtime_error("Could not create dynamic object for type SType2")); } else { std::cout<<"\nTest Result ("<<test_id++<<") Created dynamic object for type SType2"; } t1 = reinterpret_cast<SType1*>(obj); t2 = dynamic_cast<SType2*>(t1); std::cout<<"\nTest Result ("<<test_id++<<") Tested dynamic cast for SType1 to SType2"; t2->x = 10; t2->y = 20; std::cout<<"\nTest Result ("<<test_id++<<") Set data in type SType2 : "<<t2->x<<" "<<t2->y; delete t2; obj = NULL; flag = RegDynTypes::getObjectForType(std::string("SType3"), obj); if(false == flag) { throw(std::runtime_error("Could not create dynamic object for type SType3")); } else { std::cout<<"\nTest Result ("<<test_id++<<") Created dynamic object for type SType3"; } t1 = reinterpret_cast<SType1*>(obj); t2 = dynamic_cast<SType2*>(t1); t3 = dynamic_cast<SType3*>(t1); t3 = dynamic_cast<SType3*>(t2); std::cout<<"\nTest Result ("<<test_id++<<") Tested dynamic cast for SType1 to SType2 to SType3"; t3->x = 10; t3->y = 20; t3->z = 30; std::cout<<"\nTest Result ("<<test_id++<<") Set data in type SType3 : "<<t3->x<<" "<<t3->y<<" "<<t3->z; delete t3; obj = NULL; std::cout<<"\nTest #"<<arg_id<<" (Dynamic Typing Test) Succeeded."; } catch(std::exception& ee) { std::cout<<"\nTest Error ("<<test_id++<<") "<<ee.what(); std::cout<<"\nTest #"<<arg_id<<" (Dynamic Typing Test) Failed"; } }