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_IR_BUILDER_IR_H_
20#define TVM_RELAX_SCRIPT_IR_BUILDER_IR_H_
21
22#include <tvm/base.h>
23#include <tvm/relax/expr.h>
25#include <tvm/relax/type.h>
27
28namespace tvm {
29namespace script {
30namespace ir_builder {
31namespace relax {
32
34TVM_DLL ffi::Optional<tvm::relax::VDevice> LookupVDevice(ffi::String target_kind, int device_index);
35
37
44TVM_DLL FunctionFrame Function(bool is_pure, bool is_private, bool is_declaration = false,
45 bool local = false);
46
48TVM_DLL FunctionFrame LocalFunction(bool is_pure, const tvm::Var& reference);
49
51TVM_DLL tvm::Var ArgVar(const ffi::String& name, const tvm::Var& var);
52
59TVM_DLL tvm::Var Arg(const ffi::String& name, const tvm::Type& ty);
60
65TVM_DLL void FuncName(const ffi::String& name);
66
71TVM_DLL void FuncAttrs(ffi::Map<ffi::String, Any> attrs);
72
77TVM_DLL void FuncRetType(const tvm::Type& ret_ty);
78
83TVM_DLL void FuncRetValue(const tvm::relax::Expr& value);
84
86
92
98
103TVM_DLL void DataflowBlockOutput(const ffi::Array<tvm::Var>& vars);
104
106
113TVM_DLL tvm::Var Emit(const tvm::relax::Expr& value,
114 const ffi::Optional<tvm::Type>& annotate_ty = std::nullopt);
115
122TVM_DLL tvm::Var EmitMatchCast(const tvm::relax::Expr& value, const tvm::Type& ty);
123
130
133 const ffi::Optional<tvm::Type>& annotate_ty, const Location& name_loc,
134 const Location& loc = UnknownLoc());
135
138 const Location& name_loc, const Location& loc = UnknownLoc());
139
141
158
159} // namespace relax
160} // namespace ir_builder
161} // namespace script
162} // namespace tvm
163
164#endif // TVM_RELAX_SCRIPT_IR_BUILDER_IR_H_
Base IRBuilder and frame definitions.
Managed reference to ExprObj.
Definition expr.h:101
Managed reference to IfObj.
Definition stmt.h:429
Non-nullable source-location metadata.
Definition location.h:91
Managed reference to TypeObj.
Definition type.h:75
Reference to the shared immutable unknown location.
Definition location.h:105
Managed reference to VarObj.
Definition expr.h:571
Definition expr.h:205
Managed reference to ElseFrameObj.
Definition frame.h:336
Managed reference to IfFrameObj.
Definition frame.h:256
Managed reference to ThenFrameObj.
Definition frame.h:296
Parent compiler symbol visibility.
Relax types, including the richer dependent Relax type nodes.
FunctionFrame Function(bool is_pure, bool is_private, bool is_declaration=false, bool local=false)
Start a function frame.
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.
FunctionFrame LocalFunction(bool is_pure, const tvm::Var &reference)
Define a local function under its cached declaration identity.
ThenFrame Then()
Create a then.
ElseFrame Else()
Create an else.
tvm::Var EmitMatchCastWithLoc(const tvm::relax::Expr &value, const tvm::Type &ty, const Location &name_loc, const Location &loc=UnknownLoc())
Emit a match cast with separate statement and variable-name ranges.
tvm::Var ArgVar(const ffi::String &name, const tvm::Var &var)
Add a cached parameter without changing its identity.
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.
ffi::Optional< tvm::relax::VDevice > LookupVDevice(ffi::String target_kind, int device_index)
Find a module virtual device by target kind and index.
tvm::Var EmitVarBinding(const tvm::relax::VarBinding &binding)
Emit a binding to the last binding block frame.
tvm::Var EmitWithLoc(const tvm::relax::Expr &value, const ffi::Optional< tvm::Type > &annotate_ty, const Location &name_loc, const Location &loc=UnknownLoc())
Emit a binding with separate statement and variable-name ranges.
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 analysis.h:41