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/relax/expr.h>
24#include <tvm/relax/type.h>
26
27namespace tvm {
28namespace script {
29namespace ir_builder {
30namespace relax {
31
33TVM_DLL ffi::Optional<tvm::relax::VDevice> LookupVDevice(ffi::String target_kind, int device_index);
34
36
43TVM_DLL FunctionFrame Function(bool is_pure, bool is_private);
44
46TVM_DLL FunctionFrame DeclFunction(bool is_pure, bool is_private, bool local);
47
49TVM_DLL FunctionFrame LocalFunction(bool is_pure, const tvm::Var& reference);
50
52TVM_DLL tvm::Var ArgVar(const ffi::String& name, const tvm::Var& var);
53
60TVM_DLL tvm::Var Arg(const ffi::String& name, const tvm::Type& ty);
61
66TVM_DLL void FuncName(const ffi::String& name);
67
72TVM_DLL void FuncAttrs(ffi::Map<ffi::String, Any> attrs);
73
78TVM_DLL void FuncRetType(const tvm::Type& ret_ty);
79
84TVM_DLL void FuncRetValue(const tvm::relax::Expr& value);
85
87
93
99
104TVM_DLL void DataflowBlockOutput(const ffi::Array<tvm::Var>& vars);
105
107
114TVM_DLL tvm::Var Emit(const tvm::relax::Expr& value,
115 const ffi::Optional<tvm::Type>& annotate_ty = std::nullopt);
116
123TVM_DLL tvm::Var EmitMatchCast(const tvm::relax::Expr& value, const tvm::Type& ty);
124
131
134 const ffi::Optional<tvm::Type>& annotate_ty, const Location& name_loc,
135 const Location& loc = UnknownLoc());
136
139 const Location& name_loc, const Location& loc = UnknownLoc());
140
142
159
160} // namespace relax
161} // namespace ir_builder
162} // namespace script
163} // namespace tvm
164
165#endif // TVM_RELAX_SCRIPT_IR_BUILDER_IR_H_
Managed reference to ExprNode.
Definition base_expr.h:359
Managed reference to IfNode.
Definition stmt.h:415
Non-nullable source-location metadata.
Definition location.h:91
Managed reference to TypeNode.
Definition base_expr.h:80
Reference to the shared immutable unknown location.
Definition location.h:105
Managed reference to VarNode.
Definition expr.h:714
Definition expr.h:202
Managed reference to ElseFrameObj.
Definition frame.h:336
Managed reference to IfFrameObj.
Definition frame.h:256
Managed reference to ThenFrameObj.
Definition frame.h:296
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.
FunctionFrame Function(bool is_pure, bool is_private)
Start a function frame.
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.
FunctionFrame DeclFunction(bool is_pure, bool is_private, bool local)
Start a bodyless declaration using the normal signature operations.
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 attr.h:23
Relax types, including the richer dependent Relax type nodes.