(self, node, opcode)
| 1492 | self.add_operation(NNAPI_OperationCode.PRELU, inputs, outputs) |
| 1493 | |
| 1494 | def add_pool2d_node(self, node, opcode): |
| 1495 | assert node.inputsSize() == 6 |
| 1496 | assert node.outputsSize() == 1 |
| 1497 | image, kernel, stride, padding, dilation, ceil_mode = node.inputs() |
| 1498 | |
| 1499 | stride = stride or kernel |
| 1500 | |
| 1501 | # TODO: Validate ceil_mode semantics. |
| 1502 | |
| 1503 | args = self.get_conv_pool_args_2d_from_jit( |
| 1504 | self.get_size_arg(kernel), stride, padding, dilation |
| 1505 | ) |
| 1506 | if args.dilation_h != 1 or args.dilation_w != 1: |
| 1507 | raise Exception("NNAPI does not support dilated pooling.") |
| 1508 | |
| 1509 | image_id, image_oper = self.get_tensor_operand_by_jitval_fixed_size(image) |
| 1510 | assert len(image_oper.shape) == 4 |
| 1511 | |
| 1512 | out_shape = get_conv_pool_shape( |
| 1513 | image_oper.shape, args, image_oper.shape[1], False |
| 1514 | ) |
| 1515 | use_nchw = image_oper.use_nchw() |
| 1516 | |
| 1517 | inputs = [None] * 11 |
| 1518 | inputs[0] = image_id |
| 1519 | inputs[1] = self.add_immediate_int_scalar(args.pad_l) |
| 1520 | inputs[2] = self.add_immediate_int_scalar(args.pad_r) |
| 1521 | inputs[3] = self.add_immediate_int_scalar(args.pad_t) |
| 1522 | inputs[4] = self.add_immediate_int_scalar(args.pad_b) |
| 1523 | inputs[5] = self.add_immediate_int_scalar(args.stride_w) |
| 1524 | inputs[6] = self.add_immediate_int_scalar(args.stride_h) |
| 1525 | inputs[7] = self.add_immediate_int_scalar(args.kernel_w) |
| 1526 | inputs[8] = self.add_immediate_int_scalar(args.kernel_h) |
| 1527 | inputs[9] = self.add_immediate_int_scalar(NNAPI_FuseCode.FUSED_NONE) |
| 1528 | inputs[10] = self.add_immediate_bool_scalar(use_nchw) |
| 1529 | |
| 1530 | outputs = [None] * 1 |
| 1531 | outputs[0] = self.add_tensor_operand( |
| 1532 | node.outputsAt(0), image_oper._replace(shape=out_shape) |
| 1533 | ) |
| 1534 | |
| 1535 | self.add_operation(opcode, inputs, outputs) |
| 1536 | |
| 1537 | def add_avg_pool2d(self, node): |
| 1538 | assert node.inputsSize() == 7 |
no test coverage detected