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
25
26namespace tvm {
27namespace script {
28namespace ir_builder {
29namespace s_tir {
30
31using tvm::Var;
34
35FunctionFrame Function(bool is_private = false, bool persistent = false,
36 bool is_declaration = false);
37
50TensorVar MatchTensor(ffi::ObjectRef param, ffi::Array<PrimExpr> shape,
51 PrimType dtype = PrimType::Float(32), ffi::Optional<Expr> data = std::nullopt,
53 int align = -1, ffi::Optional<Layout> layout = std::nullopt,
54 ffi::Array<PrimExpr> allocated_addr = {});
55
62SBlockFrame Block(ffi::String name, bool no_realize = false, ffi::String exec_scope = "");
63
69
74void Where(PrimExpr predicate);
75
80void Reads(ffi::Array<ffi::ObjectRef> tensor_slices);
81
86void Writes(ffi::Array<ffi::ObjectRef> tensor_slices);
87
92void BlockAttrs(ffi::Map<ffi::String, ffi::Any> attrs);
93
105TensorVar SBlockAllocTensor(ffi::Array<PrimExpr> shape, PrimType dtype = PrimType::Float(32),
106 ffi::Optional<Expr> data = std::nullopt,
108 int align = -1, ffi::Optional<Layout> layout = std::nullopt,
109 ffi::Array<PrimExpr> allocated_addr = {});
110
111namespace axis {
112
120Var Spatial(Range dom, ffi::Optional<PrimExpr> binding = std::nullopt,
121 PrimType dtype = PrimType::Int(32));
122
130Var Reduce(Range dom, ffi::Optional<PrimExpr> binding = std::nullopt,
131 PrimType dtype = PrimType::Int(32));
132
140Var Scan(Range dom, ffi::Optional<PrimExpr> binding = std::nullopt,
141 PrimType dtype = PrimType::Int(32));
142
150Var Opaque(Range dom, ffi::Optional<PrimExpr> binding = std::nullopt,
151 PrimType dtype = PrimType::Int(32));
152
160ffi::Array<Var> Remap(ffi::String kinds, ffi::Array<PrimExpr> bindings,
161 PrimType dtype = PrimType::Int(32));
162
163} // namespace axis
164
165} // namespace s_tir
166} // namespace ir_builder
167} // namespace script
168} // namespace tvm
169
170#endif // TVM_S_TIR_SCRIPT_IR_BUILDER_IR_H_
IRBuilder APIs for TIRx functions and statements.
Typed reference/view over any Expr whose ExprObj::ty is PrimType.
Definition expr.h:187
Definition type.h:182
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:883
Managed reference to VarObj.
Definition expr.h:571
A registered memory space, independent of backend allocation policy.
Definition memory_scope.h:65
static TVM_RUNTIME_DLL const MemoryScope & Global()
Return the canonical global singleton.
Managed reference to BlockInitFrameObj.
Definition frame.h:169
Managed reference to SBlockFrameObj.
Definition frame.h:128
Managed reference to a tensor-program coordinate layout.
Definition layout.h:57
Checked zero-state view over an ordinary VarObj with TensorType.
Definition expr.h:48
Memory scopes and allocation properties for runtime storage.
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.
void Reads(ffi::Array< ffi::ObjectRef > tensor_slices)
The block tensor region reading statement.
TensorVar MatchTensor(ffi::ObjectRef param, ffi::Array< PrimExpr > shape, PrimType dtype=PrimType::Float(32), ffi::Optional< Expr > data=std::nullopt, runtime::MemoryScope storage_scope=runtime::MemoryScope::Global(), int align=-1, ffi::Optional< Layout > layout=std::nullopt, ffi::Array< PrimExpr > allocated_addr={})
Bind a tensor subregion in an S-TIR block.
void Where(PrimExpr predicate)
The block predicate statement.
FunctionFrame Function(bool is_private=false, bool persistent=false, bool is_declaration=false)
SBlockFrame Block(ffi::String name, bool no_realize=false, ffi::String exec_scope="")
The block declaration statement.
BlockInitFrame Init()
The block initialization statement.
void Writes(ffi::Array< ffi::ObjectRef > tensor_slices)
The block tensor region writing statement.
TensorVar SBlockAllocTensor(ffi::Array< PrimExpr > shape, PrimType dtype=PrimType::Float(32), ffi::Optional< Expr > data=std::nullopt, runtime::MemoryScope storage_scope=runtime::MemoryScope::Global(), int align=-1, ffi::Optional< Layout > layout=std::nullopt, ffi::Array< PrimExpr > allocated_addr={})
The tensor allocation function.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analysis.h:41