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_SCRIPT_IR_BUILDER_IR_H_
20#define TVM_SCRIPT_IR_BUILDER_IR_H_
21
22#include <tvm/ffi/container/tuple.h>
23#include <tvm/ffi/container/variant.h>
24#include <tvm/ir/expr.h>
25#include <tvm/ir/function.h>
27
28#include <vector>
29
30namespace tvm {
31namespace script {
32namespace ir_builder {
33namespace ir {
34
39TVM_TIRX_DLL IRModuleFrame IRModule();
40
49TVM_TIRX_DLL GlobalVar DeclFunction(const ffi::String& func_name, const BaseFunc& func_signature);
50
56TVM_TIRX_DLL void DefFunction(const ffi::String& func_name, const BaseFunc& func);
57
70 ffi::Optional<PrimExpr> step = std::nullopt,
71 ffi::Optional<PrimType> dtype = std::nullopt,
72 ffi::Optional<ffi::Map<ffi::String, Any>> annotations = std::nullopt);
73
81ForFrame Grid(ffi::Array<ffi::Variant<PrimExpr, ffi::Tuple<PrimExpr, PrimExpr>>> extents,
82 ffi::Optional<PrimType> dtype = std::nullopt);
83
91AssertFrame Assert(PrimExpr condition, ffi::String error_kind,
92 ffi::Array<ffi::String> message_parts);
93
106Var Bind(Expr value, ffi::Optional<Type> type_annotation = std::nullopt,
107 ffi::Optional<Var> var = std::nullopt);
108
115
122
128
134
140IfFrame If(PrimExpr condition);
141
147
153
161RegionFrame Region(Op op, ffi::Array<Expr> args,
162 ffi::Optional<ffi::Array<Var>> body_params = std::nullopt,
163 DictAttrs attrs = DictAttrs());
164
171
172} // namespace ir
173} // namespace ir_builder
174} // namespace script
175} // namespace tvm
176
177#endif // TVM_SCRIPT_IR_BUILDER_IR_H_
Managed reference to BaseFuncNode.
Definition function.h:181
Managed reference to BindNode.
Definition stmt.h:159
Managed reference to DictAttrsNode.
Definition attrs.h:108
Managed reference to EvaluateNode.
Definition stmt.h:372
Managed reference to ExprNode.
Definition base_expr.h:359
Managed reference to ForNode.
Definition stmt.h:511
Managed reference to GlobalVarNode.
Definition expr.h:853
Managed reference to IfNode.
Definition stmt.h:415
Reference-counted handle to a canonical named operator.
Definition op.h:147
Typed reference/view over any Expr whose ExprNode::ty is PrimType.
Definition base_expr.h:447
Managed reference to ReturnNode.
Definition stmt.h:592
Container of all statements.
Definition stmt.h:62
Managed reference to VarNode.
Definition expr.h:714
Managed reference to WhileNode.
Definition stmt.h:558
Managed reference to AssertFrameObj.
Definition frame.h:204
Managed reference to ElseFrameObj.
Definition frame.h:417
Managed reference to ForFrameObj.
Definition frame.h:152
Managed reference to IfFrameObj.
Definition frame.h:339
Managed reference to RegionFrameObj.
Definition frame.h:247
Managed reference to ThenFrameObj.
Definition frame.h:378
Managed reference to WhileFrameObj.
Definition frame.h:290
Base expr nodes in TVM.
Function nodes.
TVM_TIRX_DLL IRModuleFrame IRModule()
The IRModule declaration statement.
Definition module.h:248
TVM_TIRX_DLL GlobalVar DeclFunction(const ffi::String &func_name, const BaseFunc &func_signature)
Declare a Function without given the specific function implementation.
ThenFrame Then()
Create a then.
TVM_TIRX_DLL void DefFunction(const ffi::String &func_name, const BaseFunc &func)
Define the function which is declared before.
ElseFrame Else()
Create an else.
ForFrame Grid(ffi::Array< ffi::Variant< PrimExpr, ffi::Tuple< PrimExpr, PrimExpr > > > extents, ffi::Optional< PrimType > dtype=std::nullopt)
The grid For statement.
tvm::Stmt Continue()
Create a continue statement.
AssertFrame Assert(PrimExpr condition, ffi::String error_kind, ffi::Array< ffi::String > message_parts)
The assertion statement.
RegionFrame Region(Op op, ffi::Array< Expr > args, ffi::Optional< ffi::Array< Var > > body_params=std::nullopt, DictAttrs attrs=DictAttrs())
Construct a result-free region with lexical body parameters.
tvm::Stmt Break()
Create a break statement.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition attr.h:23
ForKind
The kind of the loop.
Definition stmt.h:433
#define TVM_TIRX_DLL
Definition base.h:83