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 */
23#ifndef TVM_SCRIPT_IR_BUILDER_IR_H_
24#define TVM_SCRIPT_IR_BUILDER_IR_H_
25
26#include <tvm/ffi/container/tuple.h>
27#include <tvm/ffi/container/variant.h>
28#include <tvm/ir/expr.h>
29#include <tvm/ir/function.h>
31
32#include <vector>
33
34namespace tvm {
35namespace script {
36namespace ir_builder {
37namespace ir {
38
43TVM_TIRX_DLL IRModuleFrame IRModule();
44
53TVM_TIRX_DLL GlobalVar DeclFunction(const ffi::String& func_name, const BaseFunc& func_signature);
54
60TVM_TIRX_DLL void DefFunction(const ffi::String& func_name, const BaseFunc& func);
61
74 ffi::Optional<PrimExpr> step = std::nullopt,
75 ffi::Optional<PrimType> dtype = std::nullopt,
76 ffi::Optional<ffi::Map<ffi::String, Any>> annotations = std::nullopt);
77
86Grid(ffi::Array<ffi::Variant<PrimExpr, ffi::Tuple<PrimExpr, PrimExpr>>> extents,
87 ffi::Optional<PrimType> dtype = std::nullopt);
88
96TVM_TIRX_DLL AssertFrame Assert(PrimExpr condition, ffi::String error_kind,
97 ffi::Array<ffi::String> message_parts);
98
105
112
118
124
131
137
143
151TVM_TIRX_DLL RegionFrame Region(Op op, ffi::Array<Expr> args,
152 ffi::Optional<ffi::Array<Var>> body_params = std::nullopt,
153 DictAttrs attrs = DictAttrs());
154
161
162} // namespace ir
163} // namespace ir_builder
164} // namespace script
165} // namespace tvm
166
167#endif // TVM_SCRIPT_IR_BUILDER_IR_H_
Base expr nodes in TVM.
Function nodes.
#define TVM_TIRX_DLL
Definition base.h:55
Shared IRBuilder frames for IRModules and statements.
Managed reference to BaseFuncObj.
Definition function.h:202
Managed reference to DictAttrsObj.
Definition attrs.h:108
Managed reference to EvaluateObj.
Definition stmt.h:386
Managed reference to ExprObj.
Definition expr.h:101
Managed reference to ForObj.
Definition stmt.h:527
Managed reference to GlobalVarObj.
Definition expr.h:709
Managed reference to IfObj.
Definition stmt.h:429
Reference-counted handle to a canonical named operator.
Definition op.h:140
Typed reference/view over any Expr whose ExprObj::ty is PrimType.
Definition expr.h:187
Managed reference to ReturnObj.
Definition stmt.h:608
Container of all statements.
Definition stmt.h:61
Managed reference to WhileObj.
Definition stmt.h:574
Managed reference to AssertFrameObj.
Definition frame.h:225
Managed reference to ElseFrameObj.
Definition frame.h:436
Managed reference to ForFrameObj.
Definition frame.h:174
Managed reference to IfFrameObj.
Definition frame.h:358
Managed reference to RegionFrameObj.
Definition frame.h:267
Managed reference to ThenFrameObj.
Definition frame.h:397
Managed reference to WhileFrameObj.
Definition frame.h:309
TVM_TIRX_DLL IRModuleFrame IRModule()
The IRModule declaration statement.
Definition module.h:285
TVM_TIRX_DLL GlobalVar DeclFunction(const ffi::String &func_name, const BaseFunc &func_signature)
Declare a Function without given the specific function implementation.
TVM_TIRX_DLL void DefFunction(const ffi::String &func_name, const BaseFunc &func)
Define the function which is declared before.
TVM_TIRX_DLL tvm::Stmt Continue()
Create a continue statement.
TVM_TIRX_DLL AssertFrame Assert(PrimExpr condition, ffi::String error_kind, ffi::Array< ffi::String > message_parts)
The assertion statement.
TVM_TIRX_DLL 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_TIRX_DLL ElseFrame Else()
Create an else.
TVM_TIRX_DLL ForFrame Grid(ffi::Array< ffi::Variant< PrimExpr, ffi::Tuple< PrimExpr, PrimExpr > > > extents, ffi::Optional< PrimType > dtype=std::nullopt)
The grid For statement.
TVM_TIRX_DLL tvm::Stmt Break()
Create a break statement.
TVM_TIRX_DLL ThenFrame Then()
Create a then.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analysis.h:41
ForKind
The kind of the loop.
Definition stmt.h:447