1%% -*-Fundamental-*- 2 3%define-kinds canonical ndk hal_1.0 hal_1.1 hal_1.2 hal_1.3 4 5%kind ndk 6%define ANN ANEURALNETWORKS_ 7%define Ann ANeuralNetworks 8%define DeclareOperation ANEURALNETWORKS_%{1} = %{2} 9%define DeclareOperation_1.2 ANEURALNETWORKS_%{1} = %{2} 10%define DeclareOperation_1.3 ANEURALNETWORKS_%{1} = %{2} 11%define FusedActivationFunc FuseCode 12%define DeclareFusedActivationFunc ANEURALNETWORKS_FUSED_%{1} = %{2} 13%define DeclareExecutionPreference ANEURALNETWORKS_PREFER_%{1} = %{2} 14%define DeclareDeviceType ANEURALNETWORKS_DEVICE_%{1} = %{2} 15%define OperandType OperandCode 16%define OperandTypeLinkPfx ANEURALNETWORKS_ 17%define OperationTypeLinkPfx ANEURALNETWORKS_ 18%define runtime_or_driver runtime 19%define NNAPILevel3 NNAPI feature level 3 20%define NNAPILevel4 NNAPI feature level 4 21%define BeforeNNAPILevel3For Before NNAPI feature level 3, for 22%define or_1.2 or {@link ANEURALNETWORKS_%{1}} 23%define NDK_if_specified (if specified) 24%define otherOperandParameters other operand parameters 25%section AVAIL1 26 * 27 * Available since NNAPI feature level 1. 28%/section 29%section AVAIL1Short 30 * 31 * Available since NNAPI feature level 1. 32%/section 33%section AVAIL2 34 * 35 * Available since NNAPI feature level 2. 36%/section 37%section AVAIL3 38 * 39 * Available since NNAPI feature level 3. 40%/section 41%section AVAIL4 42 * 43 * Available since NNAPI feature level 4. 44%/section 45%section OutputState 46 * 47 * Important: As of NNAPI feature level 3, there is no way to get the output state tensors out 48 * and NNAPI does not maintain internal states. This operator does not support the usage pattern 49 * in which multiple cells are chained and state tensors are propagated. 50%/section 51%section PaddingCodeValues 52 * {@link PaddingCode} values. 53%/section 54%/kind 55 56%kind canonical hal* 57%define ANN 58%define Ann 59%define FusedActivationFunc FusedActivationFunc 60%define DeclareFusedActivationFunc %{1} = %{2} 61%define DeclareExecutionPreference %{1} = %{2} 62%define DeclareDeviceType %{1} = %{2} 63%define OperandType OperandType 64%define OperandTypeLinkPfx OperandType:: 65%define OperationTypeLinkPfx OperationType:: 66%define runtime_or_driver driver 67%define NNAPILevel3 HAL version 1.2 68%define NNAPILevel4 HAL version 1.3 69%define NDK_if_specified 70%define otherOperandParameters extraParams 71%section AVAIL1 72%/section 73%section AVAIL1Short 74%/section 75%section AVAIL2 76%/section 77%section AVAIL3 78%/section 79%section AVAIL4 80%/section 81%section PaddingCodeValues 82 * following values: {0 (NONE), 1 (SAME), 2 (VALID)}. 83%/section 84%section OutputState 85%/section 86%/kind 87 88%kind hal_1.0 hal_1.1 89%define DeclareOperation %{1} = %{2} 90%define BeforeNNAPILevel3For For 91%define or_1.2 92%section NHWC_NCHW 93 * Supported tensor rank: 4, with "NHWC" (i.e., Num_samples, Height, Width, 94 * and Channels) data layout. 95%/section 96%section GenericZero 97%/section 98%section ZeroBatchesNNAPILevel3 99%/section 100%define DeclareOperation_1.2 @@@NOT_DEFINED@@@ 101%define DeclareOperation_1.3 @@@NOT_DEFINED@@@ 102%/kind 103 104%kind canonical hal_1.2 hal_1.3 105%define BeforeNNAPILevel3For Before HAL version 1.2, for 106%define or_1.2 or {@link OperandType::%{1}} 107%/kind 108 109%kind hal_1.2 110%define DeclareOperation %{1} = @1.1::OperationType:%{1} 111%define DeclareOperation_1.2 %{1} = %{2} 112%define DeclareOperation_1.3 @@@NOT_DEFINED@@@ 113%/kind 114 115%kind hal_1.3 116%define DeclareOperation %{1} = @1.2::OperationType:%{1} 117%define DeclareOperation_1.2 %{1} = @1.2::OperationType:%{1} 118%define DeclareOperation_1.3 %{1} = %{2} 119%/kind 120 121%kind canonical 122%define DeclareOperation %{1} = %{2} 123%define DeclareOperation_1.2 %{1} = %{2} 124%define DeclareOperation_1.3 %{1} = %{2} 125%define DeclareEnumValue %{1} = %{2} 126%define OperandLifeTime Operand::LifeTime 127%define :: :: 128%define vec std::vector 129%define string std::string 130%define init_bool = false 131%define init_float = 0.0f 132%define init_int = 0 133%define init_pod {} 134%define Dimensions Dimensions 135%define concat_or_skip_first %{2} 136%/kind 137 138%kind hal* 139%define DeclareEnumValue %{1} 140%define OperandLifeTime OperandLifeTime 141%define :: . 142%define vec vec 143%define string string 144%define init_bool 145%define init_float 146%define init_int 147%define init_pod 148%define Dimensions vec<uint32_t> 149%define concat_or_skip_first %{1}%{2} 150%/kind 151 152%kind ndk 153%define DeclareEnumValue @@@NOT_DEFINED@@@ 154%define OperandLifeTime @@@NOT_DEFINED@@@ 155%define :: @@@NOT_DEFINED@@@ 156%define vec @@@NOT_DEFINED@@@ 157%define string @@@NOT_DEFINED@@@ 158%define init_bool @@@NOT_DEFINED@@@ 159%define init_float @@@NOT_DEFINED@@@ 160%define init_int @@@NOT_DEFINED@@@ 161%define init_pod @@@NOT_DEFINED@@@ 162%define Dimensions @@@NOT_DEFINED@@@ 163%define concat_or_skip_first @@@NOT_DEFINED@@@ 164%/kind 165 166%kind canonical ndk hal_1.2 hal_1.3 167%section NHWC_NCHW 168 * Supported tensor rank: 4, with "NHWC" or "NCHW" data layout. 169 * With the default data layout NHWC, the data is stored in the order of: 170 * [batch, height, width, channels]. Alternatively, the data layout could 171 * be NCHW, the data storage order of: [batch, channels, height, width]. 172 * NCHW is supported since %{NNAPILevel3}. 173%/section 174%section GenericZero 175 * Since %{NNAPILevel3}, generic zero-sized input tensor is supported. Zero 176 * dimension is only compatible with 0 or 1. The size of the output 177 * dimension is zero if either of corresponding input dimension is zero. 178 * 179%/section 180%section ZeroBatchesNNAPILevel3 181 * Since %{NNAPILevel3}, zero batches is supported for this tensor. 182%/section 183%/kind 184 185%kind canonical ndk hal_1.3 186%define AndQuant8Signed 187%/kind 188%kind hal_1.0 hal_1.1 hal_1.2 189%define AndQuant8Signed 190%/kind 191 192%kind ndk hal_1.0 hal_1.1 hal_1.2 193%define model_or_subgraph model 194%define MODEL_or_SUBGRAPH MODEL 195%define the_model_or_a_subgraph the model 196%/kind 197 198%kind canonical hal_1.3+ 199%define model_or_subgraph subgraph 200%define MODEL_or_SUBGRAPH SUBGRAPH 201%define the_model_or_a_subgraph a subgraph 202%/kind 203 204%% Declaring enums that work across all kinds: 205%% 206%% %{enum X underlying_hal_type} { 207%% %{DeclareX ...}, 208%% ... 209%% }%{ndk_enum_name X}; 210%% 211%% Note that %{ndk_enum_name X} can be omitted for non-NDK enums because the 212%% macro definition is empty for all other kinds. 213%kind canonical 214%define enum enum class %{1} 215%define ndk_enum_name 216%define DeclarePriority %{1} = %{2} 217%/kind 218%kind ndk 219%define enum typedef enum 220%define ndk_enum_name %{1} 221%define DeclarePriority ANEURALNETWORKS_PRIORITY_%{1} = %{3} 222%/kind 223%kind hal* 224%define enum enum %{1} : %{2} 225%define ndk_enum_name 226%define DeclarePriority %{1} 227%/kind 228 229%section OEMDeprecationAndOperandTypeRangeMaxComment 230 231 /* 232 * DEPRECATED. Since HAL version 1.2, extensions are the preferred 233 * alternative to OEM operation and data types. 234 * 235 * OEM specific scalar value. 236 * OEM = 10000, 237 */ 238 /* 239 * DEPRECATED. Since HAL version 1.2, extensions are the preferred 240 * alternative to OEM operation and data types. 241 * 242 * A tensor of OEM specific values. 243 * TENSOR_OEM_BYTE = 10001, 244 */ 245 /* ADDING A NEW FUNDAMENTAL TYPE REQUIRES UPDATING THE VALUE OF 246 * OperandTypeRange::FUNDAMENTAL_MAX. 247 */ 248 /* ADDING A NEW OEM TYPE REQUIRES UPDATING THE VALUE OF 249 * OperandTypeRange::OEM_MAX. 250 */ 251%/section 252 253 254%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 255 256%% HAL OperandType for 1.0 257%% NDK OperandCode for API 27 258 259%section canonical_empty_line 260%kind canonical 261 262%/kind 263%/section 264 265%section Operand_1.0_Comment 266/** 267 * Operand types. 268 * 269 * The type of an operand in a model. 270 * 271 * Types prefaced with %{ANN}TENSOR_* must be used for tensor data (i.e., tensors 272 * with at least one dimension). Types not prefaced by %{ANN}TENSOR_* represent 273 * scalar values and must have no dimensions. 274 * 275 * Although we define many types, most operators accept just a few 276 * types. Most used are {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32}, 277 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, 278 * and {@link %{OperandTypeLinkPfx}INT32}. 279%insert AVAIL1Short 280 */ 281%/section 282 283%section Operand_1.0 284 /** A 32 bit floating point scalar value. */ 285 %{ANN}FLOAT32 = 0, 286%insert canonical_empty_line 287 /** A signed 32 bit integer scalar value. */ 288 %{ANN}INT32 = 1, 289%insert canonical_empty_line 290 /** An unsigned 32 bit integer scalar value. */ 291 %{ANN}UINT32 = 2, 292%insert canonical_empty_line 293 /** A tensor of 32 bit floating point values. */ 294 %{ANN}TENSOR_FLOAT32 = 3, 295%insert canonical_empty_line 296 /** A tensor of 32 bit integer values. */ 297 %{ANN}TENSOR_INT32 = 4, 298%insert canonical_empty_line 299 /** 300 * A tensor of 8 bit unsigned integers that represent real numbers. 301 * 302 * Attached to this tensor are two numbers that can be used to convert the 303 * 8 bit integer to the real value and vice versa. These two numbers are: 304 * - scale: a 32 bit floating point value greater than zero. 305 * - zeroPoint: a 32 bit integer, in range [0, 255]. 306 * 307 * The formula is: 308 * real_value = (integer_value - zeroPoint) * scale. 309 */ 310 %{ANN}TENSOR_QUANT8_ASYMM = 5, 311%/section 312 313%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 314 315%% HAL OperationType for 1.0 316%% NDK OperationCode for API 27 317 318%section Operation_1.0_Comment 319/** 320 * Operation types. 321 * 322 * The type of an operation in a model. 323%insert AVAIL1Short 324 */ 325%/section 326 327%section Operation_1.0 328 /** 329 * Adds two tensors, element-wise. 330 * 331 * Takes two input tensors of identical {@link %{OperandType}} and compatible 332 * dimensions. The output is the sum of both input tensors, optionally 333 * modified by an activation function. 334 * 335 * Two dimensions are compatible when: 336 * 1. they are equal, or 337 * 2. one of them is 1 338 * 339 * The size of the output is the maximum size along each dimension of the 340 * input operands. It starts with the trailing dimensions, and works its 341 * way forward. 342 * 343 * Example: 344 * 345 * input1.dimension = {4, 1, 2} 346 * input2.dimension = {5, 4, 3, 1} 347 * output.dimension = {5, 4, 3, 2} 348 * 349%insert GenericZero 350 * Supported tensor {@link %{OperandType}}: 351%kind canonical ndk hal_1.2+ 352 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 353%/kind 354 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 355 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 356%kind canonical ndk hal_1.3+ 357 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 358 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} (since %{NNAPILevel4}) 359%/kind 360 * 361 * Supported tensor rank: up to 4 362 * 363 * Inputs: 364 * * 0: A tensor. 365 * * 1: A tensor of the same {@link %{OperandType}}, and compatible dimensions 366 * as input0. 367%kind canonical ndk hal_1.3+ 368 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 369 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 370 * the scales and zeroPoint can be different from input0 scale and zeroPoint. 371%else 372 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 373 * the scales and zeroPoint can be different from input0 scale and zeroPoint. 374%/kind 375 * * 2: An {@link %{OperandTypeLinkPfx}INT32} scalar, and has to be one of the 376 * {@link %{FusedActivationFunc}} values. Specifies the activation to 377 * invoke on the result. 378%kind canonical ndk hal_1.3+ 379 * For a {@link %{OperandTypeLinkPfx}TENSOR_INT32} tensor, 380 * the {@link %{FusedActivationFunc}} must be "NONE". 381%/kind 382 * 383 * Outputs: 384 * * 0: The sum, a tensor of the same {@link %{OperandType}} as input0. 385%kind canonical ndk hal_1.3+ 386 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 387 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 388 * the scale and zeroPoint can be different from inputs' scale and zeroPoint. 389%else 390 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 391 * the scale and zeroPoint can be different from inputs' scale and zeroPoint. 392%/kind 393%insert AVAIL1 394 */ 395 %{DeclareOperation ADD 0}, 396 397 /** 398 * Performs a 2-D average pooling operation. 399 * 400 * The output dimensions are functions of the filter dimensions, stride, and 401 * padding. 402 * 403 * The values in the output tensor are computed as: 404 * 405 * output[b, i, j, channel] = 406 * sum_{di, dj}( 407 * input[b, strides[1] * i + di, strides[2] * j + dj, channel] 408 * ) / sum(1) 409 * 410 * Supported tensor {@link %{OperandType}}: 411%kind canonical ndk hal_1.2+ 412 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 413%/kind 414 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 415 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 416%kind canonical ndk hal_1.3+ 417 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 418%/kind 419 * 420%insert NHWC_NCHW 421 * 422 * Both explicit padding and implicit padding are supported. 423 * 424 * Inputs (explicit padding): 425 * * 0: A 4-D tensor, of shape [batches, height, width, depth], specifying 426 * the input. 427%insert ZeroBatchesNNAPILevel3 428 * * 1: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 429 * the left, in the ‘width’ dimension. 430 * * 2: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 431 * the right, in the ‘width’ dimension. 432 * * 3: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 433 * the top, in the ‘height’ dimension. 434 * * 4: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 435 * the bottom, in the ‘height’ dimension. 436 * * 5: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 437 * walking through input in the ‘width’ dimension. 438 * * 6: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 439 * walking through input in the ‘height’ dimension. 440 * * 7: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the filter 441 * width. 442 * * 8: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the filter 443 * height. 444 * * 9: An {@link %{OperandTypeLinkPfx}INT32} scalar, and has to be one of the 445 * {@link %{FusedActivationFunc}} values. Specifies the activation to 446 * invoke on the result. 447%kind canonical ndk hal_1.2+ 448 * * 10: An optional {@link %{OperandTypeLinkPfx}BOOL} scalar, default to false. 449 * Set to true to specify NCHW data layout for input0 and output0. 450 * Available since %{NNAPILevel3}. 451%/kind 452 * 453 * Inputs (implicit padding): 454 * * 0: A 4-D tensor, of shape [batches, height, width, depth], specifying 455 * the input. 456%insert ZeroBatchesNNAPILevel3 457 * * 1: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the implicit 458 * padding scheme, has to be one of the 459%insert PaddingCodeValues 460 * * 2: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 461 * walking through input in the ‘width’ dimension. 462 * * 3: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 463 * walking through input in the ‘height’ dimension. 464 * * 4: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the filter 465 * width. 466 * * 5: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the filter 467 * height. 468 * * 6: An {@link %{OperandTypeLinkPfx}INT32} scalar, and has to be one of the 469 * {@link %{FusedActivationFunc}} values. Specifies the activation to 470 * invoke on the result. 471%kind canonical ndk hal_1.2+ 472 * * 7: An optional {@link %{OperandTypeLinkPfx}BOOL} scalar, default to false. 473 * Set to true to specify NCHW data layout for input0 and output0. 474 * Available since %{NNAPILevel3}. 475%/kind 476 * 477 * Outputs: 478 * * 0: The output 4-D tensor, of shape 479 * [batches, out_height, out_width, depth]. 480%kind canonical ndk hal_1.3+ 481 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 482 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 483 * the scale and zeroPoint must be the same as input0. 484%else 485 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 486 * the scale and zeroPoint must be the same as input0. 487%/kind 488%insert AVAIL1 489 */ 490 %{DeclareOperation AVERAGE_POOL_2D 1}, 491 492 /** 493 * Concatenates the input tensors along the given dimension. 494 * 495 * The input tensors must have identical {@link %{OperandType}} and the same 496 * dimensions except the dimension along the concatenation axis. 497 * 498 * Supported tensor {@link %{OperandType}}: 499%kind canonical ndk hal_1.2+ 500 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 501%/kind 502 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 503 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 504%kind canonical ndk hal_1.2+ 505 * (full support since %{NNAPILevel3}, see the input section) 506%/kind 507%kind canonical ndk hal_1.3+ 508 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 509%/kind 510 * 511 * Supported tensor rank: up to 4 512 * 513 * Inputs: 514 * * 0 ~ n-1: The list of n input tensors, of shape 515 * [D0, D1, ..., Daxis(i), ..., Dm]. 516%kind canonical ndk hal_1.2+ 517 * Before %{NNAPILevel3}, all input tensors of 518%else 519 * All input tensors of 520%/kind 521 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 522 * must have the same scale and zeroPoint as the output tensor. 523%kind canonical ndk hal_1.3+ 524 * Input tensors of 525 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} 526 * are allowed to have different scale and zeroPoint. 527%/kind 528%kind canonical ndk hal_1.2+ 529 * Since %{NNAPILevel3}, zero-sized tensors are supported. 530%/kind 531 * * n: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the 532 * concatenation axis. 533 * 534 * Outputs: 535 * * 0: The output, a tensor of the same {@link %{OperandType}} as the input 536 * tensors. The output shape is [D0, D1, ..., sum(Daxis(i)), ..., Dm]. 537%kind canonical ndk hal_1.2+ 538 * Since %{NNAPILevel3}, for a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 539 * the scale and zeroPoint values can be different from 540 * input tensors. Before %{NNAPILevel3} they have to be the same as for the 541 * input tensors. 542%else 543 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, the scale and zeroPoint 544 * values must be the same as the input tensors'. 545%/kind 546%kind canonical hal_1.3+ 547 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 548 * the scale and zeroPoint values can be different from input tensors. 549%/kind 550%insert AVAIL1 551 */ 552 %{DeclareOperation CONCATENATION 2}, 553 554 /** 555 * Performs a 2-D convolution operation. 556 * 557 * The CONV_2D op sweeps a 2-D filter that can mix channels together over a 558 * batch of images, applying the filter to each window of each image of the 559 * appropriate size. 560 * 561 * The output dimensions are functions of the filter dimensions, stride, and 562 * padding. 563 * 564 * The values in the output tensor are computed as: 565 * 566 * output[b, i, j, channel] = 567 * sum_{di, dj, k} ( 568 * input[b, strides[1] * i + di, strides[2] * j + dj, k] * 569 * filter[channel, di, dj, k] 570 * ) + bias[channel] 571 * 572 * Supported tensor {@link %{OperandType}} configurations: 573 * * 32 bit floating point: 574 * * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} for input, filter, output, and bias. 575 * 576 * * Quantized: 577 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} for input, filter, and output. 578 * * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} for bias (with scale set to 579 * * * input.scale * filter.scale). 580 * 581%kind canonical ndk hal_1.2+ 582 * Available since %{NNAPILevel3}: 583 * * 16 bit floating point: 584 * * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} for input, filter, output, and bias. 585 * 586 * * Quantized with symmetric per channel quantization for the filter: 587 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} for input, and output. 588 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL} for filter. 589 * * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} for bias (scale set to 0.0, 590 * * * each value scaling is separate and equal to input.scale * filter.scales[channel]). 591 * 592%/kind 593%kind ndk hal_1.3+ 594 * Available since %{NNAPILevel4}: 595 * * Quantized signed (since %{NNAPILevel4}): 596 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} for input, filter, and output. 597 * * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} for bias (with scale set to 598 * * * input.scale * filter.scale). 599 * 600 * * Quantized signed with filter symmetric per channel quantization 601 * (since %{NNAPILevel4}): 602 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} for input, and output. 603 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL} for filter. 604 * * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} for bias (scale set to 0.0, 605 * * * each value scaling is separate and equal to input.scale * filter.scales[channel]). 606 * 607%/kind 608%insert NHWC_NCHW 609 * 610 * Both explicit padding and implicit padding are supported. 611 * 612 * Inputs (explicit padding): 613 * * 0: A 4-D tensor, of shape [batches, height, width, depth_in], 614 * specifying the input. 615%insert ZeroBatchesNNAPILevel3 616 * * 1: A 4-D tensor, of shape 617 * [depth_out, filter_height, filter_width, depth_in], specifying the 618 * filter. 619%kind canonical ndk hal_1.2+ 620 * For tensor of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL} 621 * the channel dimension (%{Ann}SymmPerChannelQuantParams::channelDim) 622 * must be set to 0. 623%/kind 624 * * 2: A 1-D tensor, of shape [depth_out], specifying the bias. For input 625 * tensor of type {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 626 * %{or_1.2 TENSOR_FLOAT16} the bias must be of the same type. 627%kind canonical ndk hal_1.3+ 628 * For filter tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 629 * and {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED}, 630%else 631 * For filter tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, 632%/kind 633 * the bias should be of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, with zeroPoint 634 * of 0 and bias_scale == input_scale * filter_scale. 635%kind canonical ndk hal_1.2+ 636 * For filter tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL}, 637 * the bias should be of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, with zeroPoint of 0 638 * and bias_scale of 0. The actual scale of each value 'i' is equal to 639 * bias_scale[i] = input_scale * filter_scale[i]. 640%/kind 641 * * 3: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 642 * the left, in the ‘width’ dimension. 643 * * 4: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 644 * the right, in the ‘width’ dimension. 645 * * 5: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 646 * the top, in the ‘height’ dimension. 647 * * 6: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 648 * the bottom, in the ‘height’ dimension. 649 * * 7: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 650 * walking through input in the ‘width’ dimension. 651 * * 8: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 652 * walking through input in the ‘height’ dimension. 653 * * 9: An {@link %{OperandTypeLinkPfx}INT32} scalar, and has to be one of the 654 * {@link %{FusedActivationFunc}} values. Specifies the activation to 655 * invoke on the result. 656%kind canonical ndk hal_1.2+ 657 * * 10: An optional {@link %{OperandTypeLinkPfx}BOOL} scalar, default to false. 658 * Set to true to specify NCHW data layout for input0 and output0. 659 * Available since %{NNAPILevel3}. 660 * * 11: An optional {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the dilation 661 * factor for width. Defaults to 1. If set to k > 1, there will be k-1 skipped 662 * cells between each filter element on width dimension. If this input is set, 663 * input 12 (dilation factor for height) must be specified as well. 664 * Available since %{NNAPILevel3}. 665 * * 12: An optional {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the dilation 666 * factor for height. Defaults to 1. If set to k > 1, there will be k-1 skipped 667 * cells between each filter element on height dimension. If this input is set, 668 * input 11 (dilation factor for width) must be specified as well. 669 * Available since %{NNAPILevel3}. 670%/kind 671 * 672 * Inputs (implicit padding): 673 * * 0: A 4-D tensor, of shape [batches, height, width, depth_in], 674 * specifying the input. 675%insert ZeroBatchesNNAPILevel3 676 * * 1: A 4-D tensor, of shape 677 * [depth_out, filter_height, filter_width, depth_in], specifying the 678 * filter. 679%kind canonical ndk hal_1.2+ 680 * For tensor of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL} 681 * the channel dimension (%{Ann}SymmPerChannelQuantParams::channelDim) 682 * must be set to 0. 683%/kind 684 * * 2: A 1-D tensor, of shape [depth_out], specifying the bias. For input 685 * tensor of type {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 686 * %{or_1.2 TENSOR_FLOAT16} the bias must be of the same 687 * type. 688%kind canonical ndk hal_1.3+ 689 * For filter tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 690 * and {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED}, 691%else 692 * For filter tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, 693%/kind 694 * the bias should be of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, with zeroPoint 695 * of 0 and bias_scale == input_scale * filter_scale. 696%kind canonical ndk hal_1.2+ 697 * For filter tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL}, 698 * the bias should be of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, with zeroPoint of 0 699 * and bias_scale of 0. The actual scale of each value 'i' is equal to 700 * bias_scale[i] = input_scale * filter_scale[i]. 701%/kind 702 * * 3: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the implicit 703 * padding scheme, has to be one of the 704%insert PaddingCodeValues 705 * * 4: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 706 * walking through input in the ‘width’ dimension. 707 * * 5: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 708 * walking through input in the ‘height’ dimension. 709 * * 6: An {@link %{OperandTypeLinkPfx}INT32} scalar, and has to be one of the 710 * {@link %{FusedActivationFunc}} values. Specifies the activation to 711 * invoke on the result. 712%kind canonical ndk hal_1.2+ 713 * * 7: An optional {@link %{OperandTypeLinkPfx}BOOL} scalar, default to false. 714 * Set to true to specify NCHW data layout for input0 and output0. 715 * Available since %{NNAPILevel3}. 716 * * 8: An optional {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the dilation 717 * factor for width. Defaults to 1. If set to k > 1, there will be k-1 skipped 718 * cells between each filter element on width dimension. If this input is set, 719 * input 9 (dilation factor for height) must be specified as well. 720 * Available since %{NNAPILevel3}. 721 * * 9: An optional {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the dilation 722 * factor for height. Defaults to 1. If set to k > 1, there will be k-1 skipped 723 * cells between each filter element on height dimension. If this input is set, 724 * input 8 (dilation factor for width) must be specified as well. 725 * Available since %{NNAPILevel3}. 726%/kind 727 * 728 * Outputs: 729 * * 0: The output 4-D tensor, of shape 730 * [batches, out_height, out_width, depth_out]. 731 * %{BeforeNNAPILevel3For} output tensor of 732 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, the following condition must 733 * be satisfied: output_scale > input_scale * filter_scale 734%insert AVAIL1 735 */ 736 %{DeclareOperation CONV_2D 3}, 737 738 /** 739 * Performs a depthwise 2-D convolution operation. 740 * 741 * Given an input tensor of shape [batches, height, width, depth_in] and a 742 * filter tensor of shape [1, filter_height, filter_width, depth_out] 743 * containing depth_out convolutional filters of depth 1, DEPTHWISE_CONV 744 * applies a different filter to each input channel (expanding from 1 745 * channel to channel_multiplier channels for each), then concatenates the 746 * results together. 747 * 748 * The output has depth_out = depth_in * depth_multiplier channels. 749 * The output dimensions are functions of the filter dimensions, stride, and 750 * padding. 751 * 752 * The values in the output tensor are computed as: 753 * 754 * output[b, i, j, k * channel_multiplier + q] = 755 * sum_{di, dj} ( 756 * input[b, strides[1] * i + di, strides[2] * j + dj, k] * 757 * filter[1, di, dj, k * channel_multiplier + q] 758 * ) + bias[k * channel_multiplier + q] 759 * 760 * Supported tensor {@link %{OperandType}} configurations: 761 * * 32 bit floating point: 762 * * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} for input, filter, output, and bias. 763 * 764 * * Quantized: 765 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} for input, filter, and output. 766 * * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} for bias (with scale set to 767 * * * input.scale * filter.scale). 768 * 769%kind canonical ndk hal_1.2+ 770 * Available since %{NNAPILevel3}: 771 * * 16 bit floating point: 772 * * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} for input, filter, output, and bias. 773 * 774 * * Quantized with symmetric per channel quantization for the filter: 775 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} for input, and output. 776 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL} for filter. 777 * * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} for bias (scale set to 0.0, 778 * * * each value scaling is separate and equal to input.scale * filter.scales[channel]). 779 * 780%/kind 781%kind canonical ndk hal_1.3+ 782 * Available since %{NNAPILevel4}: 783 * * Quantized signed (since %{NNAPILevel4}): 784 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} for input, filter, and output. 785 * * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} for bias (with scale set to 786 * * * input.scale * filter.scale). 787 * 788 * * Quantized signed with filter symmetric per channel quantization 789 * (since %{NNAPILevel4}): 790 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} for input, and output. 791 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL} for filter. 792 * * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} for bias (scale set to 0.0, 793 * * * each value scaling is separate and equal to input.scale * filter.scales[channel]). 794 * 795%/kind 796%insert NHWC_NCHW 797 * 798 * Both explicit padding and implicit padding are supported. 799 * 800 * Inputs (explicit padding): 801 * * 0: A 4-D tensor, of shape [batches, height, width, depth_in], 802 * specifying the input. 803 * * 1: A 4-D tensor, of shape [1, filter_height, filter_width, depth_out], 804 * specifying the filter. 805%kind canonical ndk hal_1.2+ 806 * For tensor of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL} 807 * the channel dimension (%{Ann}SymmPerChannelQuantParams::channelDim) 808 * must be set to 3. 809%/kind 810 * * 2: A 1-D tensor, of shape [depth_out], specifying the bias. For input 811 * tensor of type {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 812 * %{or_1.2 TENSOR_FLOAT16} the bias must be of the same type. 813%kind canonical ndk hal_1.3+ 814 * For filter tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 815 * and {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED}, 816%else 817 * For filter tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, 818%/kind 819 * the bias should be of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, with zeroPoint 820 * of 0 and bias_scale == input_scale * filter_scale. 821%kind canonical ndk hal_1.2+ 822 * For filter tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL}, 823 * the bias should be of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, with zeroPoint of 0 824 * and bias_scale of 0. The actual scale of each value 'i' is equal to 825 * bias_scale[i] = input_scale * filter_scale[i]. 826%/kind 827 * * 3: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 828 * the left, in the ‘width’ dimension. 829 * * 4: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 830 * the right, in the ‘width’ dimension. 831 * * 5: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 832 * the top, in the ‘height’ dimension. 833 * * 6: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 834 * the bottom, in the ‘height’ dimension. 835 * * 7: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 836 * walking through input in the ‘width’ dimension. 837 * * 8: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 838 * walking through input in the ‘height’ dimension. 839 * * 9: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the depthwise 840 * multiplier. 841 * * 10: An {@link %{OperandTypeLinkPfx}INT32} scalar, and has to be one of the 842 * {@link %{FusedActivationFunc}} values. Specifies the activation to 843 * invoke on the result. 844%kind canonical ndk hal_1.2+ 845 * * 11: An optional {@link %{OperandTypeLinkPfx}BOOL} scalar, default to false. 846 * Set to true to specify NCHW data layout for input0 and output0. 847 * Available since %{NNAPILevel3}. 848 * * 12: An optional {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the dilation 849 * factor for width. Defaults to 1. If set to k > 1, there will be k-1 skipped 850 * cells between each filter element on width dimension. If this input is set, 851 * input 13 (dilation factor for height) must be specified as well. 852 * Available since %{NNAPILevel3}. 853 * * 13: An optional {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the dilation 854 * factor for height. Defaults to 1. If set to k > 1, there will be k-1 skipped 855 * cells between each filter element on height dimension. If this input is set, 856 * input 12 (dilation factor for width) must be specified as well. 857 * Available since %{NNAPILevel3}. 858%/kind 859 * 860 * Inputs (implicit padding): 861 * * 0: A 4-D tensor, of shape [batches, height, width, depth_in], 862 * specifying the input. 863 * * 1: A 4-D tensor, of shape [1, filter_height, filter_width, depth_out], 864 * specifying the filter. 865 * * 2: A 1-D tensor, of shape [depth_out], specifying the bias. For input 866 * tensor of type {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 867 * %{or_1.2 TENSOR_FLOAT16} the bias must be of the same type. 868%kind canonical ndk hal_1.3+ 869 * For filter tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 870 * and {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED}, 871%else 872 * For filter tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, 873%/kind 874 * the bias should be of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, with zeroPoint 875 * of 0 and bias_scale == input_scale * filter_scale. 876%kind canonical ndk hal_1.2+ 877 * For filter tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL}, 878 * the bias should be of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, with zeroPoint of 0 879 * and bias_scale of 0. The actual scale of each value 'i' is equal to 880 * bias_scale[i] = input_scale * filter_scale[i]. 881%/kind 882 * * 3: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the implicit 883 * padding scheme, has to be one of the 884%insert PaddingCodeValues 885 * * 4: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 886 * walking through input in the ‘width’ dimension. 887 * * 5: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 888 * walking through input in the ‘height’ dimension. 889 * * 6: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the depthwise 890 * multiplier. 891 * * 7: An {@link %{OperandTypeLinkPfx}INT32} scalar, and has to be one of the 892 * {@link %{FusedActivationFunc}} values. Specifies the activation to 893 * invoke on the result. 894%kind canonical ndk hal_1.2+ 895 * * 8: An optional {@link %{OperandTypeLinkPfx}BOOL} scalar, default to false. 896 * Set to true to specify NCHW data layout for input0 and output0. 897 * Available since %{NNAPILevel3}. 898 * * 9: An optional {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the dilation 899 * factor for width. Defaults to 1. If set to k > 1, there will be k-1 skipped 900 * cells between each filter element on width dimension. If this input is set, 901 * input 10 (dilation factor for height) must be specified as well. 902 * Available since %{NNAPILevel3}. 903 * * 10: An optional {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the dilation 904 * factor for height. Defaults to 1. If set to k > 1, there will be k-1 skipped 905 * cells between each filter element on height dimension. If this input is set, 906 * input 9 (dilation factor for width) must be specified as well. 907 * Available since %{NNAPILevel3}. 908%/kind 909 * 910 * Outputs: 911 * * 0: The output 4-D tensor, of shape 912 * [batches, out_height, out_width, depth_out]. %{BeforeNNAPILevel3For} 913 * output tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, 914 * the following condition must be satisfied: 915 * output_scale > input_scale * filter_scale 916%insert AVAIL1 917 */ 918 %{DeclareOperation DEPTHWISE_CONV_2D 4}, 919 920 /** 921 * Rearranges data from depth into blocks of spatial data. 922 * 923 * More specifically, this op outputs a copy of the input tensor where 924 * values from the depth dimension are moved in spatial blocks to the height 925 * and width dimensions. The value block_size indicates the input block size 926 * and how the data is moved. 927 * 928 * Chunks of data of size block_size * block_size from depth are rearranged 929 * into non-overlapping blocks of size block_size x block_size. 930 * 931 * The width of the output tensor is input_depth * block_size, whereas the 932 * height is input_height * block_size. The depth of the input tensor must 933 * be divisible by block_size * block_size 934 * 935 * Supported tensor {@link %{OperandType}}: 936%kind canonical ndk hal_1.2+ 937 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 938%/kind 939 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 940 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 941%kind canonical ndk hal_1.3+ 942 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 943%/kind 944 * 945%insert NHWC_NCHW 946 * 947 * Inputs: 948 * * 0: A 4-D tensor, of shape [batches, height, width, depth_in], 949 * specifying the input. 950 * * 1: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the block_size. 951 * block_size must be >=1 and block_size * block_size must be a divisor 952 * of the input depth. 953%kind canonical ndk hal_1.2+ 954 * * 2: An optional {@link %{OperandTypeLinkPfx}BOOL} scalar, default to false. 955 * Set to true to specify NCHW data layout for input0 and output0. 956 * Available since %{NNAPILevel3}. 957%/kind 958 * 959 * Outputs: 960 * * 0: The output 4-D tensor, of shape [batch, height*block_size, 961 * width*block_size, depth/(block_size*block_size)]. 962%kind canonical ndk hal_1.3+ 963 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 964 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 965 * the scale and zeroPoint must be the same as input0. 966%else 967 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 968 * the scale and zeroPoint must be the same as input0. 969%/kind 970%insert AVAIL1 971 */ 972 %{DeclareOperation DEPTH_TO_SPACE 5}, 973 974 /** 975 * Dequantizes the input tensor. 976 * 977 * The formula is: 978 * 979 * output = (input - zeroPoint) * scale. 980 * 981 * Supported input tensor {@link %{OperandType}}: 982 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 983%kind canonical ndk hal_1.2+ 984 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM} (since %{NNAPILevel3}) 985 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL} (since %{NNAPILevel3}) 986%/kind 987%kind canonical ndk hal_1.3+ 988 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 989%/kind 990 * 991 * Supported output tensor {@link %{OperandType}}: 992%kind canonical ndk hal_1.2+ 993 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 994%/kind 995 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32}. 996 * 997 * Supported tensor rank: up to 4 998 * 999 * Inputs: 1000 * * 0: A tensor. 1001%kind canonical ndk hal_1.2+ 1002 * Since %{NNAPILevel3}, this tensor may be zero-sized. 1003%/kind 1004 * 1005 * Outputs: 1006 * * 0: A tensor with the same shape as input0. 1007%insert AVAIL1 1008 */ 1009 %{DeclareOperation DEQUANTIZE 6}, 1010 1011 /** 1012 * Looks up sub-tensors in the input tensor. 1013 * 1014 * This operator takes for input a tensor of values (Values) and 1015 * a one-dimensional tensor of selection indices (Lookups). 1016 * The output tensor is the concatenation of sub-tensors of Values as 1017 * selected by Lookups. 1018 * 1019 * Think of Values as being sliced along its first dimension: 1020 * The entries in Lookups select which slices are concatenated together 1021 * to create the output tensor. 1022 * 1023 * For example, if Values has shape of [40, 200, 300] and 1024 * Lookups has shape of [3], all three values found in Lookups are 1025 * expected to be between 0 and 39. The resulting tensor must 1026 * have shape of [3, 200, 300]. 1027 * 1028 * If a value in Lookups is out of bounds, the operation must fail 1029 * and an error must be reported. 1030 * 1031 * Supported value tensor {@link %{OperandType}}: 1032%kind canonical ndk hal_1.3+ 1033 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel4}) 1034%/kind 1035 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 1036%kind canonical ndk hal_1.2+ 1037 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} (since %{NNAPILevel3}) 1038 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} (since %{NNAPILevel3}) 1039%/kind 1040%kind canonical ndk hal_1.3+ 1041 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 1042%/kind 1043 * 1044 * Supported value tensor rank: from 2 1045 * 1046 * Inputs: 1047 * * 0: Lookups. A 1-D tensor of {@link %{OperandTypeLinkPfx}TENSOR_INT32}. 1048 * The values are indices into the first dimension of Values. 1049 * * 1: Values. An n-D tensor, where n >= 2, from which sub-tensors are 1050 * extracted. 1051 * 1052 * Output: 1053 * * 0: A n-D tensor with the same rank and shape as the Values 1054 * tensor, except for the first dimension which has the same size 1055 * as Lookups' only dimension. 1056%kind canonical ndk hal_1.3+ 1057 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 1058 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 1059%else 1060 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 1061%/kind 1062 * the scale and zeroPoint must be the same as input1. 1063%insert AVAIL1 1064 */ 1065 %{DeclareOperation EMBEDDING_LOOKUP 7}, 1066 1067 /** 1068 * Computes element-wise floor() on the input tensor. 1069 * 1070 * Supported tensor {@link %{OperandType}}: 1071%kind canonical ndk hal_1.2+ 1072 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 1073%/kind 1074 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 1075 * 1076 * Supported tensor rank: up to 4 1077 * 1078 * Inputs: 1079 * * 0: A tensor. 1080 * 1081 * Outputs: 1082 * * 0: The output tensor, of the same {@link %{OperandType}} and dimensions as 1083 * the input tensor. 1084%insert AVAIL1 1085 */ 1086 %{DeclareOperation FLOOR 8}, 1087 1088 /** 1089 * Denotes a fully (densely) connected layer, which connects all elements 1090 * in the input tensor with each element in the output tensor. 1091 * 1092 * This layer implements the operation: 1093 * 1094 * outputs = activation(inputs * weights’ + bias) 1095 * 1096 * Supported tensor {@link %{OperandType}}: 1097%kind canonical ndk hal_1.2+ 1098 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 1099%/kind 1100 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 1101 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 1102%kind canonical ndk hal_1.3+ 1103 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 1104%/kind 1105 * 1106 * Supported tensor rank: up to 4. 1107 * 1108 * Inputs: 1109 * * 0: A tensor of at least rank 2, specifying the input. If rank is 1110 * greater than 2, then it gets flattened to a 2-D Tensor. The 1111 * (flattened) 2-D Tensor is reshaped (if necessary) to 1112 * [batch_size, input_size], where "input_size" corresponds to the 1113 * number of inputs to the layer, matching the second dimension of 1114 * weights, and "batch_size" is calculated by dividing the number of 1115 * elements by "input_size". 1116%kind canonical ndk hal_1.2+ 1117 * Since %{NNAPILevel3}, zero batch_size is supported for this tensor. 1118%/kind 1119 * * 1: A 2-D tensor, specifying the weights, of shape 1120 * [num_units, input_size], where "num_units" corresponds to the number 1121 * of output nodes. 1122 * * 2: A 1-D tensor, of shape [num_units], specifying the bias. For input 1123 * tensor of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32}, the bias should 1124 * also be of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32}. 1125%kind canonical ndk hal_1.3+ 1126 * For input tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 1127 * and {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED}, 1128%else 1129 * For input tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, 1130%/kind 1131 * the bias should be of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, 1132 * with zeroPoint of 0 and bias_scale == input_scale * filter_scale. 1133 * * 3: An {@link %{OperandTypeLinkPfx}INT32} scalar, and has to be one of the 1134 * {@link %{FusedActivationFunc}} values. Specifies the activation to 1135 * invoke on the result. 1136 * 1137 * Outputs: 1138 * * 0: The output tensor, of shape [batch_size, num_units]. %{BeforeNNAPILevel3For} 1139 * output tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, the following 1140 * condition must be satisfied: output_scale > input_scale * filter_scale. 1141%insert AVAIL1 1142 */ 1143 %{DeclareOperation FULLY_CONNECTED 9}, 1144 1145 /** 1146 * Looks up sub-tensors in the input tensor using a key-value map. 1147 * 1148 * This operator takes for input a tensor of values (Values), 1149 * a one-dimensional tensor of selection values (Lookups) and 1150 * a one-dimensional tensor that maps these values to Values 1151 * indexes. The output tensor is the concatenation of sub-tensors of 1152 * Values as selected by Lookups via Keys. 1153 * 1154 * Think of Values as being sliced along its outer-most dimension. 1155 * The output is a concatenation of selected slices, with one slice 1156 * for each entry of Lookups. The slice selected is the one at the 1157 * same index as the Maps entry that matches the value in Lookups. 1158 * 1159 * For a hit, the corresponding sub-tensor of Values is included 1160 * in the Output tensor. For a miss, the corresponding sub-tensor in 1161 * Output must have zero values. 1162 * 1163 * For example, if Values has shape of [40, 200, 300], 1164 * Keys should have a shape of [40]. If Lookups tensor has shape 1165 * of [3], three slices are being concatenated, so the resulting tensor 1166 * must have the shape of [3, 200, 300]. If the first entry in Lookups 1167 * has the value 123456, that value must be located in Keys tensor. 1168 * If the sixth entry of Keys contains 123456, the sixth slice of Values 1169 * must be selected. If no entry in Keys has 123456, a slice of zeroes 1170 * must be concatenated. 1171 * 1172 * Supported value tensor {@link %{OperandType}}: 1173 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 1174 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 1175 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 1176 * 1177 * Supported value tensor rank: from 2 1178 * 1179 * Inputs: 1180 * * 0: Lookups. A 1-D {@link %{OperandTypeLinkPfx}TENSOR_INT32} tensor with 1181 * shape [ k ]. 1182 * * 1: Keys. A 1-D {@link %{OperandTypeLinkPfx}TENSOR_INT32} tensor with shape 1183 * [ n ]; Keys and Values pair represent a map, i.e., the ith element 1184 * in Keys (Keys[i]) is the key to select the ith sub-tensor in Values 1185 * (Values[i]), where 0 <= i <= n-1. Keys tensor *MUST* be sorted in 1186 * ascending order. 1187 * * 2: Values. A tensor with shape of [ n, … ]; i.e., the first dimension 1188 * must be n. 1189 * 1190 * Outputs: 1191 * * 0: Output. A tensor with shape [ k …]. 1192 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 1193 * the scale and zeroPoint must be the same as input2. 1194 * * 1: Hits. A boolean tensor with shape [ k ] indicates whether the lookup 1195 * hits (True) or not (False). 1196 * Stored as {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} with offset 0 1197 * and scale 1.0f. 1198 * A non-zero byte represents True, a hit. A zero indicates otherwise. 1199%insert AVAIL1 1200 */ 1201 %{DeclareOperation HASHTABLE_LOOKUP 10}, 1202 1203 /** 1204 * Applies L2 normalization along the axis dimension. 1205 * 1206 * The values in the output tensor are computed as: 1207 * 1208 * output[batch, row, col, channel] = 1209 * input[batch, row, col, channel] / 1210 * sqrt(sum_{c} pow(input[batch, row, col, c], 2)) 1211 * 1212%kind canonical ndk hal_1.2+ 1213 * By default the axis dimension is the last dimension of the input tensor. 1214 * 1215%/kind 1216 * Supported tensor {@link %{OperandType}}: 1217%kind canonical ndk hal_1.2+ 1218 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 1219%/kind 1220 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 1221%kind canonical ndk hal_1.2+ 1222 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} (since %{NNAPILevel3}) 1223%/kind 1224%kind canonical ndk hal_1.3+ 1225 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 1226%/kind 1227 * 1228%kind canonical ndk hal_1.2+ 1229 * Supported tensor rank: up to 4 1230 * Tensors with rank less than 4 are only supported since %{NNAPILevel3}. 1231%else 1232 * Supported tensor rank: 4, with "NHWC" data layout (i.e., Num_samples, 1233 * Height, Width, and Channels). 1234%/kind 1235 * 1236 * Inputs: 1237%kind canonical ndk hal_1.2+ 1238 * * 0: An n-D tensor, specifying the tensor to be normalized. 1239%else 1240 * * 0: A 4-D tensor, specifying the tensor to be normalized. 1241%/kind 1242%kind canonical ndk hal_1.2+ 1243 * * 1: An optional {@link %{OperandTypeLinkPfx}INT32} scalar, default to -1, 1244 * specifying the dimension normalization would be performed on. 1245 * Negative index is used to specify axis from the end (e.g. -1 for 1246 * the last axis). Must be in the range [-n, n). 1247 * Available since %{NNAPILevel3}. 1248%/kind 1249 * 1250 * Outputs: 1251 * * 0: A tensor of the same {@link %{OperandType}} and same shape as input0. 1252%kind canonical ndk hal_1.2+ 1253 * For {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, 1254 * the scale must be 1.f / 128 and the zeroPoint must be 128. 1255%/kind 1256%kind canonical ndk hal_1.3+ 1257 * For {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED}, 1258 * the scale must be 1.f / 128 and the zeroPoint must be 0. 1259 * 1260 * NOTE: Before %{NNAPILevel4}, if the elements along an axis are all zeros, 1261 * the result is undefined. Since %{NNAPILevel4}, if the elements along an axis 1262 * are all zeros, the result is logical zero. 1263%/kind 1264%insert AVAIL1 1265 */ 1266 %{DeclareOperation L2_NORMALIZATION 11}, 1267 1268 /** 1269 * Performs an 2-D L2 pooling operation. 1270 * 1271 * The output dimensions are functions of the filter dimensions, stride, and 1272 * padding. 1273 * 1274 * The values in the output tensor are computed as: 1275 * 1276 * output[b, i, j, c] = 1277 * sqrt(sum_{di, dj} pow(input[b, strides[1] * i + di, strides[2] * j + dj, c], 2) / 1278 * sum(1)) 1279 * 1280 * Supported tensor {@link %{OperandType}}: 1281%kind canonical ndk hal_1.2+ 1282 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 1283%/kind 1284 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 1285 * 1286%insert NHWC_NCHW 1287 * 1288 * Both explicit padding and implicit padding are supported. 1289 * 1290 * Inputs (explicit padding): 1291 * * 0: A 4-D tensor, of shape [batches, height, width, depth], specifying 1292 * the input. 1293%insert ZeroBatchesNNAPILevel3 1294 * * 1: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 1295 * the left, in the ‘width’ dimension. 1296 * * 2: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 1297 * the right, in the ‘width’ dimension. 1298 * * 3: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 1299 * the top, in the ‘height’ dimension. 1300 * * 4: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 1301 * the bottom, in the ‘height’ dimension. 1302 * * 5: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 1303 * walking through input in the ‘width’ dimension. 1304 * * 6: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 1305 * walking through input in the ‘height’ dimension. 1306 * * 7: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the filter 1307 * width. 1308 * * 8: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the filter 1309 * height. 1310 * * 9: An {@link %{OperandTypeLinkPfx}INT32} scalar, and has to be one of the 1311 * {@link %{FusedActivationFunc}} values. Specifies the activation to 1312 * invoke on the result. 1313%kind canonical ndk hal_1.2+ 1314 * * 10: An optional {@link %{OperandTypeLinkPfx}BOOL} scalar, default to false. 1315 * Set to true to specify NCHW data layout for input0 and output0. 1316 * Available since %{NNAPILevel3}. 1317%/kind 1318 * 1319 * Inputs (implicit padding): 1320 * * 0: A 4-D tensor, of shape [batches, height, width, depth], specifying 1321 * the input. 1322%insert ZeroBatchesNNAPILevel3 1323 * * 1: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the implicit 1324 * padding scheme, has to be one of the 1325%insert PaddingCodeValues 1326 * * 2: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 1327 * walking through input in the ‘width’ dimension. 1328 * * 3: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 1329 * walking through input in the ‘height’ dimension. 1330 * * 4: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the filter 1331 * width. 1332 * * 5: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the filter 1333 * height. 1334 * * 6: An {@link %{OperandTypeLinkPfx}INT32} scalar, and has to be one of the 1335 * {@link %{FusedActivationFunc}} values. Specifies the activation to 1336 * invoke on the result. 1337%kind canonical ndk hal_1.2+ 1338 * * 7: An optional {@link %{OperandTypeLinkPfx}BOOL} scalar, default to false. 1339 * Set to true to specify NCHW data layout for input0 and output0. 1340 * Available since %{NNAPILevel3}. 1341%/kind 1342 * 1343 * Outputs: 1344 * * 0: The output 4-D tensor, of shape 1345 * [batches, out_height, out_width, depth]. 1346%insert AVAIL1 1347 */ 1348 %{DeclareOperation L2_POOL_2D 12}, 1349 1350 /** 1351 * Applies Local Response Normalization along the depth dimension. 1352 * 1353 * The 4-D input tensor is treated as a 3-D array of 1-D vectors (along the 1354 * last dimension), and each vector is normalized independently. Within a 1355 * given vector, each component is divided by the weighted, squared sum of 1356 * inputs within depth_radius. 1357 * 1358 * The output is calculated using this formula: 1359 * 1360 * sqr_sum[a, b, c, d] = sum( 1361 * pow(input[a, b, c, d - depth_radius : d + depth_radius + 1], 2)) 1362 * output = input / pow((bias + alpha * sqr_sum), beta) 1363 * 1364%kind canonical ndk hal_1.2+ 1365 * For input tensor with rank less than 4, independently normalizes each 1366 * 1-D slice along specified dimension. 1367 * 1368%/kind 1369 * Supported tensor {@link %{OperandType}}: 1370%kind canonical ndk hal_1.2+ 1371 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 1372%/kind 1373 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 1374 * 1375%kind canonical ndk hal_1.2+ 1376 * Supported tensor rank: up to 4 1377 * Tensors with rank less than 4 are only supported since %{NNAPILevel3}. 1378%else 1379 * Supported tensor rank: 4, with "NHWC" data layout. 1380%/kind 1381 * 1382 * Inputs: 1383 * * 0: A 4-D tensor, of shape [batches, height, width, depth], specifying 1384 * the input. 1385 * * 1: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the radius of 1386 * the normalization window. 1387 * * 2: A scalar, specifying the bias, must not be zero. 1388%kind canonical ndk hal_1.2+ 1389 * For input tensor of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16}, the bias 1390 * value must be of {@link %{OperandTypeLinkPfx}FLOAT16}. 1391%/kind 1392 * For input tensor of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32}, the bias 1393 * value must be of {@link %{OperandTypeLinkPfx}FLOAT32}. 1394 * * 3: A scalar, specifying the scale factor, alpha. 1395%kind canonical ndk hal_1.2+ 1396 * For input tensor of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16}, the 1397 * alpha value must be of {@link %{OperandTypeLinkPfx}FLOAT16}. 1398%/kind 1399 * For input tensor of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32}, the 1400 * alpha value must be of {@link %{OperandTypeLinkPfx}FLOAT32}. 1401 * * 4: A scalar, specifying the exponent, beta. 1402%kind canonical ndk hal_1.2+ 1403 * For input tensor of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16}, the beta 1404 * value must be of {@link %{OperandTypeLinkPfx}FLOAT16}. 1405%/kind 1406 * For input tensor of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32}, the beta 1407 * value must be of {@link %{OperandTypeLinkPfx}FLOAT32}. 1408%kind canonical ndk hal_1.2+ 1409 * * 5: An optional {@link %{OperandTypeLinkPfx}INT32} scalar, default to -1, 1410 * specifying the dimension normalization would be performed on. 1411 * Negative index is used to specify axis from the end (e.g. -1 for 1412 * the last axis). Must be in the range [-n, n). 1413 * Available since %{NNAPILevel3}. 1414%/kind 1415 * 1416 * Outputs: 1417 * * 0: The output tensor of same shape as input0. 1418%insert AVAIL1 1419 */ 1420 %{DeclareOperation LOCAL_RESPONSE_NORMALIZATION 13}, 1421 1422 /** 1423 * Computes sigmoid activation on the input tensor element-wise. 1424 * 1425 * The output is calculated using this formula: 1426 * 1427 * output = 1 / (1 + exp(-input)) 1428 * 1429 * Supported tensor {@link %{OperandType}}: 1430%kind canonical ndk hal_1.2+ 1431 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 1432%/kind 1433 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 1434 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 1435%kind canonical ndk hal_1.3+ 1436 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 1437%/kind 1438 * 1439 * Supported tensor rank: up to 4. 1440 * 1441 * Inputs: 1442 * * 0: A tensor, specifying the input. 1443%kind canonical ndk hal_1.2+ 1444 * Since %{NNAPILevel3}, this tensor may be zero-sized. 1445%/kind 1446 * 1447 * Outputs: 1448 * * 0: The output tensor of same shape as input0. 1449 * For {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, 1450 * the scale must be 1.f / 256 and the zeroPoint must be 0. 1451%kind canonical ndk hal_1.3+ 1452 * For {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED}, 1453 * the scale must be 1.f / 256 and the zeroPoint must be -128. 1454%/kind 1455%insert AVAIL1 1456 */ 1457 %{DeclareOperation LOGISTIC 14}, 1458 1459 /** 1460 * Projects an input to a bit vector via locality senstive hashing. 1461 * 1462 * Supported input tensor {@link %{OperandType}}: 1463%kind canonical ndk hal_1.2+ 1464 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 1465%/kind 1466 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 1467 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 1468 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 1469 * 1470 * Supported input tensor rank: from 1 1471 * 1472 * Inputs: 1473 * * 0: Hash functions. Dim.size == 2, DataType: Float. 1474 * Tensor[0].Dim[0]: Number of hash functions. 1475 * Tensor[0].Dim[1]: Number of projected output bits generated by each 1476 * hash function. 1477 * If the projection type is Sparse: 1478 * Tensor[0].Dim[1] + ceil(log2(Tensor[0].Dim[0])) <= 32 1479 * 1480 * * 1: Input. Dim.size >= 1, no restriction on DataType. 1481 * * 2: Weight. Optional. Dim.size == 1, DataType: Float. 1482 * If not set, each input element is considered to have the same weight 1483 * of 1.0. 1484 * Tensor[1].Dim[0] == Tensor[2].Dim[0] 1485 * * 3: Type: 1486 * Sparse: 1487%kind canonical ndk hal_1.2+ 1488 * Value LSHProjectionType_SPARSE(=3) (since %{NNAPILevel3}). 1489%else 1490 * Value LSHProjectionType_SPARSE(=1). 1491%/kind 1492 * Computed bit vector is considered to be sparse. 1493 * Each output element is an int32 made up of multiple bits 1494 * computed from hash functions. 1495 * 1496%kind canonical ndk hal_1.2+ 1497 * NOTE: To avoid collisions across hash functions, an offset value 1498 * of k * (1 << Tensor[0].Dim[1]) will be added to each signature, 1499 * where k is the index of the hash function. 1500 * 1501 * Value LSHProjectionType_SPARSE_DEPRECATED(=1). 1502 * Legacy behavior that does not include the offset value. 1503 * 1504%/kind 1505 * Dense: 1506 * Value LSHProjectionType_DENSE(=2). 1507 * Computed bit vector is considered to be dense. Each output 1508 * element represents a bit and can take the value of either 1509 * 0 or 1. 1510 * 1511 * Outputs: 1512 * * 0: If the projection type is Sparse: 1513 * Output.Dim == { Tensor[0].Dim[0] } 1514 * A tensor of int32 that represents hash signatures. 1515 * 1516 * If the projection type is Dense: 1517 * Output.Dim == { Tensor[0].Dim[0] * Tensor[0].Dim[1] } 1518 * A flattened tensor that represents projected bit vectors. 1519%insert AVAIL1 1520%kind canonical ndk hal_1.2+ 1521 * The offset value for sparse projections was added in %{NNAPILevel3}. 1522%/kind 1523 */ 1524 %{DeclareOperation LSH_PROJECTION 15}, 1525 1526 /** 1527 * Performs a single time step in a Long Short-Term Memory (LSTM) layer 1528 * 1529 * The LSTM operation is described by the following equations. 1530 * 1531 * \f{eqnarray*}{ 1532 * i_t =& \sigma(W_{xi}x_t+W_{hi}h_{t-1}+W_{ci}C_{t-1}+b_i) & \\ 1533 * f_t =& \sigma(W_{xf}x_t+W_{hf}h_{t-1}+W_{cf}C_{t-1}+b_f) & \\ 1534 * C_t =& clip(f_t \odot C_{t-1} + i_t \odot 1535 * g(W_{xc}x_t+W_{hc}h_{t-1}+b_c),\ t_{cell}) & \\ 1536 * o_t =& \sigma(W_{xo}x_t+W_{ho}h_{t-1}+W_{co}C_t+b_o) & \\ 1537 * & & \\ 1538 * & clip(W_{proj}(o_t \odot g(C_t))+b_{proj},\ t_{proj}) 1539 * & if\ there\ is\ a\ projection; \\ 1540 * h_t =& & \\ 1541 * & o_t \odot g(C_t) & otherwise. \\ 1542 * \f} 1543 * Where: 1544 * * \f$x_t\f$ is the input, 1545 * * \f$i_t\f$ is the input gate, 1546 * * \f$f_t\f$ is the forget gate, 1547 * * \f$C_t\f$ is the cell state, 1548 * * \f$o_t\f$ is the output, 1549 * * \f$h_t\f$ is the output state, 1550 * * \f$\sigma\f$ is the logistic sigmoid function, 1551 * * \f$g\f$ is the cell input and cell output activation function, usually 1552 * \f$tahn\f$, 1553 * * \f$W_{xi}\f$ is the input-to-input weight matrix, 1554 * * \f$W_{hi}\f$ is the recurrent to input weight matrix, 1555 * * \f$W_{ci}\f$ is the cell-to-input weight matrix, 1556 * * \f$b_i\f$ is the input gate bias, 1557 * * \f$W_{xf}\f$ is the input-to-forget weight matrix, 1558 * * \f$W_{hf}\f$ is the recurrent-to-forget weight matrix, 1559 * * \f$W_{cf}\f$ is the cell-to-forget weight matrix, 1560 * * \f$b_f\f$ is the forget gate bias, 1561 * * \f$W_{xc}\f$ is the input-to-cell weight matrix, 1562 * * \f$W_{hc}\f$ is the recurrent-to-cell weight matrix, 1563 * * \f$b_c\f$ is the cell bias, 1564 * * \f$W_{xo}\f$ is the input-to-output weight matrix, 1565 * * \f$W_{ho}\f$ is the recurrent-to-output weight matrix, 1566 * * \f$W_{co}\f$ is the cell-to-output weight matrix, 1567 * * \f$b_o\f$ is the output gate bias, 1568 * * \f$W_{proj}\f$ is the projection weight matrix, 1569 * * \f$b_{proj}\f$ is the projection bias, 1570 * * \f$t_{cell}\f$ is the threshold for clipping the cell state, and 1571 * * \f$t_{proj}\f$ is the threshold for clipping the projected output. 1572 * * \f$\odot\f$ is the 1573 * <a href="https://en.wikipedia.org/wiki/Hadamard_product_(matrices)"> 1574 * Hadamard product</a> that takes two matrices and produces another 1575 * matrix, each element of which is the product of the corresponding 1576 * elements of the input matrices. 1577 * 1578%kind canonical ndk hal_1.2+ 1579 * Since %{NNAPILevel3} LSTM supports layer normalization. 1580 * In case layer normalization is used, the inputs to internal activation 1581 * functions (sigmoid and \f$g\f$) are normalized, rescaled and recentered 1582 * following an approach from section 3.1 from 1583 * https://arxiv.org/pdf/1607.06450.pdf 1584 * 1585%/kind 1586 * The operation has the following independently optional inputs: 1587 * * The cell-to-input weights (\f$W_{ci}\f$), cell-to-forget weights 1588 * (\f$W_{cf}\f$) and cell-to-output weights (\f$W_{co}\f$) either all 1589 * have values or neither of them have values (i.e., all set to null). If 1590 * they have values, the peephole optimization is used. 1591 * * The input-to-input weights (\f$W_{xi}\f$), recurrent-to-input weights 1592 * (\f$W_{hi}\f$) and input gate bias (\f$b_i\f$) either all have values, 1593 * or none of them have values. If they have no values, coupling of input 1594 * and forget gates (CIFG) is used, in which case the input gate 1595 * (\f$i_t\f$) is calculated using the following equation instead. 1596 * \f{eqnarray*}{ 1597 * i_t = 1 - f_t 1598 * \f} 1599 * In case peephole optimization is used and CIFG is not used 1600 * cell-to-input (\f$W_{ci}\f$) weights must be present. Otherwise, the 1601 * cell-to-input weights must have no value. 1602 * * The projection weights (\f$W_{proj}\f$) is required only for the 1603 * recurrent projection layer, and should otherwise have no value. 1604 * * The projection bias (\f$b_{proj}\f$) may (but not required to) have a 1605 * value if the recurrent projection layer exists, and should otherwise 1606 * have no value. 1607%kind canonical ndk hal_1.2+ 1608 * * (%{NNAPILevel3} or later) The four layer normalization weights either all have 1609 * values or none of them have values. Additionally, if CIFG is used, 1610 * input layer normalization weights tensor is omitted and the other layer 1611 * normalization weights either all have values or none of them have 1612 * values. Layer normalization is used when the values of all the layer 1613 * normalization weights are present. 1614%/kind 1615 * 1616 * References: 1617 * 1618 * The default non-peephole non-CIFG implementation is based on: 1619 * http://www.bioinf.jku.at/publications/older/2604.pdf 1620 * S. Hochreiter and J. Schmidhuber. "Long Short-Term Memory". Neural 1621 * Computation, 9(8):1735-1780, 1997. 1622 * 1623 * The peephole implementation and projection layer is based on: 1624 * https://research.google.com/pubs/archive/43905.pdf 1625 * Hasim Sak, Andrew Senior, and Francoise Beaufays. "Long short-term memory 1626 * recurrent neural network architectures for large scale acoustic 1627 * modeling." INTERSPEECH, 2014. 1628 * (However, the concept of peephole optimization was introduced in work 1629 * prior to this paper.) 1630 * 1631 * The coupling of input and forget gate (CIFG) is based on: 1632 * http://arxiv.org/pdf/1503.04069.pdf 1633 * Greff et al. "LSTM: A Search Space Odyssey" 1634 * 1635%kind canonical ndk hal_1.2+ 1636 * The layer normalization is based on: 1637 * https://arxiv.org/pdf/1607.06450.pdf 1638 * Jimmy Ba et al. "Layer Normalization" 1639 * 1640%/kind 1641 * Supported tensor {@link %{OperandType}}: 1642%kind canonical ndk hal_1.2+ 1643 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 1644%/kind 1645 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 1646 * 1647 * All input and output tensors must be of the same type. 1648 * 1649 * Inputs: 1650 * * 0: The input (\f$x_t\f$). 1651 * A 2-D tensor of shape [batch_size, input_size], where “batch_size” 1652 * corresponds to the batching dimension, and “input_size” is the size 1653 * of the input. 1654 * * 1: The input-to-input weights (\f$W_{xi}\f$). Optional. 1655 * A 2-D tensor of shape [num_units, input_size], where “num_units” 1656 * corresponds to the number of cell units. 1657 * * 2: The input-to-forget weights (\f$W_{xf}\f$). 1658 * A 2-D tensor of shape [num_units, input_size]. 1659 * * 3: The input-to-cell weights (\f$W_{xc}\f$). 1660 * A 2-D tensor of shape [num_units, input_size]. 1661 * * 4: The input-to-output weights (\f$W_{xo}\f$). 1662 * A 2-D tensor of shape [num_units, input_size]. 1663 * * 5: The recurrent-to-input weights (\f$W_{hi}\f$). Optional. 1664 * A 2-D tensor of shape [num_units, output_size], where “output_size” 1665 * corresponds to either the number of cell units (i.e., “num_units”), 1666 * or the second dimension of the “projection_weights”, if defined. 1667 * * 6: The recurrent-to-forget weights (\f$W_{hf}\f$). 1668 * A 2-D tensor of shape [num_units, output_size]. 1669 * * 7: The recurrent-to-cell weights (\f$W_{hc}\f$). 1670 * A 2-D tensor of shape [num_units, output_size]. 1671 * * 8: The recurrent-to-output weights (\f$W_{ho}\f$). 1672 * A 2-D tensor of shape [num_units, output_size]. 1673 * * 9: The cell-to-input weights (\f$W_{ci}\f$). Optional. 1674 * A 1-D tensor of shape [num_units]. 1675 * * 10:The cell-to-forget weights (\f$W_{cf}\f$). Optional. 1676 * A 1-D tensor of shape [num_units]. 1677 * * 11:The cell-to-output weights (\f$W_{co}\f$). Optional. 1678 * A 1-D tensor of shape [num_units]. 1679 * * 12:The input gate bias (\f$b_i\f$). Optional. 1680 * A 1-D tensor of shape [num_units]. 1681 * * 13:The forget gate bias (\f$b_f\f$). 1682 * A 1-D tensor of shape [num_units]. 1683 * * 14:The cell bias (\f$b_c\f$). 1684 * A 1-D tensor of shape [num_units]. 1685 * * 15:The output gate bias (\f$b_o\f$). 1686 * A 1-D tensor of shape [num_units]. 1687 * * 16:The projection weights (\f$W_{proj}\f$). Optional. 1688 * A 2-D tensor of shape [output_size, num_units]. 1689 * * 17:The projection bias (\f$b_{proj}\f$). Optional. 1690 * A 1-D tensor of shape [output_size]. 1691 * * 18:The output state (in) (\f$h_{t-1}\f$). 1692 * A 2-D tensor of shape [batch_size, output_size]. 1693 * * 19:The cell state (in) (\f$C_{t-1}\f$). 1694 * A 2-D tensor of shape [batch_size, num_units]. 1695 * * 20:The activation function (\f$g\f$). 1696 * A value indicating the activation function: 1697 * <ul> 1698 * <li>0: None; 1699 * <li>1: Relu; 1700 * <li>3: Relu6; 1701 * <li>4: Tanh; 1702 * <li>6: Sigmoid. 1703 * </ul> 1704 * * 21:The clipping threshold (\f$t_{cell}\f$) for the cell state, such 1705 * that values are bound within [-cell_clip, cell_clip]. If set to 0.0 1706 * then clipping is disabled. 1707%kind canonical ndk hal_1.2+ 1708 * Until %{NNAPILevel3} this scalar must be of type {@link 1709 * %{OperandTypeLinkPfx}FLOAT32}. Since %{NNAPILevel3}, if all the input 1710 * tensors have type {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32}, this 1711 * scalar must be of the type {@link %{OperandTypeLinkPfx}FLOAT32}, 1712 * otherwise if all the input tensors have the type {@link 1713 * %{OperandTypeLinkPfx}TENSOR_FLOAT16}, this scalar must be of type {@link 1714 * %{OperandTypeLinkPfx}FLOAT16}. 1715%/kind 1716 * * 22:The clipping threshold (\f$t_{proj}\f$) for the output from the 1717 * projection layer, such that values are bound within 1718 * [-proj_clip, proj_clip]. If set to 0.0 then clipping is disabled. 1719%kind canonical ndk hal_1.2+ 1720 * Until %{NNAPILevel3} this scalar must be of type {@link 1721 * %{OperandTypeLinkPfx}FLOAT32}. Since %{NNAPILevel3}, if all the input 1722 * tensors have type {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32}, this 1723 * scalar must be of the type {@link %{OperandTypeLinkPfx}FLOAT32}, 1724 * otherwise if all the input tensors have the type {@link 1725 * %{OperandTypeLinkPfx}TENSOR_FLOAT16}, this scalar must be of type {@link 1726 * %{OperandTypeLinkPfx}FLOAT16}. 1727 * Since %{NNAPILevel3} there are additional inputs to this op: 1728 * * 23:The input layer normalization weights. 1729 * A 1-D tensor of shape [num_units]. Used to rescale normalized inputs 1730 * to activation at input gate. 1731 * * 24:The forget layer normalization weights. 1732 * A 1-D tensor of shape [num_units]. Used to rescale normalized inputs 1733 * to activation at forget gate. 1734 * * 25:The cell layer normalization weights. 1735 * A 1-D tensor of shape [num_units]. Used to rescale normalized inputs 1736 * to activation at cell gate. 1737 * * 26:The output layer normalization weights. 1738 * A 1-D tensor of shape [num_units]. Used to rescale normalized inputs 1739 * to activation at output gate. 1740%/kind 1741 * 1742 * Outputs: 1743 * * 0: The scratch buffer. 1744 * A 2-D tensor of shape [batch_size, num_units * 3] with CIFG, or 1745 * [batch_size, num_units * 4] without CIFG. 1746 * * 1: The output state (out) (\f$h_t\f$). 1747 * A 2-D tensor of shape [batch_size, output_size]. 1748 * * 2: The cell state (out) (\f$C_t\f$). 1749 * A 2-D tensor of shape [batch_size, num_units]. 1750 * * 3: The output (\f$o_t\f$). 1751 * A 2-D tensor of shape [batch_size, output_size]. This is effectively 1752 * the same as the current “output state (out)” value. 1753%insert AVAIL1 1754 */ 1755 %{DeclareOperation LSTM 16}, 1756 1757 /** 1758 * Performs an 2-D max pooling operation. 1759 * 1760 * The output dimensions are functions of the filter dimensions, stride, and 1761 * padding. 1762 * 1763 * The values in the output tensor are computed as: 1764 * 1765 * output[b, i, j, channel] = 1766 * max_{di, dj} ( 1767 * input[b, strides[1] * i + di, strides[2] * j + dj, channel] 1768 * ) 1769 * 1770 * Supported tensor {@link %{OperandType}}: 1771%kind canonical ndk hal_1.2+ 1772 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 1773%/kind 1774 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 1775 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 1776%kind canonical ndk hal_1.3+ 1777 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 1778%/kind 1779 * 1780%insert NHWC_NCHW 1781 * 1782 * Both explicit padding and implicit padding are supported. 1783 * 1784 * Inputs (explicit padding): 1785 * * 0: A 4-D tensor, of shape [batches, height, width, depth], specifying 1786 * the input. 1787%insert ZeroBatchesNNAPILevel3 1788 * * 1: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 1789 * the left, in the ‘width’ dimension. 1790 * * 2: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 1791 * the right, in the ‘width’ dimension. 1792 * * 3: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 1793 * the top, in the ‘height’ dimension. 1794 * * 4: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 1795 * the bottom, in the ‘height’ dimension. 1796 * * 5: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 1797 * walking through input in the ‘width’ dimension. 1798 * * 6: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 1799 * walking through input in the ‘height’ dimension. 1800 * * 7: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the filter 1801 * width. 1802 * * 8: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the filter 1803 * height. 1804 * * 9: An {@link %{OperandTypeLinkPfx}INT32} scalar, and has to be one of the 1805 * {@link %{FusedActivationFunc}} values. Specifies the activation to 1806 * invoke on the result. 1807%kind canonical ndk hal_1.2+ 1808 * * 10: An optional {@link %{OperandTypeLinkPfx}BOOL} scalar, default to false. 1809 * Set to true to specify NCHW data layout for input0 and output0. 1810 * Available since %{NNAPILevel3}. 1811%/kind 1812 * 1813 * Inputs (implicit padding): 1814 * * 0: A 4-D tensor, of shape [batches, height, width, depth], specifying 1815 * the input. 1816%insert ZeroBatchesNNAPILevel3 1817 * * 1: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the implicit 1818 * padding scheme, has to be one of the 1819%insert PaddingCodeValues 1820 * * 2: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 1821 * walking through input in the ‘width’ dimension. 1822 * * 3: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 1823 * walking through input in the ‘height’ dimension. 1824 * * 4: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the filter 1825 * width. 1826 * * 5: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the filter 1827 * height. 1828 * * 6: An {@link %{OperandTypeLinkPfx}INT32} scalar, and has to be one of the 1829 * {@link %{FusedActivationFunc}} values. Specifies the activation to 1830 * invoke on the result. 1831%kind canonical ndk hal_1.2+ 1832 * * 7: An optional {@link %{OperandTypeLinkPfx}BOOL} scalar, default to false. 1833 * Set to true to specify NCHW data layout for input0 and output0. 1834 * Available since %{NNAPILevel3}. 1835%/kind 1836 * 1837 * Outputs: 1838 * * 0: The output 4-D tensor, of shape 1839 * [batches, out_height, out_width, depth]. 1840%kind canonical ndk hal_1.3+ 1841 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 1842 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 1843 * the scale and zeroPoint must be the same as input0. 1844%else 1845 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 1846 * the scale and zeroPoint must be the same as input0. 1847%/kind 1848%insert AVAIL1 1849 */ 1850 %{DeclareOperation MAX_POOL_2D 17}, 1851 1852 /** 1853 * Multiplies two tensors, element-wise. 1854 * 1855 * Takes two input tensors of identical {@link %{OperandType}} and compatible 1856 * dimensions. The output is the product of both input tensors, optionally 1857 * modified by an activation function. 1858 * 1859 * Two dimensions are compatible when: 1860 * 1. they are equal, or 1861 * 2. one of them is 1 1862 * 1863 * The size of the resulting output is the maximum size along each dimension 1864 * of the input operands. It starts with the trailing dimensions, and works 1865 * its way forward. 1866 * 1867%insert GenericZero 1868 * Supported tensor {@link %{OperandType}}: 1869%kind canonical ndk hal_1.2+ 1870 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 1871%/kind 1872 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 1873 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 1874%kind canonical ndk hal_1.3+ 1875 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 1876 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} (since %{NNAPILevel4}) 1877%/kind 1878 * 1879 * Supported tensor rank: up to 4 1880 * 1881 * Inputs: 1882 * * 0: A tensor. 1883 * * 1: A tensor of the same {@link %{OperandType}}, and compatible dimensions 1884 * as input0. 1885 * * 2: An {@link %{OperandTypeLinkPfx}INT32} scalar, and has to be one of the 1886 * {@link %{FusedActivationFunc}} values. Specifies the activation to 1887 * invoke on the result. 1888%kind canonical ndk hal_1.3+ 1889 * For a {@link %{OperandTypeLinkPfx}TENSOR_INT32} tensor, 1890 * the {@link %{FusedActivationFunc}} must be "NONE". 1891%/kind 1892 * 1893 * Outputs: 1894 * * 0: The product, a tensor of the same {@link %{OperandType}} as input0. 1895%kind canonical ndk hal_1.3+ 1896 * For output tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 1897 * and {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED}, 1898 * the following condition must be satisfied: 1899 * output_scale > input1_scale * input2_scale. 1900%else 1901 * For output tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, 1902 * the following condition must be satisfied: 1903 * output_scale > input1_scale * input2_scale. 1904%/kind 1905%insert AVAIL1 1906 */ 1907 %{DeclareOperation MUL 18}, 1908 1909 /** 1910 * Computes rectified linear activation on the input tensor element-wise. 1911 * 1912 * The output is calculated using this formula: 1913 * 1914 * output = max(0, input) 1915 * 1916 * Supported tensor {@link %{OperandType}}: 1917%kind canonical ndk hal_1.2+ 1918 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 1919%/kind 1920 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 1921 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 1922%kind canonical ndk hal_1.3+ 1923 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 1924%/kind 1925 * 1926 * Supported tensor rank: up to 4. 1927 * 1928 * Inputs: 1929 * * 0: A tensor, specifying the input. 1930%kind canonical ndk hal_1.2+ 1931 * Since %{NNAPILevel3}, this tensor may be zero-sized. 1932%/kind 1933 * 1934 * Outputs: 1935 * * 0: The output tensor of same shape as input0. 1936%kind canonical ndk hal_1.3+ 1937 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 1938 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 1939 * the scale and zeroPoint must be the same as input0. 1940%else 1941 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 1942 * the scale and zeroPoint must be the same as input0. 1943%/kind 1944%insert AVAIL1 1945 */ 1946 %{DeclareOperation RELU 19}, 1947 1948 /** 1949 * Computes rectified linear 1 activation on the input tensor element-wise. 1950 * 1951 * The output is calculated using this formula: 1952 * 1953 * output = min(1.f, max(-1.f, input)) 1954 * 1955 * Supported tensor {@link %{OperandType}}: 1956%kind canonical ndk hal_1.2+ 1957 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 1958%/kind 1959 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 1960 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 1961%kind canonical ndk hal_1.3+ 1962 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 1963%/kind 1964 * 1965 * Supported tensor rank: up to 4. 1966 * 1967 * Inputs: 1968 * * 0: A tensor, specifying the input. 1969%kind canonical ndk hal_1.2+ 1970 * Since %{NNAPILevel3}, this tensor may be zero-sized. 1971%/kind 1972 * 1973 * Outputs: 1974 * * 0: The output tensor of the same shape as input0. 1975%kind canonical ndk hal_1.3+ 1976 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 1977 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 1978 * the scale and zeroPoint must be the same as input0. 1979%else 1980 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 1981 * the scale and zeroPoint must be the same as input0. 1982%/kind 1983%insert AVAIL1 1984 */ 1985 %{DeclareOperation RELU1 20}, 1986 1987 /** 1988 * Computes rectified linear 6 activation on the input tensor element-wise. 1989 * 1990 * The output is calculated using this formula: 1991 * 1992 * output = min(6, max(0, input)) 1993 * 1994 * Supported tensor {@link %{OperandType}}: 1995%kind canonical ndk hal_1.2+ 1996 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 1997%/kind 1998 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 1999 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 2000%kind canonical ndk hal_1.3+ 2001 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 2002%/kind 2003 * 2004 * Supported tensor rank: up to 4. 2005 * 2006 * Inputs: 2007 * * 0: A tensor, specifying the input. 2008%kind canonical ndk hal_1.2+ 2009 * Since %{NNAPILevel3}, this tensor may be zero-sized. 2010%/kind 2011 * 2012 * Outputs: 2013 * * 0: The output tensor of same shape as input0. 2014%kind canonical ndk hal_1.3+ 2015 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 2016 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 2017 * the scale and zeroPoint must be the same as input0. 2018%else 2019 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 2020 * the scale and zeroPoint must be the same as input0. 2021%/kind 2022%insert AVAIL1 2023 */ 2024 %{DeclareOperation RELU6 21}, 2025 2026 /** 2027 * Reshapes a tensor. 2028 * 2029 * Given tensor, this operation returns a tensor that has the same values as 2030 * tensor, but with a newly specified shape. 2031 * 2032 * Supported tensor {@link %{OperandType}}: 2033%kind canonical ndk hal_1.2+ 2034 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 2035%/kind 2036 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 2037 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 2038%kind canonical ndk hal_1.3+ 2039 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 2040%/kind 2041 * 2042 * Supported tensor rank: up to 4. 2043 * 2044 * Inputs: 2045 * * 0: A tensor, specifying the tensor to be reshaped. 2046 * * 1: A 1-D tensor of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, defining the 2047 * shape of the output tensor. The number of elements implied by shape 2048 * must be the same as the number of elements in the input tensor. 2049 * 2050 * If one component of shape is the special value -1, the size of that 2051 * dimension is computed so that the total size remains constant. In 2052 * particular, a shape of [-1] flattens into 1-D. At most one component 2053 * of shape can be -1. 2054 * 2055 * Outputs: 2056 * * 0: The output tensor, of shape specified by the input shape. 2057%kind canonical ndk hal_1.3+ 2058 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 2059 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 2060 * the scale and zeroPoint must be the same as input0. 2061%else 2062 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 2063 * the scale and zeroPoint must be the same as input0. 2064%/kind 2065%insert AVAIL1 2066 */ 2067 %{DeclareOperation RESHAPE 22}, 2068 2069 /** 2070 * Resizes images to given size using the bilinear interpretation. 2071 * 2072 * Resized images must be distorted if their output aspect ratio is not the 2073 * same as input aspect ratio. The corner pixels of output may not be the 2074 * same as corner pixels of input. 2075 * 2076 * Supported tensor {@link %{OperandType}}: 2077%kind canonical ndk hal_1.2+ 2078 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 2079%/kind 2080 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 2081%kind canonical ndk hal_1.2+ 2082 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} (since %{NNAPILevel3}) 2083%/kind 2084%kind canonical ndk hal_1.3+ 2085 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 2086%/kind 2087 * 2088%insert NHWC_NCHW 2089 * 2090%kind canonical ndk hal_1.2+ 2091 * Both resizing by shape and resizing by scale are supported. 2092 * 2093%/kind 2094 * Inputs (resizing by shape): 2095 * * 0: A 4-D tensor, of shape [batches, height, width, depth], specifying 2096 * the input. 2097%insert ZeroBatchesNNAPILevel3 2098 * * 1: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the output 2099 * width of the output tensor. 2100 * * 2: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the output 2101 * height of the output tensor. 2102%kind canonical ndk hal_1.2+ 2103 * * 3: An optional {@link %{OperandTypeLinkPfx}BOOL} scalar, default to false. 2104 * Set to true to specify NCHW data layout for input0 and output0. 2105 * Available since %{NNAPILevel3}. 2106%/kind 2107%kind canonical ndk hal_1.3+ 2108 * * 4: Align corners. An optional {@link %{OperandTypeLinkPfx}BOOL} 2109 * scalar, default to false. If True, the centers of the 4 corner 2110 * pixels of the input and output tensors are aligned, preserving the 2111 * values at the corner pixels. 2112 * Available since %{NNAPILevel4}. 2113 * * 5: Half pixel centers. An optional {@link %{OperandTypeLinkPfx}BOOL} 2114 * scalar, default to false. If True, the pixel centers are assumed to 2115 * be at (0.5, 0.5). This is the default behavior of image.resize in 2116 * TF 2.0. If this parameter is True, then align_corners parameter 2117 * must be False. 2118 * Available since %{NNAPILevel4}. 2119%/kind 2120%kind canonical ndk hal_1.2+ 2121 * 2122 * Inputs (resizing by scale, since %{NNAPILevel3}): 2123 * * 0: A 4-D tensor, of shape [batches, height, width, depth], specifying 2124 * the input. Zero batches is supported for this tensor. 2125 * * 1: A scalar, specifying width_scale, the scaling factor of the width 2126 * dimension from the input tensor to the output tensor. The output 2127 * width is calculated as new_width = floor(width * width_scale). 2128 * The scalar must be of {@link %{OperandTypeLinkPfx}FLOAT16} if input0 is 2129 * of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} and of 2130 * {@link %{OperandTypeLinkPfx}FLOAT32} otherwise. 2131 * * 2: A scalar, specifying height_scale, the scaling factor of the height 2132 * dimension from the input tensor to the output tensor. The output 2133 * height is calculated as new_height = floor(height * height_scale). 2134 * The scalar must be of {@link %{OperandTypeLinkPfx}FLOAT16} if input0 is 2135 * of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} and of 2136 * {@link %{OperandTypeLinkPfx}FLOAT32} otherwise. 2137 * * 3: An optional {@link %{OperandTypeLinkPfx}BOOL} scalar, default to false. 2138 * Set to true to specify NCHW data layout for input0 and output0. 2139%/kind 2140%kind canonical ndk hal_1.3+ 2141 * * 4: Align corners. An optional {@link %{OperandTypeLinkPfx}BOOL} 2142 * scalar, default to false. If True, the centers of the 4 corner 2143 * pixels of the input and output tensors are aligned, preserving the 2144 * values at the corner pixels. 2145 * Available since %{NNAPILevel4}. 2146 * * 5: Half pixel centers. An optional {@link %{OperandTypeLinkPfx}BOOL} 2147 * scalar, default to false. If True, the pixel centers are assumed to 2148 * be at (0.5, 0.5). This is the default behavior of image.resize in 2149 * TF 2.0. If this parameter is True, then align_corners parameter 2150 * must be False. 2151 * Available since %{NNAPILevel4}. 2152%/kind 2153 * 2154 * Outputs: 2155 * * 0: The output 4-D tensor, of shape 2156 * [batches, new_height, new_width, depth]. 2157%kind canonical ndk hal_1.3+ 2158 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 2159 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 2160 * the scale and zeroPoint must be the same as input0. 2161%/kind 2162%kind canonical ndk hal_1.2 2163 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 2164 * the scale and zeroPoint must be the same as input0. 2165%/kind 2166%insert AVAIL1 2167 */ 2168 %{DeclareOperation RESIZE_BILINEAR 23}, 2169 2170 /** 2171 * A basic recurrent neural network layer. 2172 * 2173 * This layer implements the operation: 2174 * outputs = state = activation(inputs * input_weights + 2175 * state * recurrent_weights + bias) 2176 * 2177 * Where: 2178 * * “input_weights” is a weight matrix that multiplies the inputs; 2179 * * “recurrent_weights” is a weight matrix that multiplies the current 2180 * “state” which itself is the output from the previous time step 2181 * computation; 2182 * * “bias” is a bias vector (added to each output vector in the batch); 2183 * * “activation” is the function passed as the “fused_activation_function” 2184 * argument (if not “NONE”). 2185 * 2186 * Supported tensor {@link %{OperandType}}: 2187%kind canonical ndk hal_1.2+ 2188 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 2189%/kind 2190 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 2191 * 2192 * The input tensors must all be the same type. 2193 * 2194 * Inputs: 2195 * * 0: input. 2196 * A 2-D tensor of shape [batch_size, input_size], where “batch_size” 2197 * corresponds to the batching dimension, and “input_size” is the size 2198 * of the input. 2199 * * 1: weights. 2200 * A 2-D tensor of shape [num_units, input_size], where “num_units” 2201 * corresponds to the number of units. 2202 * * 2: recurrent_weights. 2203 * A 2-D tensor of shape [num_units, num_units], with columns 2204 * corresponding to the weights from each unit. 2205 * * 3: bias. 2206 * A 1-D tensor of shape [num_units]. 2207 * * 4: hidden state (in). 2208 * A 2-D tensor of shape [batch_size, num_units]. 2209 * * 5: fused_activation_function. 2210 * An optional {@link %{FusedActivationFunc}} value indicating the 2211 * activation function. If “NONE” is specified then it results in a 2212 * linear activation. 2213 * 2214 * Outputs: 2215 * * 0: hidden state (out). 2216 * A 2-D tensor of shape [batch_size, num_units]. 2217 * 2218 * * 1: output. 2219 * A 2-D tensor of shape [batch_size, num_units]. This is effectively 2220 * the same as the current state value. 2221%insert AVAIL1 2222 */ 2223 %{DeclareOperation RNN 24}, 2224 2225 /** 2226 * Computes the softmax activation on the input tensor element-wise, per 2227 * batch, by normalizing the input vector so the maximum coefficient is 2228 * zero. 2229 * 2230 * The output is calculated using this formula: 2231 * 2232 * output[batch, i] = 2233 * exp((input[batch, i] - max(input[batch, :])) * beta) / 2234 * sum_{k}{exp((input[batch, k] - max(input[batch, :])) * beta)} 2235 * 2236 * For input tensor with rank other than 2, the activation will be applied 2237 * independently on each 1-D slice along specified dimension. 2238 * 2239 * Supported tensor {@link %{OperandType}}: 2240%kind canonical ndk hal_1.2+ 2241 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 2242%/kind 2243 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 2244 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 2245%kind canonical ndk hal_1.3+ 2246 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 2247%/kind 2248 * 2249%kind hal_1.0 hal_1.1 2250 * Supported tensor rank: 2 or 4. 2251%/kind 2252%kind canonical ndk hal_1.2+ 2253 * Supported tensor rank: up to 4. 2254 * Tensors with rank other than 2 or 4 are only supported since %{NNAPILevel3}. 2255%/kind 2256 * 2257 * Inputs: 2258 * * 0: A 2-D or 4-D tensor, specifying the tensor to be reshaped. 2259%kind canonical ndk hal_1.2+ 2260 * Since %{NNAPILevel3}, this tensor may be zero-sized. 2261%/kind 2262%kind canonical ndk hal_1.3+ 2263 * * 1: A scalar, specifying the positive scaling factor for the exponent, 2264 * beta. If input0 is of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32}, 2265 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} or 2266 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED}, the scalar 2267 * must be of {@link %{OperandTypeLinkPfx}FLOAT32}. 2268%else 2269 * * 1: A scalar, specifying the positive scaling factor for the exponent, 2270 * beta. If input0 is of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} or 2271 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, the scalar must be of 2272 * {@link %{OperandTypeLinkPfx}FLOAT32}. 2273%/kind 2274%kind canonical ndk hal_1.2+ 2275 * If input0 is of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16}, then the 2276 * scalar must be of {@link %{OperandTypeLinkPfx}FLOAT16}. 2277%/kind 2278%kind canonical ndk hal_1.2+ 2279 * * 2: An optional {@link %{OperandTypeLinkPfx}INT32} scalar, default to -1, 2280 * specifying the dimension the activation would be performed on. 2281 * Negative index is used to specify axis from the end (e.g. -1 for 2282 * the last axis). Must be in the range [-n, n). 2283 * Available since %{NNAPILevel3}. 2284%/kind 2285 * 2286 * Outputs: 2287 * * 0: The output tensor of same shape as input0. 2288 * For {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, 2289 * the scale must be 1.f / 256 and the zeroPoint must be 0. 2290%kind canonical ndk hal_1.3+ 2291 * For {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED}, 2292 * the scale must be 1.f / 256 and the zeroPoint must be -128. 2293%/kind 2294%insert AVAIL1 2295 */ 2296 %{DeclareOperation SOFTMAX 25}, 2297 2298 /** 2299 * Rearranges blocks of spatial data, into depth. 2300 * 2301 * More specifically, this op outputs a copy of the input tensor where 2302 * values from the height and width dimensions are moved to the depth 2303 * dimension. The value block_size indicates the input block size and how 2304 * the data is moved. 2305 * 2306 * Chunks of data of size block_size * block_size from depth are rearranged 2307 * into non-overlapping blocks of size block_size x block_size. 2308 * 2309 * The depth of the output tensor is input_depth * block_size * block_size. 2310 * The input tensor's height and width must be divisible by block_size. 2311 * 2312 * Supported tensor {@link %{OperandType}}: 2313%kind canonical ndk hal_1.2+ 2314 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 2315%/kind 2316 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 2317 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 2318%kind canonical ndk hal_1.3+ 2319 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 2320%/kind 2321 * 2322%insert NHWC_NCHW 2323 * 2324 * Inputs: 2325 * * 0: A 4-D tensor, of shape [batches, height, width, depth_in], 2326 * specifying the input. 2327 * * 1: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the block_size. 2328 * block_size must be >=1 and block_size must be a divisor of both the 2329 * input height and width. 2330%kind canonical ndk hal_1.2+ 2331 * * 2: An optional {@link %{OperandTypeLinkPfx}BOOL} scalar, default to false. 2332 * Set to true to specify NCHW data layout for input0 and output0. 2333 * Available since %{NNAPILevel3}. 2334%/kind 2335 * 2336 * Outputs: 2337 * * 0: The output 4-D tensor, of shape [batches, height/block_size, 2338 * width/block_size, depth_in*block_size*block_size]. 2339%kind canonical ndk hal_1.3+ 2340 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 2341 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 2342 * the scale and zeroPoint must be the same as input0. 2343%else 2344 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 2345 * the scale and zeroPoint must be the same as input0. 2346%/kind 2347%insert AVAIL1 2348 */ 2349 %{DeclareOperation SPACE_TO_DEPTH 26}, 2350 2351 /** 2352 * SVDF op is a kind of stateful layer derived from the notion that a 2353 * densely connected layer that's processing a sequence of input frames can 2354 * be approximated by using a singular value decomposition of each of its 2355 * nodes. The implementation is based on: 2356 * 2357 * https://research.google.com/pubs/archive/43813.pdf 2358 * 2359 * P. Nakkiran, R. Alvarez, R. Prabhavalkar, C. Parada. 2360 * “Compressing Deep Neural Networks using a Rank-Constrained Topology”. 2361 * INTERSPEECH, 2015. 2362 * 2363 * It processes the incoming input using a 2-stage filtering mechanism: 2364 * * stage 1 performs filtering on the "features" dimension, whose outputs 2365 * get pushed into a memory of fixed-size memory_size. 2366 * * stage 2 performs filtering on the "time" dimension of the memory_size 2367 * memoized outputs of stage 1. 2368 * 2369 * Specifically, for rank 1, this layer implements the operation: 2370 * 2371 * memory = push(conv1d(inputs, weights_feature, feature_dim, 2372 * "%{ANN}PADDING_VALID")); 2373 * outputs = activation(memory * weights_time + bias); 2374 * 2375 * Where: 2376 * * “weights_feature” is a weights matrix that processes the inputs (by 2377 * convolving the input with every “feature filter”), and whose outputs 2378 * get pushed, stacked in order, into the fixed-size “memory” (the oldest 2379 * entry gets dropped); 2380 * * “weights_time” is a weights matrix that processes the “memory” (by a 2381 * batched matrix multiplication on the num_units); 2382 * * “bias” is an optional bias vector (added to each output vector in the 2383 * batch); and 2384 * * “activation” is the function passed as the “fused_activation_function” 2385 * argument (if not “NONE”). 2386 * 2387 * Each rank adds a dimension to the weights matrices by means of stacking 2388 * the filters. 2389 * 2390 * Supported tensor {@link %{OperandType}}: 2391%kind canonical ndk hal_1.2+ 2392 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 2393%/kind 2394 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 2395 * 2396 * All input tensors must be the same type. 2397 * 2398 * Inputs: 2399 * * 0: input. 2400 * A 2-D tensor of shape [batch_size, input_size], where “batch_size” 2401 * corresponds to the batching dimension, and “input_size” is the size 2402 * of the input. 2403 * * 1: weights_feature. 2404 * A 2-D tensor of shape [num_units, input_size], where “num_units” 2405 * corresponds to the number of units. 2406 * * 2: weights_time. 2407 * A 2-D tensor of shape [num_units, memory_size], where “memory_size” 2408 * corresponds to the fixed-size of the memory. 2409 * * 3: bias. 2410 * An optional 1-D tensor of shape [num_units]. 2411 * * 4: state (in). 2412 * A 2-D tensor of shape [batch_size, (memory_size - 1) * num_units * rank]. 2413 * * 5: rank. 2414 * The rank of the SVD approximation. 2415 * * 6: fused_activation_function. 2416 * An optional {@link %{FusedActivationFunc}} value indicating the 2417 * activation function. If “NONE” is specified then it results in a 2418 * linear activation. 2419 * 2420 * Outputs: 2421 * * 0: state (out). 2422 * A 2-D tensor of the same {@link %{OperandType}} as the inputs, with shape 2423 * [batch_size, (memory_size - 1) * num_units * rank]. 2424 * * 1: output. 2425 * A 2-D tensor of the same {@link %{OperandType}} as the inputs, with shape 2426 * [batch_size, num_units]. 2427%insert AVAIL1 2428 */ 2429 %{DeclareOperation SVDF 27}, 2430 2431 /** 2432 * Computes hyperbolic tangent of input tensor element-wise. 2433 * 2434 * The output is calculated using this formula: 2435 * 2436 * output = tanh(input) 2437 * 2438 * Supported tensor {@link %{OperandType}}: 2439%kind canonical ndk hal_1.2+ 2440 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 2441%/kind 2442 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 2443%kind canonical ndk hal_1.2+ 2444 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} (since %{NNAPILevel3}) 2445%/kind 2446%kind canonical ndk hal_1.3+ 2447 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 2448%/kind 2449 * 2450 * Supported tensor rank: up to 4. 2451 * 2452 * Inputs: 2453 * * 0: A tensor, specifying the input. 2454%kind canonical ndk hal_1.2+ 2455 * Since %{NNAPILevel3}, this tensor may be zero-sized. 2456%/kind 2457 * 2458 * Outputs: 2459 * * 0: The output tensor of same shape as input0. 2460%kind canonical ndk hal_1.2+ 2461 * For {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, 2462 * the scale must be 1.f / 128 and the zeroPoint must be 128. 2463%/kind 2464%kind canonical ndk hal_1.3+ 2465 * For {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED}, 2466 * the scale must be 1.f / 128 and the zeroPoint must be 0. 2467%/kind 2468%insert AVAIL1 2469 */ 2470 %{DeclareOperation TANH 28}, 2471%/section 2472 2473%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2474 2475%% HAL OperationType for 1.1 2476%% NDK OperationCode for API 28 2477 2478%section Operation_1.1 2479 /** 2480 * BatchToSpace for N-dimensional tensors. 2481 * 2482 * This operation reshapes the batch dimension (dimension 0) into M + 1 2483 * dimensions of shape block_shape + [batch], interleaves these blocks back 2484 * into the grid defined by the spatial dimensions [1, ..., M], to obtain a 2485 * result with the same rank as the input. 2486 * 2487 * This is the reverse of SpaceToBatch. 2488 * 2489 * Supported tensor {@link %{OperandType}}: 2490%kind canonical ndk hal_1.2+ 2491 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 2492%/kind 2493 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 2494 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 2495%kind canonical ndk hal_1.3+ 2496 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 2497%/kind 2498 * 2499%insert NHWC_NCHW 2500 * 2501 * Inputs: 2502 * * 0: An n-D tensor, specifying the tensor to be reshaped 2503 * * 1: A 1-D Tensor of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, the block 2504 * sizes for each spatial dimension of the input tensor. All values 2505 * must be >= 1. 2506%kind canonical ndk hal_1.2+ 2507 * * 2: An optional {@link %{OperandTypeLinkPfx}BOOL} scalar, default to false. 2508 * Set to true to specify NCHW data layout for input0 and output0. 2509 * Available since API level 29. 2510%/kind 2511 * 2512 * Outputs: 2513 * * 0: A tensor of the same {@link %{OperandType}} as input0. 2514%kind canonical ndk hal_1.3+ 2515 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 2516 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 2517 * the scale and zeroPoint must be the same as input0. 2518%else 2519 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 2520 * the scale and zeroPoint must be the same as input0. 2521%/kind 2522%insert AVAIL2 2523 */ 2524 %{DeclareOperation BATCH_TO_SPACE_ND 29}, 2525 2526 /** 2527 * Element-wise division of two tensors. 2528 * 2529 * Takes two input tensors of identical {@link %{OperandType}} and compatible 2530 * dimensions. The output is the result of dividing the first input tensor 2531 * by the second, optionally modified by an activation function. 2532 * 2533%kind canonical ndk hal_1.3+ 2534 * For inputs of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, performs 2535 * "floor division" ("//" in Python). For example, 2536 * 5 // 2 = 2 2537 * -5 // 2 = -3 2538 * 2539%/kind 2540 * Two dimensions are compatible when: 2541 * 1. they are equal, or 2542 * 2. one of them is 1 2543 * 2544 * The size of the output is the maximum size along each dimension of the 2545 * input operands. It starts with the trailing dimensions, and works its way 2546 * forward. 2547 * 2548 * Example: 2549 * input1.dimension = {4, 1, 2} 2550 * input2.dimension = {5, 4, 3, 1} 2551 * output.dimension = {5, 4, 3, 2} 2552 * 2553%insert GenericZero 2554 * Supported tensor {@link %{OperandType}}: 2555%kind canonical ndk hal_1.2+ 2556 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 2557%/kind 2558 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 2559%kind canonical ndk hal_1.3+ 2560 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} (since %{NNAPILevel4}) 2561%/kind 2562 * 2563 * Supported tensor rank: up to 4 2564 * 2565 * Inputs: 2566 * * 0: An n-D tensor, specifying the first input. 2567 * * 1: A tensor of the same {@link %{OperandType}}, and compatible dimensions 2568 * as input0. 2569 * * 2: An {@link %{OperandTypeLinkPfx}INT32} scalar, and has to be one of the 2570 * {@link %{FusedActivationFunc}} values. Specifies the activation to 2571 * invoke on the result. 2572%kind canonical ndk hal_1.3+ 2573 * For a {@link %{OperandTypeLinkPfx}TENSOR_INT32} tensor, 2574 * the {@link %{FusedActivationFunc}} must be "NONE". 2575%/kind 2576 * 2577 * Outputs: 2578 * * 0: A tensor of the same {@link %{OperandType}} as input0. 2579%insert AVAIL2 2580 */ 2581 %{DeclareOperation DIV 30}, 2582 2583 /** 2584 * Computes the mean of elements across dimensions of a tensor. 2585 * 2586 * Reduces the input tensor along the given dimensions to reduce. Unless 2587 * keep_dims is true, the rank of the tensor is reduced by 1 for each entry 2588 * in axis. If keep_dims is true, the reduced dimensions are retained with 2589 * length 1. 2590 * 2591 * Supported tensor {@link %{OperandType}}: 2592%kind canonical ndk hal_1.2+ 2593 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 2594%/kind 2595 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 2596 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 2597%kind canonical ndk hal_1.3+ 2598 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 2599%/kind 2600 * 2601 * Supported tensor rank: up to 4 2602 * 2603 * Inputs: 2604 * * 0: A tensor, specifying the input. 2605 * * 1: A 1-D Tensor of {@link %{OperandTypeLinkPfx}TENSOR_INT32}. The dimensions 2606 * to reduce. Must be in the range 2607 * [-rank(input_tensor), rank(input_tensor)). 2608 * 2609 * NOTE: When the operation was introduced, the documentation 2610 * incorrectly stated that if dimensions were empty, the operation 2611 * would reduce across all dimensions. This behavior was never 2612 * implemented. 2613 * 2614 * * 2: An {@link %{OperandTypeLinkPfx}INT32} scalar, keep_dims. If positive, 2615 * retains reduced dimensions with length 1. 2616 * 2617 * Outputs: 2618 * * 0: A tensor of the same {@link %{OperandType}} as input0. 2619%kind canonical ndk hal_1.3+ 2620 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 2621 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 2622 * the scale and zeroPoint must be the same as input0. 2623%else 2624 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 2625 * the scale and zeroPoint must be the same as input0. 2626%/kind 2627 * If all dimensions are reduced and keep_dims is false, the output 2628 * shape is [1]. 2629%insert AVAIL2 2630 */ 2631 %{DeclareOperation MEAN 31}, 2632 2633 /** 2634 * Pads a tensor. 2635 * 2636 * This operation pads a tensor according to the specified paddings. 2637 * 2638 * Supported tensor {@link %{OperandType}}: 2639%kind canonical ndk hal_1.2+ 2640 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 2641%/kind 2642 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 2643 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 2644%kind canonical ndk hal_1.3+ 2645 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 2646%/kind 2647%kind canonical ndk hal_1.2+ 2648 * (full support since %{NNAPILevel3}, see the output section) 2649%else 2650 * (the pad value is undefined) 2651%/kind 2652 * 2653 * Supported tensor rank: up to 4 2654 * 2655 * Inputs: 2656 * * 0: An n-D tensor, specifying the tensor to be padded. 2657 * * 1: A 2-D Tensor of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, the paddings 2658 * for each spatial dimension of the input tensor. The shape of the 2659 * tensor must be {rank(input0), 2}. 2660 * padding[i, 0] specifies the number of elements to be padded in the 2661 * front of dimension i. 2662 * padding[i, 1] specifies the number of elements to be padded after the 2663 * end of dimension i. 2664 * 2665 * Outputs: 2666 * * 0: A tensor of the same {@link %{OperandType}} as input0. The 2667 * output tensor has the same rank as input0, and each 2668 * dimension of the output tensor has the same size as the 2669 * corresponding dimension of the input tensor plus the size 2670 * of the padding: 2671 * output0.dimension[i] = 2672 * padding[i, 0] + input0.dimension[i] + padding[i, 1] 2673%kind canonical ndk hal_1.3+ 2674 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 2675 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 2676 * the scale and zeroPoint must be the same as input0. 2677%else 2678 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 2679 * the scale and zeroPoint must be the same as input0. 2680%/kind 2681%kind canonical ndk hal_1.2+ 2682 * 2683 * NOTE: Before %{NNAPILevel3}, the pad value for 2684 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} is undefined. 2685 * Since %{NNAPILevel3}, the pad value is always the logical zero. 2686%/kind 2687%insert AVAIL2 2688 */ 2689 %{DeclareOperation PAD 32}, 2690 2691 /** 2692 * SpaceToBatch for N-Dimensional tensors. 2693 * 2694 * This operation divides "spatial" dimensions [1, ..., M] of the input into 2695 * a grid of blocks of shape block_shape, and interleaves these blocks with 2696 * the "batch" dimension (0) such that in the output, the spatial dimensions 2697 * [1, ..., M] correspond to the position within the grid, and the batch 2698 * dimension combines both the position within a spatial block and the 2699 * original batch position. Prior to division into blocks, the spatial 2700 * dimensions of the input are optionally zero padded according to paddings. 2701 * 2702 * Supported tensor {@link %{OperandType}}: 2703%kind canonical ndk hal_1.2+ 2704 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 2705%/kind 2706 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 2707 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 2708%kind canonical ndk hal_1.3+ 2709 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 2710%/kind 2711%kind canonical ndk hal_1.2+ 2712 * (full support since %{NNAPILevel3}, see the output section) 2713%else 2714 * (the pad value is undefined) 2715%/kind 2716 * 2717%insert NHWC_NCHW 2718 * 2719 * Inputs: 2720 * * 0: An n-D tensor, specifying the input. 2721 * * 1: A 1-D Tensor of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, the block 2722 * sizes for each spatial dimension of the input tensor. All values 2723 * must be >= 1. 2724 * * 2: A 2-D Tensor of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, the paddings 2725 * for each spatial dimension of the input tensor. All values must be 2726 * >= 0. The shape of the tensor must be {M, 2}, where M is the number 2727 * of spatial dimensions. 2728 * padding[i, 0] specifies the number of element to be padded in the 2729 * front of dimension i. 2730 * padding[i, 1] specifies the number of element to be padded after the 2731 * end of dimension i. 2732%kind canonical ndk hal_1.2+ 2733 * * 3: An optional {@link %{OperandTypeLinkPfx}BOOL} scalar, default to false. 2734 * Set to true to specify NCHW data layout for input0 and output0. 2735 * Available since %{NNAPILevel3}. 2736%/kind 2737 * 2738 * Outputs: 2739 * * 0: A tensor of the same {@link %{OperandType}} as input0. 2740%kind canonical ndk hal_1.3+ 2741 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 2742 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 2743 * the scale and zeroPoint must be the same as input0. 2744%else 2745 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 2746 * the scale and zeroPoint must be the same as input0. 2747%/kind 2748%kind canonical ndk hal_1.2+ 2749 * 2750 * NOTE: Before %{NNAPILevel3}, the pad value for 2751 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} is undefined. 2752 * Since %{NNAPILevel3}, the pad value is always the logical zero. 2753%/kind 2754%insert AVAIL2 2755 */ 2756 %{DeclareOperation SPACE_TO_BATCH_ND 33}, 2757 2758 /** 2759 * Removes dimensions of size 1 from the shape of a tensor. 2760 * 2761 * Given a tensor input, this operation returns a tensor of the same 2762 * {@link %{OperandType}} with all dimensions of size 1 removed. If you don't 2763 * want to remove all size 1 dimensions, you can remove specific size 1 2764 * dimensions by specifying the axes (input1). 2765 * 2766 * Supported tensor {@link %{OperandType}}: 2767%kind canonical ndk hal_1.2+ 2768 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 2769%/kind 2770 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 2771 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 2772%kind canonical ndk hal_1.3+ 2773 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 2774%/kind 2775 * 2776 * Supported tensor rank: up to 4 2777 * 2778 * Inputs: 2779 * * 0: An n-D tensor, the tensor to be squeezed. 2780 * * 1: An optional 1-D tensor of {@link %{OperandTypeLinkPfx}TENSOR_INT32}. The 2781 * dimensions to squeeze. If specified only squeezes the dimensions 2782 * listed. Otherwise, squeezes all dimensions. The dimension index 2783 * starts at 0. An error must be reported if squeezing a dimension that 2784 * is not 1. 2785 * 2786 * Outputs: 2787 * * 0: A tensor of the same {@link %{OperandType}} as input0. Contains the 2788 * same data as input, but has one or more dimensions of size 1 2789 * removed. 2790%kind canonical ndk hal_1.3+ 2791 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 2792 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 2793 * the scale and zeroPoint must be the same as input0. 2794%else 2795 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 2796 * the scale and zeroPoint must be the same as input0. 2797%/kind 2798 * If all input dimensions are equal to 1 and are to be squeezed, the 2799 * output shape is [1]. 2800%insert AVAIL2 2801 */ 2802 %{DeclareOperation SQUEEZE 34}, 2803 2804 /** 2805 * Extracts a strided slice of a tensor. 2806 * 2807 * Roughly speaking, this op extracts a slice of size (end - begin) / stride 2808 * from the given input tensor. Starting at the location specified by begin 2809 * the slice continues by adding stride to the index until all dimensions 2810 * are not less than end. Note that a stride can be negative, which causes a 2811 * reverse slice. 2812 * 2813 * Supported tensor {@link %{OperandType}}: 2814%kind canonical ndk hal_1.2+ 2815 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 2816%/kind 2817 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 2818 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 2819%kind canonical ndk hal_1.3+ 2820 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 2821%/kind 2822 * 2823 * Supported tensor rank: up to 4 2824 * 2825 * Inputs: 2826 * * 0: An n-D tensor, specifying the tensor to be sliced. 2827 * * 1: begin, a 1-D tensor of {@link %{OperandTypeLinkPfx}TENSOR_INT32}. The 2828 * starts of the dimensions of the input tensor to be sliced. The 2829 * length must be of rank(input0). 2830 * * 2: end, a 1-D tensor of {@link %{OperandTypeLinkPfx}TENSOR_INT32}. The 2831 * ends of the dimensions of the input tensor to be sliced. The length 2832 * must be of rank(input0). 2833 * * 3: strides, a 1-D tensor of {@link %{OperandTypeLinkPfx}TENSOR_INT32}. The 2834 * strides of the dimensions of the input tensor to be sliced. The 2835 * length must be of rank(input0). The entries must be non-zero. 2836 * * 4: begin_mask, an {@link %{OperandTypeLinkPfx}INT32} scalar. If the ith bit 2837 * of begin_mask is set, begin[i] is ignored and the fullest possible 2838 * range in that dimension is used instead. 2839 * * 5: end_mask, an {@link %{OperandTypeLinkPfx}INT32} scalar. If the ith bit of 2840 * end_mask is set, end[i] is ignored and the fullest possible range in 2841 * that dimension is used instead. 2842 * * 6: shrink_axis_mask, an {@link %{OperandTypeLinkPfx}INT32} scalar. If the 2843 * ith bit of shrink_axis_mask is set, the ith dimension specification 2844 * shrinks the dimensionality by 1, taking on the value at index 2845 * begin[i]. In this case, the ith specification must define a 2846 * slice of size 1, e.g. begin[i] = x, end[i] = x + 1. 2847 * 2848 * Outputs: 2849 * * 0: A tensor of the same {@link %{OperandType}} as input0 and rank (n - k), 2850 * where k is the number of bits set in shrink_axis_mask. 2851%kind canonical ndk hal_1.3+ 2852 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 2853 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 2854 * the scale and zeroPoint must be the same as input0. 2855%else 2856 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 2857 * the scale and zeroPoint must be the same as input0. 2858%/kind 2859 * If shrink_axis_mask is true for all input dimensions, the output 2860 * shape is [1]. 2861%insert AVAIL2 2862 */ 2863 %{DeclareOperation STRIDED_SLICE 35}, 2864 2865 /** 2866 * Element-wise subtraction of two tensors. 2867 * 2868 * Takes two input tensors of identical {@link %{OperandType}} and compatible 2869 * dimensions. The output is the result of subtracting the second input 2870 * tensor from the first one, optionally modified by an activation function. 2871 * 2872 * Two dimensions are compatible when: 2873 * 1. they are equal, or 2874 * 2. one of them is 1 2875 * 2876 * The size of the output is the maximum size along each dimension of the 2877 * input operands. It starts with the trailing dimensions, and works its way 2878 * forward. 2879 * 2880 * Example: 2881 * input1.dimension = {4, 1, 2} 2882 * input2.dimension = {5, 4, 3, 1} 2883 * output.dimension = {5, 4, 3, 2} 2884 * 2885%insert GenericZero 2886 * Supported tensor {@link %{OperandType}}: 2887%kind canonical ndk hal_1.2+ 2888 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 2889%/kind 2890 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 2891%kind canonical ndk hal_1.2+ 2892 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} (since %{NNAPILevel3}) 2893%/kind 2894%kind canonical ndk hal_1.3+ 2895 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 2896 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} (since %{NNAPILevel4}) 2897%/kind 2898 * 2899 * Supported tensor rank: up to 4 2900 * 2901 * Inputs: 2902 * * 0: An n-D tensor, specifying the first input. 2903 * * 1: A tensor of the same {@link %{OperandType}}, and compatible dimensions 2904 * as input0. 2905 * * 2: An {@link %{OperandTypeLinkPfx}INT32} scalar, and has to be one of the 2906 * {@link %{FusedActivationFunc}} values. Specifies the activation to 2907 * invoke on the result. 2908%kind canonical ndk hal_1.3+ 2909 * For a {@link %{OperandTypeLinkPfx}TENSOR_INT32} tensor, 2910 * the {@link %{FusedActivationFunc}} must be "NONE". 2911%/kind 2912 * 2913 * Outputs: 2914 * * 0: A tensor of the same {@link %{OperandType}} as input0. 2915%kind hal_1.2 2916 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 2917 * the scale and zeroPoint can be different from inputs' scale and zeroPoint. 2918%/kind 2919%kind canonical ndk hal_1.3+ 2920 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 2921 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 2922 * the scale and zeroPoint can be different from inputs' scale and zeroPoint. 2923%/kind 2924%insert AVAIL2 2925 */ 2926 %{DeclareOperation SUB 36}, 2927 2928 /** 2929 * Transposes the input tensor, permuting the dimensions according to the 2930 * perm tensor. 2931 * 2932 * The returned tensor's dimension i corresponds to the input dimension 2933 * perm[i]. If perm is not given, it is set to (n-1...0), where n is the 2934 * rank of the input tensor. Hence by default, this operation performs a 2935 * regular matrix transpose on 2-D input Tensors. 2936 * 2937 * Supported tensor {@link %{OperandType}}: 2938%kind canonical ndk hal_1.2+ 2939 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} (since %{NNAPILevel3}) 2940%/kind 2941 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 2942 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 2943%kind canonical ndk hal_1.3+ 2944 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 2945%/kind 2946 * 2947 * Supported tensor rank: up to 4 2948 * 2949 * Inputs: 2950 * * 0: An n-D tensor, specifying the tensor to be transposed. 2951%kind canonical ndk hal_1.2+ 2952 * Since %{NNAPILevel3}, this tensor may be zero-sized. 2953%/kind 2954 * * 1: An optional 1-D Tensor of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, 2955 * the permutation of the dimensions of the input tensor. 2956 * 2957 * Outputs: 2958 * * 0: A tensor of the same {@link %{OperandType}} as input0. 2959%kind canonical ndk hal_1.3+ 2960 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 2961 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 2962 * the scale and zeroPoint must be the same as input0. 2963%else 2964 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 2965 * the scale and zeroPoint must be the same as input0. 2966%/kind 2967%insert AVAIL2 2968 */ 2969 %{DeclareOperation TRANSPOSE 37}, 2970%/section 2971 2972%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2973 2974%% HAL OperandType for 1.2 2975%% NDK OperandCode for API 29 2976 2977%section Operand_1.2 2978 /** 2979 * An 8 bit boolean scalar value. 2980 * 2981 * Values of this operand type are either true or false. A zero value 2982 * represents false; any other value represents true. 2983%insert AVAIL3 2984 */ 2985 %{ANN}BOOL = 6, 2986%insert canonical_empty_line 2987 /** 2988 * A tensor of 16 bit signed integers that represent real numbers. 2989 * 2990 * Attached to this tensor is a number representing real value scale that is 2991 * used to convert the 16 bit number to a real value in the following way: 2992 * realValue = integerValue * scale. 2993 * 2994 * scale is a 32 bit floating point with value greater than zero. 2995%insert AVAIL3 2996 */ 2997 %{ANN}TENSOR_QUANT16_SYMM = 7, 2998%insert canonical_empty_line 2999 /** 3000 * A tensor of IEEE 754 16 bit floating point values. 3001%insert AVAIL3 3002 */ 3003 %{ANN}TENSOR_FLOAT16 = 8, 3004%insert canonical_empty_line 3005 /** 3006 * A tensor of 8 bit boolean values. 3007 * 3008 * Values of this operand type are either true or false. A zero value 3009 * represents false; any other value represents true. 3010%insert AVAIL3 3011 */ 3012 %{ANN}TENSOR_BOOL8 = 9, 3013%insert canonical_empty_line 3014 /** 3015 * An IEEE 754 16 bit floating point scalar value. 3016%insert AVAIL3 3017 */ 3018 %{ANN}FLOAT16 = 10, 3019%insert canonical_empty_line 3020 /** 3021 * A tensor of 8 bit signed integers that represent real numbers. 3022 * 3023 * This tensor is associated with additional fields that can 3024 * be used to convert the 8 bit signed integer to the real value and vice versa. 3025 * These fields are: 3026 * - channelDim: a 32 bit unsigned integer indicating channel dimension. 3027 * - scales: an array of positive 32 bit floating point values. 3028 * The size of the scales array must be equal to dimensions[channelDim]. 3029 * 3030%kind ndk 3031 * {@link ANeuralNetworksModel_setOperandSymmPerChannelQuantParams} must be used 3032 * to set the parameters for an Operand of this type. 3033 * 3034%/kind 3035%kind canonical hal_1.2+ 3036 *{@link %{Ann}SymmPerChannelQuantParams} must hold the parameters for an Operand of this type. 3037%/kind 3038 * The channel dimension of this tensor must not be unknown (dimensions[channelDim] != 0). 3039 * 3040 * The formula is: 3041 * realValue[..., C, ...] = 3042 * integerValue[..., C, ...] * scales[C] 3043 * where C is an index in the Channel dimension. 3044%insert AVAIL3 3045 */ 3046 %{ANN}TENSOR_QUANT8_SYMM_PER_CHANNEL = 11, 3047%insert canonical_empty_line 3048 /** 3049 * A tensor of 16 bit unsigned integers that represent real numbers. 3050 * 3051 * Attached to this tensor are two numbers that can be used to convert the 3052 * 16 bit integer to the real value and vice versa. These two numbers are: 3053 * - scale: a 32 bit floating point value greater than zero. 3054 * - zeroPoint: a 32 bit integer, in range [0, 65535]. 3055 * 3056 * The formula is: 3057 * real_value = (integer_value - zeroPoint) * scale. 3058%insert AVAIL3 3059 */ 3060 %{ANN}TENSOR_QUANT16_ASYMM = 12, 3061%insert canonical_empty_line 3062 /** 3063 * A tensor of 8 bit signed integers that represent real numbers. 3064 * 3065 * Attached to this tensor is a number representing real value scale that is 3066 * used to convert the 8 bit number to a real value in the following way: 3067 * realValue = integerValue * scale. 3068 * 3069 * scale is a 32 bit floating point with value greater than zero. 3070%insert AVAIL3 3071 */ 3072 %{ANN}TENSOR_QUANT8_SYMM = 13, 3073%/section 3074 3075%section Operand_1.2_MAX 3076 FUNDAMENTAL_MAX = 13, 3077%/section 3078 3079%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3080 3081%% HAL OperationType for 1.2 3082%% NDK OperationCode for API 29 3083 3084%section Operation_1.2 3085 /** 3086 * Computes the absolute value of a tensor, element-wise. 3087 * 3088 * Supported tensor {@link %{OperandType}}: 3089 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 3090 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 3091%kind canonical ndk hal_1.3+ 3092 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} (since %{NNAPILevel4}) 3093%/kind 3094 * 3095 * Supported tensor rank: from 1. 3096 * 3097 * Inputs: 3098 * * 0: A tensor. 3099 * 3100 * Outputs: 3101 * * 0: The output tensor of same shape as input0. 3102%insert AVAIL3 3103 */ 3104 %{DeclareOperation_1.2 ABS 38}, 3105 3106 /** 3107 * Returns the index of the largest element along an axis. 3108 * 3109 * Supported tensor {@link %{OperandType}}: 3110 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 3111 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 3112 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 3113 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 3114%kind canonical ndk hal_1.3+ 3115 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 3116%/kind 3117 * 3118 * Supported tensor rank: from 1 3119 * 3120 * Inputs: 3121 * * 0: An n-D tensor specifying the input. Must be non-empty. 3122 * * 1: An {@link %{OperandTypeLinkPfx}INT32} scalar specifying the axis to 3123 * reduce across. Negative index is used to specify axis from the 3124 * end (e.g. -1 for the last axis). Must be in the range [-n, n). 3125 * 3126 * Outputs: 3127 * * 0: An (n - 1)-D {@link %{OperandTypeLinkPfx}TENSOR_INT32} tensor. 3128 * If input is 1-dimensional, the output shape is [1]. 3129%insert AVAIL3 3130 */ 3131 // There is no underscore in ARG_MAX to avoid name conflict with 3132 // the macro defined in libc/kernel/uapi/linux/limits.h. 3133 %{DeclareOperation_1.2 ARGMAX 39}, 3134 3135 /** 3136 * Returns the index of the smallest element along an axis. 3137 * 3138 * Supported tensor {@link %{OperandType}}: 3139 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 3140 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 3141 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 3142 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 3143%kind canonical ndk hal_1.3+ 3144 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 3145%/kind 3146 * 3147 * Supported tensor rank: from 1 3148 * 3149 * Inputs: 3150 * * 0: An n-D tensor specifying the input. Must be non-empty. 3151 * * 1: An {@link %{OperandTypeLinkPfx}INT32} scalar specifying the axis to 3152 * reduce across. Negative index is used to specify axis from the 3153 * end (e.g. -1 for the last axis). Must be in the range [-n, n). 3154 * 3155 * Outputs: 3156 * * 0: An (n - 1)-D {@link %{OperandTypeLinkPfx}TENSOR_INT32} tensor. 3157 * If input is 1-dimensional, the output shape is [1]. 3158%insert AVAIL3 3159 */ 3160 %{DeclareOperation_1.2 ARGMIN 40}, // See ARGMAX for naming discussion. 3161 3162 /** 3163 * Transform axis-aligned bounding box proposals using bounding box deltas. 3164 * 3165 * Given the positions of bounding box proposals and the corresponding 3166 * bounding box deltas for each class, return the refined bounding box 3167 * regions. The resulting bounding boxes are cliped against the edges of 3168 * the image. 3169 * 3170 * Supported tensor {@link %{OperandType}}: 3171 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 3172 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 3173 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_ASYMM} 3174 * 3175 * Inputs: 3176 * * 0: A 2-D Tensor of shape [num_rois, 4], specifying the locations of the 3177 * bounding box proposals, each line with format [x1, y1, x2, y2]. 3178 * For tensor of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_ASYMM}, 3179 * the zeroPoint must be 0 and the scale must be 0.125. Zero num_rois 3180 * is supported for this tensor. 3181 * * 1: A 2-D Tensor of shape [num_rois, num_classes * 4], specifying the 3182 * bounding box delta for each region of interest and each class. The 3183 * bounding box deltas are organized in the following order 3184 * [dx, dy, dw, dh], where dx and dy is the relative correction factor 3185 * for the center position of the bounding box with respect to the width 3186 * and height, dw and dh is the log-scale relative correction factor 3187 * for the width and height. For input0 of type 3188 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_ASYMM}, this tensor should be 3189%kind canonical ndk hal_1.3+ 3190 * of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} or 3191 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED}. Zero num_rois is 3192%else 3193 * of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}. Zero num_rois is 3194%/kind 3195 * supported for this tensor. 3196 * * 2: An 1-D {@link %{OperandTypeLinkPfx}TENSOR_INT32} tensor, of shape 3197 * [num_rois], specifying the batch index of each box. Boxes with 3198 * the same batch index are grouped together. Zero num_rois is 3199 * supported for this tensor. 3200 * * 3: A 2-D Tensor of shape [batches, 2], specifying the information of 3201 * each image in the batch, each line with format 3202 * [image_height, image_width]. 3203 * 3204 * Outputs: 3205 * * 0: A tensor of the same {@link %{OperandType}} as input0, with shape 3206 * [num_rois, num_classes * 4], specifying the coordinates of each 3207 * output bounding box for each class, with format [x1, y1, x2, y2]. 3208 * For type of {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_ASYMM}, the 3209 * scale must be 0.125 and the zero point must be 0. 3210%insert AVAIL3 3211 */ 3212 %{DeclareOperation_1.2 AXIS_ALIGNED_BBOX_TRANSFORM 41}, 3213 3214 /** 3215 * A recurrent neural network layer that applies an LSTM cell to a 3216 * sequence of inputs in forward and backward directions. 3217 * 3218 * The op supports cross-linking via an auxiliary input. Regular cell feeds 3219 * one input into the two RNN cells in the following way: 3220 * 3221 * INPUT (INPUT_REVERSED) 3222 * | | 3223 * --------------------- 3224 * | FW_LSTM BW_LSTM | 3225 * --------------------- 3226 * | | 3227 * FW_OUT BW_OUT 3228 * 3229 * An op with cross-linking takes two inputs and feeds them into the RNN 3230 * cells in the following way: 3231 * 3232 * AUX_INPUT (AUX_INPUT_REVERSED) 3233 * | | 3234 * INPUT | (INPUT_R'D.)| 3235 * | | | | 3236 * ----------------------- 3237 * | \ / \ / | 3238 * | FW_LSTM BW_LSTM | 3239 * ----------------------- 3240 * | | 3241 * FW_OUT BW_OUT 3242 * 3243 * The cross-linking mode is enabled iff auxiliary input and auxiliary 3244 * weights are present. While stacking this op on top of itself, this 3245 * allows to connect both forward and backward outputs from previous cell 3246 * to the next cell's input. 3247 * 3248%kind canonical ndk hal_1.3+ 3249 * Since %{NNAPILevel4} parallel linking mode is supported. The mode is 3250 * enabled if auxiliary input is present but auxiliary weights are omitted. 3251 * In this case, the cell feeds inputs into the RNN in the following way: 3252 * 3253 * INPUT (AUX_INPUT_REVERSED) 3254 * | | 3255 * --------------------- 3256 * | FW_LSTM BW_LSTM | 3257 * --------------------- 3258 * | | 3259 * FW_OUT BW_OUT 3260 * 3261 * While stacking this op on top of itself, this allows to connect both 3262 * forward and backward outputs from previous cell to the next cell's 3263 * corresponding inputs. 3264 * 3265%/kind 3266 * Supported tensor {@link %{OperandType}}: 3267 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 3268 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 3269 * 3270 * Supported tensor rank: 3, either time-major or batch-major. 3271 * 3272 * All input and output tensors must be of the same type. 3273 * 3274 * Inputs: 3275 * * 0: The input. 3276 * A 3-D tensor of shape: 3277 * If time-major: [max_time, batch_size, input_size] 3278 * If batch-major: [batch_size, max_time, input_size] 3279 * where "max_time" is the number of timesteps (sequence length), 3280 * "batch_size" corresponds to the batching dimension, and 3281 * "input_size" is the size of the input. 3282 * * 1: The forward input-to-input weights. Optional. 3283 * A 2-D tensor of shape [fw_num_units, input_size], where “fw_num_units” 3284 * corresponds to the number of forward cell units. 3285 * * 2: The forward input-to-forget weights. 3286 * A 2-D tensor of shape [fw_num_units, input_size]. 3287 * * 3: The forward input-to-cell weights. 3288 * A 2-D tensor of shape [fw_num_units, input_size]. 3289 * * 4: The forward input-to-output weights. 3290 * A 2-D tensor of shape [fw_num_units, input_size]. 3291 * * 5: The forward recurrent-to-input weights. Optional. 3292 * A 2-D tensor of shape [fw_num_units, fw_output_size], where “fw_output_size” 3293 * corresponds to either the number of cell units (i.e., fw_num_units), 3294 * or the second dimension of the “fw_projection_weights”, if defined. 3295 * * 6: The forward recurrent-to-forget weights. 3296 * A 2-D tensor of shape [fw_num_units, fw_output_size]. 3297 * * 7: The forward recurrent-to-cell weights. 3298 * A 2-D tensor of shape [fw_num_units, fw_output_size]. 3299 * * 8: The forward recurrent-to-output weights. 3300 * A 2-D tensor of shape [fw_num_units, fw_output_size]. 3301 * * 9: The forward cell-to-input weights. Optional. 3302 * A 1-D tensor of shape [fw_num_units]. 3303 * * 10: The forward cell-to-forget weights. Optional. 3304 * A 1-D tensor of shape [fw_num_units]. 3305 * * 11: The forward cell-to-output weights. Optional. 3306 * A 1-D tensor of shape [fw_num_units]. 3307 * * 12: The forward input gate bias. Optional. 3308 * A 1-D tensor of shape [fw_num_units]. 3309 * * 13: The forward forget gate bias. 3310 * A 1-D tensor of shape [fw_num_units]. 3311 * * 14: The forward cell gate bias. 3312 * A 1-D tensor of shape [fw_num_units]. 3313 * * 15: The forward output gate bias. 3314 * A 1-D tensor of shape [fw_num_units]. 3315 * * 16: The forward projection weights. Optional. 3316 * A 2-D tensor of shape [fw_output_size, fw_num_units]. 3317 * * 17: The forward projection bias. Optional. 3318 * A 1-D tensor of shape [fw_output_size]. 3319 * * 18: The backward input-to-input weights. Optional. 3320 * A 2-D tensor of shape [bw_num_units, input_size], where “bw_num_units” 3321 * corresponds to the number of backward cell units. 3322 * * 19: The backward input-to-forget weights. 3323 * A 2-D tensor of shape [bw_num_units, input_size]. 3324 * * 20: The backward input-to-cell weights. 3325 * A 2-D tensor of shape [bw_num_units, input_size]. 3326 * * 21: The backward input-to-output weights. 3327 * A 2-D tensor of shape [bw_num_units, input_size]. 3328 * * 22: The backward recurrent-to-input weights. Optional. 3329 * A 2-D tensor of shape [bw_num_units, bw_output_size], where “bw_output_size” 3330 * corresponds to either the number of cell units (i.e., “bw_num_units”), 3331 * or the second dimension of the “bw_projection_weights”, if defined. 3332 * * 23: The backward recurrent-to-forget weights. 3333 * A 2-D tensor of shape [bw_num_units, bw_output_size]. 3334 * * 24: The backward recurrent-to-cell weights. 3335 * A 2-D tensor of shape [bw_num_units, bw_output_size]. 3336 * * 25: The backward recurrent-to-output weights. 3337 * A 2-D tensor of shape [bw_num_units, bw_output_size]. 3338 * * 26: The backward cell-to-input weights. Optional. 3339 * A 1-D tensor of shape [bw_num_units]. 3340 * * 27: The backward cell-to-forget weights. Optional. 3341 * A 1-D tensor of shape [bw_num_units]. 3342 * * 28: The backward cell-to-output weights. Optional. 3343 * A 1-D tensor of shape [bw_num_units]. 3344 * * 29: The backward input gate bias. Optional. 3345 * A 1-D tensor of shape [bw_num_units]. 3346 * * 30: The backward forget gate bias. 3347 * A 1-D tensor of shape [bw_num_units]. 3348 * * 31: The backward cell gate bias. 3349 * A 1-D tensor of shape [bw_num_units]. 3350 * * 32: The backward output gate bias. 3351 * A 1-D tensor of shape [bw_num_units]. 3352 * * 33: The backward projection weights. Optional. 3353 * A 2-D tensor of shape [bw_output_size, bw_num_units]. 3354 * * 34: The backward projection bias. Optional. 3355 * A 1-D tensor of shape [bw_output_size]. 3356 * * 35: The forward input activation state. 3357 * A 2-D tensor of shape [batch_size, bw_output_size]. 3358 * * 36: The forward input cell state. 3359 * A 2-D tensor of shape [batch_size, bw_num_units]. 3360 * * 37: The backward input activation state. 3361 * A 2-D tensor of shape [batch_size, bw_output_size]. 3362 * * 38: The backward input cell state. 3363 * A 2-D tensor of shape [batch_size, bw_num_units]. 3364%kind canonical ndk hal_1.3+ 3365 * * 39: The auxiliary input. Optional. 3366 * A 3-D tensor of shape [max_time, batch_size, aux_input_size], 3367 * where “batch_size” corresponds to the batching dimension, and 3368 * “aux_input_size” is the size of the auxiliary input. Optional. See 3369 * the docs above for the usage modes explanation. 3370 * * 40: The forward auxiliary input-to-input weights. 3371 * Optional. See the docs above for the usage modes explanation. 3372 * A 2-D tensor of shape [fw_num_units, aux_input_size]. 3373 * * 41: The forward auxiliary input-to-forget weights. 3374 * Optional. See the docs above for the usage modes explanation. 3375 * A 2-D tensor of shape [fw_num_units, aux_input_size]. 3376 * * 42: The forward auxiliary input-to-cell weights. 3377 * Optional. See the docs above for the usage modes explanation. 3378 * A 2-D tensor of shape [fw_num_units, aux_input_size]. 3379 * * 43: The forward auxiliary input-to-output weights. 3380 * Optional. See the docs above for the usage modes explanation. 3381 * A 2-D tensor of shape [fw_num_units, aux_input_size]. 3382 * * 44: The backward auxiliary input-to-input weights. 3383 * Optional. See the docs above for the usage modes explanation. 3384 * A 2-D tensor of shape [bw_num_units, aux_input_size]. 3385 * * 45: The backward auxiliary input-to-forget weights. 3386 * Optional. See the docs above for the usage modes explanation. 3387 * A 2-D tensor of shape [bw_num_units, aux_input_size]. 3388 * * 46: The backward auxiliary input-to-cell weights. 3389 * Optional. See the docs above for the usage modes explanation. 3390 * A 2-D tensor of shape [bw_num_units, aux_input_size]. 3391 * * 47: The backward auxiliary input-to-output weights. 3392 * Optional. See the docs above for the usage modes explanation. 3393 * A 2-D tensor of shape [bw_num_units, aux_input_size]. 3394%else 3395 * * 39: The auxiliary input. Optional. 3396 * A 3-D tensor of shape [max_time, batch_size, input_size], where “batch_size” 3397 * corresponds to the batching dimension, and “input_size” is the size 3398 * of the input. 3399 * * 40: The forward auxiliary input-to-input weights. Optional. 3400 * A 2-D tensor of shape [fw_num_units, input_size]. 3401 * * 41: The forward auxiliary input-to-forget weights. Optional. 3402 * A 2-D tensor of shape [fw_num_units, input_size]. 3403 * * 42: The forward auxiliary input-to-cell weights. Optional. 3404 * A 2-D tensor of shape [fw_num_units, input_size]. 3405 * * 43: The forward auxiliary input-to-output weights. Optional. 3406 * A 2-D tensor of shape [fw_num_units, input_size]. 3407 * * 44: The backward auxiliary input-to-input weights. Optional. 3408 * A 2-D tensor of shape [bw_num_units, input_size]. 3409 * * 45: The backward auxiliary input-to-forget weights. Optional. 3410 * A 2-D tensor of shape [bw_num_units, input_size]. 3411 * * 46: The backward auxiliary input-to-cell weights. Optional. 3412 * A 2-D tensor of shape [bw_num_units, input_size]. 3413 * * 47: The backward auxiliary input-to-output weights. Optional. 3414 * A 2-D tensor of shape [bw_num_units, input_size]. 3415%/kind 3416 * * 48: The activation function. 3417 * A value indicating the activation function: 3418 * <ul> 3419 * <li>0: None; 3420 * <li>1: Relu; 3421 * <li>3: Relu6; 3422 * <li>4: Tanh; 3423 * <li>6: Sigmoid. 3424 * </ul> 3425 * * 49: The clipping threshold for the cell state, such 3426 * that values are bound within [-cell_clip, cell_clip]. If set to 0.0 3427 * then clipping is disabled. 3428 * If all the input tensors have type {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32}, 3429 * this scalar must be of the type {@link %{OperandTypeLinkPfx}FLOAT32}, 3430 * otherwise if all the input tensors have the type 3431 * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16}, this scalar must be 3432 * of type {@link %{OperandTypeLinkPfx}FLOAT16}. 3433 * * 50: The clipping threshold for the output from the 3434 * projection layer, such that values are bound within 3435 * [-proj_clip, proj_clip]. If set to 0.0 then clipping is disabled. 3436 * If all the input tensors have type {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32}, 3437 * this scalar must be of the type {@link %{OperandTypeLinkPfx}FLOAT32}, 3438 * otherwise if all the input tensors have the type 3439 * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16}, this scalar must be 3440 * of type {@link %{OperandTypeLinkPfx}FLOAT16}. 3441 * * 51: merge_outputs 3442 * An {@link %{OperandTypeLinkPfx}BOOL} scalar specifying if the outputs 3443 * from forward and backward cells should be merged. 3444 * * 52: time_major 3445 * An {@link %{OperandTypeLinkPfx}BOOL} scalar specifying the shape format 3446 * of input and output tensors. 3447 * * 53: The forward input layer normalization weights. Optional. 3448 * A 1-D tensor of shape [fw_num_units]. Used to rescale normalized inputs 3449 * to activation at input gate. 3450 * * 54: The forward forget layer normalization weights. Optional. 3451 * A 1-D tensor of shape [fw_num_units]. Used to rescale normalized inputs 3452 * to activation at forget gate. 3453 * * 55: The forward cell layer normalization weights. Optional. 3454 * A 1-D tensor of shape [fw_num_units]. Used to rescale normalized inputs 3455 * to activation at cell gate. 3456 * * 56: The forward output layer normalization weights. Optional. 3457 * A 1-D tensor of shape [fw_num_units]. Used to rescale normalized inputs 3458 * to activation at output gate. 3459 * * 57: The backward input layer normalization weights. Optional. 3460 * A 1-D tensor of shape [bw_num_units]. Used to rescale normalized inputs 3461 * to activation at input gate. 3462 * * 58: The backward forget layer normalization weights. Optional. 3463 * A 1-D tensor of shape [bw_num_units]. Used to rescale normalized inputs 3464 * to activation at forget gate. 3465 * * 59: The backward cell layer normalization weights. Optional. 3466 * A 1-D tensor of shape [bw_num_units]. Used to rescale normalized inputs 3467 * to activation at cell gate. 3468 * * 60: The backward output layer normalization weights. Optional. 3469 * A 1-D tensor of shape [bw_num_units]. Used to rescale normalized inputs 3470 * to activation at output gate. 3471 * 3472 * Outputs: 3473 * * 0: The forward output. 3474 * A 3-D tensor of shape: 3475 * If time-major and not merge_outputs: 3476 * [max_time, batch_size, fw_output_size] 3477 * If time-major and merge_outputs: 3478 * [max_time, batch_size, fw_output_size + bw_output_size] 3479 * If batch-major and not merge_outputs: 3480 * [batch_size, max_time, fw_output_size] 3481 * If batch-major and merge_outputs: 3482 * [batch_size, max_time, fw_output_size + bw_output_size] 3483 * * 1: The backward output. Unused if merge_outputs is true. 3484 * A 3-D tensor of shape: 3485 * If time-major: [max_time, batch_size, bw_output_size] 3486 * If batch-major: [batch_size, max_time, bw_output_size] 3487%kind canonical ndk hal_1.3+ 3488 * * 2: The forward activation state output. 3489 * A 2-D tensor of shape [batch_size, fw_output_size] containing an 3490 * activation state from the last time step in the sequence. This 3491 * output is optional and can be omitted. If this output is present 3492 * then outputs 3-5 must be present as well. 3493 * Available since %{NNAPILevel4}. 3494 * * 3: The forward cell state output. 3495 * A tensor of shape [batch_size, fw_cell_size] containing a cell state 3496 * from the last time step in the sequence. This output is optional 3497 * and can be omitted. If this output is present 3498 * then outputs 2, 4, 5 must be present as well. 3499 * Available since %{NNAPILevel4}. 3500 * * 4: The backward activation state output. 3501 * A 2-D tensor of shape [batch_size, bw_output_size] containing an 3502 * activation state from the last time step in the sequence. This 3503 * output is optional and can be omitted. If this output is present 3504 * then outputs 2, 3, 5 must be present as well. 3505 * Available since %{NNAPILevel4}. 3506 * * 5: The backward cell state output. 3507 * A tensor of shape [batch_size, bw_cell_size] containing a cell state 3508 * from the last time step in the sequence. This output is optional 3509 * and can be omitted. If this output is present 3510 * then outputs 2-4 must be present as well. 3511 * Available since %{NNAPILevel4}. 3512%/kind 3513%insert AVAIL3 3514%insert OutputState 3515 */ 3516 %{DeclareOperation_1.2 BIDIRECTIONAL_SEQUENCE_LSTM 42}, 3517 3518 /** 3519 * A recurrent neural network layer that applies a basic RNN cell to a 3520 * sequence of inputs in forward and backward directions. 3521 * 3522 * This Op unrolls the input along the sequence dimension, and implements 3523 * the following operation for each element in the sequence s = 3524 * 1...sequence_length: 3525 * fw_outputs[s] = fw_state = activation(inputs[s] * fw_input_weights’ + 3526 * fw_state * fw_recurrent_weights’ + fw_bias) 3527 * 3528 * And for each element in sequence t = sequence_length : 1 3529 * bw_outputs[t] = bw_state = activation(inputs[t] * bw_input_weights’ + 3530 * bw_state * bw_recurrent_weights’ + bw_bias) 3531 * 3532 * Where: 3533 * * “{fw,bw}_input_weights” is a weight matrix that multiplies the inputs; 3534 * * “{fw,bw}_recurrent_weights” is a weight matrix that multiplies the 3535 * current “state” which itself is the output from the previous time step 3536 * computation; 3537 * * “{fw,bw}_bias” is a bias vector (added to each output vector in the 3538 * batch); 3539 * * “activation” is the function passed as the “fused_activation_function” 3540 * argument (if not “NONE”). 3541 * 3542 * The op supports cross-linking via an auxiliary input. Regular cell feeds 3543 * one input into the two RNN cells in the following way: 3544 * 3545 * INPUT (INPUT_REVERSED) 3546 * | | 3547 * --------------------- 3548 * | FW_RNN BW_RNN | 3549 * --------------------- 3550 * | | 3551 * FW_OUT BW_OUT 3552 * 3553 * An op with cross-linking takes two inputs and feeds them into the RNN 3554 * cells in the following way: 3555 * 3556 * AUX_INPUT (AUX_INPUT_REVERSED) 3557 * | | 3558 * INPUT | (INPUT_R'D.)| 3559 * | | | | 3560 * ----------------------- 3561 * | \ / \ / | 3562 * | FW_RNN BW_RNN | 3563 * ----------------------- 3564 * | | 3565 * FW_OUT BW_OUT 3566 * 3567 * The cross-linking mode is enabled iff auxiliary input and auxiliary 3568 * weights are present. While stacking this op on top of itself, this 3569 * allows to connect both forward and backward outputs from previous cell 3570 * to the next cell's input. 3571 * 3572%kind canonical ndk hal_1.3+ 3573 * Since %{NNAPILevel4} parallel linking mode is supported. The mode is 3574 * enabled if auxiliary input is present but auxiliary weights are omitted. 3575 * In this case, the cell feeds inputs into the RNN in the following way: 3576 * 3577 * INPUT (AUX_INPUT_REVERSED) 3578 * | | 3579 * --------------------- 3580 * | FW_RNN BW_RNN | 3581 * --------------------- 3582 * | | 3583 * FW_OUT BW_OUT 3584 * 3585 * While stacking this op on top of itself, this allows to connect both 3586 * forward and backward outputs from previous cell to the next cell's 3587 * corresponding inputs. 3588 * 3589%/kind 3590 * Supported tensor {@link %{OperandType}}: 3591 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 3592 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 3593 * 3594 * The input tensors must all be the same type. 3595 * 3596 * Inputs: 3597 * * 0: input. 3598 * A 3-D tensor. The shape is defined by the input 6 (timeMajor). If 3599 * it is set to true, then the input has a shape [maxTime, batchSize, 3600 * inputSize], otherwise the input has a shape [batchSize, maxTime, 3601 * inputSize]. 3602 * * 1: fwWeights. 3603 * A 2-D tensor of shape [fwNumUnits, inputSize]. 3604 * * 2: fwRecurrentWeights. 3605 * A 2-D tensor of shape [fwNumUnits, fwNumUnits]. 3606 * * 3: fwBias. 3607 * A 1-D tensor of shape [fwNumUnits]. 3608 * * 4: fwHiddenState. 3609 * A 2-D tensor of shape [batchSize, fwNumUnits]. Specifies a hidden 3610 * state input for the first time step of the computation. 3611 * * 5: bwWeights. 3612 * A 2-D tensor of shape [bwNumUnits, inputSize]. 3613 * * 6: bwRecurrentWeights. 3614 * A 2-D tensor of shape [bwNumUnits, bwNumUnits]. 3615 * * 7: bwBias. 3616 * A 1-D tensor of shape [bwNumUnits]. 3617 * * 8: bwHiddenState 3618 * A 2-D tensor of shape [batchSize, bwNumUnits]. Specifies a hidden 3619 * state input for the first time step of the computation. 3620%kind canonical ndk hal_1.3+ 3621 * * 9: auxInput. 3622 * A 3-D tensor. The shape is defined by the input 6 (timeMajor). If 3623 * it is set to true, then the input has a shape [maxTime, batchSize, 3624 * auxInputSize], otherwise the input has a shape [batchSize, maxTime, 3625 * auxInputSize]. Can be omitted. See the docs above for the usage 3626 * modes explanation. 3627 * * 10:fwAuxWeights. 3628 * A 2-D tensor of shape [fwNumUnits, auxInputSize]. Can be omitted. 3629 * See the docs above for the usage modes explanation. 3630 * * 11:bwAuxWeights. 3631 * A 2-D tensor of shape [bwNumUnits, auxInputSize]. Can be omitted. 3632 * See the docs above for the usage modes explanation. 3633%else 3634 * * 9: auxInput. 3635 * A 3-D tensor. The shape is the same as of the input 0. 3636 * * 10:fwAuxWeights. 3637 * A 2-D tensor of shape [fwNumUnits, inputSize]. 3638 * * 11:bwAuxWeights. 3639 * A 2-D tensor of shape [bwNumUnits, inputSize]. 3640%/kind 3641 * * 12:fusedActivationFunction. 3642 * A {@link %{FusedActivationFunc}} value indicating the activation function. If 3643 * “NONE” is specified then it results in a linear activation. 3644 * * 13:timeMajor 3645 * An {@link %{OperandTypeLinkPfx}BOOL} scalar specifying the shape format 3646 * of input and output tensors. 3647 * * 14:mergeOutputs 3648 * An {@link %{OperandTypeLinkPfx}BOOL} scalar specifying if the outputs 3649 * from forward and backward cells are separate (if set to false) or 3650 * concatenated (if set to true). 3651 * Outputs: 3652 * * 0: fwOutput. 3653 * A 3-D tensor. The first two dimensions of the shape are defined by 3654 * the input 6 (timeMajor) and the third dimension is defined by the 3655 * input 14 (mergeOutputs). If timeMajor is set to true, then the first 3656 * two dimensions are [maxTime, batchSize], otherwise they are set to 3657 * [batchSize, maxTime]. If mergeOutputs is set to true, then the third 3658 * dimension is equal to (fwNumUnits + bwNumUnits), otherwise it is set 3659 * to fwNumUnits. 3660 * * 1: bwOutput. 3661 * A 3-D tensor. If the input 14 (mergeOutputs) is set to true, then 3662 * this tensor is not produced. The shape is defined by the input 6 3663 * (timeMajor). If it is set to true, then the shape is set to 3664 * [maxTime, batchSize, bwNumUnits], otherwise the shape is set to 3665 * [batchSize, maxTime, bwNumUnits]. 3666%kind canonical ndk hal_1.3+ 3667 * * 2: The forward hidden state output. 3668 * A 2-D tensor of shape [batchSize, fwNumUnits] containing a hidden 3669 * state from the last time step in the sequence. This output is 3670 * optional and can be omitted. If this output is present then output 3671 * 3 must be present as well. 3672 * Available since %{NNAPILevel4}. 3673 * * 3: The backward hidden state output. 3674 * A 2-D tensor of shape [batchSize, bwNumUnits] containing a hidden 3675 * state from the last time step in the sequence. This output is 3676 * optional and can be omitted. If this output is present then output 3677 * 2 must be present as well. 3678 * Available since %{NNAPILevel4}. 3679%/kind 3680%insert AVAIL3 3681%insert OutputState 3682 */ 3683 %{DeclareOperation_1.2 BIDIRECTIONAL_SEQUENCE_RNN 43}, 3684 3685 /** 3686 * Greedily selects a subset of bounding boxes in descending order of score. 3687 * 3688 * This op applies NMS algorithm to each class. In each loop of execution, 3689 * the box with maximum score gets selected and removed from the pending set. 3690 * The scores of the rest of boxes are lowered according to the 3691 * intersection-over-union (IOU) overlapping with the previously selected 3692 * boxes and a specified NMS kernel method. Any boxes with score less 3693 * than a threshold are removed from the pending set. 3694 * 3695 * Three NMS kernels are supported: 3696 * * Hard: score_new = score_old * (1 if IoU < threshold else 0) 3697 * * Linear: score_new = score_old * (1 if IoU < threshold else 1 - IoU) 3698 * * Gaussian: score_new = score_old * exp(- IoU^2 / sigma) 3699 * 3700 * Axis-aligned bounding boxes are represented by its upper-left corner 3701 * coordinate (x1,y1) and lower-right corner coordinate (x2,y2). A valid 3702 * bounding box should satisfy x1 <= x2 and y1 <= y2. 3703 * 3704 * Supported tensor {@link %{OperandType}}: 3705 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 3706 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 3707 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 3708%kind canonical ndk hal_1.3+ 3709 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 3710%/kind 3711 * 3712 * Inputs: 3713 * * 0: A 2-D Tensor of shape [num_rois, num_classes], specifying the score 3714 * of each bounding box proposal. The boxes are grouped by batches in the 3715 * first dimension. Zero num_rois is supported for this tensor. 3716 * * 1: A 2-D Tensor specifying the bounding boxes of shape 3717 * [num_rois, num_classes * 4], organized in the order [x1, y1, x2, y2]. 3718 * The boxes are grouped by batches in the first dimension. The sequential 3719 * order of the boxes corresponds with input0. For input0 of type 3720 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, this tensor should be of 3721 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_ASYMM}, with zeroPoint of 0 and 3722 * scale of 0.125. 3723%kind canonical ndk hal_1.3+ 3724 * For input0 of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED}, 3725 * this tensor should be of {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_ASYMM}, 3726 * with zeroPoint of -128 and scale of 0.125. 3727%/kind 3728 * Zero num_rois is supported for this tensor. 3729 * * 2: A 1-D {@link %{OperandTypeLinkPfx}TENSOR_INT32} tensor, of shape 3730 * [num_rois], specifying the batch index of each box. Boxes with 3731 * the same batch index are grouped together. 3732 * * 3: An {@link %{OperandTypeLinkPfx}FLOAT32} scalar, score_threshold. Boxes 3733 * with scores lower than the threshold are filtered before sending 3734 * to the NMS algorithm. 3735 * * 4: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the maximum 3736 * number of selected bounding boxes for each image. Set to a negative 3737 * value for unlimited number of output bounding boxes. 3738 * * 5: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the NMS 3739 * kernel method, options are 0:hard, 1:linear, 2:gaussian. 3740 * * 6: An {@link %{OperandTypeLinkPfx}FLOAT32} scalar, specifying the IoU 3741 * threshold in hard and linear NMS kernel. This field is ignored if 3742 * gaussian kernel is selected. 3743 * * 7: An {@link %{OperandTypeLinkPfx}FLOAT32} scalar, specifying the sigma in 3744 * gaussian NMS kernel. This field is ignored if gaussian kernel is 3745 * not selected. 3746 * * 8: An {@link %{OperandTypeLinkPfx}FLOAT32} scalar, nms_score_threshold. 3747 * Boxes with scores lower than the threshold are dropped during the 3748 * score updating phase in soft NMS. 3749 * 3750 * Outputs: 3751 * * 0: A 1-D Tensor of the same {@link %{OperandType}} as input0, with shape 3752 * [num_output_rois], specifying the score of each output box. The boxes 3753 * are grouped by batches, but the sequential order in each batch is not 3754 * guaranteed. For type of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, 3755%kind canonical ndk hal_1.3+ 3756 * guaranteed. For type of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 3757 * or {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED}, 3758%else 3759 * guaranteed. For type of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 3760%/kind 3761 * the scale and zero point must be the same as input0. 3762 * * 1: A 2-D Tensor of the same {@link %{OperandType}} as input1, with shape 3763 * [num_output_rois, 4], specifying the coordinates of each 3764 * output bounding box with the same format as input1. The sequential 3765 * order of the boxes corresponds with output0. For type of 3766 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_ASYMM}, the scale must be 3767 * 0.125 and the zero point must be 0. 3768 * * 2: A 1-D {@link %{OperandTypeLinkPfx}TENSOR_INT32} tensor, of shape 3769 * [num_output_rois], specifying the class of each output box. The 3770 * sequential order of the boxes corresponds with output0. 3771 * * 3: A 1-D {@link %{OperandTypeLinkPfx}TENSOR_INT32} tensor, of shape 3772 * [num_output_rois], specifying the batch index of each box. Boxes 3773 * with the same batch index are grouped together. 3774%insert AVAIL3 3775 */ 3776 %{DeclareOperation_1.2 BOX_WITH_NMS_LIMIT 44}, 3777 3778 /** 3779 * Casts a tensor to a type. 3780 * 3781 * This operation ignores the scale and zeroPoint of quanized tensors, 3782 * e.g. it treats a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} input 3783 * as a tensor of uint8 values. 3784 * 3785 * Supported tensor {@link %{OperandType}}: 3786 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 3787 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 3788 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 3789 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 3790%kind canonical ndk hal_1.3+ 3791 * Since %{NNAPILevel4}, casting tensors of the following 3792 * {@link %{OperandType}} to the same {@link %{OperandType}} is supported: 3793 * * {@link %{OperandTypeLinkPfx}TENSOR_BOOL8} 3794 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 3795 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_ASYMM} 3796 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_SYMM} 3797 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} 3798 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM} 3799%/kind 3800 * 3801 * Supported tensor rank: from 1 3802 * 3803 * Inputs: 3804 * * 0: A tensor. 3805 * 3806 * Outputs: 3807 * * 0: A tensor with the same shape as input0. 3808%insert AVAIL3 3809 */ 3810 %{DeclareOperation_1.2 CAST 45}, 3811 3812 /** 3813 * Shuffle the channels of the input tensor. 3814 * 3815 * Given an input tensor and a integer value of num_groups, CHANNEL_SHUFFLE 3816 * divide the channel dimension into num_groups groups, and reorganize the 3817 * channels by grouping channels with the same index in each group. 3818 * 3819 * Along the channel dimension, the output is calculated using this formula: 3820 * 3821 * output_channel[k * num_groups + g] = input_channel[g * group_size + k] 3822 * 3823 * where group_size = num_channels / num_groups 3824 * 3825 * The number of channels must be divisible by num_groups. 3826 * 3827 * Supported tensor {@link %{OperandType}}: 3828 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 3829 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 3830 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 3831%kind canonical ndk hal_1.3+ 3832 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 3833%/kind 3834 * 3835 * Supported tensor rank: up to 4 3836 * 3837 * Inputs: 3838 * * 0: An n-D tensor, specifying the tensor to be shuffled. 3839 * * 1: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the number of 3840 * groups. 3841 * * 2: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the dimension 3842 * channel shuffle would be performed on. Negative index is used to 3843 * specify axis from the end (e.g. -1 for the last axis). Must be in 3844 * the range [-n, n). 3845 * 3846 * Outputs: 3847 * * 0: A tensor of the same {@link %{OperandType}} and same shape as input0. 3848%kind canonical ndk hal_1.3+ 3849 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 3850 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 3851 * the scale and zeroPoint must be the same as input0. 3852%else 3853 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 3854 * the scale and zeroPoint must be the same as input0. 3855%/kind 3856%insert AVAIL3 3857 */ 3858 %{DeclareOperation_1.2 CHANNEL_SHUFFLE 46}, 3859 3860 /** 3861 * Apply postprocessing steps to bounding box detections. 3862 * 3863 * Bounding box detections are generated by applying transformation on a set 3864 * of predefined anchors with the bounding box deltas from bounding box 3865 * regression. A final step of hard NMS is applied to limit the number of 3866 * returned boxes. 3867 * 3868 * Supported tensor {@link %{OperandType}}: 3869 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 3870 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 3871 * 3872 * Inputs: 3873 * * 0: A 3-D Tensor of shape [batches, num_anchors, num_classes], specifying 3874 * the score of each anchor with each class. Class 0 for each 3875 * [batches, num_anchors, 0] is background and will be ignored. 3876 * * 1: A 3-D Tensor of shape [batches, num_anchors, length_box_encoding], with 3877 * the first four values in length_box_encoding specifying the bounding 3878 * box deltas. The box deltas are encoded in the order of [dy, dx, dh, dw], 3879 * where dy and dx is the linear-scale relative correction factor for the 3880 * center position of the bounding box with respect to the width and height, 3881 * dh and dw is the log-scale relative correction factor for the width and 3882 * height. All the entries in length_box_encoding beyond the first four 3883 * values are ignored in this operation. 3884 * * 2: A 2-D Tensor of shape [num_anchors, 4], specifying the shape of each 3885 * predefined anchor, with format [ctr_y, ctr_x, h, w], where ctr_y and 3886 * ctr_x are the center position of the box, and h and w are the height 3887 * and the width. 3888 * * 3: An {@link %{OperandTypeLinkPfx}FLOAT32} scalar, specifying the scaling 3889 * factor for dy in bounding box deltas. 3890 * * 4: An {@link %{OperandTypeLinkPfx}FLOAT32} scalar, specifying the scaling 3891 * factor for dx in bounding box deltas. 3892 * * 5: An {@link %{OperandTypeLinkPfx}FLOAT32} scalar, specifying the scaling 3893 * factor for dh in bounding box deltas. 3894 * * 6: An {@link %{OperandTypeLinkPfx}FLOAT32} scalar, specifying the scaling 3895 * factor for dw in bounding box deltas. 3896 * * 7: An {@link %{OperandTypeLinkPfx}BOOL} scalar, set to true to use regular 3897 * multi-class NMS algorithm that do NMS separately for each class, 3898 * set to false for a faster algorithm that only do one single NMS 3899 * using the highest class score.. 3900 * * 8: An {@link %{OperandTypeLinkPfx}INT32} scalar, max_num_detections, specifying 3901 * the maximum number of boxes for the output. Boxes with the lowest 3902 * scores are discarded to meet the limit. 3903 * * 9: An {@link %{OperandTypeLinkPfx}INT32} scalar, only used when input7 is 3904 * set to false, specifying the maximum number of classes per detection. 3905 * * 10: An {@link %{OperandTypeLinkPfx}INT32} scalar, only used when input7 is 3906 * set to true, specifying the maximum number of detections when 3907 * applying NMS algorithm for each single class. 3908 * * 11: A scalar, score_threshold. Boxes with scores lower than the 3909 * threshold are filtered before sending to the NMS algorithm. The 3910 * scalar must be of {@link %{OperandTypeLinkPfx}FLOAT16} if input0 is of 3911 * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} and of 3912 * {@link %{OperandTypeLinkPfx}FLOAT32} if input0 is of 3913 * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32}. 3914 * * 12: A scalar, specifying the IoU threshold for hard NMS. The scalar 3915 * must be of {@link %{OperandTypeLinkPfx}FLOAT16} if input0 is of 3916 * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} and of 3917 * {@link %{OperandTypeLinkPfx}FLOAT32} if input0 is of 3918 * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32}. 3919 * * 13: An {@link %{OperandTypeLinkPfx}BOOL} scalar, set to true to include 3920 * background class in the list of label map for the output, set 3921 * to false to not include the background. When the background 3922 * class is included, it has label 0 and the output classes start 3923 * at 1 in the label map, otherwise, the output classes start at 0. 3924 * 3925 * Outputs: 3926 * * 0: A 2-D tensor of the same {@link %{OperandType}} as input0, with shape 3927 * [batches, max_num_detections], specifying the score of each output 3928 * detections. 3929 * * 1: A 3-D tensor of shape [batches, max_num_detections, 4], specifying the 3930 * coordinates of each output bounding box, with format 3931 * [y1, x1, y2, x2]. 3932 * * 2: A 2-D {@link %{OperandTypeLinkPfx}TENSOR_INT32} tensor, of shape 3933 * [batches, max_num_detections], specifying the class label for each 3934 * output detection. 3935 * * 3: An 1-D {@link %{OperandTypeLinkPfx}TENSOR_INT32} tensor, of shape [batches], 3936 * specifying the number of valid output detections for each batch. 3937%insert AVAIL3 3938 */ 3939 %{DeclareOperation_1.2 DETECTION_POSTPROCESSING 47}, 3940 3941 /** 3942 * For input tensors x and y, computes x == y elementwise. 3943 * 3944 * Supported tensor {@link %{OperandType}}: 3945 * * {@link %{OperandTypeLinkPfx}TENSOR_BOOL8} 3946 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 3947 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 3948 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 3949 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 3950%kind canonical ndk hal_1.3+ 3951 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 3952%/kind 3953 * 3954 * Supported tensor rank: from 1 3955 * 3956 * This operation supports broadcasting. 3957 * 3958 * Inputs: 3959 * * 0: A tensor. 3960 * * 1: A tensor of the same {@link %{OperandType}} and dimensions compatible 3961 * with input0. 3962 * 3963 * Outputs: 3964 * * 0: A tensor of {@link %{OperandTypeLinkPfx}TENSOR_BOOL8}. 3965%insert AVAIL3 3966 */ 3967 %{DeclareOperation_1.2 EQUAL 48}, 3968 3969 /** 3970 * Computes exponential of x element-wise. 3971 * 3972 * Supported tensor {@link %{OperandType}}: 3973 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 3974 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 3975 * 3976 * Supported tensor rank: from 1. 3977 * 3978 * Inputs: 3979 * * 0: A tensor. 3980 * 3981 * Outputs: 3982 * * 0: The output tensor of same shape as input0. 3983%insert AVAIL3 3984 */ 3985 %{DeclareOperation_1.2 EXP 49}, 3986 3987 /** 3988 * Inserts a dimension of 1 into a tensor's shape. 3989 * 3990 * Given a tensor input, this operation inserts a dimension of 1 at the 3991 * given dimension index of input's shape. The dimension index starts at 3992 * zero; if you specify a negative dimension index, it is counted backward 3993 * from the end. 3994 * 3995 * Supported tensor {@link %{OperandType}}: 3996 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 3997 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 3998 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 3999 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 4000%kind canonical ndk hal_1.3+ 4001 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 4002%/kind 4003 * 4004 * Supported tensor rank: from 1 4005 * 4006 * Inputs: 4007 * * 0: An n-D tensor. 4008 * * 1: An {@link %{OperandTypeLinkPfx}INT32} scalar specifying the dimension 4009 * index to expand. Must be in the range [-(n + 1), (n + 1)). 4010 * 4011 * Outputs: 4012 * * 0: An (n + 1)-D tensor with the same {@link %{OperandType}} and data as 4013 * input0. 4014%kind canonical ndk hal_1.3+ 4015 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 4016 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 4017%else 4018 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 4019%/kind 4020 * the scale and zeroPoint must be the same as input0. 4021%insert AVAIL3 4022 */ 4023 %{DeclareOperation_1.2 EXPAND_DIMS 50}, 4024 4025 /** 4026 * Gathers values along an axis. 4027 * 4028 * Produces an output tensor with shape 4029 * input0.dimension[:axis] + indices.dimension + input0.dimension[axis + 1:] 4030 * where: 4031 * # Vector indices (output is rank(input0)). 4032 * output[a_0, ..., a_n, i, b_0, ..., b_n] = 4033 * input0[a_0, ..., a_n, indices[i], b_0, ..., b_n] 4034 * 4035 * # Higher rank indices (output is rank(input0) + rank(indices) - 1). 4036 * output[a_0, ..., a_n, i, ..., j, b_0, ... b_n] = 4037 * input0[a_0, ..., a_n, indices[i, ..., j], b_0, ..., b_n] 4038 * 4039 * Supported tensor {@link %{OperandType}}: 4040 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 4041 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 4042 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 4043 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 4044%kind canonical ndk hal_1.3+ 4045 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 4046%/kind 4047 * 4048 * Supported tensor rank: from 1 4049 * 4050 * Inputs: 4051 * * 0: An n-D tensor from which to gather values. 4052 * * 1: An {@link %{OperandTypeLinkPfx}INT32} scalar specifying the axis. 4053 * Negative index is used to specify axis from the end 4054 * (e.g. -1 for the last axis). Must be in the range [-n, n). 4055 * * 2: A k-D tensor {@link %{OperandTypeLinkPfx}TENSOR_INT32} of indices. 4056 * The values must be in the bounds of the corresponding dimensions 4057 * of input0. 4058 * 4059 * Outputs: 4060 * * 0: An (n + k - 1)-D tensor with the same {@link %{OperandType}} as input0. 4061%kind canonical ndk hal_1.3+ 4062 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 4063 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 4064%else 4065 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 4066%/kind 4067 * the scale and zeroPoint must be the same as input0. 4068%insert AVAIL3 4069 */ 4070 %{DeclareOperation_1.2 GATHER 51}, 4071 4072 /** 4073 * Generate aixs-aligned bounding box proposals. 4074 * 4075 * Bounding box proposals are generated by applying transformation on a set 4076 * of predefined anchors with the bounding box deltas from bounding box 4077 * regression. A final step of hard NMS is applied to limit the number of 4078 * returned boxes. 4079 * 4080 * Axis-aligned bounding boxes are represented by its upper-left corner 4081 * coordinate (x1,y1) and lower-right corner coordinate (x2,y2). A valid 4082 * bounding box should satisfy x1 <= x2 and y1 <= y2. 4083 * 4084 * Supported tensor {@link %{OperandType}}: 4085 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 4086 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 4087 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 4088%kind canonical ndk hal_1.3+ 4089 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 4090%/kind 4091 * 4092 * Inputs: 4093 * * 0: A 4-D Tensor specifying the score of each anchor at each 4094 * location. With "NHWC" data layout, the tensor shape is 4095 * [batches, height, width, num_anchors]. With "NCHW" data layout, 4096 * the tensor shape is [batches, num_anchors, height, width]. 4097 * * 1: A 4-D Tensor specifying the bounding box deltas. With "NHWC" data 4098 * layout, the tensor shape is [batches, height, width, num_anchors * 4]. 4099 * With "NCHW" data layout, the tensor shape is 4100 * [batches, num_anchors * 4, height, width]. The box deltas are encoded 4101 * in the order of [dx, dy, dw, dh], where dx and dy is the linear-scale 4102 * relative correction factor for the center position of the bounding box 4103 * with respect to the width and height, dw and dh is the log-scale 4104 * relative correction factor for the width and height. The last 4105 * dimensions is the channel dimension. 4106 * * 2: A 2-D Tensor of shape [num_anchors, 4], specifying the shape of each 4107 * predefined anchor, with format [x1, y1, x2, y2]. For input0 of type 4108%kind canonical ndk hal_1.3+ 4109 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} or 4110 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED}, this tensor should be of 4111%else 4112 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, this tensor should be of 4113%/kind 4114 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_SYMM}, with scale of 0.125. 4115 * * 3: A 2-D Tensor of shape [batches, 2], specifying the size of 4116 * each image in the batch, with format [image_height, image_width]. 4117%kind canonical ndk hal_1.3+ 4118 * For input0 of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} or 4119 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED}, this 4120%else 4121 * For input0 of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, this 4122%/kind 4123 * tensor should be of {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_SYMM}, with 4124 * scale of 0.125. 4125 * * 4: An {@link %{OperandTypeLinkPfx}FLOAT32} scalar, specifying the ratio 4126 * from the height of original image to the height of feature map. 4127 * * 5: An {@link %{OperandTypeLinkPfx}FLOAT32} scalar, specifying the ratio 4128 * from the width of original image to the width of feature map. 4129 * * 6: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the maximum 4130 * number of boxes before going into the hard NMS algorithm. Boxes 4131 * with the lowest scores are discarded to meet the limit. Set to 4132 * a non-positive value for unlimited number. 4133 * * 7: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the maximum 4134 * number of boxes returning from the hard NMS algorithm. Boxes 4135 * with the lowest scores are discarded to meet the limit. Set to 4136 * a non-positive value for unlimited number. 4137 * * 8: An {@link %{OperandTypeLinkPfx}FLOAT32} scalar, specifying the IoU 4138 * threshold for hard NMS. 4139 * * 9: An {@link %{OperandTypeLinkPfx}FLOAT32} scalar, min_size. Boxes with 4140 * height or width lower than the absolute threshold are filtered out. 4141 * * 10: An {@link %{OperandTypeLinkPfx}BOOL} scalar, set to true to specify 4142 * NCHW data layout for input0 and input1. Set to false for NHWC. 4143 * 4144 * Outputs: 4145 * * 0: A tensor of the same {@link %{OperandType}} as input0, of shape 4146 * [num_output_rois], specifying the score of each output box. 4147 * The boxes are grouped by batches, but the sequential order in 4148 * each batch is not guaranteed. For type of 4149%kind canonical ndk hal_1.3+ 4150 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} or 4151 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED}, the scale and zero 4152%else 4153 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, the scale and zero 4154%/kind 4155 * point must be the same as input0. 4156 * * 1: A tensor of the same {@link %{OperandType}} as input3, of shape 4157 * [num_output_rois, 4], specifying the coordinates of each output 4158 * bounding box for each class, with format [x1, y1, x2, y2]. 4159 * The sequential order of the boxes corresponds with output0. 4160 * For type of {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_ASYMM}, the 4161 * scale must be 0.125 and the zero point must be 0. 4162 * * 2: A 1-D {@link %{OperandTypeLinkPfx}TENSOR_INT32} tensor, of shape 4163 * [num_output_rois], specifying the batch index of each box. Boxes 4164 * with the same batch index are grouped together. 4165%insert AVAIL3 4166 */ 4167 %{DeclareOperation_1.2 GENERATE_PROPOSALS 52}, 4168 4169 /** 4170 * For input tensors x and y, computes x > y elementwise. 4171 * 4172 * Supported tensor {@link %{OperandType}}: 4173 * * {@link %{OperandTypeLinkPfx}TENSOR_BOOL8} 4174 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 4175 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 4176 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 4177 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 4178%kind canonical ndk hal_1.3+ 4179 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 4180%/kind 4181 * 4182 * Supported tensor rank: from 1 4183 * 4184 * This operation supports broadcasting. 4185 * 4186 * Inputs: 4187 * * 0: A tensor. 4188 * * 1: A tensor of the same {@link %{OperandType}} and dimensions compatible 4189 * with input0. 4190 * 4191 * Outputs: 4192 * * 0: A tensor of {@link %{OperandTypeLinkPfx}TENSOR_BOOL8}. 4193%insert AVAIL3 4194 */ 4195 %{DeclareOperation_1.2 GREATER 53}, 4196 /** 4197 * For input tensors x and y, computes x >= y elementwise. 4198 * 4199 * Supported tensor {@link %{OperandType}}: 4200 * * {@link %{OperandTypeLinkPfx}TENSOR_BOOL8} 4201 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 4202 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 4203 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 4204 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 4205%kind canonical ndk hal_1.3+ 4206 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 4207%/kind 4208 * 4209 * Supported tensor rank: from 1 4210 * 4211 * This operation supports broadcasting. 4212 * 4213 * Inputs: 4214 * * 0: A tensor. 4215 * * 1: A tensor of the same {@link %{OperandType}} and dimensions compatible 4216 * with input0. 4217 * 4218 * Outputs: 4219 * * 0: A tensor of {@link %{OperandTypeLinkPfx}TENSOR_BOOL8}. 4220%insert AVAIL3 4221 */ 4222 %{DeclareOperation_1.2 GREATER_EQUAL 54}, 4223 4224 /** 4225 * Performs a grouped 2-D convolution operation. 4226 * 4227 * Given an input tensor of shape [batches, height, width, depth_in] and a 4228 * filter tensor of shape [depth_out, filter_height, filter_width, depth_group] 4229 * containing depth_out convolutional filters of depth depth_group, GROUPED_CONV 4230 * applies a group of different filters to each input channel group, then 4231 * concatenates the results together. 4232 * 4233 * Specifically, the input channels are divided into num_groups groups, each with 4234 * depth depth_group, i.e. depth_in = num_groups * depth_group. The convolutional 4235 * filters are also divided into num_groups groups, i.e. depth_out is divisible 4236 * by num_groups. GROUPED_CONV applies each group of filters to the corresponding 4237 * input channel group, and the result are concatenated together. 4238 * 4239 * The output dimensions are functions of the filter dimensions, stride, and 4240 * padding. 4241 * 4242 * The values in the output tensor are computed as: 4243 * 4244 * output[b, i, j, g * channel_multiplier + q] = 4245 * sum_{di, dj, dk} ( 4246 * input[b, strides[1] * i + di, strides[2] * j + dj, 4247 * g * depth_group + dk] * 4248 * filter[g * channel_multiplier + q, di, dj, dk] 4249 * ) + bias[channel] 4250 * 4251 * where channel_multiplier = depth_out / num_groups 4252 * 4253 * Supported tensor {@link %{OperandType}} configurations: 4254 * * 16 bit floating point: 4255 * * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} for input, filter, output, and bias. 4256 * 4257 * * 32 bit floating point: 4258 * * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} for input, filter, output, and bias. 4259 * 4260 * * Quantized: 4261 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} for input, filter, and output. 4262 * * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} for bias (with scale set to 4263 * * * input.scale * filter.scale). 4264%kind canonical ndk hal_1.3+ 4265 * 4266 * * Quantized signed (since %{NNAPILevel4}): 4267 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} for input, filter, and output. 4268 * * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} for bias (with scale set to 4269 * * * input.scale * filter.scale). 4270%/kind 4271 * 4272 * * Quantized with symmetric per channel quantization for the filter: 4273 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} for input, and output. 4274 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL} for filter. 4275 * * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} for bias (scale set to 0.0, 4276 * * * each value scaling is separate and equal to input.scale * filter.scales[channel]). 4277%kind canonical ndk hal_1.3+ 4278 * 4279 * * Quantized signed with filter symmetric per channel quantization 4280 * (since %{NNAPILevel4}): 4281 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} for input, and output. 4282 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL} for filter. 4283 * * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} for bias (scale set to 0.0, 4284 * * * each value scaling is separate and equal to input.scale * filter.scales[channel]). 4285%/kind 4286 * 4287 * Supported tensor rank: 4, with "NHWC" or "NCHW" data layout. 4288 * With the default data layout NHWC, the data is stored in the order of: 4289 * [batch, height, width, channels]. Alternatively, the data layout could 4290 * be NCHW, the data storage order of: [batch, channels, height, width]. 4291 * 4292 * Both explicit padding and implicit padding are supported. 4293 * 4294 * Inputs (explicit padding): 4295 * * 0: A 4-D tensor, of shape [batches, height, width, depth_in], 4296 * specifying the input, where depth_in = num_groups * depth_group. 4297 * * 1: A 4-D tensor, of shape 4298 * [depth_out, filter_height, filter_width, depth_group], specifying 4299 * the filter, where depth_out must be divisible by num_groups. For 4300 * tensor of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL} 4301 * the channel dimension (channelDim at 4302 * {@link %{Ann}SymmPerChannelQuantParams}) must be set to 0. 4303 * * 2: A 1-D tensor, of shape [depth_out], specifying the bias. For input 4304 * tensor of type {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} or 4305 * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16}, the bias must be of the same type. 4306%kind canonical ndk hal_1.3+ 4307 * For filter tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 4308 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} 4309%else 4310 * For filter tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, 4311%/kind 4312 * the bias should be of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, with zeroPoint 4313 * of 0 and bias_scale == input_scale * filter_scale. For filter tensor 4314 * of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL}, the bias 4315 * should be of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, with zeroPoint of 4316 * 0 and bias_scale of 0. The actual scale of each value 'i' is equal to 4317 * bias_scale[i] = input_scale * filter_scale[i]. 4318 * * 3: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 4319 * the left, in the ‘width’ dimension. 4320 * * 4: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 4321 * the right, in the ‘width’ dimension. 4322 * * 5: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 4323 * the top, in the ‘height’ dimension. 4324 * * 6: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 4325 * the bottom, in the ‘height’ dimension. 4326 * * 7: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 4327 * walking through input in the ‘width’ dimension. 4328 * * 8: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 4329 * walking through input in the ‘height’ dimension. 4330 * * 9: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the number of 4331 * groups. 4332 * * 10: An {@link %{OperandTypeLinkPfx}INT32} scalar, and has to be one of the 4333 * {@link %{FusedActivationFunc}} values. Specifies the activation to 4334 * invoke on the result. 4335 * * 11: An {@link %{OperandTypeLinkPfx}BOOL} scalar, set to true to specify 4336 * NCHW data layout for input0 and output0. Set to false for NHWC. 4337 * 4338 * Inputs (implicit padding): 4339 * * 0: A 4-D tensor, of shape [batches, height, width, depth_in], 4340 * specifying the input, where depth_in = num_groups * depth_group. 4341 * * 1: A 4-D tensor, of shape 4342 * [depth_out, filter_height, filter_width, depth_group], specifying 4343 * the filter, where depth_out must be divisible by num_groups. For 4344 * tensor of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL} 4345 * the channel dimension (%{Ann}SymmPerChannelQuantParams::channelDim) 4346 * must be set to 0. 4347 * * 2: A 1-D tensor, of shape [depth_out], specifying the bias. For input 4348 * tensor of type {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} or 4349 * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16}, the bias must be of the same 4350 * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16}, the bias must be of the same type. 4351%kind canonical ndk hal_1.3+ 4352 * For filter tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 4353 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} 4354%else 4355 * For filter tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, 4356%/kind 4357 * the bias should be of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, with zeroPoint 4358 * of 0 and bias_scale == input_scale * filter_scale. For filter tensor 4359 * of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL}, the bias 4360 * should be of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, with zeroPoint of 4361 * 0 and bias_scale of 0. The actual scale of each value 'i' is equal to 4362 * bias_scale[i] = input_scale * filter_scale[i]. 4363 * * 3: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the implicit 4364 * padding scheme, has to be one of the 4365%insert PaddingCodeValues 4366 * * 4: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 4367 * walking through input in the ‘width’ dimension. 4368 * * 5: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 4369 * walking through input in the ‘height’ dimension. 4370 * * 6: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the number of 4371 * groups. 4372 * * 7: An {@link %{OperandTypeLinkPfx}INT32} scalar, and has to be one of the 4373 * {@link %{FusedActivationFunc}} values. Specifies the activation to 4374 * invoke on the result. 4375 * * 8: An {@link %{OperandTypeLinkPfx}BOOL} scalar, set to true to specify 4376 * NCHW data layout for input0 and output0. Set to false for NHWC. 4377 * 4378 * Outputs: 4379 * * 0: The output 4-D tensor, of shape 4380 * [batches, out_height, out_width, depth_out]. 4381%kind canonical ndk hal_1.3+ 4382 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 4383 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 4384 * the scale and zeroPoint can be different from inputs' scale and zeroPoint. 4385%else 4386 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 4387 * the scale and zeroPoint can be different from inputs' scale and zeroPoint. 4388%/kind 4389%insert AVAIL3 4390 */ 4391 %{DeclareOperation_1.2 GROUPED_CONV_2D 55}, 4392 4393 /** 4394 * Localize the maximum keypoints from heatmaps. 4395 * 4396 * This operation approximates the accurate maximum keypoint scores and 4397 * indices after bicubic upscaling by using Taylor expansion up to the 4398 * quadratic term. 4399 * 4400 * The bounding box is represented by its upper-left corner coordinate 4401 * (x1,y1) and lower-right corner coordinate (x2,y2) in the original image. 4402 * A valid bounding box should satisfy x1 <= x2 and y1 <= y2. 4403 * 4404 * Supported tensor {@link %{OperandType}}: 4405 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 4406 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 4407 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 4408%kind canonical ndk hal_1.3+ 4409 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 4410%/kind 4411 * 4412 * Supported tensor rank: 4, with "NHWC" or "NCHW" data layout. 4413 * With the default data layout NHWC, the data is stored in the order of: 4414 * [batch, height, width, channels]. Alternatively, the data layout could 4415 * be NCHW, the data storage order of: [batch, channels, height, width]. 4416 * 4417 * Inputs: 4418 * * 0: A 4-D Tensor of shape 4419 * [num_boxes, heatmap_size, heatmap_size, num_keypoints], 4420 * specifying the heatmaps, the height and width of heatmaps should 4421 * be the same, and must be greater than or equal to 2. 4422 * * 1: A 2-D Tensor of shape [num_boxes, 4], specifying the bounding boxes, 4423 * each with format [x1, y1, x2, y2]. For input0 of type 4424 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, this tensor should 4425 * be of {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_ASYMM}, with zeroPoint 4426 * of 0 and scale of 0.125. 4427%kind canonical ndk hal_1.3+ 4428 * For input0 of type 4429 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED}, this tensor 4430 * should be of {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_ASYMM}, with 4431 * zeroPoint of -128 and scale of 0.125. 4432%/kind 4433 * * 2: An {@link %{OperandTypeLinkPfx}BOOL} scalar, set to true to specify 4434 * NCHW data layout for input0. Set to false for NHWC. 4435 * 4436 * Outputs: 4437 * * 0: A tensor of the same {@link %{OperandType}} as input0, with shape 4438 * [num_boxes, num_keypoints], specifying score of the keypoints. 4439%kind canonical ndk hal_1.3+ 4440 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} or 4441 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 4442 * the scale and zeroPoint can be different from input0 scale and zeroPoint. 4443%else 4444 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 4445 * the scale and zeroPoint can be different from input0 scale and zeroPoint. 4446%/kind 4447 * * 1: A tensor of the same {@link %{OperandType}} as input1, with shape 4448 * [num_boxes, num_keypoints, 2], specifying the location of 4449 * the keypoints, the second dimension is organized as 4450 * [keypoint_x, keypoint_y]. 4451 * For type of {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_ASYMM}, the 4452 * scale must be 0.125 and the zero point must be 0. 4453%insert AVAIL3 4454 */ 4455 %{DeclareOperation_1.2 HEATMAP_MAX_KEYPOINT 56}, 4456 4457 /** 4458 * Applies instance normalization to the input tensor. 4459 * 4460 * The values in the output tensor are computed as: 4461 * 4462 * output[b, h, w, c] = 4463 * (input[b, h, w, c] - mean[b, c]) * gamma / 4464 * sqrt(var[b, c] + epsilon) + beta 4465 * 4466 * Where the mean and variance are computed across the spatial dimensions: 4467 * 4468 * mean[b, c] = 4469 * sum_{h, w}(input[b, h, w, c]) / sum(1) 4470 * 4471 * var[b, c] = 4472 * sum_{h, w}(pow(input[b, h, w, c] - mean[b, c], 2)) / sum(1) 4473 * 4474 * Supported tensor {@link %{OperandType}}: 4475 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 4476 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 4477 * 4478 * Supported tensor rank: 4, with "NHWC" or "NCHW" data layout. 4479 * With the default data layout NHWC, the data is stored in the order of: 4480 * [batch, height, width, channels]. Alternatively, the data layout could 4481 * be NCHW, the data storage order of: [batch, channels, height, width]. 4482 * 4483 * Inputs: 4484 * * 0: An n-D tensor, specifying the tensor to be normalized. 4485 * * 1: A scalar, specifying gamma, the scale applied to the normalized 4486 * tensor. The scalar must be of {@link %{OperandTypeLinkPfx}FLOAT16} if 4487 * input0 is of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} and of 4488 * {@link %{OperandTypeLinkPfx}FLOAT32} if input0 is of 4489 * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32}. 4490 * * 2: A scalar, specifying beta, the offset applied to the normalized 4491 * tensor. The scalar must be of {@link %{OperandTypeLinkPfx}FLOAT16} if 4492 * input0 is of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} and of 4493 * {@link %{OperandTypeLinkPfx}FLOAT32} if input0 is of 4494 * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32}. 4495 * * 3: A scalar, specifying epsilon, the small value added to variance to 4496 * avoid dividing by zero. The scalar must be of {@link %{OperandTypeLinkPfx}FLOAT16} if 4497 * input0 is of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} and of 4498 * {@link %{OperandTypeLinkPfx}FLOAT32} if input0 is of 4499 * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32}. 4500 * * 4: An {@link %{OperandTypeLinkPfx}BOOL} scalar, set to true to specify 4501 * NCHW data layout for input0 and output0. Set to false for NHWC. 4502 * 4503 * Outputs: 4504 * * 0: A tensor of the same {@link %{OperandType}} and same shape as input0. 4505%insert AVAIL3 4506 */ 4507 %{DeclareOperation_1.2 INSTANCE_NORMALIZATION 57}, 4508 4509 /** 4510 * For input tensors x and y, computes x < y elementwise. 4511 * 4512 * Supported tensor {@link %{OperandType}}: 4513 * * {@link %{OperandTypeLinkPfx}TENSOR_BOOL8} 4514 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 4515 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 4516 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 4517 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 4518%kind canonical ndk hal_1.3+ 4519 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 4520%/kind 4521 * 4522 * Supported tensor rank: from 1 4523 * 4524 * This operation supports broadcasting. 4525 * 4526 * Inputs: 4527 * * 0: A tensor. 4528 * * 1: A tensor of the same {@link %{OperandType}} and dimensions compatible 4529 * with input0. 4530 * 4531 * Outputs: 4532 * * 0: A tensor of {@link %{OperandTypeLinkPfx}TENSOR_BOOL8}. 4533%insert AVAIL3 4534 */ 4535 %{DeclareOperation_1.2 LESS 58}, 4536 4537 /** 4538 * For input tensors x and y, computes x <= y elementwise. 4539 * 4540 * Supported tensor {@link %{OperandType}}: 4541 * * {@link %{OperandTypeLinkPfx}TENSOR_BOOL8} 4542 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 4543 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 4544 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 4545 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 4546%kind canonical ndk hal_1.3+ 4547 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 4548%/kind 4549 * 4550 * Supported tensor rank: from 1 4551 * 4552 * This operation supports broadcasting. 4553 * 4554 * Inputs: 4555 * * 0: A tensor. 4556 * * 1: A tensor of the same {@link %{OperandType}} and dimensions compatible 4557 * with input0. 4558 * 4559 * Outputs: 4560 * * 0: A tensor of {@link %{OperandTypeLinkPfx}TENSOR_BOOL8}. 4561%insert AVAIL3 4562 */ 4563 %{DeclareOperation_1.2 LESS_EQUAL 59}, 4564 4565 /** 4566 * Computes natural logarithm of x element-wise. 4567 * 4568 * Supported tensor {@link %{OperandType}}: 4569 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 4570 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 4571 * 4572 * Supported tensor rank: from 1. 4573 * 4574 * Inputs: 4575 * * 0: A tensor. 4576 * 4577 * Outputs: 4578 * * 0: The output tensor of same shape as input0. 4579%insert AVAIL3 4580 */ 4581 %{DeclareOperation_1.2 LOG 60}, 4582 4583 /** 4584 * Returns the truth value of x AND y element-wise. 4585 * 4586 * Supported tensor {@link %{OperandType}}: 4587 * * {@link %{OperandTypeLinkPfx}TENSOR_BOOL8} 4588 * 4589 * Supported tensor rank: from 1 4590 * 4591 * This operation supports broadcasting. 4592 * 4593 * Inputs: 4594 * * 0: A tensor of {@link %{OperandTypeLinkPfx}TENSOR_BOOL8}. 4595 * * 1: A tensor of {@link %{OperandTypeLinkPfx}TENSOR_BOOL8} and dimensions 4596 * compatible with input0. 4597 * 4598 * Outputs: 4599 * * 0: A tensor of {@link %{OperandTypeLinkPfx}TENSOR_BOOL8}. 4600%insert AVAIL3 4601 */ 4602 %{DeclareOperation_1.2 LOGICAL_AND 61}, 4603 4604 /** 4605 * Computes the truth value of NOT x element-wise. 4606 * 4607 * Supported tensor {@link %{OperandType}}: 4608 * * {@link %{OperandTypeLinkPfx}TENSOR_BOOL8} 4609 * 4610 * Supported tensor rank: from 1. 4611 * 4612 * Inputs: 4613 * * 0: A tensor. 4614 * 4615 * Outputs: 4616 * * 0: The output tensor of same shape as input0. 4617%insert AVAIL3 4618 */ 4619 %{DeclareOperation_1.2 LOGICAL_NOT 62}, 4620 4621 /** 4622 * Returns the truth value of x OR y element-wise. 4623 * 4624 * Supported tensor {@link %{OperandType}}: 4625 * * {@link %{OperandTypeLinkPfx}TENSOR_BOOL8} 4626 * 4627 * Supported tensor rank: from 1 4628 * 4629 * This operation supports broadcasting. 4630 * 4631 * Inputs: 4632 * * 0: A tensor of {@link %{OperandTypeLinkPfx}TENSOR_BOOL8}. 4633 * * 1: A tensor of {@link %{OperandTypeLinkPfx}TENSOR_BOOL8} and dimensions 4634 * compatible with input0. 4635 * 4636 * Outputs: 4637 * * 0: A tensor of {@link %{OperandTypeLinkPfx}TENSOR_BOOL8}. 4638%insert AVAIL3 4639 */ 4640 %{DeclareOperation_1.2 LOGICAL_OR 63}, 4641 4642 /** 4643 * Computes the log softmax activations given logits. 4644 * 4645 * The output is calculated using this formula: 4646 * 4647 * output = logits * beta - log(reduce_sum(exp(logits * beta), axis)) 4648 * 4649 * Supported tensor {@link %{OperandType}}: 4650 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 4651 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 4652 * 4653 * Supported tensor rank: from 1. 4654 * 4655 * Inputs: 4656 * * 0: A tensor specifying the input logits. 4657 * * 1: A scalar, specifying the positive scaling factor for the exponent, 4658 * beta. 4659 * For input tensor of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16}, the beta 4660 * value must be of {@link %{OperandTypeLinkPfx}FLOAT16}. 4661 * For input tensor of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32}, the beta 4662 * value must be of {@link %{OperandTypeLinkPfx}FLOAT32}. 4663 * * 2: An {@link %{OperandTypeLinkPfx}INT32} scalar specifying the axis to 4664 * reduce across. Negative index is used to specify axis from the 4665 * end (e.g. -1 for the last axis). Must be in the range [-n, n). 4666 * 4667 * Outputs: 4668 * * 0: The output tensor of the same {@link %{OperandType}} and shape as 4669 * input0. 4670%insert AVAIL3 4671 */ 4672 %{DeclareOperation_1.2 LOG_SOFTMAX 64}, 4673 4674 /** 4675 * Returns the element-wise maximum of two tensors. 4676 * 4677 * Supported tensor {@link %{OperandType}}: 4678 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 4679 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 4680 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 4681 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 4682%kind canonical ndk hal_1.3+ 4683 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 4684%/kind 4685 * 4686 * Supported tensor rank: from 1. 4687 * 4688 * Inputs: 4689 * * 0: A tensor. 4690 * * 1: A tensor of the same {@link %{OperandType}} and compatible dimensions 4691 * with input0. 4692 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 4693 * the scales and zeroPoint can be different from input0 scale and zeroPoint. 4694 * 4695 * Outputs: 4696 * * 0: A tensor of the same {@link %{OperandType}} as input0. 4697%kind canonical ndk hal_1.3+ 4698 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 4699 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 4700 * the scale and zeroPoint can be different from inputs' scale and zeroPoint. 4701%else 4702 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 4703 * the scale and zeroPoint can be different from inputs' scale and zeroPoint. 4704%/kind 4705%insert AVAIL3 4706 */ 4707 %{DeclareOperation_1.2 MAXIMUM 65}, 4708 4709 /** 4710 * Returns the element-wise minimum of two tensors. 4711 * 4712 * Supported tensor {@link %{OperandType}}: 4713 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 4714 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 4715 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 4716 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 4717%kind canonical ndk hal_1.3+ 4718 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 4719%/kind 4720 * 4721 * Supported tensor rank: from 1. 4722 * 4723 * Inputs: 4724 * * 0: A tensor. 4725 * * 1: A tensor of the same {@link %{OperandType}} and compatible dimensions 4726 * with input0. 4727 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 4728 * the scales and zeroPoint can be different from input0 scale and zeroPoint. 4729 * 4730 * Outputs: 4731 * * 0: A tensor of the same {@link %{OperandType}} as input0. 4732%kind canonical ndk hal_1.3+ 4733 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 4734 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 4735 * the scale and zeroPoint can be different from inputs' scale and zeroPoint. 4736%else 4737 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 4738 * the scale and zeroPoint can be different from inputs' scale and zeroPoint. 4739%/kind 4740%insert AVAIL3 4741 */ 4742 %{DeclareOperation_1.2 MINIMUM 66}, 4743 4744 /** 4745 * Computes numerical negative value element-wise. 4746 * 4747 * Supported tensor {@link %{OperandType}}: 4748 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 4749 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 4750 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 4751 * 4752 * Supported tensor rank: from 1. 4753 * 4754 * Inputs: 4755 * * 0: A tensor. 4756 * 4757 * Outputs: 4758 * * 0: The output tensor of same shape as input0. 4759%insert AVAIL3 4760 */ 4761 %{DeclareOperation_1.2 NEG 67}, 4762 4763 /** 4764 * For input tensors x and y, computes x != y elementwise. 4765 * 4766 * Supported tensor {@link %{OperandType}}: 4767 * * {@link %{OperandTypeLinkPfx}TENSOR_BOOL8} 4768 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 4769 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 4770 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 4771 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 4772%kind canonical ndk hal_1.3+ 4773 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 4774%/kind 4775 * 4776 * Supported tensor rank: from 1 4777 * 4778 * This operation supports broadcasting. 4779 * 4780 * Inputs: 4781 * * 0: A tensor. 4782 * * 1: A tensor of the same {@link %{OperandType}} and dimensions compatible 4783 * with input0. 4784 * 4785 * Outputs: 4786 * * 0: A tensor of {@link %{OperandTypeLinkPfx}TENSOR_BOOL8}. 4787%insert AVAIL3 4788 */ 4789 %{DeclareOperation_1.2 NOT_EQUAL 68}, 4790 4791 /** 4792 * Pads a tensor with the given constant value according to the specified 4793 * paddings. 4794 * 4795 * Supported tensor {@link %{OperandType}}: 4796 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 4797 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 4798 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 4799%kind canonical ndk hal_1.3+ 4800 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 4801%/kind 4802 * 4803 * Supported tensor rank: up to 4 4804 * 4805 * Inputs: 4806 * * 0: An n-D tensor, specifying the tensor to be padded. 4807 * * 1: A 2-D Tensor of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, the paddings 4808 * for each spatial dimension of the input tensor. The shape of the 4809 * tensor must be {rank(input0), 2}. 4810 * padding[i, 0] specifies the number of elements to be padded in the 4811 * front of dimension i. 4812 * padding[i, 1] specifies the number of elements to be padded after 4813 * the end of dimension i. 4814 * * 2: A scalar specifying the value to use for padding input0. 4815 * For input tensor of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16}, the 4816 * pad value must be of {@link %{OperandTypeLinkPfx}FLOAT16}. 4817 * For input tensor of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32}, the 4818 * pad value must be of {@link %{OperandTypeLinkPfx}FLOAT32}. 4819%kind canonical ndk hal_1.3+ 4820 * For input tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 4821 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED}, 4822%else 4823 * For input tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, 4824%/kind 4825 * the pad value must be of {@link %{OperandTypeLinkPfx}INT32}. The 4826 * scale and zeroPoint are assumed to be the same as in input0. 4827 * 4828 * Outputs: 4829 * * 0: A tensor of the same {@link %{OperandType}} as input0. The 4830 * output tensor has the same rank as input0, and each 4831 * dimension of the output tensor has the same size as the 4832 * corresponding dimension of the input tensor plus the size 4833 * of the padding: 4834 * output0.dimension[i] = 4835 * padding[i, 0] + input0.dimension[i] + padding[i, 1] 4836%kind canonical ndk hal_1.3+ 4837 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 4838 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 4839 * the scale and zeroPoint must be the same as input0. 4840%else 4841 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 4842 * the scale and zeroPoint must be the same as input0. 4843%/kind 4844%insert AVAIL3 4845 */ 4846 %{DeclareOperation_1.2 PAD_V2 69}, 4847 4848 /** 4849 * Computes the power of one value to another. 4850 * 4851 * Given a tensor base and a tensor exponent, this operation computes 4852 * base^exponent elementwise. 4853 * 4854 * This operations supports broadcasting. The size of the output is the 4855 * maximum size along each dimension of the input operands. It starts with 4856 * the trailing dimensions, and works its way forward. 4857 * 4858 * For example: 4859 * base.dimension = {4, 1, 2} 4860 * exponent.dimension = {5, 4, 3, 1} 4861 * output.dimension = {5, 4, 3, 2} 4862 * 4863 * Supported tensor {@link %{OperandType}}: 4864 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 4865 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 4866 * 4867 * Supported tensor rank: from 1 4868 * 4869 * Inputs: 4870 * * 0: A tensor specifying the base. 4871 * * 1: A tensor specifying the exponent. 4872 * 4873 * Outputs: 4874 * * 0: An output tensor. 4875%insert AVAIL3 4876 */ 4877 %{DeclareOperation_1.2 POW 70}, 4878 4879 /** 4880 * Parametric Rectified Linear Unit. 4881 * 4882 * It follows: f(x) = alpha * x for x < 0, f(x) = x for x >= 0, where alpha 4883 * is a learned array with the same {@link %{OperandType}} and compatible 4884 * dimensions as input x. 4885 * 4886 * Two dimensions are compatible when: 4887 * 1. they are equal, or 4888 * 2. one of them is 1 4889 * 4890 * The size of the output is the maximum size along each dimension of the 4891 * input operands. It starts with the trailing dimensions, and works its way 4892 * forward. 4893 * 4894 * Example: 4895 * input.dimension = {4, 1, 2} 4896 * alpha.dimension = {5, 4, 3, 1} 4897 * output.dimension = {5, 4, 3, 2} 4898 * 4899 * Supported tensor {@link %{OperandType}}: 4900 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 4901 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 4902 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 4903%kind canonical ndk hal_1.3+ 4904 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 4905%/kind 4906 * 4907 * Supported tensor rank: from 1 4908 * 4909 * Inputs: 4910 * * 0: A tensor, specifying the input. 4911 * * 1: A tensor of the same {@link %{OperandType}}, and compatible dimensions 4912 * as input0, specifying the alpha. 4913 * 4914 * Outputs: 4915 * * 0: A tensor of the same {@link %{OperandType}} as input0. 4916%kind canonical ndk hal_1.3+ 4917 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 4918 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 4919 * the scales and zeroPoint can be different from input0 scale and zeroPoint. 4920%else 4921 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 4922 * the scales and zeroPoint can be different from input0 scale and zeroPoint. 4923%/kind 4924%insert AVAIL3 4925 */ 4926 %{DeclareOperation_1.2 PRELU 71}, 4927 4928 /** 4929 * Quantizes the input tensor. 4930 * 4931 * The formula for {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} output tensor is: 4932 * 4933 * output = max(0, min(255, round(input / scale) + zeroPoint) 4934 * 4935%kind canonical ndk hal_1.3+ 4936 * The formula for {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} output 4937 * tensor is: 4938 * 4939 * output = max(-128, min(127, round(input / scale) + zeroPoint) 4940 * 4941%/kind 4942 * Supported input tensor {@link %{OperandType}}: 4943 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 4944 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 4945 * 4946 * Supported output tensor {@link %{OperandType}}: 4947 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 4948%kind canonical ndk hal_1.3+ 4949 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 4950%/kind 4951 * 4952 * Supported tensor rank: from 1 4953 * 4954 * Inputs: 4955 * * 0: A tensor, may be zero-sized. 4956 * 4957 * Outputs: 4958 * * 0: The output tensor of same shape as input0, but with 4959%kind canonical ndk hal_1.3+ 4960 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} or. 4961 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED}. 4962%else 4963 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}. 4964%/kind 4965%insert AVAIL3 4966 */ 4967 %{DeclareOperation_1.2 QUANTIZE 72}, 4968 4969 /** 4970 * A version of quantized LSTM, using 16 bit quantization for internal 4971 * state. 4972 * 4973 * There is no projection layer, so cell state size is equal to the output 4974 * size. 4975 * 4976 * Inputs: 4977 * * 0: A 2-D tensor of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 4978 * and shape [numBatches, inputSize] specifying the input to the LSTM 4979 * cell. Tensor is quantized with a fixed quantization range of 4980 * [-1, 127/128] (scale = 1/128, zeroPoint = 128). 4981 * * 1: The input-to-input weights. 4982 * A 2-D tensor of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 4983 * and shape [outputSize, inputSize] specifying input-to-input part of 4984 * weights for fully-connected layer inside the LSTM cell. 4985 * Quantization zero point and scale must be the same across all the 4986 * weights. 4987 * * 2: The input-to-forget weights. 4988 * A 2-D tensor of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 4989 * and shape [outputSize, inputSize] specifying input-to-forget part of 4990 * weights for fully-connected layer inside the LSTM cell. 4991 * Quantization zero point and scale must be the same across all the 4992 * weights. 4993 * * 3: The input-to-cell weights. 4994 * A 2-D tensor of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 4995 * and shape [outputSize, inputSize] specifying input-to-cell part of 4996 * weights for fully-connected layer inside the LSTM cell. 4997 * Quantization zero point and scale must be the same across all the 4998 * weights. 4999 * * 4: The input-to-output weights. 5000 * A 2-D tensor of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 5001 * and shape [outputSize, inputSize] specifying input-to-output part of 5002 * weights for fully-connected layer inside the LSTM cell. 5003 * Quantization zero point and scale must be the same across all the 5004 * weights. 5005 * * 5: The recurrent-to-input weights. 5006 * A 2-D tensor of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 5007 * and shape [outputSize, outputSize] specifying recurrent-to-input part 5008 * of weights for fully-connected layer inside the LSTM cell. 5009 * Quantization zero point and scale must be the same across all the 5010 * weights. 5011 * * 6: The recurrent-to-forget weights. 5012 * A 2-D tensor of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 5013 * and shape [outputSize, outputSize] specifying recurrent-to-forget 5014 * part of weights for fully-connected layer inside the LSTM cell. 5015 * Quantization zero point and scale must be the same across all the 5016 * weights. 5017 * * 7: The recurrent-to-cell weights. 5018 * A 2-D tensor of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 5019 * and shape [outputSize, outputSize] specifying recurrent-to-cell part 5020 * of weights for fully-connected layer inside the LSTM cell. 5021 * Quantization zero point and scale must be the same across all the 5022 * weights. 5023 * * 8: The recurrent-to-output weights. 5024 * A 2-D tensor of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 5025 * and shape [outputSize, outputSize] specifying recurrent-to-output 5026 * part of weights for fully-connected layer inside the LSTM cell. 5027 * Quantization zero point and scale must be the same across all the 5028 * weights. 5029 * * 9: The input gate bias. 5030 * A 1-D tensor of type {@link %{OperandTypeLinkPfx}TENSOR_INT32} and shape 5031 * [outputSize] specifying the bias for the fully-connected layer 5032 * inside the LSTM cell. Bias is quantized with scale being a product 5033 * of input and weights scales and zeroPoint equal to 0. 5034 * * 10:The forget gate bias. 5035 * A 1-D tensor of type {@link %{OperandTypeLinkPfx}TENSOR_INT32} and shape 5036 * [outputSize] specifying the bias for the fully-connected layer 5037 * inside the LSTM cell. Bias is quantized with scale being a product 5038 * of input and weights scales and zeroPoint equal to 0. 5039 * * 11:The cell bias. 5040 * A 1-D tensor of type {@link %{OperandTypeLinkPfx}TENSOR_INT32} and shape 5041 * [outputSize] specifying the bias for the fully-connected layer 5042 * inside the LSTM cell. Bias is quantized with scale being a product 5043 * of input and weights scales and zeroPoint equal to 0. 5044 * * 12:The output gate bias. 5045 * A 1-D tensor of type {@link %{OperandTypeLinkPfx}TENSOR_INT32} and shape 5046 * [outputSize] specifying the bias for the fully-connected layer 5047 * inside the LSTM cell. Bias is quantized with scale being a product 5048 * of input and weights scales and zeroPoint equal to 0. 5049 * * 13: A 2-D tensor of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_SYMM} 5050 * and shape [numBatches, outputSize] specifying the cell state from the 5051 * previous time step of the LSTM cell. It is quantized using a 5052 * quantization range of [-2^4, 2^4 * 32767/32768] (scale = 2^4 / 5053 * 32768, zeroPoint = 0). 5054 * * 14: A 2-D tensor of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 5055 * and shape [numBathes, outputSize] specifying the output of the LSTM 5056 * cell from previous time-step. Tensor is quantized with a fixed 5057 * quantization range of [-1, 127/128] (scale = 1/128, zeroPoint = 5058 * 128). 5059 * 5060 * 5061 * Outputs: 5062 * * 0: A 2-D tensor of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_SYMM} 5063 * and shape [numBatches, outputSize] which contains a cell state from 5064 * the current time step. Tensor is quantized using a quantization 5065 * range of [-2^4, 2^4 * 32767/32768] (scale = 2^4 / 32768, zeroPoint = 5066 * 0). 5067 * * 1: A 2-D tensor of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 5068 * and shape [numBathes, outputSize] which contains the output value. 5069 * Tensor is quantized with a fixed quantization range of [-1, 127/128] 5070 * (scale = 1/128, zeroPoint = 128). 5071 */ 5072 %{DeclareOperation_1.2 QUANTIZED_16BIT_LSTM 73}, 5073 5074 /** 5075 * Draws samples from a multinomial distribution. 5076 * 5077 * Supported tensor {@link %{OperandType}}: 5078 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 5079 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 5080 * 5081 * Inputs: 5082 * * 0: A 2-D tensor with shape [batches, classes], specifying the 5083 * unnormalized log-probabilities for all classes. 5084 * * 1: A scalar {@link %{OperandTypeLinkPfx}INT32}, specifying the number of 5085 * independent samples to draw for each row slice. 5086 * * 2: A 1-D {@link %{OperandTypeLinkPfx}TENSOR_INT32} tensor with shape [2], 5087 * specifying seeds used to initialize the random distribution. If both 5088 * provided seeds are 0, both will be randomly generated. 5089 * Outputs: 5090 * * 0: A 2-D {@link %{OperandTypeLinkPfx}TENSOR_INT32} tensor with shape 5091 * [batches, samples], containing the drawn samples. 5092%insert AVAIL3 5093 */ 5094 %{DeclareOperation_1.2 RANDOM_MULTINOMIAL 74}, 5095 5096 /** 5097 * Reduces a tensor by computing the "logical and" of elements along given 5098 * dimensions. 5099 * 5100 * If keep_dims is true, the reduced dimensions are 5101 * retained with length 1. Otherwise, the rank of the tensor is reduced by 5102 * 1 for each entry in dimensions. 5103 * 5104 * Supported tensor {@link %{OperandType}}: 5105 * * {@link %{OperandTypeLinkPfx}TENSOR_BOOL8} 5106 * 5107 * Supported tensor rank: up to 4 5108 * 5109 * Inputs: 5110 * * 0: An n-D tensor. 5111 * * 1: A 1-D tensor of {@link %{OperandTypeLinkPfx}TENSOR_INT32}. The dimensions 5112 * to reduce. Dimension values must be in the range [-n, n). 5113 * * 2: An {@link %{OperandTypeLinkPfx}BOOL} scalar, keep_dims. If true, 5114 * retains reduced dimensions with length 1. 5115 * 5116 * Outputs: 5117 * * 0: A tensor of the same {@link %{OperandType}} as input0. 5118 * If all dimensions are reduced and keep_dims is false, the output 5119 * shape is [1]. 5120%insert AVAIL3 5121 */ 5122 %{DeclareOperation_1.2 REDUCE_ALL 75}, 5123 5124 /** 5125 * Reduces a tensor by computing the "logical or" of elements along given 5126 * dimensions. 5127 * 5128 * If keep_dims is true, the reduced dimensions are 5129 * retained with length 1. Otherwise, the rank of the tensor is reduced by 5130 * 1 for each entry in dimensions. 5131 * 5132 * Supported tensor {@link %{OperandType}}: 5133 * * {@link %{OperandTypeLinkPfx}TENSOR_BOOL8} 5134 * 5135 * Supported tensor rank: up to 4 5136 * 5137 * Inputs: 5138 * * 0: An n-D tensor. 5139 * * 1: A 1-D tensor of {@link %{OperandTypeLinkPfx}TENSOR_INT32}. The dimensions 5140 * to reduce. Dimension values must be in the range [-n, n). 5141 * * 2: An {@link %{OperandTypeLinkPfx}BOOL} scalar, keep_dims. If true, 5142 * retains reduced dimensions with length 1. 5143 * 5144 * Outputs: 5145 * * 0: A tensor of the same {@link %{OperandType}} as input0. 5146 * If all dimensions are reduced and keep_dims is false, the output 5147 * shape is [1]. 5148%insert AVAIL3 5149 */ 5150 %{DeclareOperation_1.2 REDUCE_ANY 76}, 5151 5152 /** 5153 * Reduces a tensor by computing the maximum of elements along given 5154 * dimensions. 5155 * 5156 * If keep_dims is true, the reduced dimensions are 5157 * retained with length 1. Otherwise, the rank of the tensor is reduced by 5158 * 1 for each entry in dimensions. 5159 * 5160 * Supported tensor {@link %{OperandType}}: 5161 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 5162 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 5163 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 5164%kind canonical ndk hal_1.3+ 5165 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 5166%/kind 5167 * 5168 * Supported tensor rank: up to 4 5169 * 5170 * Inputs: 5171 * * 0: An n-D tensor. 5172 * * 1: A 1-D tensor of {@link %{OperandTypeLinkPfx}TENSOR_INT32}. The dimensions 5173 * to reduce. Dimension values must be in the range [-n, n). 5174 * * 2: An {@link %{OperandTypeLinkPfx}BOOL} scalar, keep_dims. If true, 5175 * retains reduced dimensions with length 1. 5176 * 5177 * Outputs: 5178 * * 0: A tensor of the same {@link %{OperandType}} as input0. 5179 * If all dimensions are reduced and keep_dims is false, the output 5180 * shape is [1]. 5181%kind canonical ndk hal_1.3+ 5182 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 5183 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 5184 * the scale and zeroPoint must be the same as input0. 5185%else 5186 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 5187 * the scale and zeroPoint must be the same as input0. 5188%/kind 5189%insert AVAIL3 5190 */ 5191 %{DeclareOperation_1.2 REDUCE_MAX 77}, 5192 5193 /** 5194 * Reduces a tensor by computing the minimum of elements along given 5195 * dimensions. 5196 * 5197 * If keep_dims is true, the reduced dimensions are 5198 * retained with length 1. Otherwise, the rank of the tensor is reduced by 5199 * 1 for each entry in dimensions. 5200 * 5201 * Supported tensor {@link %{OperandType}}: 5202 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 5203 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 5204 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 5205%kind canonical ndk hal_1.3+ 5206 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 5207%/kind 5208 * 5209 * Supported tensor rank: up to 4 5210 * 5211 * Inputs: 5212 * * 0: An n-D tensor. 5213 * * 1: A 1-D tensor of {@link %{OperandTypeLinkPfx}TENSOR_INT32}. The dimensions 5214 * to reduce. Dimension values must be in the range [-n, n). 5215 * * 2: An {@link %{OperandTypeLinkPfx}BOOL} scalar, keep_dims. If true, 5216 * retains reduced dimensions with length 1. 5217 * 5218 * Outputs: 5219 * * 0: A tensor of the same {@link %{OperandType}} as input0. 5220 * If all dimensions are reduced and keep_dims is false, the output 5221 * shape is [1]. 5222%kind canonical ndk hal_1.3+ 5223 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 5224 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 5225 * the scale and zeroPoint must be the same as input0. 5226%else 5227 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 5228 * the scale and zeroPoint must be the same as input0. 5229%/kind 5230%insert AVAIL3 5231 */ 5232 %{DeclareOperation_1.2 REDUCE_MIN 78}, 5233 5234 /** 5235 * Reduces a tensor by multiplying elements along given dimensions. 5236 * 5237 * If keep_dims is true, the reduced dimensions are 5238 * retained with length 1. Otherwise, the rank of the tensor is reduced by 5239 * 1 for each entry in dimensions. 5240 * 5241 * Supported tensor {@link %{OperandType}}: 5242 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 5243 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 5244 * 5245 * Supported tensor rank: up to 4 5246 * 5247 * Inputs: 5248 * * 0: An n-D tensor. 5249 * * 1: A 1-D tensor of {@link %{OperandTypeLinkPfx}TENSOR_INT32}. The dimensions 5250 * to reduce. Dimension values must be in the range [-n, n). 5251 * * 2: An {@link %{OperandTypeLinkPfx}BOOL} scalar, keep_dims. If true, 5252 * retains reduced dimensions with length 1. 5253 * 5254 * Outputs: 5255 * * 0: A tensor of the same {@link %{OperandType}} as input0. 5256 * If all dimensions are reduced and keep_dims is false, the output 5257 * shape is [1]. 5258%insert AVAIL3 5259 */ 5260 %{DeclareOperation_1.2 REDUCE_PROD 79}, 5261 5262 /** 5263 * Reduces a tensor by summing elements along given dimensions. 5264 * 5265 * If keep_dims is true, the reduced dimensions are 5266 * retained with length 1. Otherwise, the rank of the tensor is reduced by 5267 * 1 for each entry in dimensions. 5268 * 5269 * Supported tensor {@link %{OperandType}}: 5270 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 5271 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 5272 * 5273 * Supported tensor rank: up to 4 5274 * 5275 * Inputs: 5276 * * 0: An n-D tensor. 5277 * * 1: A 1-D tensor of {@link %{OperandTypeLinkPfx}TENSOR_INT32}. The dimensions 5278 * to reduce. Dimension values must be in the range [-n, n). 5279 * * 2: An {@link %{OperandTypeLinkPfx}BOOL} scalar, keep_dims. If true, 5280 * retains reduced dimensions with length 1. 5281 * 5282 * Outputs: 5283 * * 0: A tensor of the same {@link %{OperandType}} as input0. 5284 * If all dimensions are reduced and keep_dims is false, the output 5285 * shape is [1]. 5286%insert AVAIL3 5287 */ 5288 %{DeclareOperation_1.2 REDUCE_SUM 80}, 5289 5290 /** 5291 * Select and scale the feature map of each region of interest to a unified 5292 * output size by average pooling sampling points from bilinear interpolation. 5293 * 5294 * The region of interest is represented by its upper-left corner coordinate 5295 * (x1,y1) and lower-right corner coordinate (x2,y2) in the original image. 5296 * A spatial scaling factor is applied to map into feature map coordinate. 5297 * A valid region of interest should satisfy x1 <= x2 and y1 <= y2. 5298 * 5299 * No rounding is applied in this operation. The sampling points are unified 5300 * distributed in the pooling bin and their values are calculated by bilinear 5301 * interpolation. 5302 * 5303 * Supported tensor {@link %{OperandType}}: 5304 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 5305 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 5306 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 5307%kind canonical ndk hal_1.3+ 5308 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 5309%/kind 5310 * 5311 * Supported tensor rank: 4, with "NHWC" or "NCHW" data layout. 5312 * With the default data layout NHWC, the data is stored in the order of: 5313 * [batch, height, width, channels]. Alternatively, the data layout could 5314 * be NCHW, the data storage order of: [batch, channels, height, width]. 5315 * 5316 * Inputs: 5317 * * 0: A 4-D tensor, specifying the feature map. 5318 * * 1: A 2-D Tensor of shape [num_rois, 4], specifying the locations of 5319 * the regions of interest, each line with format [x1, y1, x2, y2]. 5320 * For input0 of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, 5321 * this tensor should be of {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_ASYMM}, 5322 * with zeroPoint of 0 and scale of 0.125. Zero num_rois is 5323 * supported for this tensor. 5324 * * 2: An 1-D {@link %{OperandTypeLinkPfx}TENSOR_INT32} tensor, of shape 5325 * [num_rois], specifying the batch index of each box. Boxes with 5326 * the same batch index are grouped together. Zero num_rois is 5327 * supported for this tensor. 5328 * * 3: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the output 5329 * height of the output tensor. 5330 * * 4: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the output 5331 * width of the output tensor. 5332 * * 5: An {@link %{OperandTypeLinkPfx}FLOAT32} scalar, specifying the ratio 5333 * from the height of original image to the height of feature map. 5334 * * 6: An {@link %{OperandTypeLinkPfx}FLOAT32} scalar, specifying the ratio 5335 * from the width of original image to the width of feature map. 5336 * * 7: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the number of 5337 * sampling points in height dimension used to compute the output. 5338 * Set to 0 for adaptive value of ceil(roi_height/out_height). 5339 * * 8: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the number of 5340 * sampling points in width dimension used to compute the output. 5341 * Set to 0 for adaptive value of ceil(roi_width/out_width). 5342 * * 9: An {@link %{OperandTypeLinkPfx}BOOL} scalar, set to true to specify 5343 * NCHW data layout for input0 and output0. Set to false for NHWC. 5344 * 5345 * Outputs: 5346 * * 0: A tensor of the same {@link %{OperandType}} as input0. The output 5347 * shape is [num_rois, out_height, out_width, depth]. 5348%kind canonical ndk hal_1.3+ 5349 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 5350 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 5351%else 5352 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 5353%/kind 5354 * the scale and zeroPoint can be different from the input0 scale and zeroPoint. 5355%insert AVAIL3 5356 */ 5357 %{DeclareOperation_1.2 ROI_ALIGN 81}, 5358 5359 /** 5360 * Select and scale the feature map of each region of interest to a unified 5361 * output size by max-pooling. 5362 * 5363 * The region of interest is represented by its upper-left corner coordinate 5364 * (x1,y1) and lower-right corner coordinate (x2,y2) in the original image. 5365 * A spatial scaling factor is applied to map into feature map coordinate. 5366 * A valid region of interest should satisfy x1 <= x2 and y1 <= y2. 5367 * 5368 * Rounding is applied in this operation to ensure integer boundary for 5369 * regions of interest and pooling bins. 5370 * 5371 * Supported tensor {@link %{OperandType}}: 5372 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 5373 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 5374 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 5375%kind canonical ndk hal_1.3+ 5376 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 5377%/kind 5378 * 5379 * Supported tensor rank: 4, with "NHWC" or "NCHW" data layout. 5380 * With the default data layout NHWC, the data is stored in the order of: 5381 * [batch, height, width, channels]. Alternatively, the data layout could 5382 * be NCHW, the data storage order of: [batch, channels, height, width]. 5383 * 5384 * Inputs: 5385 * * 0: A 4-D tensor, specifying the feature map. 5386 * * 1: A 2-D Tensor of shape [num_rois, 4], specifying the locations of 5387 * the regions of interest, each line with format [x1, y1, x2, y2]. 5388%kind canonical ndk hal_1.3+ 5389 * For input0 of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 5390 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 5391%else 5392 * For input0 of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, 5393%/kind 5394 * this tensor should be of {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_ASYMM}, 5395 * with zeroPoint of 0 and scale of 0.125. 5396 * * 2: An 1-D {@link %{OperandTypeLinkPfx}TENSOR_INT32} tensor, of shape 5397 * [num_rois], specifying the batch index of each box. Boxes with 5398 * the same batch index are grouped together. 5399 * * 3: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the output 5400 * height of the output tensor. 5401 * * 4: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the output 5402 * width of the output tensor. 5403 * * 5: An {@link %{OperandTypeLinkPfx}FLOAT32} scalar, specifying the ratio 5404 * from the height of original image to the height of feature map. 5405 * * 6: An {@link %{OperandTypeLinkPfx}FLOAT32} scalar, specifying the ratio 5406 * from the width of original image to the width of feature map. 5407 * * 7: An {@link %{OperandTypeLinkPfx}BOOL} scalar, set to true to specify 5408 * NCHW data layout for input0 and output0. Set to false for NHWC. 5409 * 5410 * Outputs: 5411 * * 0: A tensor of the same {@link %{OperandType}} as input0. The output 5412 * shape is [num_rois, out_height, out_width, depth]. 5413%kind canonical ndk hal_1.3+ 5414 * For input0 of type {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 5415 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 5416%else 5417 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 5418%/kind 5419 * the scale and zeroPoint must be the same as input0. 5420%insert AVAIL3 5421 */ 5422 %{DeclareOperation_1.2 ROI_POOLING 82}, 5423 5424 /** 5425 * Computes reciprocal of square root of x element-wise. 5426 * 5427 * Supported tensor {@link %{OperandType}}: 5428 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 5429 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 5430 * 5431 * Supported tensor rank: from 1. 5432 * 5433 * Inputs: 5434 * * 0: A tensor. 5435 * 5436 * Outputs: 5437 * * 0: The output tensor of same shape as input0. 5438%insert AVAIL3 5439 */ 5440 %{DeclareOperation_1.2 RSQRT 83}, 5441 5442 /** 5443 * Using a tensor of booleans c and input tensors x and y select values 5444 * elementwise from both input tensors: 5445 * 5446 * O[i] = C[i] ? x[i] : y[i]. 5447 * 5448 * Supported tensor {@link %{OperandType}}: 5449 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 5450 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 5451 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 5452 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 5453%kind canonical ndk hal_1.3 5454 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 5455%/kind 5456 * 5457 * Supported tensor rank: from 1 5458 * 5459 * Inputs: 5460 * * 0: A tensor of type {@link %{OperandTypeLinkPfx}TENSOR_BOOL8} acting as a 5461 * mask that chooses, based on the value at each element, whether the 5462 * corresponding element in the output should be taken from input1 (if 5463 * true) or input2 (if false). 5464 * * 1: An input tensor of the same shape as input0. 5465%kind hal_1.2 5466 * * 2: An input tensor of the same shape and type as input1. 5467 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 5468 * the scales and zeroPoint can be different from input1 scale and zeroPoint. 5469%else 5470 * * 2: An input tensor of the same shape and type as input1. 5471 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 5472 * and {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 5473 * the scales and zeroPoint can be different from input1 scale and zeroPoint. 5474%/kind 5475 * 5476 * Outputs: 5477 * * 0: A tensor of the same type and shape as input1 and input2. 5478 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 5479 * the scale and zeroPoint can be different from inputs' scale and zeroPoint. 5480%insert AVAIL3 5481 */ 5482 %{DeclareOperation_1.2 SELECT 84}, 5483 5484 /** 5485 * Computes sin of x element-wise. 5486 * 5487 * Supported tensor {@link %{OperandType}}: 5488 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 5489 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 5490 * 5491 * Supported tensor rank: from 1. 5492 * 5493 * Inputs: 5494 * * 0: A tensor. 5495 * 5496 * Outputs: 5497 * * 0: The output tensor of same shape as input0. 5498%insert AVAIL3 5499 */ 5500 %{DeclareOperation_1.2 SIN 85}, 5501 5502 /** 5503 * Extracts a slice of specified size from the input tensor starting at a 5504 * specified location. 5505 * 5506 * The starting location is specified as a 1-D tensor containing offsets 5507 * for each dimension. The size is specified as a 1-D tensor containing 5508 * either size of a slice along corresponding dimension or -1. In the latter 5509 * case, all the remaining elements in dimension are included in the slice. 5510 * 5511 * A sum of begin offset and a size of a slice must not exceed size of a 5512 * corresponding dimension. 5513 * 5514 * Supported tensor {@link %{OperandType}}: 5515 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 5516 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 5517 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 5518 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 5519%kind canonical ndk hal_1.3+ 5520 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 5521%/kind 5522 * 5523 * Supported tensor rank: from 1 5524 * 5525 * Inputs: 5526 * * 0: An n-D tensor to take slice from, may be zero-sized. 5527 * * 1: A 1-D tensor of type {@link %{OperandTypeLinkPfx}TENSOR_INT32} specifying 5528 * the beginning indices of the slice in each dimension. 5529 * * 2: A 1-D tensor of type {@link %{OperandTypeLinkPfx}TENSOR_INT32} specifying 5530 * the size of the slice in each dimension. 5531 * 5532 * Outputs: 5533 * * 0: An n-D tensor of the same type as the input containing the slice. 5534%kind canonical ndk hal_1.3+ 5535 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 5536 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 5537%else 5538 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 5539%/kind 5540 * its scale and zeroPoint has to be same as the input0 scale and zeroPoint. 5541%insert AVAIL3 5542 */ 5543 %{DeclareOperation_1.2 SLICE 86}, 5544 5545 /** 5546 * Splits a tensor along a given axis into num_splits subtensors. 5547 * 5548 * Supported tensor {@link %{OperandType}}: 5549 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 5550 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 5551 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 5552 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 5553%kind canonical ndk hal_1.3+ 5554 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 5555%/kind 5556 * 5557 * Supported tensor rank: from 1 5558 * 5559 * Inputs: 5560 * * 0: An n-D tensor to split. 5561 * * 1: An {@link %{OperandTypeLinkPfx}INT32} scalar specifying the axis along 5562 * which to split. 5563 * * 2: An {@link %{OperandTypeLinkPfx}INT32} scalar indicating the number of 5564 * splits along given axis. Must evenly divide axis size. 5565 * 5566 * Outputs: 5567 * * 0 ~ (num_splits - 1): Resulting subtensors. 5568%kind canonical ndk hal_1.3+ 5569 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 5570 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 5571 * the scale and zeroPoint must be the same as input0. 5572%else 5573 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 5574 * the scale and zeroPoint must be the same as input0. 5575%/kind 5576%insert AVAIL3 5577 */ 5578 %{DeclareOperation_1.2 SPLIT 87}, 5579 5580 /** 5581 * Computes square root of x element-wise. 5582 * 5583 * Supported tensor {@link %{OperandType}}: 5584 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 5585 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 5586 * 5587 * Supported tensor rank: from 1. 5588 * 5589 * Inputs: 5590 * * 0: A tensor. 5591 * 5592 * Outputs: 5593 * * 0: The output tensor of same shape as input0. 5594%insert AVAIL3 5595 */ 5596 %{DeclareOperation_1.2 SQRT 88}, 5597 5598 /** 5599 * Constructs a tensor by tiling a given tensor. 5600 * 5601 * This operation creates a new tensor by replicating `input` `multiples` 5602 * times. The output tensor's i-th dimension has `input.dims(i) * multiples[i]` 5603 * elements, and the values of `input` are replicated `multiples[i]` times 5604 * along the i-th dimension. 5605 * For example, tiling `[a b c d]` by `[2]` produces `[a b c d a b c d]`. 5606 * 5607 * Supported tensor {@link %{OperandType}}: 5608 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 5609 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 5610 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 5611 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 5612%kind canonical ndk hal_1.3+ 5613 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 5614%/kind 5615 * 5616 * Supported tensor rank: from 1 5617 * 5618 * Inputs: 5619 * * 0: input, an n-D tensor specifying the input. 5620 * * 1: multiples, a 1-D tensor of {@link %{OperandTypeLinkPfx}TENSOR_INT32}. 5621 * The length of multiples must be n. 5622 * 5623 * Outputs: 5624 * * 0: A tiled tensor of the same {@link %{OperandType}} and rank as `input`. 5625%kind canonical ndk hal_1.3+ 5626 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 5627 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 5628 * the scale and zeroPoint must be the same as input0. 5629%else 5630 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 5631 * the scale and zeroPoint must be the same as input0. 5632%/kind 5633%insert AVAIL3 5634 */ 5635 %{DeclareOperation_1.2 TILE 89}, 5636 5637 /** 5638 * Finds values and indices of the k largest entries for the last dimension. 5639 * 5640 * Resulting values in each dimensions are sorted in descending order. If 5641 * two values are equal, the one with larger index appears first. 5642 * 5643 * Supported tensor {@link %{OperandType}}: 5644 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 5645 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 5646 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 5647 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 5648%kind canonical ndk hal_1.3+ 5649 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 5650%/kind 5651 * 5652 * Supported tensor rank: from 1 5653 * 5654 * Inputs: 5655 * * 0: input, an n-D tensor specifying the input. 5656 * * 1: k, an {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the number of 5657 * top elements to look for along the last dimension. 5658 * 5659 * Outputs: 5660 * * 0: An n-D tensor of the same type as the input, containing the k 5661 * largest elements along each last dimensional slice. 5662%kind canonical ndk hal_1.3+ 5663 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 5664 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 5665 * the scale and zeroPoint must be the same as input0. 5666%else 5667 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 5668 * the scale and zeroPoint must be the same as input0. 5669%/kind 5670 * * 1: An n-D tensor of type {@link %{OperandTypeLinkPfx}TENSOR_INT32} 5671 * containing the indices of values within the last dimension of input. 5672%insert AVAIL3 5673 */ 5674 %{DeclareOperation_1.2 TOPK_V2 90}, 5675 5676 /** 5677 * Performs the transpose of 2-D convolution operation. 5678 * 5679 * This operation is sometimes called "deconvolution" after Deconvolutional 5680 * Networks, but is actually the transpose (gradient) of 5681 * {@link %{OperandTypeLinkPfx}CONV_2D} rather than an actual deconvolution. 5682 * 5683 * The output dimensions are functions of the filter dimensions, stride, and 5684 * padding. 5685 * 5686 * Supported tensor {@link %{OperandType}} configurations: 5687 * * 16 bit floating point: 5688 * * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} for input, filter, output, and bias. 5689 * 5690 * * 32 bit floating point: 5691 * * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} for input, filter, output, and bias. 5692 * 5693 * * Quantized: 5694 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} for input, filter, and output. 5695 * * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} for bias (with scale set to 5696 * * * input.scale * filter.scale). 5697 * 5698 * * Quantized with symmetric per channel quantization for the filter: 5699 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} for input, and output. 5700 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL} for filter. 5701 * * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} for bias (scale set to 0.0, 5702 * * * each value scaling is separate and equal to input.scale * filter.scales[channel]). 5703%kind canonical ndk hal_1.3+ 5704 * 5705 * Available since %{NNAPILevel4}: 5706 * * Quantized signed (since %{NNAPILevel4}): 5707 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} for input, filter, and output. 5708 * * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} for bias (with scale set to 5709 * * * input.scale * filter.scale). 5710 * 5711 * * Quantized signed with filter symmetric per channel quantization 5712 * (since %{NNAPILevel4}): 5713 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} for input, and output. 5714 * * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL} for filter. 5715 * * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} for bias (scale set to 0.0, 5716 * * * each value scaling is separate and equal to input.scale * filter.scales[channel]). 5717%/kind 5718 * 5719 * Supported tensor rank: 4, with "NHWC" or "NCHW" data layout. 5720 * With the default data layout NHWC, the data is stored in the order of: 5721 * [batch, height, width, channels]. Alternatively, the data layout could 5722 * be NCHW, the data storage order of: [batch, channels, height, width]. 5723 * 5724 * Both explicit padding and implicit padding are supported. 5725 * 5726 * Inputs (explicit padding): 5727 * * 0: A 4-D tensor, of shape [batches, height, width, depth_in], 5728 * specifying the input. 5729%kind ndk 5730 * Since API level 29, zero batches is supported for this tensor. 5731%/kind 5732 * * 1: A 4-D tensor, of shape 5733 * [depth_out, filter_height, filter_width, depth_in], specifying the 5734 * filter. For tensor of type 5735 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL} the channel 5736 * dimension (%{Ann}SymmPerChannelQuantParams::channelDim) must be set to 0. 5737 * * 2: A 1-D tensor, of shape [depth_out], specifying the bias. For input 5738 * tensor of type {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} or 5739 * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16}, the bias must be of the 5740 * same type. 5741%kind canonical ndk hal_1.3+ 5742 * For filter tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 5743 * and {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED}, 5744%else 5745 * For filter tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, 5746%/kind 5747 * the bias should be of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, 5748 * with zeroPoint of 0 and bias_scale == input_scale * filter_scale. 5749 * For filter tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL}, 5750 * the bias must be of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, with zeroPoint of 0 5751 * and bias_scale of 0. The actual scale of each value 'i' is equal to 5752 * bias_scale[i] = input_scale * filter_scale[i]. 5753 * * 3: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 5754 * the left, in the ‘width’ dimension. 5755 * * 4: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 5756 * the right, in the ‘width’ dimension. 5757 * * 5: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 5758 * the top, in the ‘height’ dimension. 5759 * * 6: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the padding on 5760 * the bottom, in the ‘height’ dimension. 5761 * * 7: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 5762 * walking through input in the ‘width’ dimension. 5763 * * 8: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 5764 * walking through input in the ‘height’ dimension. 5765 * * 9: An {@link %{OperandTypeLinkPfx}INT32} scalar, and has to be one of the 5766 * {@link %{FusedActivationFunc}} values. Specifies the activation to 5767 * invoke on the result. 5768 * * 10: An {@link %{OperandTypeLinkPfx}BOOL} scalar, set to true to specify 5769 * NCHW data layout for input0 and output0. Set to false for NHWC. 5770 * 5771 * Inputs (implicit padding): 5772 * * 0: A 4-D tensor, of shape [batches, height, width, depth_in], 5773 * specifying the input. 5774%kind ndk 5775 * Since API level 29, zero batches is supported for this tensor. 5776%/kind 5777 * * 1: A 4-D tensor, of shape 5778 * [depth_out, filter_height, filter_width, depth_in], specifying the 5779 * filter. For tensor of type 5780 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL} the channel 5781 * dimension (%{Ann}SymmPerChannelQuantParams::channelDim) must be set to 0. 5782 * * 2: A 1-D tensor, of shape [depth_out], specifying the bias. For input 5783 * tensor of type {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} or 5784 * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16}, the bias should be of the 5785 * same type. 5786%kind canonical ndk hal_1.3+ 5787 * For filter tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 5788 * and {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED}, 5789%else 5790 * For filter tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM}, 5791%/kind 5792 * the bias should be of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, 5793 * with zeroPoint of 0 and bias_scale == input_scale * filter_scale. 5794 * For filter tensor of {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL}, 5795 * the bias must be of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, with zeroPoint of 0 5796 * and bias_scale of 0. The actual scale of each value 'i' is equal to 5797 * bias_scale[i] = input_scale * filter_scale[i]. 5798 * * 3: An {@link %{OperandTypeLinkPfx}TENSOR_INT32} tensor, specifying the output 5799 * tensor shape. 5800 * * 4: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the implicit 5801 * padding scheme, has to be one of the 5802%insert PaddingCodeValues 5803 * * 5: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 5804 * walking through input in the ‘width’ dimension. 5805 * * 6: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the stride when 5806 * walking through input in the ‘height’ dimension. 5807 * * 7: An {@link %{OperandTypeLinkPfx}INT32} scalar, and has to be one of the 5808 * {@link %{FusedActivationFunc}} values. Specifies the activation to 5809 * invoke on the result. 5810 * * 8: An {@link %{OperandTypeLinkPfx}BOOL} scalar, set to true to specify 5811 * NCHW data layout for input0 and output0. Set to false for NHWC. 5812 * 5813 * Outputs: 5814 * * 0: The output 4-D tensor, of shape 5815 * [batches, out_height, out_width, depth_out]. 5816%kind canonical ndk hal_1.3+ 5817 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 5818 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 5819%else 5820 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 5821%/kind 5822 * the scale and zeroPoint can be different from inputs' scale and zeroPoint. 5823%insert AVAIL3 5824 */ 5825 %{DeclareOperation_1.2 TRANSPOSE_CONV_2D 91}, 5826 5827 /** 5828 * A recurrent neural network specified by an LSTM cell. 5829 * 5830 * Performs (fully) dynamic unrolling of input. 5831 * 5832 * This Op unrolls the input along the time dimension, and implements the 5833 * following operation for each element in the sequence 5834 * s = 1...sequence_length: 5835 * outputs[s] = projection(state = activation(LSTMOp(inputs[s]))) 5836 * 5837 * Where LSTMOp is the LSTM op as in {@link %{OperandTypeLinkPfx}LSTM}, 5838 * the "projection" is an optional projection layer from state and output 5839 * and the “activation” is the function passed as the 5840 * “fused_activation_function” argument (if not “NONE”). 5841 * 5842 * Supported tensor {@link %{OperandType}}: 5843 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 5844 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 5845 * 5846 * Supported tensor rank: 3, either time-major or batch-major. 5847 * 5848 * All input and output tensors must be of the same type. 5849 * 5850 * Inputs: 5851 * * 0: The input (\f$x_t\f$). 5852 * A 3-D tensor of shape: 5853 * If time-major: [max_time, batch_size, input_size] 5854 * If batch-major: [batch_size, max_time, input_size] 5855 * where “max_time” is the number of timesteps (sequence length), 5856 * “batch_size” corresponds to the batching dimension, and 5857 * “input_size” is the size of the input. 5858 * * 1: The input-to-input weights (\f$W_{xi}\f$). Optional. 5859 * A 2-D tensor of shape [num_units, input_size], where “num_units” 5860 * corresponds to the number of cell units. 5861 * * 2: The input-to-forget weights (\f$W_{xf}\f$). 5862 * A 2-D tensor of shape [num_units, input_size]. 5863 * * 3: The input-to-cell weights (\f$W_{xc}\f$). 5864 * A 2-D tensor of shape [num_units, input_size]. 5865 * * 4: The input-to-output weights (\f$W_{xo}\f$). 5866 * A 2-D tensor of shape [num_units, input_size]. 5867 * * 5: The recurrent-to-input weights (\f$W_{hi}\f$). Optional. 5868 * A 2-D tensor of shape [num_units, output_size], where “output_size” 5869 * corresponds to either the number of cell units (i.e., “num_units”), 5870 * or the second dimension of the “projection_weights”, if defined. 5871 * * 6: The recurrent-to-forget weights (\f$W_{hf}\f$). 5872 * A 2-D tensor of shape [num_units, output_size]. 5873 * * 7: The recurrent-to-cell weights (\f$W_{hc}\f$). 5874 * A 2-D tensor of shape [num_units, output_size]. 5875 * * 8: The recurrent-to-output weights (\f$W_{ho}\f$). 5876 * A 2-D tensor of shape [num_units, output_size]. 5877 * * 9: The cell-to-input weights (\f$W_{ci}\f$). Optional. 5878 * A 1-D tensor of shape [num_units]. 5879 * * 10:The cell-to-forget weights (\f$W_{cf}\f$). Optional. 5880 * A 1-D tensor of shape [num_units]. 5881 * * 11:The cell-to-output weights (\f$W_{co}\f$). Optional. 5882 * A 1-D tensor of shape [num_units]. 5883 * * 12:The input gate bias (\f$b_i\f$). Optional. 5884 * A 1-D tensor of shape [num_units]. 5885 * * 13:The forget gate bias (\f$b_f\f$). 5886 * A 1-D tensor of shape [num_units]. 5887 * * 14:The cell bias (\f$b_c\f$). 5888 * A 1-D tensor of shape [num_units]. 5889 * * 15:The output gate bias (\f$b_o\f$). 5890 * A 1-D tensor of shape [num_units]. 5891 * * 16:The projection weights (\f$W_{proj}\f$). Optional. 5892 * A 2-D tensor of shape [output_size, num_units]. 5893 * * 17:The projection bias (\f$b_{proj}\f$). Optional. 5894 * A 1-D tensor of shape [output_size]. 5895 * * 18:The output state (in) (\f$h_{t-1}\f$). 5896 * A 2-D tensor of shape [batch_size, output_size]. 5897 * * 19:The cell state (in) (\f$C_{t-1}\f$). 5898 * A 2-D tensor of shape [batch_size, num_units]. 5899 * * 20:The activation function (\f$g\f$). 5900 * A value indicating the activation function: 5901 * <ul> 5902 * <li>0: None; 5903 * <li>1: Relu; 5904 * <li>3: Relu6; 5905 * <li>4: Tanh; 5906 * <li>6: Sigmoid. 5907 * </ul> 5908 * * 21:The clipping threshold (\f$t_{cell}\f$) for the cell state, such 5909 * that values are bound within [-cell_clip, cell_clip]. If set to 0.0 5910 * then clipping is disabled. 5911 * * 22:The clipping threshold (\f$t_{proj}\f$) for the output from the 5912 * projection layer, such that values are bound within 5913 * [-proj_clip, proj_clip]. If set to 0.0 then clipping is disabled. 5914 * * 23:Time-major if true, batch-major if false. 5915 * * 24:The input layer normalization weights. Optional. 5916 * A 1-D tensor of shape [num_units]. Used to rescale normalized inputs 5917 * to activation at input gate. 5918 * * 25:The forget layer normalization weights. Optional. 5919 * A 1-D tensor of shape [num_units]. Used to rescale normalized inputs 5920 * to activation at forget gate. 5921 * * 26:The cell layer normalization weights. Optional. 5922 * A 1-D tensor of shape [num_units]. Used to rescale normalized inputs 5923 * to activation at cell gate. 5924 * * 27:The output layer normalization weights. Optional. 5925 * A 1-D tensor of shape [num_units]. Used to rescale normalized inputs 5926 * to activation at output gate. 5927 * 5928 * Outputs: 5929 * * 0: The output (\f$o_t\f$). 5930 * A 3-D tensor of shape: 5931 * If time-major: [max_time, batch_size, output_size] 5932 * If batch-major: [batch_size, max_time, output_size] 5933%kind canonical ndk hal_1.3+ 5934 * * 1: A tensor of shape [batch_size, output_size] containing a hidden 5935 * state from the last time step in the sequence. This output is 5936 * optional and can be omitted. If this output is present then 5937 * output #2 must be present as well. 5938 * Available since %{NNAPILevel4}. 5939 * * 2: A tensor of shape [batch_size, cell_size] containing a cell state 5940 * from the last time step in the sequence. This output is optional 5941 * and can be omitted. 5942 * Available since %{NNAPILevel4}. 5943%/kind 5944%insert AVAIL3 5945%insert OutputState 5946 */ 5947 %{DeclareOperation_1.2 UNIDIRECTIONAL_SEQUENCE_LSTM 92}, 5948 5949 /** 5950 * A recurrent neural network layer that applies a basic RNN cell to a 5951 * sequence of inputs. 5952 * 5953 * This layer unrolls the input along the sequence dimension, and implements 5954 * the following operation 5955 * for each element in the sequence s = 1...sequence_length: 5956 * outputs[s] = state = activation(inputs[s] * input_weights’ + state * 5957 * recurrent_weights’ + bias) 5958 * 5959 * Where: 5960 * * “input_weights” is a weight matrix that multiplies the inputs; 5961 * * “recurrent_weights” is a weight matrix that multiplies the current 5962 * “state” which itself is the output from the previous time step 5963 * computation; 5964 * * “bias” is a bias vector (added to each output vector in the batch); 5965 * * “activation” is the function passed as the “fused_activation_function” 5966 * argument (if not “NONE”). 5967 * 5968 * Supported tensor {@link %{OperandType}}: 5969 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 5970 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 5971 * 5972 * The input tensors must all be the same type. 5973 * 5974 * Inputs: 5975 * * 0: input. 5976 * A 3-D tensor. The shape is defined by the input 6 (timeMajor). If 5977 * it is set to 1, then the input has a shape [maxTime, batchSize, 5978 * inputSize], otherwise the input has a shape [batchSize, maxTime, 5979 * inputSize]. 5980 * * 1: weights. 5981 * A 2-D tensor of shape [numUnits, inputSize]. 5982 * * 2: recurrent_weights. 5983 * A 2-D tensor of shape [numUnits, numUnits]. 5984 * * 3: bias. 5985 * A 1-D tensor of shape [numUnits]. 5986 * * 4: hidden state 5987 * A 2-D tensor of shape [batchSize, numUnits]. Specifies a hidden 5988 * state input for the first time step of the computation. 5989 * * 5: fusedActivationFunction. 5990 * A {@link %{FusedActivationFunc}} value indicating the activation function. If 5991 * “NONE” is specified then it results in a linear activation. 5992 * * 6: timeMajor 5993 * An {@link %{OperandTypeLinkPfx}INT32} scalar specifying the shape format 5994 * of input and output tensors. Must be set to either 0 or 1. 5995 * Outputs: 5996 * * 0: output. 5997 * A 3-D tensor. The shape is defined by the input 6 (timeMajor). If 5998 * it is set to 1, then the output has a shape [maxTime, batchSize, 5999 * numUnits], otherwise the output has a shape [batchSize, maxTime, 6000 * numUnits]. 6001%kind ndk hal_1.3+ 6002 * * 1: A tensor of shape [batchSize, numUnits] containing hidden state 6003 * from the last time step in the sequence. This output is optional 6004 * and can be omitted. 6005 * Available since %{NNAPILevel4}. 6006%/kind 6007%insert AVAIL3 6008%insert OutputState 6009 */ 6010 %{DeclareOperation_1.2 UNIDIRECTIONAL_SEQUENCE_RNN 93}, 6011 6012 /** 6013 * Resizes images to given size using the nearest neighbor interpretation. 6014 * 6015 * Resized images must be distorted if their output aspect ratio is not the 6016 * same as input aspect ratio. The corner pixels of output may not be the 6017 * same as corner pixels of input. 6018 * 6019 * Supported tensor {@link %{OperandType}}: 6020 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 6021 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 6022 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 6023%kind ndk hal_1.3+ 6024 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} (since %{NNAPILevel4}) 6025%/kind 6026 * 6027 * Supported tensor rank: 4, with "NHWC" or "NCHW" data layout. 6028 * With the default data layout NHWC, the data is stored in the order of: 6029 * [batch, height, width, channels]. Alternatively, the data layout could 6030 * be NCHW, the data storage order of: [batch, channels, height, width]. 6031 * 6032 * Both resizing by shape and resizing by scale are supported. 6033 * 6034 * Inputs (resizing by shape): 6035 * * 0: A 4-D tensor, of shape [batches, height, width, depth], specifying 6036 * the input. Zero batches is supported for this tensor. 6037 * * 1: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the output 6038 * width of the output tensor. 6039 * * 2: An {@link %{OperandTypeLinkPfx}INT32} scalar, specifying the output 6040 * height of the output tensor. 6041 * * 3: An {@link %{OperandTypeLinkPfx}BOOL} scalar, default to false. 6042 * Set to true to specify NCHW data layout for input0 and output0. 6043%kind canonical ndk hal_1.3+ 6044 * * 4: Align corners. An optional {@link %{OperandTypeLinkPfx}BOOL} 6045 * scalar, default to false. If True, the centers of the 4 corner 6046 * pixels of the input and output tensors are aligned, preserving the 6047 * values at the corner pixels. 6048 * Available since %{NNAPILevel4}. 6049 * * 5: Half pixel centers. An optional {@link %{OperandTypeLinkPfx}BOOL} 6050 * scalar, default to false. If True, the pixel centers are assumed to 6051 * be at (0.5, 0.5). This is the default behavior of image.resize in 6052 * TF 2.0. If this parameter is True, then align_corners parameter 6053 * must be False. 6054 * Available since %{NNAPILevel4}. 6055%/kind 6056 * 6057 * Inputs (resizing by scale): 6058 * * 0: A 4-D tensor, of shape [batches, height, width, depth], specifying 6059 * the input. Zero batches is supported for this tensor. 6060 * * 1: A scalar, specifying width_scale, the scaling factor of the width 6061 * dimension from the input tensor to the output tensor. The output 6062 * width is calculated as new_width = floor(width * width_scale). 6063 * The scalar must be of {@link %{OperandTypeLinkPfx}FLOAT16} if input0 is 6064 * of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} and of 6065 * {@link %{OperandTypeLinkPfx}FLOAT32} otherwise. 6066 * * 2: A scalar, specifying height_scale, the scaling factor of the height 6067 * dimension from the input tensor to the output tensor. The output 6068 * height is calculated as new_height = floor(height * height_scale). 6069 * The scalar must be of {@link %{OperandTypeLinkPfx}FLOAT16} if input0 is 6070 * of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} and of 6071 * {@link %{OperandTypeLinkPfx}FLOAT32} otherwise. 6072 * * 3: An {@link %{OperandTypeLinkPfx}BOOL} scalar, default to false. 6073 * Set to true to specify NCHW data layout for input0 and output0. 6074%kind canonical ndk hal_1.3+ 6075 * * 4: Align corners. An optional {@link %{OperandTypeLinkPfx}BOOL} 6076 * scalar, default to false. If True, the centers of the 4 corner 6077 * pixels of the input and output tensors are aligned, preserving the 6078 * values at the corner pixels. 6079 * Available since %{NNAPILevel4}. 6080 * * 5: Half pixel centers. An optional {@link %{OperandTypeLinkPfx}BOOL} 6081 * scalar, default to false. If True, the pixel centers are assumed to 6082 * be at (0.5, 0.5). This is the default behavior of image.resize in 6083 * TF 2.0. If this parameter is True, then align_corners parameter 6084 * must be False. 6085 * Available since %{NNAPILevel4}. 6086%/kind 6087 * 6088 * Outputs: 6089 * * 0: The output 4-D tensor, of shape 6090 * [batches, new_height, new_width, depth]. 6091%kind canonical ndk hal_1.3+ 6092 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} and 6093 * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} tensor, 6094 * the scale and zeroPoint must be the same as input0. 6095%else 6096 * For a {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} tensor, 6097 * the scale and zeroPoint must be the same as input0. 6098%/kind 6099%insert AVAIL3 6100 */ 6101 %{DeclareOperation_1.2 RESIZE_NEAREST_NEIGHBOR 94}, 6102%/section 6103 6104%section Operation_1.2_MAX 6105 FUNDAMENTAL_MAX = 94, 6106%/section 6107 6108%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 6109 6110%% HAL OperandType for 1.3 6111%% NDK OperandCode for API 30 6112 6113%section Operand_1.3 6114 /** 6115 * A tensor of 8 bit signed integers that represent real numbers. 6116 * 6117 * Attached to this tensor are two numbers that can be used to convert the 6118 * 8 bit integer to the real value and vice versa. These two numbers are: 6119 * - scale: a 32 bit floating point value greater than zero. 6120 * - zeroPoint: a 32 bit integer, in range [-128, 127]. 6121 * 6122 * The formula is: 6123 * real_value = (integer_value - zeroPoint) * scale. 6124%insert AVAIL4 6125 */ 6126 %{ANN}TENSOR_QUANT8_ASYMM_SIGNED = 14, 6127 6128 /** 6129 * A reference to a %{model_or_subgraph}. 6130%kind ndk 6131 * 6132 * {@link ANeuralNetworksModel_setOperandValueFromModel} must be used to set 6133 * the value for an Operand of this type. 6134%/kind 6135%kind canonical hal* 6136 * 6137 * Must have the lifetime {@link %{OperandLifeTime}::SUBGRAPH}. 6138%/kind 6139%insert AVAIL4 6140 */ 6141 %{ANN}%{MODEL_or_SUBGRAPH} = 15, 6142%/section 6143 6144%section Operand_1.3_MAX 6145 FUNDAMENTAL_MAX = 15, 6146%/section 6147 6148%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 6149 6150%% HAL OperationType for 1.3 6151%% NDK OperationCode for API 30 6152 6153%section Operation_1.3 6154 /** 6155 * Quantized version of {@link %{OperationTypeLinkPfx}LSTM}. 6156 * 6157 * The input and the output use asymmetric quantized types, while the rest 6158 * use symmetric ones. 6159 * 6160 * Inputs: 6161 * * 0: The input to the LSTM cell. 6162 * Type: {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} 6163 * Shape: [batchSize, inputSize] 6164 * * 1: The input-to-input weights. Optional. 6165 * Type: {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM} 6166 * Shape: [numUnits, inputSize] 6167 * * 2: The input-to-forget weights. 6168 * Type: {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM} 6169 * Shape: [numUnits, inputSize] 6170 * * 3: The input-to-cell weights. 6171 * Type: {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM} 6172 * Shape: [numUnits, inputSize] 6173 * * 4: The input-to-output weights. 6174 * Type: {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM} 6175 * Shape: [numUnits, inputSize] 6176 * * 5: The recurrent-to-input weights. Optional. 6177 * Type: {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM} 6178 * Shape: [numUnits, outputSize] 6179 * * 6: The recurrent-to-forget weights. 6180 * Type: {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM} 6181 * Shape: [numUnits, outputSize] 6182 * * 7: The recurrent-to-cell weights. 6183 * Type: {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM} 6184 * Shape: [numUnits, outputSize] 6185 * * 8: The recurrent-to-output weights. 6186 * Type: {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM} 6187 * Shape: [numUnits, outputSize] 6188 * * 9: The cell-to-input weights (for peephole). Optional. 6189 * Type: {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_SYMM} 6190 * Shape: [numUnits] 6191 * * 10: The cell-to-forget weights (for peephole). Optional. 6192 * Type: {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_SYMM} 6193 * Shape: [numUnits] 6194 * * 11: The cell-to-output weights (for peephole). Optional. 6195 * Type: {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_SYMM} 6196 * Shape: [numUnits] 6197 * * 12: The input gate bias. Quantized with scale being the 6198 * product of input and weights scales and zeroPoint equal to 0. 6199 * Optional. 6200 * Type: {@link %{OperandTypeLinkPfx}TENSOR_INT32} 6201 * Shape: [numUnits] 6202 * * 13: The forget gate bias. Quantized with scale being the 6203 * product of input and weights scales and zeroPoint equal to 0. 6204 * Type: {@link %{OperandTypeLinkPfx}TENSOR_INT32} 6205 * Shape: [numUnits] 6206 * * 14: The cell bias. Quantized with scale being the 6207 * product of input and weights scales and zeroPoint equal to 0. 6208 * Type: {@link %{OperandTypeLinkPfx}TENSOR_INT32} 6209 * Shape: [numUnits] 6210 * * 15: The output gate bias. Quantized with scale being the 6211 * product of input and weights scales and zeroPoint equal to 0. 6212 * Type: {@link %{OperandTypeLinkPfx}TENSOR_INT32} 6213 * Shape: [numUnits] 6214 * * 16: The projection weights. Optional. 6215 * Type: {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM} 6216 * Shape: [outputSize, numUnits] 6217 * * 17: The projection bias. Quantized with scale being the 6218 * product of input and weights scales and zeroPoint equal to 0. 6219 * Optional. 6220 * Type: {@link %{OperandTypeLinkPfx}TENSOR_INT32} 6221 * Shape: [outputSize] 6222 * * 18: The output from the previous time step. 6223 * Type: {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} 6224 * Shape: [batchSize, outputSize] 6225 * * 19: The cell state from the previous time step. 6226 * Type: {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_SYMM} 6227 * Shape: [batchSize, numUnits] 6228 * * 20: The input layer normalization weights. Used to rescale 6229 * normalized inputs to activation at input gate. Optional. 6230 * Type: {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_SYMM} 6231 * Shape: [numUnits] 6232 * * 21: The forget layer normalization weights. Used to 6233 * rescale normalized inputs to activation at forget gate. Optional. 6234 * Type: {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_SYMM} 6235 * Shape: [numUnits] 6236 * * 22: The cell layer normalization weights. Used to rescale 6237 * normalized inputs to activation at cell gate. Optional. 6238 * Type: {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_SYMM} 6239 * Shape: [numUnits] 6240 * * 23: The output layer normalization weights. Used to 6241 * rescale normalized inputs to activation at output gate. Optional. 6242 * Type: {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_SYMM} 6243 * Shape: [numUnits] 6244 * * 24: The cell clip. If provided the cell state is clipped 6245 * by this value prior to the cell output activation. Optional. 6246 * Type: {@link %{OperandTypeLinkPfx}FLOAT32}. 6247 * * 25: The projection clip. If provided and projection is enabled, 6248 * this is used for clipping the projected values. Optional. 6249 * Type: {@link %{OperandTypeLinkPfx}FLOAT32}. 6250 * * 26: The scale of the intermediate result of matmul, 6251 * i.e. input to layer normalization, at input gate. 6252 * Type: {@link %{OperandTypeLinkPfx}FLOAT32}. 6253 * * 27: The scale of the intermediate result of matmul, 6254 * i.e. input to layer normalization, at forget gate. 6255 * Type: {@link %{OperandTypeLinkPfx}FLOAT32}. 6256 * * 28: The scale of the intermediate result of matmul, 6257 * i.e. input to layer normalization, at cell gate. 6258 * Type: {@link %{OperandTypeLinkPfx}FLOAT32}. 6259 * * 29: The scale of the intermediate result of matmul, 6260 * i.e. input to layer normalization, at output gate. 6261 * Type: {@link %{OperandTypeLinkPfx}FLOAT32}. 6262 * * 30: The zero point of the hidden state, i.e. input to 6263 * projection. 6264 * Type: {@link %{OperandTypeLinkPfx}INT32}. 6265 * * 31: The scale of the hidden state, i.e. input to 6266 * projection. 6267 * Type: {@link %{OperandTypeLinkPfx}FLOAT32}. 6268 * 6269 * Outputs: 6270 * * 0: The output state (out). 6271 * Type: {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} 6272 * Shape: [batchSize, outputSize] 6273 * * 1: The cell state (out). 6274 * Type: {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_SYMM} 6275 * Shape: [batchSize, numUnits] 6276 * * 2: The output. This is effectively the same as the current 6277 * "output state (out)" value. 6278 * Type: {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} 6279 * Shape: [batchSize, outputSize] 6280%insert AVAIL4 6281 */ 6282 %{DeclareOperation_1.3 QUANTIZED_LSTM 95}, 6283 6284 /** 6285 * Executes one of the two referenced %{model_or_subgraph}s as determined by a boolean 6286 * value. 6287 * 6288 * The inputs and outputs of the two referenced %{model_or_subgraph}s must agree with the 6289 * signature of this operation. That is, if the operation has (3 + n) inputs 6290 * and m outputs, both %{model_or_subgraph}s must have n inputs and m outputs with the same 6291 * types, ranks%{NDK_if_specified}, dimensions%{NDK_if_specified}, scales, 6292 * zeroPoints, and %{otherOperandParameters} as the corresponding operation 6293 * inputs and outputs. 6294%kind canonical hal* 6295 * All of the operands mentioned must have fully specified dimensions. 6296%/kind 6297 * 6298 * Inputs: 6299 * * 0: A value of type {@link %{OperandTypeLinkPfx}TENSOR_BOOL8} and shape [1] 6300 * that determines which of the two referenced %{model_or_subgraph}s to execute. 6301 * The operand must have fully specified dimensions. 6302 * * 1: A {@link %{OperandTypeLinkPfx}%{MODEL_or_SUBGRAPH}} reference to the %{model_or_subgraph} to be 6303 * executed if the condition is true. 6304 * * 2: A {@link %{OperandTypeLinkPfx}%{MODEL_or_SUBGRAPH}} reference to the %{model_or_subgraph} to be 6305 * executed if the condition is false. 6306 * * 3 ~ (n + 2): Inputs to be passed to the %{model_or_subgraph} selected for execution. 6307 * 6308 * Outputs: 6309 * * 0 ~ (m - 1): Outputs produced by the selected %{model_or_subgraph}. 6310%insert AVAIL4 6311 */ 6312 %{DeclareOperation_1.3 IF 96}, 6313 6314 /** 6315 * Executes the body %{model_or_subgraph} until the condition %{model_or_subgraph} outputs false. 6316 * 6317 * The inputs to this operation are the condition %{model_or_subgraph}, the body %{model_or_subgraph}, 6318 * and operand values for the first iteration of the loop. The values are 6319 * implicitly split into three groups of input-output, state-only, and 6320 * input-only values, as described below. 6321 * 6322 * The outputs of this operation are the final values of input-output 6323 * operands. 6324 * 6325 * Both the condition and body %{model_or_subgraph} receive (m + k + n) inputs. 6326 * * The first m (m >= 1) inputs are input-output operands. For the first 6327 * iteration, these are initialized from the corresponding inputs of the 6328 * WHILE operation. In subsequent iterations, their values come from the 6329 * corresponding outputs of the body %{model_or_subgraph} produced during the previous 6330 * iteration. 6331 * * The next k (k >= 0) inputs are state-only operands. They are similar to 6332 * the input-output operands, except that their values are no longer 6333 * available after the loop terminates. 6334 * * The last n (n >= 0) inputs are input-only operands. Their values come 6335 * from the corresponding inputs of the WHILE operation. 6336 * 6337 * The body %{model_or_subgraph} produces (m + k) outputs. 6338 * * The first m outputs are input-output operands. They become the outputs 6339 * of the WHILE operation when a termination condition is reached. 6340 * * The last k outputs are state-only operands. Their values are no longer 6341 * available after the loop terminates. 6342 * 6343 * The numbers m, k, and n are inferred by the %{runtime_or_driver} as follows: 6344 * m = (WHILE operation output count) 6345 * k = (body %{model_or_subgraph} output count) - m 6346 * n = (body %{model_or_subgraph} input count) - m - k 6347 * 6348 * The pseudo-code below illustrates the flow of a WHILE operation with 6349 * inputs condition, body, initial_input_output, initial_state, input_only 6350 * (m = 1, k = 1, n = 1): 6351 * 6352 * input_output = initial_input_output 6353 * state = initial_state 6354 * while condition(input_output, state, input_only): 6355 * input_output, state = body(input_output, state, input_only) 6356 * return input_output 6357 * 6358%kind ndk 6359 * To prevent infinite loops, there is an implicit execution timeout 6360 * associated with each loop ("loop timeout duration"). See {@link 6361 * ANeuralNetworksExecution_setLoopTimeout}. 6362 * 6363%/kind 6364 * Inputs: 6365 * * 0: A {@link %{OperandTypeLinkPfx}%{MODEL_or_SUBGRAPH}} reference to the condition 6366 * %{model_or_subgraph}. The %{model_or_subgraph} must have (m + k + n) inputs with 6367 * the same types, ranks%{NDK_if_specified}, dimensions%{NDK_if_specified}, 6368 * scales, zeroPoints, and %{otherOperandParameters} as the 6369 * corresponding inputs of the WHILE operation and exactly one output 6370 * of {@link %{OperandTypeLinkPfx}TENSOR_BOOL8} and shape [1]. 6371%kind ndk 6372 * The output operand must have fully specified dimensions. 6373%/kind 6374%kind canonical hal* 6375 * All of the operands mentioned must have fully specified dimensions. 6376%/kind 6377 * * 1: A {@link %{OperandTypeLinkPfx}%{MODEL_or_SUBGRAPH}} reference to the body %{model_or_subgraph}. 6378 * The %{model_or_subgraph} must have (m + k + n) inputs and (m + k) outputs with 6379 * the same types, ranks%{NDK_if_specified}, dimensions%{NDK_if_specified}, 6380 * scales, zeroPoints, and %{otherOperandParameters} as the 6381 * corresponding inputs and outputs of the WHILE operation. 6382%kind canonical hal* 6383 * All of the operands mentioned must have fully specified dimensions. 6384%/kind 6385 * * (m inputs): Initial values for input-output operands. 6386 * * (k inputs): Initial values for state-only operands. 6387 * * (n inputs): Values for input-only operands. 6388 * 6389 * Outputs: 6390 * * 0 ~ (m - 1): Outputs produced by the loop. 6391%insert AVAIL4 6392 */ 6393 %{DeclareOperation_1.3 WHILE 97}, 6394 6395 /** 6396 * Computes exponential linear activation on the input tensor element-wise. 6397 * 6398 * The output is calculated using the following formula: 6399 * 6400 * ELU(x) = max(0, x) + min(0, alpha * (exp(x) - 1)) 6401 * 6402 * Supported tensor {@link %{OperandType}}: 6403 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 6404 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 6405 * 6406 * Supported tensor rank: from 1. 6407 * 6408 * Inputs: 6409 * * 0: A tensor, specifying the input. May be zero-sized. 6410 * * 1: A scalar, specifying the alpha parameter. 6411 * For input tensor of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16}, 6412 * the alpha value must be of {@link %{OperandTypeLinkPfx}FLOAT16}. 6413 * For input tensor of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32}, 6414 * the alpha value must be of {@link %{OperandTypeLinkPfx}FLOAT32}. 6415 * 6416 * Outputs: 6417 * * 0: The output tensor of same shape and type as input0. 6418%insert AVAIL4 6419 */ 6420 %{DeclareOperation_1.3 ELU 98}, 6421 6422 /** 6423 * Computes hard-swish activation on the input tensor element-wise. 6424 * 6425 * Hard swish activation is introduced in 6426 * https://arxiv.org/pdf/1905.02244.pdf 6427 * 6428 * The output is calculated using the following formula: 6429 * 6430 * h-swish(x) = x * max(0, min(6, (x + 3))) / 6 6431 6432 * Supported tensor {@link %{OperandType}}: 6433 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 6434 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 6435 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 6436 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} 6437 * 6438 * Supported tensor rank: from 1. 6439 * 6440 * Inputs: 6441 * * 0: A tensor, specifying the input. May be zero-sized. 6442 * 6443 * Outputs: 6444 * * 0: The output tensor of same shape and type as input0. 6445 * Scale and zero point of this tensor may be different from the input 6446 * tensor's parameters. 6447%insert AVAIL4 6448 */ 6449 %{DeclareOperation_1.3 HARD_SWISH 99}, 6450 6451 /** 6452 * Creates a tensor filled with a scalar value. 6453 * 6454 * Supported output tensor {@link %{OperandType}}: 6455 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 6456 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 6457 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 6458 * 6459 * Supported tensor rank: from 1. 6460 * 6461 * Inputs: 6462 * * 0: A 1-D tensor, specifying the desired output tensor shape. 6463 * * 1: A scalar, specifying the value to fill the output tensors with. 6464 * For output tensor of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16}, 6465 * the scalar must be of {@link %{OperandTypeLinkPfx}FLOAT16}. 6466 * For output tensor of {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32}, 6467 * the scalar must be of {@link %{OperandTypeLinkPfx}FLOAT32}. 6468 * For output tensor of {@link %{OperandTypeLinkPfx}TENSOR_INT32}, 6469 * the scalar must be of {@link %{OperandTypeLinkPfx}INT32}. 6470 * 6471 * Outputs: 6472 * * 0: The output tensor. 6473%insert AVAIL4 6474 */ 6475 %{DeclareOperation_1.3 FILL 100}, 6476 6477 /** 6478 * Returns the rank of a tensor. 6479 * 6480 * The rank of a tensor is the number of dimensions in it. Also known as 6481 * "order", "degree", "ndims". 6482 * 6483 * Supported tensor {@link %{OperandType}}: 6484 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT16} 6485 * * {@link %{OperandTypeLinkPfx}TENSOR_FLOAT32} 6486 * * {@link %{OperandTypeLinkPfx}TENSOR_INT32} 6487 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM} 6488 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_SYMM} 6489 * * {@link %{OperandTypeLinkPfx}TENSOR_BOOL8} 6490 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM_PER_CHANNEL} 6491 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT16_ASYMM} 6492 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_SYMM} 6493 * * {@link %{OperandTypeLinkPfx}TENSOR_QUANT8_ASYMM_SIGNED} 6494 * 6495 * Supported tensor rank: from 1. 6496 * 6497 * Inputs: 6498 * * 0: The input tensor. 6499 * 6500 * Outputs: 6501 * * 0: A scalar of {@link %{OperandTypeLinkPfx}INT32}, specifying the rank 6502 * of the input tensor. 6503%insert AVAIL4 6504 */ 6505 %{DeclareOperation_1.3 RANK 101}, 6506%/section 6507 6508%section Operation_1.3_MAX 6509 FUNDAMENTAL_MAX = 101, 6510%/section 6511 6512%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 6513 6514%% Misc HAL types 6515 6516%section OperandLifeTime 6517/** 6518 * How an operand is used. 6519 */ 6520%kind canonical 6521enum class LifeTime { 6522%else 6523%{enum OperandLifeTime int32_t} { 6524%/kind 6525 /** 6526 * The operand is internal to the model. It's created by an operation and 6527 * consumed by other operations. It must be an output operand of 6528 * exactly one operation. 6529 */ 6530 %{DeclareEnumValue TEMPORARY_VARIABLE 0}, 6531 6532 /** 6533 * The operand is an input of %{the_model_or_a_subgraph}. It must not be an output 6534 * operand of any operation. 6535 * 6536 * An operand can't be both input and output of a %{model_or_subgraph}. 6537 */ 6538%kind hal_1.0 6539 %{DeclareEnumValue MODEL_INPUT 1}, 6540%else 6541 %{DeclareEnumValue SUBGRAPH_INPUT 1}, 6542%/kind 6543 6544 /** 6545 * The operand is an output of %{the_model_or_a_subgraph}. It must be an output 6546 * operand of exactly one operation. 6547 * 6548 * An operand can't be both input and output of a %{model_or_subgraph}. 6549 */ 6550%kind hal_1.0 6551 %{DeclareEnumValue MODEL_OUTPUT 2}, 6552%else 6553 %{DeclareEnumValue SUBGRAPH_OUTPUT 2}, 6554%/kind 6555 6556 /** 6557 * The operand is a constant found in Model%{::}operandValues. It must 6558 * not be an output operand of any operation. 6559 */ 6560 %{DeclareEnumValue CONSTANT_COPY 3}, 6561 6562 /** 6563 * The operand is a constant that was specified via a Memory 6564 * object. It must not be an output operand of any operation. 6565 */ 6566 %{DeclareEnumValue CONSTANT_REFERENCE 4}, 6567 6568 /** 6569 * The operand does not have a value. This is valid only for optional 6570 * arguments of operations. 6571 */ 6572 %{DeclareEnumValue NO_VALUE 5}, 6573%kind canonical hal_1.3+ 6574 6575 /** 6576 * The operand is a reference to a subgraph. It must be an input to one 6577 * or more {@link OperationType::IF} or {@link OperationType::WHILE} 6578 * operations. 6579 */ 6580 %{DeclareEnumValue SUBGRAPH 6}, 6581%/kind 6582%kind canonical 6583 6584 /** 6585 * This operand is a constant found in a user buffer. It must not be an 6586 * output operand of any operation. 6587 */ 6588 %{DeclareEnumValue POINTER 7}, 6589%/kind 6590}; 6591%/section 6592 6593%section DeviceStatus 6594/** 6595 * Status of a device. 6596 */ 6597%{enum DeviceStatus int32_t} { 6598 %{DeclareEnumValue AVAILABLE 0}, 6599 %{DeclareEnumValue BUSY 1}, 6600 %{DeclareEnumValue OFFLINE 2}, 6601 %{DeclareEnumValue UNKNOWN 3}, 6602}; 6603%/section 6604 6605%kind canonical 6606%define init_execTime = kDefaultExecTime 6607%define init_powerUsage = kDefaultPowerUsage 6608%else 6609%define init_execTime 6610%define init_powerUsage 6611%/kind 6612 6613%section PerformanceInfo 6614/** 6615 * Performance information for the reference workload. 6616 * 6617 * Used by a driver to report its performance characteristics. 6618 */ 6619struct PerformanceInfo { 6620 /** 6621 * Ratio of the time taken by the driver to execute the 6622 * workload compared to the time the CPU would take for the 6623 * same workload. A lower number is better. 6624 */ 6625 float execTime%{init_execTime}; 6626 6627 /** 6628 * Ratio of the energy used by the driver compared to what 6629 * the CPU would use for doing the same workload. A lower number 6630 * is better. 6631 */ 6632 float powerUsage%{init_powerUsage}; 6633}; 6634%/section 6635 6636%section OutputShape 6637/** 6638 * Describes the shape information of an output operand after execution. 6639 */ 6640struct OutputShape { 6641 /** 6642 * Dimensions of the operand. 6643 */ 6644 %{vec}<uint32_t> dimensions; 6645 6646 /** 6647 * Whether the provided buffer size is sufficient for the output. 6648 */ 6649 bool isSufficient%{init_bool}; 6650}; 6651%/section 6652 6653%section MeasureTiming 6654/** 6655 * Specifies whether or not to measure timing information during execution. 6656 */ 6657%{enum MeasureTiming int32_t} { 6658 NO = 0, 6659 YES = 1, 6660}; 6661%/section 6662 6663%section ExecutionPreference 6664/** 6665 * Execution preferences. 6666%insert AVAIL1Short 6667 */ 6668%{enum ExecutionPreference int32_t} { 6669 /** 6670 * Prefer executing in a way that minimizes battery drain. 6671 * This is desirable for compilations that will be executed often. 6672 */ 6673 %{DeclareExecutionPreference LOW_POWER 0}, 6674 /** 6675 * Prefer returning a single answer as fast as possible, even if this causes 6676 * more power consumption. 6677 */ 6678 %{DeclareExecutionPreference FAST_SINGLE_ANSWER 1}, 6679 /** 6680 * Prefer maximizing the throughput of successive frames, for example when 6681 * processing successive frames coming from the camera. 6682 */ 6683 %{DeclareExecutionPreference SUSTAINED_SPEED 2}, 6684%kind canonical 6685 DEFAULT = FAST_SINGLE_ANSWER, 6686%/kind 6687}%{ndk_enum_name PreferenceCode}; 6688%/section 6689 6690%section DeviceType 6691/** 6692 * Device types. 6693 * 6694 * The type of NNAPI device. 6695 */ 6696%{enum DeviceType int32_t} { 6697%kind hal* 6698 // Leaving 0 unused as it means unknown type in NDK NNAPI. There is no 6699 // HAL equivalent of unknown type and a 1.2 HAL implementation must belong 6700 // to one of the categories below. 6701%else 6702 /** The device type cannot be provided. */ 6703 %{DeclareDeviceType UNKNOWN 0}, 6704%/kind 6705 /** The device does not fall into any category below. */ 6706 %{DeclareDeviceType OTHER 1}, 6707 /** The device runs NNAPI models on single or multi-core CPU. */ 6708 %{DeclareDeviceType CPU 2}, 6709 /** The device can run NNAPI models and also accelerate graphics APIs such 6710 * as OpenGL ES and Vulkan. */ 6711 %{DeclareDeviceType GPU 3}, 6712 /** Dedicated accelerator for Machine Learning workloads. */ 6713 %{DeclareDeviceType ACCELERATOR 4}, 6714}%{ndk_enum_name DeviceTypeCode}; 6715%/section 6716 6717%% NOTE: This is different from the NDK PriorityCode. 6718%section Priority 6719/** 6720%kind ndk 6721 * Relative execution priority. 6722 * 6723 * Available since NNAPI feature level 4. 6724%else 6725 * Priority given to a prepared model for execution. 6726%/kind 6727 */ 6728%{enum Priority int32_t} { 6729 %{DeclarePriority LOW 0 90}, 6730 %{DeclarePriority MEDIUM 1 100}, 6731 %{DeclarePriority HIGH 2 110}, 6732%kind canonical ndk 6733 %{DeclarePriority DEFAULT MEDIUM ANEURALNETWORKS_PRIORITY_MEDIUM}, 6734%/kind 6735}%{ndk_enum_name PriorityCode}; 6736%/section 6737 6738%kind canonical 6739%define OptionalDuration OptionalDuration 6740%else 6741%define OptionalDuration uint64_t 6742%/kind 6743 6744%section Timing 6745/** 6746%kind hal_1.2 6747 6748%/kind 6749 * Timing information measured during execution. Each time is a duration from 6750 * the beginning of some task to the end of that task, including time when that 6751 * task is not active (for example, preempted by some other task, or 6752 * waiting for some resource to become available). 6753 * 6754%kind hal* 6755 * Times are measured in microseconds. 6756 * When a time is not available, it must be reported as UINT64_MAX. 6757%else 6758 * Times are measured in nanoseconds. 6759%/kind 6760 */ 6761struct Timing { 6762 /** Execution time on device (not driver, which runs on host processor). */ 6763 %{OptionalDuration} timeOnDevice; 6764 /** Execution time in driver (including time on device). */ 6765 %{OptionalDuration} timeInDriver; 6766}; 6767%/section 6768 6769%section Capabilities_float_quant_performance 6770 /** 6771 * Driver performance when operating on float32 data. 6772 */ 6773 PerformanceInfo float32Performance; 6774 6775 /** 6776 * Driver performance when operating on asymmetric 8-bit quantized data. 6777 */ 6778 PerformanceInfo quantized8Performance; 6779%/section 6780 6781%kind canonical 6782%define OperandPerformanceTable OperandPerformanceTable 6783%else 6784%define OperandPerformanceTable vec<OperandPerformance> 6785%/kind 6786 6787%section Capabilities_relaxedPerformance 6788 /** 6789 * Driver performance when operating on float32 data but performing 6790 * calculations with range and/or precision as low as that of the IEEE 6791 * 754 16-bit floating-point format. 6792 */ 6793%kind hal_1.1 6794 PerformanceInfo relaxedFloat32toFloat16Performance; 6795%else 6796 PerformanceInfo relaxedFloat32toFloat16PerformanceScalar; 6797 PerformanceInfo relaxedFloat32toFloat16PerformanceTensor; 6798%/kind 6799%/section 6800 6801%section Capabilities_operandPerformance 6802 /** 6803 * Performance by operand type. Must be sorted by OperandType. 6804%kind hal_1.2 6805 * If a particular OperandType is not present in operandPerformance, 6806 * its performance is treated as { .execTime = FLT_MAX, .powerUsage = FLT_MAX }. 6807%else 6808 * 6809 * If a particular {@link OperandType} is not present in operandPerformance, 6810 * its performance is treated as 6811 * { .execTime = FLT_MAX, .powerUsage = FLT_MAX }. 6812 * 6813 * Performance does not apply to {@link OperandType::SUBGRAPH}, and a driver 6814 * must not report operand performance for {@link OperandType::SUBGRAPH}. 6815%/kind 6816 */ 6817 %{OperandPerformanceTable} operandPerformance; 6818%/section 6819 6820%section Capabilities_if_while_performance 6821 /** 6822 * Performance of an {@link OperationType::IF} operation is the sum of 6823 * {@link Capabilities::ifPerformance} and the mean of performance for the 6824 * two branch subgraphs, where performance for a subgraph is the sum of the 6825 * performance of all operations within the subgraph. 6826 */ 6827 PerformanceInfo ifPerformance; 6828 6829 /** 6830 * Performance of a {@link OperationType::WHILE} operation is the sum of 6831 * {@link Capabilities::whilePerformance}, performance for the condition 6832 * subgraph and performance for the body subgraph, where performance for a 6833 * subgraph is the sum of the performance of all operations within the 6834 * subgraph. 6835 */ 6836 PerformanceInfo whilePerformance; 6837%/section 6838 6839%section OperandPerformance 6840/** 6841 * Driver performance when operating on a particular data type. 6842 * In the case of float32 data, this is used when the calculations 6843 * are not relaxed. 6844 */ 6845struct OperandPerformance { 6846 OperandType type%{init_pod}; 6847 PerformanceInfo info; 6848}; 6849%/section 6850 6851%section Capabilities 6852/** 6853 * The capabilities of a driver. 6854%kind hal_1.2 6855 * 6856 * Performance of an operation comes from the type of its first operand. 6857 * This represents performance for non extension operand types. 6858%/kind 6859%kind canonical hal_1.3+ 6860 * 6861 * This represents performance of non-extension operations. 6862 * 6863 * Performance of an operation other than {@link OperationType::IF} and 6864 * {@link OperationType::WHILE} comes from the type of its first operand. 6865%/kind 6866 */ 6867struct Capabilities { 6868%kind canonical 6869%insert-indented 4 PerformanceInfo 6870 6871%insert-indented 4 OperandPerformance 6872 6873 class OperandPerformanceTable { 6874 public: 6875 static Result<OperandPerformanceTable> create( 6876 std::vector<OperandPerformance> operandPerformances); 6877 6878 PerformanceInfo lookup(OperandType type) const; 6879 const std::vector<OperandPerformance>& asVector() const; 6880 6881 private: 6882 explicit OperandPerformanceTable(std::vector<OperandPerformance> operandPerformances); 6883 std::vector<OperandPerformance> mSorted; 6884 }; 6885 6886%insert Capabilities_relaxedPerformance 6887 6888%insert Capabilities_operandPerformance 6889 6890%insert Capabilities_if_while_performance 6891%/kind 6892%kind hal_1.0 6893%insert Capabilities_float_quant_performance 6894%/kind 6895%kind hal_1.1 6896%insert Capabilities_float_quant_performance 6897 6898%insert Capabilities_relaxedPerformance 6899%/kind 6900%kind hal_1.2 6901%insert Capabilities_relaxedPerformance 6902 6903%insert-indented 4 OperandPerformance 6904 6905%insert Capabilities_operandPerformance 6906%/kind 6907%kind hal_1.3 6908%insert Capabilities_relaxedPerformance 6909 6910%insert-indented 4 OperandPerformance 6911 6912%insert Capabilities_operandPerformance 6913 6914%insert Capabilities_if_while_performance 6915%/kind 6916}; 6917%/section 6918 6919%section DataLocation 6920/** 6921 * Describes the location of a data object. 6922 */ 6923struct DataLocation { 6924%kind canonical 6925 /** 6926 * The address of the memory where the data is found. 6927 * 6928 * This field is only active when lifetime is POINTER. 6929 */ 6930 std::variant<const void*, void*> pointer; 6931 6932%/kind 6933 /** 6934 * The index of the memory pool where this location is found. 6935 */ 6936 uint32_t poolIndex%{init_int}; 6937 6938 /** 6939 * Offset in bytes from the start of the pool. 6940 */ 6941 uint32_t offset%{init_int}; 6942 6943 /** 6944 * The length of the data in bytes. 6945 */ 6946 uint32_t length%{init_int}; 6947%kind canonical 6948 6949 /** 6950 * The end padding of the specified memory region in bytes. 6951 */ 6952 uint32_t padding%{init_int}; 6953%/kind 6954}; 6955%/section 6956 6957%section Extension_name 6958 /** 6959 * The extension name. 6960 * 6961 * The name must consist of lowercase latin letters, numbers, periods, and 6962 * underscore signs. The name must contain at least one period. 6963 * 6964 * The name must start with the reverse domain name of the vendor. 6965 * 6966 * Example: com.google.test_extension 6967 */ 6968 %{string} name; 6969%/section 6970 6971%section Extension 6972/** 6973 * Information about an extension. 6974 */ 6975struct Extension { 6976%kind hal* 6977%insert Extension_name 6978 6979%/kind 6980 /** 6981 * Information about an extension operand type. 6982 */ 6983 struct OperandTypeInformation { 6984 /** 6985 * The extension operand type. 6986 */ 6987 uint16_t type%{init_int}; 6988 6989 /** 6990 * Indicates whether the extension operand type represents a tensor or 6991 * a scalar. 6992 */ 6993 bool isTensor%{init_bool}; 6994 6995 /** 6996 * The byte size of the operand (if scalar) or of a single element (if 6997 * tensor). 6998 */ 6999 uint32_t byteSize%{init_int}; 7000 }; 7001 7002%kind canonical 7003%insert Extension_name 7004 7005%/kind 7006 /** 7007 * Information about operand types defined by the extension. 7008 */ 7009 %{vec}<OperandTypeInformation> operandTypes; 7010}; 7011%/section 7012 7013%section Operation 7014/** 7015 * Describes one operation of the model's graph. 7016 */ 7017struct Operation { 7018 /** 7019 * The operation type. 7020%kind hal_1.2+ 7021 * 7022 * Besides the values listed in {@link OperationType}, any value above 7023 * {@link OperationTypeRange::BASE_MAX} is possible and should be interpreted 7024 * as an extension type according to {@link Model::extensionNameToPrefix}. 7025%/kind 7026 */ 7027 OperationType type%{init_pod}; 7028 7029 /** 7030 * Describes the table that contains the indexes of the inputs of the 7031 * operation. The offset is the index in the operandIndexes table. 7032 */ 7033 %{vec}<uint32_t> inputs; 7034 7035 /** 7036 * Describes the table that contains the indexes of the outputs of the 7037 * operation. The offset is the index in the operandIndexes table. 7038 */ 7039 %{vec}<uint32_t> outputs; 7040}; 7041%/section 7042 7043%section FusedActivationFunc 7044/** 7045 * Fused activation function types. 7046%insert AVAIL1Short 7047 */ 7048%kind canonical 7049enum class FusedActivationFunc : int32_t { 7050%else 7051%{enum FusedActivationFunc int32_t} { 7052%/kind 7053 /** NO fused activation function. */ 7054 %{DeclareFusedActivationFunc NONE 0}, 7055 /** Fused ReLU activation function. */ 7056 %{DeclareFusedActivationFunc RELU 1}, 7057 /** Fused ReLU1 activation function. */ 7058 %{DeclareFusedActivationFunc RELU1 2}, 7059 /** Fused ReLU6 activation function. */ 7060 %{DeclareFusedActivationFunc RELU6 3}, 7061}%{ndk_enum_name FuseCode}; 7062%/section 7063 7064%section ExtraParams_Comment 7065/** 7066 * Additional parameters specific to a particular operand type. 7067 */ 7068%/section 7069 7070%section ExtraParams_none_Comment 7071/** 7072 * No additional parameters. 7073 */ 7074%/section 7075 7076%section ExtraParams_channelQuant_Comment 7077/** 7078 * Symmetric per-channel quantization parameters. 7079 * 7080 * Only applicable to operands of type %{ANN}TENSOR_QUANT8_SYMM_PER_CHANNEL. 7081 */ 7082%/section 7083 7084%section ExtraParams_extension_Comment 7085/** 7086 * Extension operand parameters. 7087 * 7088 * The framework treats this as an opaque data blob. 7089 * The format is up to individual extensions. 7090 */ 7091%/section 7092 7093%section SymmPerChannelQuantParams_Comment 7094/** 7095 * Parameters for %{ANN}TENSOR_QUANT8_SYMM_PER_CHANNEL operand. 7096 */ 7097%/section 7098 7099%section SymmPerChannelQuantParams 7100%insert SymmPerChannelQuantParams_Comment 7101struct SymmPerChannelQuantParams { 7102 /** Array of scaling values for each channel. Each value must be greater than zero. */ 7103 %{vec}<float> scales; 7104 /** Index of the channel dimension */ 7105 uint32_t channelDim%{init_int}; 7106}; 7107%/section 7108 7109%kind canonical 7110%section location_pointer_is_null 7111 * - location.pointer is null. 7112%/section 7113%else 7114%section location_pointer_is_null 7115%/section 7116%/kind 7117 7118%% List item symbol 7119%kind hal* 7120%define li . 7121%else 7122%define li - 7123%/kind 7124 7125%section Operand 7126/** 7127 * Describes one operand of the model's graph. 7128 */ 7129struct Operand { 7130%kind canonical 7131%insert-indented 4 OperandLifeTime 7132 7133%insert-indented 4 ExtraParams_none_Comment 7134 using NoParams = std::monostate; 7135 7136%insert-indented 4 SymmPerChannelQuantParams 7137 7138%insert-indented 4 ExtraParams_extension_Comment 7139 using ExtensionParams = std::vector<uint8_t>; 7140 7141%insert-indented 4 ExtraParams_Comment 7142 using ExtraParams = std::variant<NoParams, SymmPerChannelQuantParams, ExtensionParams>; 7143 7144%/kind 7145 /** 7146%kind canonical 7147 * The data type. 7148 * 7149 * Besides the values listed in {@link OperationType}, any value equal or over 7150 * (1 << kExtensionTypeBits) is possible and should be interpreted 7151 * as an extension type according to {@link Model::extensionNameToPrefix}. 7152%/kind 7153%kind hal_1.2+ 7154 * The data type. 7155 * 7156 * Besides the values listed in {@link OperandType}, any value above 7157 * {@link OperandTypeRange::BASE_MAX} is possible and should be interpreted 7158 * as an extension type according to {@link Model::extensionNameToPrefix}. 7159%/kind 7160%kind hal_1.0 7161 * Data type of the operand. 7162%/kind 7163 */ 7164 OperandType type%{init_pod}; 7165 7166 /** 7167 * Dimensions of the operand. 7168 * 7169 * For a scalar operand, dimensions.size() must be 0. 7170%kind hal_1.0 7171 * 7172 * For a tensor operand, dimensions.size() must be at least 1; 7173 * however, any of the dimensions may be unspecified. 7174%/kind 7175 * 7176 * A tensor operand with all dimensions specified has "fully 7177 * specified" dimensions. Whenever possible (i.e., whenever the 7178 * dimensions are known at model construction time), a tensor 7179 * operand should have (but is not required to have) fully 7180 * specified dimensions, in order to enable the best possible 7181 * performance. 7182 * 7183 * If a tensor operand's dimensions are not fully specified, the 7184 * dimensions of the operand are deduced from the operand 7185 * dimensions and values of the operation for which that operand 7186%kind hal_1.0 hal_1.1 hal_1.2 7187 * is an output. 7188%else 7189 * is an output or from the corresponding {@link OperationType::IF} or 7190 * {@link OperationType::WHILE} operation input operand dimensions in the 7191 * case of referenced subgraph input operands. 7192%/kind 7193 * 7194 * In the following situations, a tensor operand's dimensions must 7195 * be fully specified: 7196 * 7197%kind canonical 7198 * %{li} The operand has lifetime CONSTANT_COPY, CONSTANT_REFERENCE, or 7199 * POINTER. 7200%else 7201 * %{li} The operand has lifetime CONSTANT_COPY or 7202 * CONSTANT_REFERENCE. 7203%/kind 7204 * 7205%kind hal_1.0 7206 * %{li} The operand has lifetime MODEL_INPUT or MODEL_OUTPUT. Fully 7207 * specified dimensions must either be present in the 7208%/kind 7209%kind hal_1.2 7210 * %{li} The operand has lifetime MODEL_INPUT. Fully 7211 * specified dimensions must either be present in the 7212%/kind 7213%kind canonical hal_1.3+ 7214 * %{li} The operand has lifetime SUBGRAPH_INPUT and belongs to the main 7215 * subgraph. Fully specified dimensions must either be present in the 7216%/kind 7217 * Operand or they must be provided in the corresponding 7218 * RequestArgument. 7219%kind hal_1.0 7220 * EXCEPTION: If the input or output is optional and omitted 7221%else 7222 * EXCEPTION: If the input is optional and omitted 7223%/kind 7224 * (by setting the hasNoValue field of the corresponding 7225 * RequestArgument to true) then it need not have fully 7226 * specified dimensions. 7227 * 7228 * A tensor operand with some number of unspecified dimensions is 7229 * represented by setting each unspecified dimension to 0. 7230%kind canonical hal_1.2+ 7231 * 7232 * A tensor operand with unspecified rank is represented by providing 7233 * an empty dimensions vector. 7234%/kind 7235 */ 7236 %{Dimensions} dimensions; 7237%kind hal* 7238 7239 /** 7240 * The number of times this operand appears as an operation input. 7241 * 7242 * (For example, if this operand appears once in one operation's 7243 * input list, and three times in another operation's input list, 7244 * then numberOfConsumers = 4.) 7245 */ 7246 uint32_t numberOfConsumers; 7247%/kind 7248 7249 /** 7250 * Quantized scale of the operand. 7251 * 7252%kind hal_1.0 7253 * Only applicable if the operand is of type TENSOR_QUANT8_ASYMM or 7254 * TENSOR_INT32. 7255%else 7256 * Must be 0 when not applicable to an operand type. 7257 * 7258 * See {@link OperandType}. 7259%/kind 7260 */ 7261 float scale%{init_float}; 7262 7263 /** 7264 * Quantized zero-point offset of the operand. 7265 * 7266%kind hal_1.0 7267 * Only applicable if the operand is of type TENSOR_QUANT8_ASYMM. 7268%else 7269 * Must be 0 when not applicable to an operand type. 7270 * 7271 * See {@link OperandType}. 7272%/kind 7273 */ 7274 int32_t zeroPoint%{init_int}; 7275 7276 /** 7277 * How the operand is used. 7278 */ 7279 %{concat_or_skip_first Operand LifeTime} lifetime%{init_pod}; 7280 7281 /** 7282 * Where to find the data for this operand. 7283%kind hal_1.0 hal_1.1 hal_1.2 7284 * If the lifetime is TEMPORARY_VARIABLE, MODEL_INPUT, MODEL_OUTPUT, or 7285 * NO_VALUE: 7286%else 7287 * If the lifetime is TEMPORARY_VARIABLE, SUBGRAPH_INPUT, SUBGRAPH_OUTPUT, 7288 * or NO_VALUE: 7289%/kind 7290 * - All the fields must be 0. 7291 * If the lifetime is CONSTANT_COPY: 7292%insert location_pointer_is_null 7293 * - location.poolIndex is 0. 7294 * - location.offset is the offset in bytes into Model%{::}operandValues. 7295 * - location.length is set. 7296%kind canonical 7297 * - location.padding is 0. 7298%/kind 7299 * If the lifetime is CONSTANT_REFERENCE: 7300%insert location_pointer_is_null 7301 * - location.poolIndex is set. 7302 * - location.offset is the offset in bytes into the specified pool. 7303 * - location.length is set. 7304%kind canonical 7305 * - location.padding is set. 7306%/kind 7307%kind canonical hal_1.3+ 7308 * If the lifetime is SUBGRAPH: 7309%insert location_pointer_is_null 7310 * - location.poolIndex is 0. 7311 * - location.offset is the index of the referenced subgraph in 7312 * {@link Model::referenced}. 7313 * - location.length is 0. 7314%/kind 7315%kind canonical 7316 * - location.padding is 0. 7317%/kind 7318%kind canonical 7319 * If the lifetime is POINTER: 7320 * - location.pointer is non-null. 7321 * - location.poolIndex is 0. 7322 * - location.offset is 0. 7323 * - location.length is set. 7324 * - location.padding is 0. 7325%/kind 7326 */ 7327 DataLocation location; 7328%kind hal_1.2 7329 7330%insert-indented 4 ExtraParams_Comment 7331 safe_union ExtraParams { 7332%insert-indented 8 ExtraParams_none_Comment 7333 Monostate none; 7334 7335%insert-indented 8 ExtraParams_channelQuant_Comment 7336 SymmPerChannelQuantParams channelQuant; 7337 7338%insert-indented 8 ExtraParams_extension_Comment 7339 vec<uint8_t> extension; 7340 } extraParams; 7341%/kind 7342%kind canonical hal_1.3 7343 7344%insert-indented 4 ExtraParams_Comment 7345 %{concat_or_skip_first @1.2::Operand. ExtraParams} extraParams; 7346%/kind 7347}; 7348%/section 7349 7350%kind canonical 7351%define OperandValues OperandValues 7352%define SharedMemory SharedMemory 7353%else 7354%define OperandValues vec<uint8_t> 7355%define SharedMemory memory 7356%/kind 7357 7358%section Model_1.0 7359 /** 7360 * A byte buffer containing operand data that were copied into the model. 7361 * 7362 * An operand's value must be located here if and only if Operand::lifetime 7363 * equals %{OperandLifeTime}::CONSTANT_COPY. 7364 */ 7365 %{OperandValues} operandValues; 7366 7367 /** 7368 * A collection of shared memory pools containing operand values. 7369 * 7370 * An operand's value must be located here if and only if Operand::lifetime 7371 * equals %{OperandLifeTime}::CONSTANT_REFERENCE. 7372 */ 7373 %{vec}<%{SharedMemory}> pools; 7374%/section 7375 7376%section Model_1.1 7377 /** 7378 * 'true' indicates TENSOR_FLOAT32 may be calculated with range and/or 7379 * precision as low as that of the IEEE 754 16-bit floating-point format. 7380 * 'false' indicates TENSOR_FLOAT32 must be calculated using at least the 7381 * range and precision of the IEEE 754 32-bit floating-point format. 7382 */ 7383 bool relaxComputationFloat32toFloat16%{init_bool}; 7384%/section 7385 7386%section Model_1.2 7387 /** 7388 * The mapping between extension names and prefixes of operand and 7389 * operation type values. 7390 * 7391%kind canonical 7392 * An operand or operation whose numeric type value is equal to or greater 7393 * than (1 << kExtensionTypeBits) should be interpreted 7394%/kind 7395%kind hal* 7396 * An operand or operation whose numeric type value is above 7397 * {@link OperandTypeRange::BASE_MAX} or 7398 * {@link OperationTypeRange::BASE_MAX} respectively should be interpreted 7399%/kind 7400 * as an extension operand. The low 7401%kind hal_1.2 7402 * {@link Model::ExtensionTypeEncoding::LOW_BITS_TYPE} bits of the value 7403 * correspond to the type ID within the extension and the high 7404 * {@link Model::ExtensionTypeEncoding::HIGH_BITS_PREFIX} bits encode 7405%/kind 7406%kind hal_1.3 7407 * {@link @1.2::Model::ExtensionTypeEncoding::LOW_BITS_TYPE} bits of the 7408 * value correspond to the type ID within the extension and the high 7409 * {@link @1.2::Model::ExtensionTypeEncoding::HIGH_BITS_PREFIX} bits encode 7410%/kind 7411%kind canonical 7412 * {@link kExtensionTypeBits} bits of the value correspond to the type ID 7413 * within the extension and the high {@link kExtensionPrefixBits} bits encode 7414%/kind 7415 * the "prefix", which maps uniquely to the extension name. 7416 * 7417 * For example, if a model contains an operation whose value is 7418 * 0xAAAABBBB and extensionNameToPrefix contains an entry with 7419 * prefix=0xAAAA and name="vendor.test.test_extension", then 7420 * the operation should be interpreted as the operation 0xBBBB 7421 * of the extension named vendor.test.test_extension. 7422 * 7423 * This is a one-to-one correspondence. That is, there must be at most one 7424 * prefix corresponding to each extension name and at most one extension 7425 * name corresponding to each prefix. 7426 */ 7427%kind hal_1.3 7428 %{vec}<@1.2::Model.ExtensionNameAndPrefix> extensionNameToPrefix; 7429%else 7430 %{vec}<ExtensionNameAndPrefix> extensionNameToPrefix; 7431%/kind 7432%/section 7433 7434%section Model_1.3_main_and_referenced_subgraphs 7435 /** 7436 * The top-level subgraph. 7437 */ 7438 Subgraph main; 7439 7440 /** 7441 * Referenced subgraphs. 7442 * 7443 * Each subgraph is referenced by the main subgraph or at least one other 7444 * referenced subgraph. 7445 * 7446 * There must be no reference cycles. 7447 */ 7448 %{vec}<Subgraph> referenced; 7449%/section 7450 7451%section Subgraph_fields 7452 /** 7453 * All operands included in the %{model_or_subgraph}. 7454 */ 7455 %{vec}<Operand> operands; 7456 7457 /** 7458 * All operations included in the %{model_or_subgraph}. 7459 * 7460 * The operations are sorted into execution order. Every operand 7461 * with lifetime %{MODEL_or_SUBGRAPH}_OUTPUT or TEMPORARY_VARIABLE must be 7462 * written before it is read. 7463 */ 7464 %{vec}<Operation> operations; 7465 7466 /** 7467 * Input indexes of the %{model_or_subgraph}. There must be at least one. 7468 * 7469 * Each value corresponds to the index of the operand in "operands". 7470 */ 7471 %{vec}<uint32_t> inputIndexes; 7472 7473 /** 7474 * Output indexes of the %{model_or_subgraph}. There must be at least one. 7475 * 7476 * Each value corresponds to the index of the operand in "operands". 7477 */ 7478 %{vec}<uint32_t> outputIndexes; 7479%/section 7480 7481%section Subgraph 7482/** 7483 * An excerpt of the execution graph. 7484 */ 7485struct Subgraph { 7486%insert Subgraph_fields 7487}; 7488%/section 7489 7490%section ExtensionNameAndPrefix 7491/** 7492 * A correspondence between an extension name and a prefix of operand and 7493 * operation type values. 7494 */ 7495struct ExtensionNameAndPrefix { 7496 /** 7497 * The extension name. 7498 * 7499 * See {@link Extension::name} for the format specification. 7500 */ 7501 %{string} name; 7502 7503 /** 7504 * The unique extension identifier within the model. 7505 * 7506 * See {@link Model::extensionNameToPrefix}. 7507 */ 7508 uint16_t prefix%{init_int}; 7509}; 7510%/section 7511 7512%section ExtensionTypeEncoding 7513/** 7514 * Numeric values of extension operand and operation types have the 7515 * following structure: 7516 * - 16 high bits represent the "prefix", which corresponds uniquely to the 7517 * extension name. 7518 * - 16 low bits represent the type ID within the extension. 7519 */ 7520%kind canonical 7521constexpr uint8_t kExtensionTypeBits = 16; 7522constexpr uint8_t kExtensionPrefixBits = 16; 7523constexpr uint32_t kTypeWithinExtensionMask = 0xFFFF; 7524%else 7525enum ExtensionTypeEncoding : uint8_t { 7526 HIGH_BITS_PREFIX = 16, 7527 LOW_BITS_TYPE = 16, 7528}; 7529%/kind 7530%/section 7531 7532%section Model 7533/** 7534 * A Neural Network Model. 7535 * 7536 * This includes not only the execution graph, but also constant data such as 7537 * weights or scalars added at construction time. The only information that 7538%kind hal_1.0 7539 * might not be known is the shape of the input tensors. 7540%else 7541 * may not be known is the shape of the input tensors. 7542%/kind 7543 */ 7544struct Model { 7545%kind canonical 7546%insert-indented 4 Subgraph 7547 7548 class OperandValues { 7549 public: 7550 OperandValues(); 7551 OperandValues(const uint8_t* data, size_t length); 7552 7553 // Append a segment of memory (starting at `data` with `length` number of bytes) to the back 7554 // of `OperandValues`, adding padding as necessary so that the appended data is aligned. 7555 // Refer to `getAlignmentForLength` for more information on alignment (such as what the 7556 // current alignments are for different data lengths). 7557 DataLocation append(const uint8_t* data, size_t length); 7558 7559 const uint8_t* data() const; 7560 size_t size() const; 7561 7562 private: 7563 std::vector<uint8_t> mData; 7564 }; 7565 7566%insert-indented 4 ExtensionNameAndPrefix 7567 7568%insert Model_1.3_main_and_referenced_subgraphs 7569 7570%insert Model_1.0 7571 7572%insert Model_1.1 7573 7574%insert Model_1.2 7575%/kind 7576%kind hal_1.0 7577%insert Subgraph_fields 7578 7579%insert Model_1.0 7580%/kind 7581%kind hal_1.1 7582%insert Subgraph_fields 7583 7584%insert Model_1.0 7585 7586%insert Model_1.1 7587%/kind 7588%kind hal_1.2 7589%insert Subgraph_fields 7590 7591%insert Model_1.0 7592 7593%insert Model_1.1 7594 7595%insert Model_1.2 7596 7597%insert-indented 4 ExtensionNameAndPrefix 7598 7599%insert-indented 4 ExtensionTypeEncoding 7600%/kind 7601%kind hal_1.3 7602%insert Model_1.3_main_and_referenced_subgraphs 7603 7604%insert Model_1.0 7605 7606%insert Model_1.1 7607 7608%insert Model_1.2 7609%/kind 7610}; 7611%/section 7612 7613%section BufferDesc 7614/** 7615 * A buffer descriptor. Describes the properties of a buffer. 7616 */ 7617struct BufferDesc { 7618 /** 7619 * Dimensions of the buffer. May have unknown dimensions or rank. A buffer with some number 7620 * of unspecified dimensions is represented by setting each unspecified dimension to 0. A 7621 * buffer with unspecified rank is represented by providing an empty dimensions vector. 7622 */ 7623 %{Dimensions} dimensions; 7624}; 7625%/section 7626 7627%section BufferRole 7628/** 7629 * Describes a role of an input or output to a prepared model. 7630 */ 7631struct BufferRole { 7632 /** 7633 * The index of the IPreparedModel within the "preparedModel" argument passed in 7634 * IDevice::allocate. 7635 */ 7636 uint32_t modelIndex%{init_int}; 7637 7638 /** 7639 * The index of the input or output operand. 7640 */ 7641 uint32_t ioIndex%{init_int}; 7642 7643 /** 7644 * A floating-point value within the range (0.0, 1.0]. Describes how likely the 7645 * buffer is to be used in the specified role. This is provided as a hint to 7646 * optimize the case when multiple roles prefer different buffer locations or data 7647 * layouts. 7648 */ 7649%kind canonical 7650 float probability%{init_float}; 7651%else 7652 float frequency%{init_float}; 7653%/kind 7654}; 7655%/section 7656 7657%kind canonical 7658%define inputIndexes Model::main::inputIndexes 7659%define outputIndexes Model::main::outputIndexes 7660%/kind 7661%kind hal_1.3 7662%define inputIndexes Model.main.inputIndexes 7663%define outputIndexes Model.main.outputIndexes 7664%/kind 7665%kind hal_1.0 hal_1.1 hal_1.2 7666%define inputIndexes Model.inputIndexes 7667%define outputIndexes Model.outputIndexes 7668%/kind 7669%kind ndk 7670%define inputIndexes @@@NOT_DEFINED@@@ 7671%define outputIndexes @@@NOT_DEFINED@@@ 7672%/kind 7673 7674%kind canonical 7675%define inputs inputs 7676%define outputs outputs 7677%else 7678%define inputs input 7679%define outputs output 7680%/kind 7681 7682%section Request_inputs_and_outputs 7683 /** 7684 * Input data and information to be used in the execution of a prepared 7685 * model. 7686 * 7687 * The index of the input corresponds to the index in %{inputIndexes}. 7688 * E.g., %{inputs}[i] corresponds to %{inputIndexes}[i]. 7689 */ 7690 %{vec}<%{concat_or_skip_first Request Argument}> inputs; 7691 7692 /** 7693 * Output data and information to be used in the execution of a prepared 7694 * model. 7695 * 7696 * The index of the output corresponds to the index in %{outputIndexes}. 7697 * E.g., %{outputs}[i] corresponds to %{outputIndexes}[i]. 7698 */ 7699 %{vec}<%{concat_or_skip_first Request Argument}> outputs; 7700%/section 7701 7702%section Request_pools 7703 /** 7704%kind hal_1.0 7705 * A collection of shared memory pools containing operand data for both the 7706%else 7707 * A collection of memory pools containing operand data for both the 7708%/kind 7709 * inputs and the outputs to a model. 7710 */ 7711%kind hal_1.0 7712 vec<memory> pools; 7713%else 7714 %{vec}<MemoryPool> pools; 7715%/kind 7716%/section 7717 7718%section Request_MemoryPool_Comment 7719/** 7720 * A memory pool. 7721 */ 7722%/section 7723 7724%section RequestArgument 7725/** 7726 * Metadata information specifying the location of the input or output data and 7727 * any updates to the input or output operand. 7728 */ 7729struct %{concat_or_skip_first Request Argument} { 7730%kind canonical 7731 enum class LifeTime { 7732 POOL = 0, 7733 NO_VALUE = 1, 7734 POINTER = 2, 7735 }; 7736 7737%/kind 7738%kind hal_1.0 7739 /** 7740 * If true, the argument does not have a value. This can be used for 7741 * operations that take optional arguments. If true, the fields of location 7742 * are set to 0 and the dimensions vector is left empty. 7743 */ 7744 bool hasNoValue; 7745%/kind 7746%kind canonical 7747 LifeTime lifetime%{init_pod}; 7748%/kind 7749 7750 /** 7751 * The location within one of the memory pools passed in the Request. 7752 */ 7753 DataLocation location; 7754 7755 /** 7756 * Updated dimension information. 7757 * 7758 * If dimensions.size() > 0, dimension information was provided 7759 * along with the argument. This can be the case for models that 7760 * accept inputs of varying size. This can't change the rank, just 7761 * the value of the dimensions that were unspecified in the 7762 * model. If dimensions.size() > 0, then all dimensions must be 7763 * specified here; and any dimension that was specified in the 7764 * model must have the same value here. 7765 * 7766 * If the dimensions in the model are not fully specified, then 7767 * they must be fully specified here, unless hasNoValue is set to 7768 * true. If the dimensions in the model are fully specified, then 7769 * either dimensions.size() may be 0, or the dimensions in the 7770 * model must be identical to the dimensions here. 7771 */ 7772 %{Dimensions} dimensions; 7773}; 7774%/section 7775 7776%section Request 7777/** 7778 * Inputs to be sent to and outputs to be retrieved from a prepared model. 7779 * 7780 * A Request serves two primary tasks: 7781 * 1) Provides the input and output data to be used when executing the model. 7782 * 2) Specifies any updates to the input operand metadata that were left 7783 * unspecified at model preparation time. 7784 * 7785 * An output must not overlap with any other output, with an input, or 7786 * with an operand of lifetime CONSTANT_REFERENCE. 7787 */ 7788struct Request { 7789%kind canonical 7790%insert-indented 4 RequestArgument 7791 7792 /** 7793 * Specifies a driver-managed buffer. It is the token corresponding to an 7794 * IBuffer returned from IDevice::allocate, and is specific to the IDevice 7795 * object. 7796 */ 7797 enum class MemoryDomainToken : uint32_t {}; 7798 7799%insert-indented 4 Request_MemoryPool_Comment 7800 using MemoryPool = std::variant<SharedMemory, MemoryDomainToken, SharedBuffer>; 7801 7802%/kind 7803%insert Request_inputs_and_outputs 7804%kind hal_1.3 7805 7806%insert-indented 4 Request_MemoryPool_Comment 7807 safe_union MemoryPool { 7808 /** 7809 * Specifies a client-managed shared memory pool. 7810 */ 7811 memory hidlMemory; 7812 7813 /** 7814 * Specifies a driver-managed buffer. It is the token returned from IDevice::allocate, 7815 * and is specific to the IDevice object. 7816 */ 7817 uint32_t token; 7818 }; 7819%/kind 7820 7821%insert Request_pools 7822}; 7823%/section 7824 7825%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 7826