tvm
postproc.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 
20 #ifndef TVM_META_SCHEDULE_POSTPROC_H_
21 #define TVM_META_SCHEDULE_POSTPROC_H_
22 
23 #include <tvm/node/reflection.h>
24 #include <tvm/runtime/object.h>
27 
28 namespace tvm {
29 namespace meta_schedule {
30 
31 class TuneContext;
32 
36 class PostprocNode : public runtime::Object {
37  public:
39  virtual ~PostprocNode() = default;
40 
42 
48  virtual void InitializeWithTuneContext(const TuneContext& context) = 0;
49 
55  virtual bool Apply(const tir::Schedule& sch) = 0;
56 
57  static constexpr const char* _type_key = "meta_schedule.Postproc";
59 };
60 
62 class PyPostprocNode : public PostprocNode {
63  public:
80 
87 
89  // `f_initialize_with_tune_context` is not visited
90  // `f_apply` is not visited
91  // `f_as_string` is not visited
92  }
93 
94  void InitializeWithTuneContext(const TuneContext& context) final;
95  bool Apply(const tir::Schedule& sch) final;
96 
97  static constexpr const char* _type_key = "meta_schedule.PyPostproc";
99 };
100 
105 class Postproc : public runtime::ObjectRef {
106  public:
114  TVM_DLL static Postproc PyPostproc(
115  PyPostprocNode::FInitializeWithTuneContext f_initialize_with_tune_context, //
116  PyPostprocNode::FApply f_apply, //
117  PyPostprocNode::FAsString f_as_string);
122  TVM_DLL static Postproc DisallowDynamicLoop();
128  TVM_DLL static Postproc RewriteCooperativeFetch();
134  TVM_DLL static Postproc RewriteParallelVectorizeUnroll();
139  TVM_DLL static Postproc RewriteReductionBlock();
145  TVM_DLL static Postproc RewriteUnboundBlock(int max_threadblocks);
152  TVM_DLL static Postproc RewriteTensorize(bool vectorize_init_loop = false);
157  TVM_DLL static Postproc VerifyGPUCode();
163  TVM_DLL static Postproc RewriteLayout();
165 };
166 
167 } // namespace meta_schedule
168 } // namespace tvm
169 
170 #endif // TVM_META_SCHEDULE_POSTPROC_H_
The postprocessor with customized methods on the python-side.
Definition: postproc.h:62
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
Managed reference to PostprocNode.
Definition: postproc.h:105
FInitializeWithTuneContext f_initialize_with_tune_context
The packed function to the InitializeWithTuneContext function.
Definition: postproc.h:82
base class of all object containers.
Definition: object.h:167
FApply f_apply
The packed function to the Apply function.
Definition: postproc.h:84
#define TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName)
Definition: object.h:744
Managed reference to ScheduleNode.
Definition: schedule.h:618
Managed reference to TuneContextNode.
Definition: tune_context.h:129
Visitor class to get the attributes of an AST/IR node. The content is going to be called for each fie...
Definition: reflection.h:52
static constexpr const char * _type_key
Definition: postproc.h:57
bool VerifyGPUCode(const PrimFunc &func, Map< String, PrimExpr > constraints)
Verify the correctness of a GPU code It will check the whether the amount of memory usage or the numb...
Rules to apply a postprocessor to a schedule.
Definition: postproc.h:36
Base class of all object reference.
Definition: object.h:511
TVM_DECLARE_BASE_OBJECT_INFO(PostprocNode, Object)
A managed object in the TVM runtime.
#define TVM_DECLARE_FINAL_OBJECT_INFO(TypeName, ParentType)
helper macro to declare type information in a final class.
Definition: object.h:671
FAsString f_as_string
The packed function to the AsString function.
Definition: postproc.h:86
virtual void InitializeWithTuneContext(const TuneContext &context)=0
Initialize the design space generator with tuning context.
virtual bool Apply(const tir::Schedule &sch)=0
Apply a postprocessor to the given schedule.
virtual ~PostprocNode()=default
Virtual destructor.
void VisitAttrs(tvm::AttrVisitor *v)
Definition: postproc.h:88
Reflection and serialization of compiler IR/AST nodes.
Type-erased function used across TVM API.
void VisitAttrs(tvm::AttrVisitor *v)
Definition: postproc.h:41