• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2023 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef NNACL_KERNEL_ARG_MIN_MAX_H_
18 #define NNACL_KERNEL_ARG_MIN_MAX_H_
19 
20 #include "nnacl/op_base.h"
21 #include "nnacl/tensor_c.h"
22 #include "nnacl/kernel.h"
23 #ifdef ENABLE_ARM64
24 #include <arm_neon.h>
25 #endif
26 
27 typedef struct ArgElement {
28   uint32_t index_;
29   union ArgData {
30     int8_t i8_data_;
31     int32_t i_data_;
32     float f_data_;
33 #ifdef ENABLE_ARM
34 #if (!SUPPORT_NNIE) || (defined SUPPORT_34XX)
35     float16_t f16_data_;
36 #endif
37 #endif
38   } data_;
39 } ArgElement;
40 
41 typedef int (*COMPARE_FUNCTION)(const void *a, const void *b);
42 
43 typedef struct ArgMinMaxComputeParam {
44   int32_t axis_;
45   int32_t dims_size_;
46   int32_t topk_;
47   bool get_max_;
48   bool keep_dims_;
49   bool out_value_;
50   int32_t in_strides_[COMM_SHAPE_SIZE];
51   int32_t out_strides_[COMM_SHAPE_SIZE];
52   ArgElement *arg_elements_;
53 } ArgMinMaxComputeParam;
54 
55 typedef struct ArgMinMaxStruct {
56   KernelBase base_;
57   ArgMinMaxComputeParam compute_;
58   bool arg_elements_alloc_;
59 } ArgMinMaxStruct;
60 
61 KernelBase *CreateArgMinMax(OpParameter *param, int data_type);
62 
63 #endif  // NNACL_KERNEL_ARG_MIN_MAX_H_
64