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 
20 /*!
21  * \file tvm/relay/attrs/reduce.h
22  * \brief Auxiliary attributes for reduce operators.
23  */
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 
34 /*! \brief Attributes for Reduce operators */
35 struct ReduceAttrs : public tvm::AttrsNode<ReduceAttrs> {
36   Array<Integer> axis;
37   bool keepdims;
38   bool exclude;
39 
40   TVM_DECLARE_ATTRS(ReduceAttrs, "relay.attrs.ReduceAttrs") {
41     TVM_ATTR_FIELD(axis)
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 
64 struct VarianceAttrs : public tvm::AttrsNode<VarianceAttrs> {
65   Array<Integer> axis;
66   bool keepdims;
67   bool exclude;
68   bool unbiased;
69 
70   TVM_DECLARE_ATTRS(VarianceAttrs, "relay.attrs.VarianceAttrs") {
71     TVM_ATTR_FIELD(axis)
72         .set_default(NullValue<Array<Integer>>())
73         .describe(R"code(The axis or axes along which to perform the reduction.
74 
75       The default, `axis=()`, will compute over all elements into a
76       scalar array with shape `(1,)`.
77 
78       If `axis` is int, a reduction is performed on a particular axis.
79 
80       If `axis` is a tuple of ints, a reduction is performed on all the axes
81       specified in the tuple.
82 
83       If `exclude` is true, reduction will be performed on the axes that are
84       NOT in axis instead.)code");
85 
86     TVM_ATTR_FIELD(keepdims).set_default(false).describe(
87         "If this is set to `True`, the reduced axes are left "
88         "in the result as dimension with size one.");
89     TVM_ATTR_FIELD(exclude).set_default(false).describe(
90         "Whether to perform reduction on axis that are NOT in axis instead.");
91     TVM_ATTR_FIELD(unbiased).set_default(false).describe("Whether to use the unbiased estimation.");
92   }
93 };
94 }  // namespace relay
95 }  // namespace tvm
96 #endif  // TVM_RELAY_ATTRS_REDUCE_H_
97