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_RELAX_SCRIPT_BUILDER_IR_H_
20 #define TVM_RELAX_SCRIPT_BUILDER_IR_H_
21 
22 #include <tvm/relax/expr.h>
24 #include <tvm/relax/type.h>
26 
27 namespace tvm {
28 namespace script {
29 namespace ir_builder {
30 namespace relax {
31 
33 
40 TVM_DLL FunctionFrame Function(bool is_pure, bool is_private);
41 
48 TVM_DLL tvm::relax::Var Arg(const ffi::String& name, const tvm::Type& ty);
49 
54 TVM_DLL void FuncName(const ffi::String& name);
55 
60 TVM_DLL void FuncAttrs(ffi::Map<ffi::String, Any> attrs);
61 
66 TVM_DLL void FuncRetType(const tvm::Type& ret_ty);
67 
72 TVM_DLL void FuncRetValue(const tvm::relax::Expr& value);
73 
75 
81 
87 
92 TVM_DLL void DataflowBlockOutput(const ffi::Array<tvm::relax::Var>& vars);
93 
95 
102 TVM_DLL tvm::relax::Var Emit(const tvm::relax::Expr& value,
103  const ffi::Optional<tvm::Type>& annotate_ty = std::nullopt);
104 
111 TVM_DLL tvm::relax::Var EmitMatchCast(const tvm::relax::Expr& value, const tvm::Type& ty);
112 
119 
121 
138 
139 } // namespace relax
140 } // namespace ir_builder
141 } // namespace script
142 } // namespace tvm
143 
144 #endif // TVM_RELAX_SCRIPT_BUILDER_IR_H_
Managed reference to ExprNode.
Definition: base_expr.h:311
Managed reference to TypeNode.
Definition: base_expr.h:77
Definition: expr.h:379
Definition: expr.h:155
Managed reference to ElseFrameNode.
Definition: frame.h:319
Managed reference to IfFrameNode.
Definition: frame.h:239
Managed reference to ThenFrameNode.
Definition: frame.h:279
tvm::relax::Var EmitVarBinding(const tvm::relax::VarBinding &binding)
Emit a binding to the last binding block frame.
BindingBlockFrame BindingBlock()
Start a binding block frame.
IfFrame If(tvm::relax::Expr condition)
Create an if statement.
ThenFrame Then()
Create a then.
ElseFrame Else()
Create an else.
tvm::relax::Var EmitMatchCast(const tvm::relax::Expr &value, const tvm::Type &ty)
Emit a match_cast binding to the last binding block frame.
FunctionFrame Function(bool is_pure, bool is_private)
Start a function frame.
BindingBlockFrame Dataflow()
Start a dataflow binding block frame.
void FuncRetType(const tvm::Type &ret_ty)
Specify the return type of the last function frame.
tvm::relax::Var Arg(const ffi::String &name, const tvm::Type &ty)
Add a parameter to the last function frame.
void FuncName(const ffi::String &name)
Specify the name of the last function frame.
tvm::relax::Var Emit(const tvm::relax::Expr &value, const ffi::Optional< tvm::Type > &annotate_ty=std::nullopt)
Emit a binding to the last binding block frame.
void FuncAttrs(ffi::Map< ffi::String, Any > attrs)
Specify the attrs of the last function frame.
void DataflowBlockOutput(const ffi::Array< tvm::relax::Var > &vars)
Expose the dataflow block output variables as global ones.
void FuncRetValue(const tvm::relax::Expr &value)
Specify the return value of the last function frame.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition: analyzer.h:40
Relax types, including the richer dependent Relax type nodes.