tvm
reduce.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
24 #ifndef TVM_RELAY_ATTRS_REDUCE_H_
25 #define TVM_RELAY_ATTRS_REDUCE_H_
26 
27 #include <tvm/ir/attrs.h>
28 
29 #include <string>
30 
31 namespace tvm {
32 namespace relay {
33 
35 struct ReduceAttrs : public tvm::AttrsNode<ReduceAttrs> {
37  bool keepdims;
38  bool exclude;
39 
40  TVM_DECLARE_ATTRS(ReduceAttrs, "relay.attrs.ReduceAttrs") {
42  .set_default(NullValue<Array<Integer>>())
43  .describe(R"code(The axis or axes along which to perform the reduction.
44 
45  The default, `axis=()`, will compute over all elements into a
46  scalar array with shape `(1,)`.
47 
48  If `axis` is int, a reduction is performed on a particular axis.
49 
50  If `axis` is a tuple of ints, a reduction is performed on all the axes
51  specified in the tuple.
52 
53  If `exclude` is true, reduction will be performed on the axes that are
54  NOT in axis instead.)code");
55 
56  TVM_ATTR_FIELD(keepdims).set_default(false).describe(
57  "If this is set to `True`, the reduced axes are left "
58  "in the result as dimension with size one.");
59  TVM_ATTR_FIELD(exclude).set_default(false).describe(
60  "Whether to perform reduction on axis that are NOT in axis instead.");
61  }
62 };
63 
65 struct ArgReduceAttrs : public tvm::AttrsNode<ArgReduceAttrs> {
67  bool keepdims;
69  bool exclude;
70 
71  TVM_DECLARE_ATTRS(ArgReduceAttrs, "relay.attrs.ArgReduceAttrs") {
73  .set_default(NullValue<Array<Integer>>())
74  .describe(R"code(The axis or axes along which to perform the reduction.
75 
76  The default, `axis=()`, will compute over all elements into a
77  scalar array with shape `(1,)`.
78 
79  If `axis` is int, a reduction is performed on a particular axis.
80 
81  If `axis` is a tuple of ints, a reduction is performed on all the axes
82  specified in the tuple.
83 
84  If `exclude` is true, reduction will be performed on the axes that are
85  NOT in axis instead.)code");
86 
87  TVM_ATTR_FIELD(keepdims).set_default(false).describe(
88  "If this is set to `True`, the reduced axes are left "
89  "in the result as dimension with size one.");
91  .set_default(false)
92  .describe(
93  "Whether to select the last index if the target element appears multiple times, else "
94  "select the first index which the target element appears");
95  TVM_ATTR_FIELD(exclude).set_default(false).describe(
96  "Whether to perform reduction on axis that are NOT in axis instead.");
97  }
98 };
99 
100 struct VarianceAttrs : public tvm::AttrsNode<VarianceAttrs> {
102  bool keepdims;
103  bool exclude;
104  bool unbiased;
105 
106  TVM_DECLARE_ATTRS(VarianceAttrs, "relay.attrs.VarianceAttrs") {
108  .set_default(NullValue<Array<Integer>>())
109  .describe(R"code(The axis or axes along which to perform the reduction.
110 
111  The default, `axis=()`, will compute over all elements into a
112  scalar array with shape `(1,)`.
113 
114  If `axis` is int, a reduction is performed on a particular axis.
115 
116  If `axis` is a tuple of ints, a reduction is performed on all the axes
117  specified in the tuple.
118 
119  If `exclude` is true, reduction will be performed on the axes that are
120  NOT in axis instead.)code");
121 
122  TVM_ATTR_FIELD(keepdims).set_default(false).describe(
123  "If this is set to `True`, the reduced axes are left "
124  "in the result as dimension with size one.");
125  TVM_ATTR_FIELD(exclude).set_default(false).describe(
126  "Whether to perform reduction on axis that are NOT in axis instead.");
127  TVM_ATTR_FIELD(unbiased).set_default(false).describe("Whether to use the unbiased estimation.");
128  }
129 };
130 } // namespace relay
131 } // namespace tvm
132 #endif // TVM_RELAY_ATTRS_REDUCE_H_
The base class of the all the Use "curiously recurring template pattern".
Definition: attrs.h:870
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
Helpers for attribute objects.
#define TVM_ATTR_FIELD(FieldName)
Declare an attribute field.
Definition: attrs.h:76
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
TObjectRef NullValue()
Create a NodeRef type that represents null.
Definition: attrs.h:84
Attributes for Reduce operators which reduce by finding a single element. E.g. argmin.
Definition: reduce.h:65
bool keepdims
Definition: reduce.h:67
Array< Integer > axis
Definition: reduce.h:66
bool select_last_index
Definition: reduce.h:68
bool exclude
Definition: reduce.h:69
TVM_DECLARE_ATTRS(ArgReduceAttrs, "relay.attrs.ArgReduceAttrs")
Definition: reduce.h:71
Attributes for Reduce operators.
Definition: reduce.h:35
Array< Integer > axis
Definition: reduce.h:36
TVM_DECLARE_ATTRS(ReduceAttrs, "relay.attrs.ReduceAttrs")
Definition: reduce.h:40
bool exclude
Definition: reduce.h:38
bool keepdims
Definition: reduce.h:37
Definition: reduce.h:100
bool exclude
Definition: reduce.h:103
bool keepdims
Definition: reduce.h:102
TVM_DECLARE_ATTRS(VarianceAttrs, "relay.attrs.VarianceAttrs")
Definition: reduce.h:106
Array< Integer > axis
Definition: reduce.h:101
bool unbiased
Definition: reduce.h:104