tvm
Loading...
Searching...
No Matches
op_attr.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_RELAX_OP_ATTR_H_
25#define TVM_RELAX_OP_ATTR_H_
26
28#include <tvm/relax/expr.h>
30#include <tvm/relax/type.h>
31#include <tvm/te/tensor.h>
32
33namespace tvm {
34namespace relax {
35
36class LayoutDecision;
37class InferLayoutOutput;
38
40 // Elementwise operation
42 // Broadcasting operator, can always map output axis to the input in order.
43 // for example :code:`out[i, ax1, j, ax2] = input[i, j]`.
44 // Note that the axis need to be in order so transpose is not a bcast operator.
46 // Injective operator, can always injectively map output axis to a single input axis.
47 // All injective operator can still be safely fused to injective and reduction.
49 // Communicative reduction operator.
51 // Complex operation, can still fuse elemwise operations into its output.
52 // but cannot chain another complex op
54 // The pattern for tuple nodes. Can fuse into subsequent injective ops,
55 // but treated specially
56 kTuple = 7,
57 // Opaque operation, cannot fuse anything.
58 kOpaque = 8
59};
60
61namespace op_attr {
62inline constexpr ffi::reflection::AttrKey<bool> kPurity{"FPurity"};
63
68inline constexpr ffi::reflection::AttrKey<ffi::String> kCallPacked{"FCallPacked"};
85inline constexpr ffi::reflection::AttrKey<
86 ffi::TypedFunction<Expr(const BlockBuilder& bb, Call call)>>
87 kNormalize{"FNormalize"};
102inline constexpr ffi::reflection::AttrKey<
103 ffi::TypedFunction<Expr(const BlockBuilder& bb, const Call& call)>>
104 kLegalize{"FLegalize"};
112inline constexpr ffi::reflection::AttrKey<
113 ffi::TypedFunction<Expr(const BlockBuilder& bb, const Call& call)>>
114 kLowerBuiltin{"FLowerBuiltin"};
124inline constexpr ffi::reflection::AttrKey<ffi::TypedFunction<tvm::ffi::Array<Expr>(
125 const Var& orig_var, const Call& orig_call, const Var& output_grad, const BlockBuilder& ctx)>>
126 kPrimalGradient{"FPrimalGradient"};
133inline constexpr ffi::reflection::AttrKey<
134 ffi::TypedFunction<Type(const Call& call, const BlockBuilder& ctx)>>
135 kInferTypeWithBuilder{"relax.FInferTypeWithBuilder"};
136inline constexpr ffi::reflection::AttrKey<bool> kDataDependent{"FDataDependent"};
137inline constexpr ffi::reflection::AttrKey<bool> kRequiresArgumentShapes{"RequiresArgumentShapes"};
138inline constexpr ffi::reflection::AttrKey<bool> kAllocator{"TAllocator"};
139inline constexpr ffi::reflection::AttrKey<
140 ffi::TypedFunction<Call(const Call& call_node, DLDataType out_dtype)>>
141 kInferMixedPrecision{"FInferMixedPrecision"};
143inline constexpr ffi::reflection::AttrKey<int> kMixedPrecisionPolicy{"TMixedPrecisionPolicy"};
150inline constexpr ffi::reflection::AttrKey<ffi::TypedFunction<InferLayoutOutput(
151 const Call& call, const ffi::Map<ffi::String, ffi::Array<ffi::String>>& desired_layouts,
152 const ffi::Map<Var, NestedMsg<LayoutDecision>>& var_layout_map)>>
153 kInferLayout{"FRelaxInferLayout"};
154} // namespace op_attr
155
156// Compatibility names; new callers can deduce the value type from the key.
157using FCallPacked = decltype(op_attr::kCallPacked)::ValueType;
159using FNormalize = decltype(op_attr::kNormalize)::ValueType;
160using FLegalize = decltype(op_attr::kLegalize)::ValueType;
161using FLowerBuiltin = decltype(op_attr::kLowerBuiltin)::ValueType;
162using FPrimalGradient = decltype(op_attr::kPrimalGradient)::ValueType;
163
164namespace distributed {
165namespace op_attr {
166inline constexpr ffi::reflection::AttrKey<FInferTypeWithBuilder> kInferTypeWithBuilder{
167 "relax.dist.FInferTypeWithBuilder"};
168} // namespace op_attr
169} // namespace distributed
170
171} // namespace relax
172} // namespace tvm
173#endif // TVM_RELAX_OP_ATTR_H_
The utility for constructing Relax binding blocks.
Managed reference to CallObj.
Definition expr.h:825
Managed reference to TypeObj.
Definition type.h:75
Managed reference to VarObj.
Definition expr.h:571
Definition block_builder.h:262
Container that stores possibly nested message with leaf message type T.
Definition nested_msg.h:119
Relax types, including the richer dependent Relax type nodes.
Dataflow tensor object.
constexpr ffi::reflection::AttrKey< FInferTypeWithBuilder > kInferTypeWithBuilder
Definition op_attr.h:166
constexpr ffi::reflection::AttrKey< ffi::String > kCallPacked
Packed function implementation for operators. The relax operator will be lowered to this packed funct...
Definition op_attr.h:68
constexpr ffi::reflection::AttrKey< bool > kRequiresArgumentShapes
Definition op_attr.h:137
constexpr ffi::reflection::AttrKey< ffi::TypedFunction< tvm::ffi::Array< Expr >(const Var &orig_var, const Call &orig_call, const Var &output_grad, const BlockBuilder &ctx)> > kPrimalGradient
Gradient for a specific op.
Definition op_attr.h:126
constexpr ffi::reflection::AttrKey< bool > kPurity
Definition op_attr.h:62
constexpr ffi::reflection::AttrKey< bool > kAllocator
Definition op_attr.h:138
constexpr ffi::reflection::AttrKey< ffi::TypedFunction< Expr(const BlockBuilder &bb, const Call &call)> > kLowerBuiltin
The function type of a function to lower the runtime builtin.
Definition op_attr.h:114
constexpr ffi::reflection::AttrKey< bool > kDataDependent
Definition op_attr.h:136
constexpr ffi::reflection::AttrKey< int > kMixedPrecisionPolicy
the operator pattern
Definition op_attr.h:143
constexpr ffi::reflection::AttrKey< ffi::TypedFunction< Expr(const BlockBuilder &bb, Call call)> > kNormalize
The function type of a normalization function.
Definition op_attr.h:87
constexpr ffi::reflection::AttrKey< ffi::TypedFunction< Expr(const BlockBuilder &bb, const Call &call)> > kLegalize
The function type of a legalization function.
Definition op_attr.h:104
constexpr ffi::reflection::AttrKey< ffi::TypedFunction< Type(const Call &call, const BlockBuilder &ctx)> > kInferTypeWithBuilder
Infer output type given the call.
Definition op_attr.h:135
constexpr ffi::reflection::AttrKey< ffi::TypedFunction< InferLayoutOutput(const Call &call, const ffi::Map< ffi::String, ffi::Array< ffi::String > > &desired_layouts, const ffi::Map< Var, NestedMsg< LayoutDecision > > &var_layout_map)> > kInferLayout
SLayout conversion interface.
Definition op_attr.h:153
constexpr ffi::reflection::AttrKey< ffi::TypedFunction< Call(const Call &call_node, DLDataType out_dtype)> > kInferMixedPrecision
Definition op_attr.h:141
decltype(op_attr::kInferTypeWithBuilder)::ValueType FInferTypeWithBuilder
Definition op_attr.h:158
decltype(op_attr::kLowerBuiltin)::ValueType FLowerBuiltin
Definition op_attr.h:161
decltype(op_attr::kNormalize)::ValueType FNormalize
Definition op_attr.h:159
decltype(op_attr::kLegalize)::ValueType FLegalize
Definition op_attr.h:160
OpPatternKind
Definition op_attr.h:39
@ kOpaque
Definition op_attr.h:58
@ kTuple
Definition op_attr.h:56
@ kElemWise
Definition op_attr.h:41
@ kOutEWiseFusable
Definition op_attr.h:53
@ kInjective
Definition op_attr.h:48
@ kBroadcast
Definition op_attr.h:45
@ kCommReduce
Definition op_attr.h:50
decltype(op_attr::kCallPacked)::ValueType FCallPacked
Definition op_attr.h:157
tvm::Expr Expr
Definition type.h:42
decltype(op_attr::kPrimalGradient)::ValueType FPrimalGradient
Definition op_attr.h:162
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analysis.h:41
Helper container to store nested message for robust tuple-aware analysis.