tvm
ir.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 #ifndef TVM_SCRIPT_IR_BUILDER_RELAX_IR_H_
20 #define TVM_SCRIPT_IR_BUILDER_RELAX_IR_H_
21 
22 #include <tvm/relax/expr.h>
23 #include <tvm/relax/struct_info.h>
26 
27 namespace tvm {
28 namespace script {
29 namespace ir_builder {
30 namespace relax {
31 
33 
40 TVM_DLL FunctionFrame Function(const Bool& is_pure, const Bool& is_private);
41 
48 TVM_DLL tvm::relax::Var Arg(const String& name, const tvm::relax::StructInfo& struct_info);
49 
54 TVM_DLL void FuncName(const String& name);
55 
60 TVM_DLL void FuncAttrs(Map<String, ObjectRef> attrs);
61 
66 TVM_DLL void FuncRetStructInfo(const tvm::relax::StructInfo& ret_sinfo);
67 
72 TVM_DLL void FuncRetValue(const tvm::relax::Expr& value);
73 
75 
81 
86 TVM_DLL BlockFrame Dataflow();
87 
92 TVM_DLL void DataflowBlockOutput(const Array<tvm::relax::Var>& vars);
93 
95 
103  const tvm::relax::Expr& value,
104  const Optional<tvm::relax::StructInfo>& annotate_struct_info = NullOpt);
105 
113  const tvm::relax::StructInfo& struct_info);
114 
121 
123 
140 
141 } // namespace relax
142 } // namespace ir_builder
143 } // namespace script
144 } // namespace tvm
145 
146 #endif // TVM_SCRIPT_IR_BUILDER_RELAX_IR_H_
Boolean constant.
Definition: expr.h:597
Managed reference to RelayExprNode.
Definition: expr.h:442
Managed reference to StructInfoNode.
Definition: expr.h:129
Definition: expr.h:755
Definition: expr.h:422
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
Map container of NodeRef->NodeRef in DSL graph. Map implements copy on write semantics,...
Definition: map.h:1271
Optional container that to represent to a Nullable variant of T.
Definition: optional.h:51
Reference to string objects.
Definition: string.h:98
Managed reference to ElseFrameNode.
Definition: frame.h:288
Managed reference to IfFrameNode.
Definition: frame.h:222
Managed reference to ThenFrameNode.
Definition: frame.h:255
tvm::relax::Var EmitMatchCast(const tvm::relax::Expr &value, const tvm::relax::StructInfo &struct_info)
Emit a match_cast binding to the last binding block frame.
tvm::relax::Var Emit(const tvm::relax::Expr &value, const Optional< tvm::relax::StructInfo > &annotate_struct_info=NullOpt)
Emit a binding to the last binding block frame.
BlockFrame BindingBlock()
Start a binding block frame.
tvm::relax::Var EmitVarBinding(const tvm::relax::VarBinding &binding)
Emit a binding to the last binding block frame.
IfFrame If(tvm::relax::Expr condition)
Create an if statement.
FunctionFrame Function(const Bool &is_pure, const Bool &is_private)
Start a function frame.
ThenFrame Then()
Create a then.
ElseFrame Else()
Create an else.
tvm::relax::Var Arg(const String &name, const tvm::relax::StructInfo &struct_info)
Add a parameter to the last function frame.
void FuncRetStructInfo(const tvm::relax::StructInfo &ret_sinfo)
Specify the return struct info of the last function frame.
void FuncName(const String &name)
Specify the name of the last function frame.
BlockFrame Dataflow()
Start a dataflow binding block frame.
void FuncAttrs(Map< String, ObjectRef > attrs)
Specify the attrs of the last function frame.
void FuncRetValue(const tvm::relax::Expr &value)
Specify the return value of the last function frame.
void DataflowBlockOutput(const Array< tvm::relax::Var > &vars)
Expose the dataflow block output variables as global ones.
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
constexpr runtime::NullOptType NullOpt
Definition: optional.h:169