tvm
Loading...
Searching...
No Matches
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
27namespace tvm {
28namespace script {
29namespace ir_builder {
30namespace relax {
31
33
40TVM_DLL FunctionFrame Function(bool is_pure, bool is_private);
41
48TVM_DLL tvm::Var Arg(const ffi::String& name, const tvm::Type& ty);
49
54TVM_DLL void FuncName(const ffi::String& name);
55
60TVM_DLL void FuncAttrs(ffi::Map<ffi::String, Any> attrs);
61
66TVM_DLL void FuncRetType(const tvm::Type& ret_ty);
67
73
75
81
87
92TVM_DLL void DataflowBlockOutput(const ffi::Array<tvm::Var>& vars);
93
95
103 const ffi::Optional<tvm::Type>& annotate_ty = std::nullopt);
104
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:335
Managed reference to TypeNode.
Definition base_expr.h:77
Managed reference to VarNode.
Definition expr.h:372
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition with_context.h:59
Definition expr.h:283
Managed reference to ElseFrameNode.
Definition frame.h:319
Managed reference to IfFrameNode.
Definition frame.h:239
Managed reference to ThenFrameNode.
Definition frame.h:279
BindingBlockFrame BindingBlock()
Start a binding block frame.
tvm::Var Arg(const ffi::String &name, const tvm::Type &ty)
Add a parameter to the last function frame.
IfFrame If(tvm::relax::Expr condition)
Create an if statement.
ThenFrame Then()
Create a then.
ElseFrame Else()
Create an else.
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::Var EmitMatchCast(const tvm::relax::Expr &value, const tvm::Type &ty)
Emit a match_cast binding to the last binding block frame.
void FuncName(const ffi::String &name)
Specify the name of the last function frame.
tvm::Var EmitVarBinding(const tvm::relax::VarBinding &binding)
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.
tvm::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 FuncRetValue(const tvm::relax::Expr &value)
Specify the return value of the last function frame.
void DataflowBlockOutput(const ffi::Array< tvm::Var > &vars)
Expose the dataflow block output variables as global ones.
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.