summaryrefslogtreecommitdiff
path: root/runtimes/include/NeuralNetworksEx.h
blob: 601bb2cf7c3e5e7fe7857740f666ec4a682f6f66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
/*
 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @file     NeuralNetworksEx.h
 * @brief    This file contains ANeuralNetworksModel_addOperationEx function definition
 * @note     This header describes experimental feature,
 *           so specification here can be changed or/and removed
 */
#ifndef NN_RUNTIME_NEURAL_NETWORKS_EX_H
#define NN_RUNTIME_NEURAL_NETWORKS_EX_H

#include <sys/cdefs.h>

__BEGIN_DECLS

/**
 * @brief Extended operation types
 */
typedef enum {
  /** extends operation. */

  /**
   * Casts a tensor/tensor-values to a new type
   *
   * The output value is calucated as:
   *
   *     output =  new_type(input)
   *
   * Ex:
   * X = {1.8,2.2}, dtype of X = float32
   * Y = Cast(X), dtype of Y = int32
   * then Y = {1,2}
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_FLOAT32}
   * * {@link ANEURALNETWORKS_TENSOR_INT32}
   * * {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM}
   *
   * Supported tensor rank: up to 4
   *
   * Inputs:
   * * 0: An n-D tensor, specifying the first input.
   *
   * Outputs:
   * * 0: The output tensor, of the same {@link OperandCode} and shape as input0.
   */
  ANEURALNETWORKS_CAST_EX = 50000,

  /**
   * Gathers values along an axis.
   *
   * Produces an output tensor with shape
   *     input0.dimension[:axis] + indices.dimension + input0.dimension[axis + 1:]
   * where:
   *     # Vector indices (output is rank(input0)).
   *     output[a_0, ..., a_n, i, b_0, ..., b_n] =
   *       input0[a_0, ..., a_n, indices[i], b_0, ..., b_n]
   *
   *     # Higher rank indices (output is rank(input0) + rank(indices) - 1).
   *     output[a_0, ..., a_n, i, ..., j, b_0, ... b_n] =
   *       input0[a_0, ..., a_n, indices[i, ..., j], b_0, ..., b_n]
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_FLOAT32}
   * * {@link ANEURALNETWORKS_TENSOR_INT32}
   * * {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM}
   *
   * Supported tensor rank: from 1
   *
   * Inputs:
   * * 0: An n-D tensor from which to gather values.
   * * 1: A k-D tensor {@link ANEURALNETWORKS_TENSOR_INT32} of indices.
   *      The values must be in the bounds of the corresponding dimensions
   *      of input0.
   * * 2: An {@link ANEURALNETWORKS_INT32} scalar specifying the axis.
   *      Negative index is used to specify axis from the end
   *      (e.g. -1 for the last axis). Must be in the range [-n, n).
   *
   * Outputs:
   * * 0: An (n + k - 1)-D tensor with the same {@link OperandCode} as input0.
   */
  ANEURALNETWORKS_GATHER_EX = 50001, /**< Gather slices according to indexes and axis */

  /**
   * Finds values and indices of the k largest entries for the last dimension.
   *
   * Resulting values in each dimensions are sorted in descending order. If
   * two values are equal, the one with larger index appears first.
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_FLOAT32}
   * * {@link ANEURALNETWORKS_TENSOR_INT32}
   * * {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM}
   *
   * Supported tensor rank: from 1
   *
   * Inputs:
   * * 0: input, an n-D tensor specifying the input.
   * * 1: k, an {@link ANEURALNETWORKS_INT32} scalar, specifying the number of
   *      top elements to look for along the last dimension.
   *
   * Outputs:
   * * 0: An n-D tensor of the same type as the input, containing the k
   *      largest elements along each last dimensional slice.
   * * 1: An n-D tensor of type {@link ANEURALNETWORKS_TENSOR_INT32}
   *      containing the indices of values within the last dimension of input.
   */
  ANEURALNETWORKS_TOPK_V2_EX = 50002,

  /**
   * Computes the maximum of elements across dimensions of a tensor.
   *
   * Reduces the input tensor along the given dimensions to reduce.
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_FLOAT32}
   * * {@link ANEURALNETWORKS_TENSOR_INT32}
   * * {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM}
   *
   * Supported tensor rank: up to 4
   *
   * Inputs:
   * * 0: A tensor, specifying the input.
   * * 1: A 1-D Tensor of {@link ANEURALNETWORKS_TENSOR_INT32}. The dimensions
   *      to reduce.
   *
   * Outputs:
   * * 0: A tensor of the same {@link OperandCode} as input0.
   */
  ANEURALNETWORKS_REDUCE_MAX_EX = 50003,

  /**
   * Splits a tensor along a given axis into num_splits subtensors.
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_FLOAT32}
   * * {@link ANEURALNETWORKS_TENSOR_INT32}
   * * {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM}
   *
   * Supported tensor rank: from 1
   *
   * Inputs:
   * * 0: An n-D tensor to split.
   * * 1: An {@link ANEURALNETWORKS_INT32} scalar specifying the axis along
   *      which to split.
   * * 2: An {@link ANEURALNETWORKS_INT32} scalar indicating the number of
   *      splits along given axis. Must evenly divide axis size.
   *
   * Outputs:
   * * 0 ~ (num_splits - 1): Resulting subtensors.
   */
  ANEURALNETWORKS_SPLIT_EX = 50004, /**< Splits a tensor into sub tensors */

  /**
   * Computes element-wise reciprocal of square root of the input tensor.
   *
   * The output is calculated using this formula:
   *
   *      output = 1/sqrt(input)
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_FLOAT32}
   *
   * Supported tensor rank: up to 4
   *
   * Inputs:
   * * 0: An n-D tensor, specifying the first input.
   *
   * Outputs:
   * * 0: The output tensor, of the same {@link OperandCode} and shape as input0.
   */
  ANEURALNETWORKS_RSQRT_EX = 50005,

  /**
   * Computes element-wise squared difference on the input tensors.
   *
   * Takes two input tensors of identical {@link OperandCode} and compatible dimensions.
   * The output is the result of squaring of difference given by subtracting the second input tensor
   * from the first one.
   *
   * Two dimensions are compatible when:
   *     1. they are equal, or
   *     2. one of them is 1
   *
   * The size of the output is the maximum size along each dimension of the
   * input operands. It starts with the trailing dimensions, and works its way
   * forward.
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_FLOAT32}
   *
   * Supported tensor rank: up to 4
   *
   * Inputs:
   * * 0: An n-D tensor, specifying the first input.
   * * 1: A tensor of the same {@link OperandCode}, and compatible dimensions
   *      as input0.
   *
   * Outputs:
   * * 0: The output tensor, of the same {@link OperandCode} as input0.
   */
  ANEURALNETWORKS_SQUARED_DIFFERENCE_EX = 50006,

  /**
   * Computes numerical negative value element-wise on the input tensor.
   *
   * Given an input tensor of {@link OperandCode},
   * The output is the numerical negative value element-wise on the input tensor.
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_FLOAT32}
   * * {@link ANEURALNETWORKS_TENSOR_INT32}
   *
   * Supported tensor rank: up to 4
   *
   * Inputs:
   * * 0: An n-D tensor, specifying the input.
   *
   * Outputs:
   * * 0: The output tensor, of the same {@link OperandCode} and shape as input0.
   */
  ANEURALNETWORKS_NEG_EX = 50007,

  /**
   * Computes exponential value element-wise on the input tensor.
   *
   * Given an input tensor of {@link OperandCode},
   * The output is the exponential value element-wise on the input tensor.
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_FLOAT32}
   *
   * Supported tensor rank: up to 4
   *
   * Inputs:
   * * 0: An n-D tensor, specifying the input.
   *
   * Outputs:
   * * 0: The output tensor, of the same {@link OperandCode} and shape as input0.
   */
  ANEURALNETWORKS_EXP_EX = 50008,

  /**
   * Computes the sum of elements across dimensions of a tensor.
   *
   * Reduces the input tensor along the given dimensions to reduce.
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_FLOAT32}
   *
   * Supported tensor rank: up to 4
   *
   * Inputs:
   * * 0: A tensor, specifying the input.
   * * 1: A 1-D Tensor of {@link ANEURALNETWORKS_TENSOR_INT32}. The dimensions
   *      to reduce.
   *
   * Outputs:
   * * 0: A tensor of the same {@link OperandCode} as input0.
   */
  ANEURALNETWORKS_REDUCE_SUM_EX = 50009,

  /**
   * A transposed convolutional layer carries out a regular convolution
   * but reverts its spatial transformation.
   * Transpose convolution basically performs convolution with transposed weights.
   *
   * Supported tensor {@link OperandCode}:
   * {@link ANEURALNETWORKS_TENSOR_FLOAT32}
   * {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM}
   *
   * Supported tensor rank: only 4
   *
   * Inputs:
   *   0: An {@link ANEURALNETWORKS_INT32} 1-D four element tensor, specifying the output shape.
   *   1: A 4-D tensor, of shape [depth_out, filter_height, filter_width, depth_in],
   *      specifying the filter.
   *   2: A 4-D tensor, of shape [batches, height, width, depth_in], specifying the input.
   *   3: An {@link ANEURALNETWORKS_INT32} scalar, specifying the padding type.
   *   4: An {@link ANEURALNETWORKS_INT32} scalar, specifying the stride when
   *      walking through input in the ‘width’ dimension.
   *   5: An {@link ANEURALNETWORKS_INT32} scalar, specifying the stride when
   *      walking through input in the height dimension.
   *
   * Outputs:
   *   0: The output 4-D tensor, of shape [batches, out_height, out_width, depth_out].
   */
  ANEURALNETWORKS_TRANSPOSE_CONV_EX = 50010,

  /**
   * Computes element-wise truth value by comparing the two input tensors for equality.
   *
   * Takes two input tensors of identical {@link OperandCode} and compatible dimensions.
   * The output is the result of comparison of two input tensors.
   *
   * Two dimensions are compatible when:
   *     1. they are equal, or
   *     2. one of them is 1
   *
   * The size of the output is the maximum size along each dimension of the
   * input operands. It starts with the trailing dimensions, and works its way
   * forward.
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_FLOAT32}
   * * {@link ANEURALNETWORKS_TENSOR_INT32}
   * * {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM}
   *
   * Supported tensor rank: up to 4
   *
   * Inputs:
   * * 0: An n-D tensor, specifying the first input.
   * * 1: A tensor of the same {@link OperandCode}, and compatible dimensions
   *      as input0.
   *
   * Outputs:
   * * 0: A boolean tensor indicating the truth value of (x == y)
   *      Stored as {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM} with offset 0
   *      and scale 1.0f.
   *      A non-zero byte represents True, a hit. A zero indicates otherwise.
   */
  ANEURALNETWORKS_EQUAL_EX = 50011,

  /**
   * Computes element-wise absolute value of the input tensor.
   *
   * The output is calculated using this formula:
   *
   *      output = fabs(input)
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_FLOAT32}
   * * {@link ANEURALNETWORKS_TENSOR_INT32}
   *
   * Supported tensor rank: up to 4
   *
   * Inputs:
   * * 0: An n-D tensor, specifying the first input.
   *
   * Outputs:
   * * 0: The output tensor, of the same {@link OperandCode} and shape as input0.
   */
  ANEURALNETWORKS_ABS_EX = 50012,
  /**
   * Packs a list of rank-R tensors into one rank- (R+1) tensor along the axis dimension.
   *
   * The input tensors must have identical {@link OperandCode} and the same
   * dimensions.
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_FLOAT32}
   * * {@link ANEURALNETWORKS_TENSOR_INT32}
   * * {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM}
   *
   * Supported tensor rank: up to 3
   *
   * Inputs:
   * * 0 ~ n-1: The list of n input tensors, of shape
   *            [D0, D1, ..., Daxis(i), ..., Dm]. For inputs of
   *            {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM}, all input tensors
   *            must have the same scale and zeroPoint.
   * * n: An {@link ANEURALNETWORKS_INT32} scalar, specifying the
   *      number of input tensors.
   * * n+1: An {@link ANEURALNETWORKS_INT32} scalar, specifying the
   *        pack axis.
   *
   * Outputs:
   * * 0: The output, a tensor of the same {@link OperandCode} as the input
   *      tensors. The output shape is [D0, D1, ..., N at Daxis(i), ..., Dm+1]
   *      where N is the number of tensors to be packed.
   */
  ANEURALNETWORKS_PACK_EX = 50013,
  /**
   * Unpacks a given rank-R tensors into num_splits rank- (R-1) tensors along the axis dimension.
   * num_splits has to respect integral divisibility of dimension value along axis dimension
   * of the input.
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_FLOAT32}
   * * {@link ANEURALNETWORKS_TENSOR_INT32}
   * * {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM}
   *
   * Supported tensor rank: up to 4
   *
   * Inputs:
   * * 0: The input shape is [D0, D1, ..., N at Daxis(i), ..., Dm+1].
   * * 1: An {@link ANEURALNETWORKS_INT32} scalar, specifying the
   *      number of splits along unpack axis.
   * * 2: An {@link ANEURALNETWORKS_INT32} scalar, specifying the
   *      unpack axis.
   *
   * Outputs:
   * * 0 ~ n-1: The list of n output tensors, of shape
   *            [D0, D1, ..., Daxis(i), ..., Dm]. The output tensors are of the same
   *            {@link OperandCode} as the input tensor 0.
   */
  ANEURALNETWORKS_UNPACK_EX = 50014,

  /**
   * Returns the index of the largest element along an axis.
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_FLOAT32}
   * * {@link ANEURALNETWORKS_TENSOR_INT32}
   * * {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM}
   *
   * Supported tensor rank: from 1
   *
   * Inputs:
   * * 0: An n-D tensor, specifying the input.
   * * 1: An {@link ANEURALNETWORKS_INT32} scalar specifying the axis to
   *      reduce across. Negative index is used to specify axis from the
   *      end (e.g. -1 for the last axis). Must be in the range [-n, n).
   *
   * Outputs:
   * * 0: An (n - 1)-D {@link ANEURALNETWORKS_TENSOR_INT32} tensor.
   */
  ANEURALNETWORKS_ARGMAX_EX = 50015,

  /**
   * Element-wise square root computation of the input tensor.
   *
   * The output is calculated using this formula:
   *
   *     output = sqrt(input)
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_FLOAT32}
   *
   * Supported tensor rank: up to 4
   *
   * Inputs:
   * * 0: An n-D tensor, specifying the first input.
   *
   * Outputs:
   * * 0: The output tensor, of the same {@link OperandCode} and shape as input0.
   */
  ANEURALNETWORKS_SQRT_EX = 50016,

  /**
  * Computes element-wise truth value by comparing the input tensors for non-equality.
  *
  * Takes two input tensors of identical {@link OperandCode} and compatible dimensions.
  * The output is the result of comparison of two input tensors.
  *
  * Two dimensions are compatible when:
  *     1. they are equal, or
  *     2. one of them is 1
  *
  * The size of the output is the maximum size along each dimension of the
  * input operands. It starts with the trailing dimensions, and works its way
  * forward.
  *
  * Supported tensor {@link OperandCode}:
  * * {@link ANEURALNETWORKS_TENSOR_FLOAT32}
  * * {@link ANEURALNETWORKS_TENSOR_INT32}
  * * {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM}
  *
  * Supported tensor rank: up to 4
  *
  * Inputs:
  * * 0: An n-D tensor, specifying the first input.
  * * 1: A tensor of the same {@link OperandCode}, and compatible dimensions
  *      as input0.
  *
  * Outputs:
  * * 0: A boolean tensor indicating the truth value of non-equality of input tensors
  *      Stored as {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM} with offset 0
  *      and scale 1.0f.
  *      A non-zero byte represents True, a hit. A zero indicates otherwise.
  */
  ANEURALNETWORKS_NOT_EQUAL_EX = 50017,

  /**
   * Computes element-wise truth value of the input tensor negation.
   *
   * Takes one input tensor.
   * The output is the negation, which is logical complement, of the input tensor.
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM}
   *
   * Supported tensor rank: up to 4
   *
   * Inputs:
   * * 0: An n-D boolean tensor, specifying the input.
   *      Stored as {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM} with offset 0
   *      and scale 1.0f.
   *      A non-zero byte represents True. A zero indicates otherwise.
   *
   * Outputs:
   * * 0: A boolean tensor of the same size as input indicating the truth value of (NOT x)
   *      Stored as {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM} with offset 0
   *      and scale 1.0f.
   *      A non-zero byte represents True. A zero indicates otherwise.
   */
  ANEURALNETWORKS_LOGICAL_NOT_EX = 50018,

  /**
   * Computes element-wise truth value of two input tensors for LOGICAL AND.
   *
   * Takes two input tensors of identical {@link OperandCode} and compatible dimensions.
   * The output is the result of comparison of two input tensors.
   *
   * Two dimensions are compatible when:
   *     1. they are equal, or
   *     2. one of them is 1
   *
   * The size of the output is the maximum size along each dimension of the
   * input operands. It starts with the trailing dimensions, and works its way
   * forward.
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM}
   *
   * Supported tensor rank: up to 4
   *
   * Inputs:
   * * 0: An n-D boolean tensor, specifying the first input.
   *      Stored as {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM} with offset 0
   *      and scale 1.0f.
   *      A non-zero byte represents True, a hit. A zero indicates otherwise.
   * * 1: A tensor of the same {@link OperandCode}, and compatible dimensions
   *      as input0.
   *
   * Outputs:
   * * 0: A boolean tensor indicating the truth value of two input tensors for LOGICAL AND.
   *      Stored as {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM} with offset 0
   *      and scale 1.0f.
   *      A non-zero byte represents True, a hit. A zero indicates otherwise.
   */
  ANEURALNETWORKS_LOGICAL_AND_EX = 50019,

  /**
   * Computes element-wise truth value of two input tensors for LOGICAL OR.
   *
   * Takes two input tensors of identical {@link OperandCode} and compatible dimensions.
   * The output is the result of comparison of two input tensors.
   *
   * Two dimensions are compatible when:
   *     1. they are equal, or
   *     2. one of them is 1
   *
   * The size of the output is the maximum size along each dimension of the
   * input operands. It starts with the trailing dimensions, and works its way
   * forward.
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM}
   *
   * Supported tensor rank: up to 4
   *
   * Inputs:
   * * 0: An n-D boolean tensor, specifying the first input.
   *      Stored as {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM} with offset 0
   *      and scale 1.0f.
   *      A non-zero byte represents True, a hit. A zero indicates otherwise.
   * * 1: A tensor of the same {@link OperandCode}, and compatible dimensions
   *      as input0.
   *
   * Outputs:
   * * 0: A boolean tensor indicating the truth value of two input tensors for LOGICAL OR.
   *      Stored as {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM} with offset 0
   *      and scale 1.0f.
   *      A non-zero byte represents True, a hit. A zero indicates otherwise.
   */
  ANEURALNETWORKS_LOGICAL_OR_EX = 50020,

  /**
   * Computes the minimum of elements across dimensions of a tensor.
   *
   * Reduces the input tensor along the given dimensions to reduce.
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_FLOAT32}
   * * {@link ANEURALNETWORKS_TENSOR_INT32}
   * * {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM}
   *
   * Supported tensor rank: up to 4
   *
   * Inputs:
   * * 0: A tensor, specifying the input.
   * * 1: A 1-D Tensor of {@link ANEURALNETWORKS_TENSOR_INT32}. The dimensions
   *      to reduce.
   *
   * Outputs:
   * * 0: A tensor of the same {@link OperandCode} as input0.
   */
  ANEURALNETWORKS_REDUCE_MIN_EX = 50021,

  /**
   * Parametric Rectified Linear Unit.
   *
   * It follows: f(x) = alpha * x for x < 0, f(x) = x for x >= 0, where alpha
   * is a learned array with the same {@link OperandCode} and compatible
   * dimensions as input x.
   *
   * Two dimensions are compatible when:
   *     1. they are equal, or
   *     2. one of them is 1
   *
   * The size of the output is the maximum size along each dimension of the
   * input operands. It starts with the trailing dimensions, and works its way
   * forward.
   *
   * Example:
   *     input.dimension  =    {4, 1, 2}
   *     alpha.dimension  = {5, 4, 3, 1}
   *     output.dimension = {5, 4, 3, 2}
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_FLOAT32}
   * * {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM}
   *
   * Supported tensor rank: up to 4
   *
   * Inputs:
   * * 0: A tensor, specifying the input.
   * * 1: A tensor of the same {@link OperandCode}, and compatible dimensions
   *      as input0, specifying the alpha.
   *
   * Outputs:
   * * 0: A tensor of the same {@link OperandCode} as input0.
   */
  ANEURALNETWORKS_PRELU_EX = 50022,

  /**
   * Returns a one-hot tensor.
   *
   * The locations represented by indices in indices take value on_value, while all other locations
   * take value off_value.
   * The on_value and off_value must have matching data types. They must be the same data type as
   * specified by the data type of output.
   *
   * If the input indices is rank N, the output will have rank N+1. The new axis is created at
   * dimension axis.
   * If indices is a scalar the output shape will be a vector of length depth.
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_FLOAT32}
   * * {@link ANEURALNETWORKS_TENSOR_INT32}
   *
   * Supported tensor rank: up to 4
   *
   * Inputs:
   * * 0: An {@link ANEURALNETWORKS_INT32} tensor, specifying the indices.
   * * 1: An {@link ANEURALNETWORKS_INT32} scalar, specifying the depth.
   * * 2: A scalar, specifying the on_value.
   * * 3: A scalar, specifying the off_value.
   * * 4: An {@link ANEURALNETWORKS_INT32} scalar, specifying the axis to fill. Optional.
   *      (default: -1, a new inner-most axis).
   *
   * Outputs:
   * * 0: The one-hot tensor.
   */
  ANEURALNETWORKS_ONE_HOT_EX = 50023,

  /**
   * For input tensors x and y, computes x >= y elementwise.
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_FLOAT32}
   * * {@link ANEURALNETWORKS_TENSOR_INT32}
   * * {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM}
   *
   * Supported tensor rank: from 1
   *
   * This operation supports broadcasting.
   *
   * Inputs:
   * * 0: A tensor.
   * * 1: A tensor of the same {@link OperandCode} and dimensions compatible
   *      with input0.
   *
   * Outputs:
   * * 0: A boolean tensor of {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM}
   *      with offset 0 and scale 1.0f.
   */
  ANEURALNETWORKS_GREATER_EQUAL_EX = 50024,

  /**
   * For input tensors x and y, computes x < y elementwise.
   *
   * Supported tensor {@link OperandCode}:
   * * {@link ANEURALNETWORKS_TENSOR_FLOAT32}
   * * {@link ANEURALNETWORKS_TENSOR_INT32}
   * * {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM}
   *
   * Supported tensor rank: from 1
   *
   * This operation supports broadcasting.
   *
   * Inputs:
   * * 0: A tensor.
   * * 1: A tensor of the same {@link OperandCode} and dimensions compatible
   *      with input0.
   *
   * Outputs:
   * * 0: A tensor of {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM}
   *      with offset 0 and scale 1.0f.
   */
  ANEURALNETWORKS_LESS_EX = 50025,
} OperationCodeEx; // extends OperationCode

typedef OperationCodeEx ANeuralNetworksOperationTypeEx;

/**
 * @brief Add an extended operation to a model.
 *
 * @param[in] model The model to be modified.
 * @param[in] type The type of extended operation.
 * @param[in] inputCount The number of entries in the inputs array.
 * @param[in] inputs An array of indexes identifying each operand.
 * @param[in] outputCount The number of entries in the outputs array.
 * @param[in] outputs An array of indexes identifying each operand.
 *
 * @note The operands specified by inputs and outputs must have been
 *       previously added by calls to {@link ANeuralNetworksModel_addOperand}.\n
 *       Attempting to modify a model once {@link ANeuralNetworksModel_finish} has been
 *       called will return an error.\n
 *       See {@link ANeuralNetworksModel} for information on multithreaded usage.
 *
 * @return ANEURALNETWORKS_NO_ERROR if successful.
 */
int ANeuralNetworksModel_addOperationEx(ANeuralNetworksModel *model,
                                        ANeuralNetworksOperationTypeEx type, uint32_t inputCount,
                                        const uint32_t *inputs, uint32_t outputCount,
                                        const uint32_t *outputs);

__END_DECLS

#endif // NN_RUNTIME_NEURAL_NETWORKS_EX_H