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_S_TIR_SCRIPT_IR_BUILDER_IR_H_
20#define TVM_S_TIR_SCRIPT_IR_BUILDER_IR_H_
21
24
25namespace tvm {
26namespace script {
27namespace ir_builder {
28namespace s_tir {
29
30using tvm::Var;
33
34FunctionFrame Function(bool is_private = false, bool persistent = false);
35FunctionFrame DeclFunction(bool is_private = false, bool persistent = false);
36
52TensorVar MatchTensor(ffi::ObjectRef param, ffi::Array<PrimExpr> shape,
53 PrimType dtype = PrimType::Float(32), ffi::Optional<Expr> data = std::nullopt,
54 ffi::Array<PrimExpr> strides = {},
55 ffi::Optional<PrimExpr> elem_offset = std::nullopt,
56 ffi::String storage_scope = "global", int align = -1, int offset_factor = 0,
57 ffi::Optional<Layout> layout = std::nullopt,
58 ffi::Array<PrimExpr> allocated_addr = {});
59
66SBlockFrame Block(ffi::String name, bool no_realize = false, ffi::String exec_scope = "");
67
73
78void Where(PrimExpr predicate);
79
84void Reads(ffi::Array<ffi::ObjectRef> tensor_slices);
85
90void Writes(ffi::Array<ffi::ObjectRef> tensor_slices);
91
96void BlockAttrs(ffi::Map<ffi::String, ffi::Any> attrs);
97
112TensorVar SBlockAllocTensor(ffi::Array<PrimExpr> shape, PrimType dtype = PrimType::Float(32),
113 ffi::Optional<Expr> data = std::nullopt,
114 ffi::Array<PrimExpr> strides = {},
115 ffi::Optional<PrimExpr> elem_offset = std::nullopt,
116 ffi::String storage_scope = "", int align = -1, int offset_factor = 0,
117 ffi::Optional<Layout> layout = std::nullopt,
118 ffi::Array<PrimExpr> allocated_addr = {});
119
120namespace axis {
121
129Var Spatial(Range dom, ffi::Optional<PrimExpr> binding = std::nullopt,
130 PrimType dtype = PrimType::Int(32));
131
139Var Reduce(Range dom, ffi::Optional<PrimExpr> binding = std::nullopt,
140 PrimType dtype = PrimType::Int(32));
141
149Var Scan(Range dom, ffi::Optional<PrimExpr> binding = std::nullopt,
150 PrimType dtype = PrimType::Int(32));
151
159Var Opaque(Range dom, ffi::Optional<PrimExpr> binding = std::nullopt,
160 PrimType dtype = PrimType::Int(32));
161
169ffi::Array<Var> Remap(ffi::String kinds, ffi::Array<PrimExpr> bindings,
170 PrimType dtype = PrimType::Int(32));
171
172} // namespace axis
173
174} // namespace s_tir
175} // namespace ir_builder
176} // namespace script
177} // namespace tvm
178
179#endif // TVM_S_TIR_SCRIPT_IR_BUILDER_IR_H_
Typed reference/view over any Expr whose ExprNode::ty is PrimType.
Definition base_expr.h:447
Definition base_expr.h:161
static TVM_TIRX_DLL PrimType Int(int bits, int lanes=1)
Construct a signed integer type with fixed lanes.
static TVM_TIRX_DLL PrimType Float(int bits, int lanes=1)
Construct a floating-point type with fixed lanes.
Range container
Definition expr.h:1025
Managed reference to VarNode.
Definition expr.h:714
Managed reference to BlockInitFrameObj.
Definition frame.h:169
Managed reference to SBlockFrameObj.
Definition frame.h:128
Definition layout.h:131
Checked zero-state view over an ordinary VarNode with TensorType.
Definition expr.h:50
Var Reduce(Range dom, ffi::Optional< PrimExpr > binding=std::nullopt, PrimType dtype=PrimType::Int(32))
The reduced block axis defining function.
Var Spatial(Range dom, ffi::Optional< PrimExpr > binding=std::nullopt, PrimType dtype=PrimType::Int(32))
The spatial block axis defining function.
Var Opaque(Range dom, ffi::Optional< PrimExpr > binding=std::nullopt, PrimType dtype=PrimType::Int(32))
The opaque block axis defining function.
Var Scan(Range dom, ffi::Optional< PrimExpr > binding=std::nullopt, PrimType dtype=PrimType::Int(32))
The scanning block axis defining function.
ffi::Array< Var > Remap(ffi::String kinds, ffi::Array< PrimExpr > bindings, PrimType dtype=PrimType::Int(32))
The block axis remapping function.
void BlockAttrs(ffi::Map< ffi::String, ffi::Any > attrs)
The block annotation statement.
TensorVar SBlockAllocTensor(ffi::Array< PrimExpr > shape, PrimType dtype=PrimType::Float(32), ffi::Optional< Expr > data=std::nullopt, ffi::Array< PrimExpr > strides={}, ffi::Optional< PrimExpr > elem_offset=std::nullopt, ffi::String storage_scope="", int align=-1, int offset_factor=0, ffi::Optional< Layout > layout=std::nullopt, ffi::Array< PrimExpr > allocated_addr={})
The tensor allocation function.
void Reads(ffi::Array< ffi::ObjectRef > tensor_slices)
The block tensor region reading statement.
void Where(PrimExpr predicate)
The block predicate statement.
TensorVar MatchTensor(ffi::ObjectRef param, ffi::Array< PrimExpr > shape, PrimType dtype=PrimType::Float(32), ffi::Optional< Expr > data=std::nullopt, ffi::Array< PrimExpr > strides={}, ffi::Optional< PrimExpr > elem_offset=std::nullopt, ffi::String storage_scope="global", int align=-1, int offset_factor=0, ffi::Optional< Layout > layout=std::nullopt, ffi::Array< PrimExpr > allocated_addr={})
Bind a tensor subregion in an S-TIR block.
SBlockFrame Block(ffi::String name, bool no_realize=false, ffi::String exec_scope="")
The block declaration statement.
BlockInitFrame Init()
The block initialization statement.
FunctionFrame DeclFunction(bool is_private=false, bool persistent=false)
void Writes(ffi::Array< ffi::ObjectRef > tensor_slices)
The block tensor region writing statement.
FunctionFrame Function(bool is_private=false, bool persistent=false)
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition attr.h:23