tvm
Loading...
Searching...
No Matches
transform.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
24#ifndef TVM_TIRX_TRANSFORM_H_
25#define TVM_TIRX_TRANSFORM_H_
26
27#include <tvm/ir/function.h>
28#include <tvm/ir/prim/expr.h>
29#include <tvm/ir/transform.h>
30#include <tvm/target/target.h>
31#include <tvm/tirx/function.h>
32
33#include <string>
34#include <vector>
35
36namespace tvm {
37namespace tirx {
38namespace transform {
39
48
51
60TVM_TIRX_DLL Pass CreateFunctionPass(
61 ffi::TypedFunction<ffi::Optional<Function>(ffi::RValueRef<Function>, IRModule, PassContext)>
62 pass_func,
63 int opt_level, ffi::String name);
64
73inline Pass CreateFunctionPass(
74 std::function<ffi::Optional<Function>(Function, IRModule, PassContext)> pass_func,
75 int opt_level, ffi::String name) {
76 ffi::TypedFunction<ffi::Optional<Function>(ffi::RValueRef<Function>, IRModule, PassContext)>
77 callback = [pass_func = std::move(pass_func)](ffi::RValueRef<Function> func, IRModule mod,
78 PassContext ctx) -> ffi::Optional<Function> {
79 return pass_func(*std::move(func), std::move(mod), std::move(ctx));
80 };
81 return CreateFunctionPass(std::move(callback), opt_level, std::move(name));
82}
83
96TVM_TIRX_DLL Pass VectorizeLoop(bool enable_vectorize = true);
97
107
115
122
128
134
141
154
157
185
205
212
218
225
235
245
252
260TVM_TIRX_DLL Pass FP8ComputeLegalize(ffi::String promote_dtype = "float16");
261
267
274
284
291
298
306
312
317TVM_TIRX_DLL Pass Filter(ffi::TypedFunction<bool(Function)> fcond);
318
327
336
337} // namespace transform
338} // namespace tirx
339} // namespace tvm
340
341#endif // TVM_TIRX_TRANSFORM_H_
Function nodes.
TIR expressions.
Utilities for IR transformations.
#define TVM_TIRX_DLL
Definition base.h:55
TIR Function.
Managed reference class to IRModuleObj.
Definition module.h:292
Managed reference class to TargetObj.
Definition target.h:155
Managed reference to FunctionObj.
Definition function.h:107
PassContextObj contains the information that a pass can rely on, such as analysis results.
Definition transform.h:607
PassContext that is used to configure the pass behavior.
Definition transform.h:64
Meta data that will be used to help optimization and analysis.
Definition transform.h:232
Managed reference class for PassInfoObj.
Definition transform.h:255
PassObj is the base type of different types of optimization passes. It is designed as a pure class an...
Definition transform.h:277
Definition transform.h:307
Definition transform.h:390
TVM_TIRX_DLL Pass CommonSubexprElim()
Implements Common Subexpression Elimination (CSE) for TIR which introduces Bind statements for duplic...
TVM_TIRX_DLL Pass LowerThreadAllreduce()
Lower cross-thread reductions to target-specific communication.
TVM_TIRX_DLL Pass AnnotateEntryFunc()
Set a Function as the entry point if it is only function in IRModule.
TVM_TIRX_DLL Pass LowerIntrin()
Lower the target specific function intrinsics in each of the function.
TVM_TIRX_DLL Pass SplitHostDevice()
Annotate, split, and lower host/device functions.
TVM_TIRX_DLL Pass BF16StorageLegalize()
Legalize bf16 storage types to u16.
TVM_TIRX_DLL Pass RenormalizeSplitPattern()
Renormalize the split pattern from floordiv(floormod()) to floormod(floordiv()).
TVM_TIRX_DLL Pass FP8ComputeLegalize(ffi::String promote_dtype="float16")
Legalize fp8 compute Ops. Add a cast to fp16/fp32 before Ops, then add a cast back to fp8.
TVM_TIRX_DLL Pass NarrowDataType(int target_bits)
Narrow down PrimExpr datatype in stmt to target_bits.
TVM_TIRX_DLL Pass UnrollLoop()
unroll the constant loop marked by unroll. This pass also automatically attach pragma unroll tag to l...
TVM_TIRX_DLL Pass LowerTVMBuiltin()
Lower builtin intrinsics.
TVM_TIRX_DLL Pass VectorizeLoop(bool enable_vectorize=true)
Lower vectorization loops.
TVM_TIRX_DLL Pass StorageRewrite()
Rewrite storage allocation pattern. Moves the allocation to outer most possible scope....
TVM_TIRX_DLL Pass RemoveNoOp()
Remove No Op from the Stmt.
TVM_TIRX_DLL Pass PointerValueTypeRewrite()
Rewrite the pointer content type of arguments, as well as Alloc internal to the function to use the m...
TVM_TIRX_DLL Pass LowerTensorLayouts()
Apply tensor layouts to physical storage and accesses.
TVM_TIRX_DLL Pass BindTarget(Target target)
Annotate a Function with a given target.
TVM_TIRX_DLL Pass TileDispatch()
Lower TIRx op calls using registered op dispatchers for the given target.
TVM_TIRX_DLL Pass StmtSimplify()
Run statement-level arithmetic simplifications on the TIR Function.
TVM_TIRX_DLL Pass Filter(ffi::TypedFunction< bool(Function)> fcond)
Filter Functions with a given condition.
TVM_TIRX_DLL Pass SkipAssert()
skip assert stmt.
TVM_TIRX_DLL Pass ConvertSSA()
Convert an IRModule to be SSA form.
TVM_TIRX_DLL Pass ForceNarrowIndexToInt32()
Force to narrow down indexing expressions and integer tensors to int32 dtype.
TVM_TIRX_DLL Pass DecorateDeviceScope()
Wrap a function body in a device scope region.
TVM_TIRX_DLL Pass FlattenTensor()
Flatten the multi-dimensional TensorLoad and TensorStore to single dimensional TensorLoad/TensorStore...
TVM_TIRX_DLL Pass FP8StorageLegalize()
Legalize fp8 storage types to u8.
TVM_TIRX_DLL Pass BF16ComputeLegalize()
Legalize bf16 compute Ops. Add a cast to fp32 before Ops, then add a cast back to bf16.
TVM_TIRX_DLL Pass MakePackedAPI()
Transform the high-level Function to a low-level version that can be used as an API function.
TVM_TIRX_DLL Pass HoistIf()
Hoist loop-invariant If statements outside eligible loops.
TVM_TIRX_DLL Pass CreateModulePass(ffi::TypedFunction< IRModule(ffi::RValueRef< IRModule >, PassContext)> pass_func, int opt_level, ffi::String name)
Create a module pass from an owning FFI callback.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analysis.h:41
Compilation target object.