-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Meta Schedule][M3c] Schedule Rules, Mutator & Postprocs (#485) [Meta Schedule][M3c] PostOrderApply (#486) Fix Post Order Apply (#490) [MetaSchedule] Relay Integration (#489) [M3c][Meta Schedule] Add Trace Correctness Test for PostOrderApply (#492) Fix replay trace. (#493) [M3c][Meta Schedule] Implement the Replay Func class. (#495) [PR] Test script for meta-schedule task extraction. Interface to load… (#494) [Meta Schedule Refactor] Get child blocks (#500) Read-at && Write-at (#497) [M3c][Meta Schedule] Measure Callbacks (#498) [Bug] Fix Infinite Loop Caused When Calling Methods Not Overrided In PyClass (#496) [MetaSchedule] Sample-Perfect-Tile (#501) [MetaSchedule] TE Workloads (#502) [TensorIR] GetProducer, GetConsumer (#506) [MetaScheduleRefactor] Annotate&Unannotate (#505) [MetaSchedule] Multi-Level-Tiling & Auto-Inline (#503) [Tests] Add unittests for auto-inline and multi-level-tiling (#508) [Meta Schedule] Minor Fixes (#507) [MetaSchedule] Rewrite Cooperative-Fetching / Unbound-Block / Reduction-Block (#509) [MetaSchedule] Rewrite Parallel-Vectorize-Unroll / Verify-GPU / Disallow-Dynamic-Loops (#499) [Meta Schedule] Add Helper Function & Minor Modification (#512) [MetaSchedule] Test for Rewrite Parallel-Vectorize-Unroll (#513) [Meta Schedule] Feature Extractor & Cost Model (#510) Blockize & Tensorize (#514) Layout Rewriting: Suggest-Index-Map (#520) [MetaSchedule] Parallel-Vectorize-Unroll & Random-Compute-Location (#516) [Meta Schedule] Per-Store-Feature (#521) Add traced schedule for blockize & tensorize (#526) [Meta Schedule] Add XGBoost Model & Random Model (#519) User-Interface: Tune-TIR (#525) User-Interface: Tune-TE (#527) [Minor] More logging on python (#528) Get CUDA tuning working (#529) [MetaSchedule] TensorRT BYOC (#518) [BugFix] LocalBuilder API (#531) [Meta Schedule] Add Cost Model Update Measure Callback (#530) [Bugfix] BuilderInput with default params (#532) [MetaSchedule] Mutator-Tile-Size, Mutate-Parallel, Mutate-Unroll (#534) [Meta Schedule] Evolutionary Search (#522) [BugFix] Remove duplicated definition of MakeMultinomialSampler (#535) [Meta Schedule] Fix some bugs (#537) Initiate Experiments for CPU Performance Alignment with Ansor (#538) [Meta Schedule] Tweak experiment scripts (#539) [Meta Schedule] Initiate experiments on CUDA (#540) [TIR][Schedule] Buffer transform (#523) Auto Tensor Core (#524) Working on Evo Search (#542) [Meta Schedule] Add Replay Tuning Interface (#543) Evolutionary Search on CPU (#544) Misc improvement over the error message (#545) [TIR][Schedule] Software pipelining (#533) [Meta Schedule Refactor] fixing unit tests (#547) [MetaSchedule] Mutator-Compute-Location (#548) Misc Improvement of Evolutionary Search (#549) Hotfix for software pipeline (#552) Misc Improvement (#550) [Cherry-Pick][TensorIR] Primitive "SetScope" (#9738) (#555) Rule RFactor (#551) [MemHammer] Rewrite Rules (#554) [MetaSchedule] Schedule Rule: Cross-Thread Reduction (#556) [MetaSchedule] Performance Alignment - NRM and SFM (CUDA) (#559) [MetaSchedule] Perf Alignment - NRM on CUDA (#560) [TIR] Reorder the block iters of the blocks generated by RFactor (#561) Co-authored-by: Siyuan Feng <Hzfengsy@sjtu.edu.cn> Co-authored-by: Bohan Hou <32121147+spectrometerHBH@users.noreply.github.com> Co-authored-by: Hongyi Jin <3231950289@qq.com> Co-authored-by: Ruihang Lai <lairuihangdongdong@qq.com> Co-authored-by: Junru Shao <junrushao1994@gmail.com> Co-authored-by: Wuwei Lin <wuwei@apache.org> Co-authored-by: Sunghyun Park <49998730+sunggg@users.noreply.github.com> Co-authored-by: Xiyou Zhou <xiyou@octoml.ai>
- Loading branch information
1 parent
654a687
commit ae4b33d
Showing
204 changed files
with
27,315 additions
and
677 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
#ifndef TVM_META_SCHEDULE_MUTATOR_H_ | ||
#define TVM_META_SCHEDULE_MUTATOR_H_ | ||
|
||
#include <tvm/tir/schedule/schedule.h> | ||
|
||
namespace tvm { | ||
namespace meta_schedule { | ||
|
||
class TuneContext; | ||
|
||
/*! \brief Mutator is designed to mutate the trace to explore the design space. */ | ||
class MutatorNode : public runtime::Object { | ||
public: | ||
/*! \brief Virtual destructor. */ | ||
virtual ~MutatorNode() = default; | ||
|
||
void VisitAttrs(tvm::AttrVisitor* v) {} | ||
|
||
/*! | ||
* \brief Initialize the design space generator with tuning context. | ||
* \param tune_context The tuning context for initialization. | ||
* \note This method is supposed to be called only once before every other method. | ||
*/ | ||
virtual void InitializeWithTuneContext(const TuneContext& context) = 0; | ||
|
||
/*! | ||
* \brief Apply the mutator function to the given trace. | ||
* \param trace The given trace for mutation. | ||
* \param rand_state The random state for mutation. | ||
* \return None if mutator failed, otherwise return the mutated trace. | ||
*/ | ||
virtual Optional<tir::Trace> Apply(const tir::Trace& trace, | ||
support::LinearCongruentialEngine::TRandState* rand_state) = 0; | ||
|
||
static constexpr const char* _type_key = "meta_schedule.Mutator"; | ||
TVM_DECLARE_BASE_OBJECT_INFO(MutatorNode, Object); | ||
}; | ||
|
||
/*! \brief The mutator with customized methods on the python-side. */ | ||
class PyMutatorNode : public MutatorNode { | ||
public: | ||
/*! | ||
* \brief The function type of `InitializeWithTuneContext` method. | ||
* \param tune_context The tuning context for initialization. | ||
*/ | ||
using FInitializeWithTuneContext = runtime::TypedPackedFunc<void(const TuneContext&)>; | ||
/*! | ||
* \brief Apply the mutator function to the given trace. | ||
* \param trace The given trace for mutation. | ||
* \return None if mutator failed, otherwise return the mutated trace. | ||
*/ | ||
using FApply = runtime::TypedPackedFunc<Optional<tir::Trace>( | ||
const tir::Trace&, support::LinearCongruentialEngine::TRandState rand_state)>; | ||
/*! | ||
* \brief Get the mutator as string with name. | ||
* \return The string of the mutator. | ||
*/ | ||
using FAsString = runtime::TypedPackedFunc<String()>; | ||
|
||
/*! \brief The packed function to the `InitializeWithTuneContext` function. */ | ||
FInitializeWithTuneContext f_initialize_with_tune_context; | ||
/*! \brief The packed function to the `Apply` function. */ | ||
FApply f_apply; | ||
/*! \brief The packed function to the `AsString` function. */ | ||
FAsString f_as_string; | ||
|
||
void VisitAttrs(tvm::AttrVisitor* v) { | ||
// `f_initialize_with_tune_context` is not visited | ||
// `f_apply` is not visited | ||
// `f_as_string` is not visited | ||
} | ||
|
||
void InitializeWithTuneContext(const TuneContext& context) final { | ||
ICHECK(f_initialize_with_tune_context != nullptr) | ||
<< "PyMutator's InitializeWithTuneContext method not implemented!"; | ||
this->f_initialize_with_tune_context(context); | ||
} | ||
|
||
Optional<tir::Trace> Apply(const tir::Trace& trace, | ||
support::LinearCongruentialEngine::TRandState* rand_state) final { | ||
ICHECK(f_apply != nullptr) << "PyMutator's Apply method not implemented!"; | ||
return this->f_apply(trace, *rand_state); | ||
} | ||
|
||
static constexpr const char* _type_key = "meta_schedule.PyMutator"; | ||
TVM_DECLARE_FINAL_OBJECT_INFO(PyMutatorNode, MutatorNode); | ||
}; | ||
|
||
/*! | ||
* \brief Managed reference to MutatorNode | ||
* \sa MutatorNode | ||
*/ | ||
class Mutator : public runtime::ObjectRef { | ||
public: | ||
/*! \brief Create a Mutator that mutates the tile size. */ | ||
TVM_DLL static Mutator MutateTileSize(); | ||
/*! | ||
* \brief Create a Mutator that mutates the parallel extent | ||
* \param max_jobs_per_core The maximum number of parallel jobs per core. | ||
* \return The created mutator. | ||
*/ | ||
TVM_DLL static Mutator MutateParallel(int64_t max_jobs_per_core); | ||
/*! \brief Create a Mutator that mutates auto unroll step */ | ||
TVM_DLL static Mutator MutateUnroll(); | ||
/*! | ||
* \brief Create a Mutator that mutates the outcome of SampleComputeLocation | ||
* \return The mutator created | ||
*/ | ||
TVM_DLL static Mutator MutateComputeLocation(); | ||
/*! | ||
* \brief Create a mutator with customized methods on the python-side. | ||
* \param f_initialize_with_tune_context The packed function of `InitializeWithTuneContext`. | ||
* \param f_apply The packed function of `Apply`. | ||
* \param f_as_string The packed function of `AsString`. | ||
* \return The mutator created. | ||
*/ | ||
TVM_DLL static Mutator PyMutator( | ||
PyMutatorNode::FInitializeWithTuneContext f_initialize_with_tune_context, // | ||
PyMutatorNode::FApply f_apply, // | ||
PyMutatorNode::FAsString f_as_string); | ||
TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS(Mutator, ObjectRef, MutatorNode); | ||
}; | ||
|
||
} // namespace meta_schedule | ||
} // namespace tvm | ||
|
||
#endif // TVM_META_SCHEDULE_MUTATOR_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
#ifndef TVM_META_SCHEDULE_POSTPROC_H_ | ||
#define TVM_META_SCHEDULE_POSTPROC_H_ | ||
|
||
#include <tvm/tir/schedule/schedule.h> | ||
|
||
namespace tvm { | ||
namespace meta_schedule { | ||
|
||
class TuneContext; | ||
|
||
/*! | ||
* \brief Rules to apply a postprocessor to a schedule. | ||
*/ | ||
class PostprocNode : public runtime::Object { | ||
public: | ||
/*! \brief Virtual destructor. */ | ||
virtual ~PostprocNode() = default; | ||
|
||
void VisitAttrs(tvm::AttrVisitor* v) {} | ||
|
||
/*! | ||
* \brief Initialize the design space generator with tuning context. | ||
* \param tune_context The tuning context for initialization. | ||
* \note This method is supposed to be called only once before every other method. | ||
*/ | ||
virtual void InitializeWithTuneContext(const TuneContext& context) = 0; | ||
|
||
/*! | ||
* \brief Apply a postprocessor to the given schedule. | ||
* \param sch The schedule to be post processed. | ||
* \return Whether the postprocessor was successfully applied. | ||
*/ | ||
virtual bool Apply(const tir::Schedule& sch) = 0; | ||
|
||
static constexpr const char* _type_key = "meta_schedule.Postproc"; | ||
TVM_DECLARE_BASE_OBJECT_INFO(PostprocNode, Object); | ||
}; | ||
|
||
/*! \brief The postprocessor with customized methods on the python-side. */ | ||
class PyPostprocNode : public PostprocNode { | ||
public: | ||
/*! | ||
* \brief The function type of `InitializeWithTuneContext` method. | ||
* \param tune_context The tuning context for initialization. | ||
*/ | ||
using FInitializeWithTuneContext = runtime::TypedPackedFunc<void(const TuneContext&)>; | ||
/*! | ||
* \brief Apply a postprocessor to the given schedule. | ||
* \param sch The schedule to be post processed. | ||
* \return Whether the postprocessor was successfully applied. | ||
*/ | ||
using FApply = runtime::TypedPackedFunc<bool(const tir::Schedule&)>; | ||
/*! | ||
* \brief Get the postprocessor function as string with name. | ||
* \return The string of the postprocessor function. | ||
*/ | ||
using FAsString = runtime::TypedPackedFunc<String()>; | ||
|
||
/*! \brief The packed function to the `InitializeWithTuneContext` function. */ | ||
FInitializeWithTuneContext f_initialize_with_tune_context; | ||
/*! \brief The packed function to the `Apply` function. */ | ||
FApply f_apply; | ||
/*! \brief The packed function to the `AsString` function. */ | ||
FAsString f_as_string; | ||
|
||
void VisitAttrs(tvm::AttrVisitor* v) { | ||
// `f_initialize_with_tune_context` is not visited | ||
// `f_apply` is not visited | ||
// `f_as_string` is not visited | ||
} | ||
|
||
void InitializeWithTuneContext(const TuneContext& context) final { | ||
ICHECK(f_initialize_with_tune_context != nullptr) | ||
<< "PyPostproc's InitializeWithTuneContext method not implemented!"; | ||
this->f_initialize_with_tune_context(context); | ||
} | ||
|
||
bool Apply(const tir::Schedule& sch) final { | ||
ICHECK(f_apply != nullptr) << "PyPostproc's Apply method not implemented!"; | ||
return this->f_apply(sch); | ||
} | ||
|
||
static constexpr const char* _type_key = "meta_schedule.PyPostproc"; | ||
TVM_DECLARE_FINAL_OBJECT_INFO(PyPostprocNode, PostprocNode); | ||
}; | ||
|
||
/*! | ||
* \brief Managed reference to PostprocNode | ||
* \sa PostprocNode | ||
*/ | ||
class Postproc : public runtime::ObjectRef { | ||
public: | ||
/*! | ||
* \brief Create a postprocessor with customized methods on the python-side. | ||
* \param f_initialize_with_tune_context The packed function of `InitializeWithTuneContext`. | ||
* \param f_apply The packed function of `Apply`. | ||
* \param f_as_string The packed function of `AsString`. | ||
* \return The postprocessor created. | ||
*/ | ||
TVM_DLL static Postproc PyPostproc( | ||
PyPostprocNode::FInitializeWithTuneContext f_initialize_with_tune_context, // | ||
PyPostprocNode::FApply f_apply, // | ||
PyPostprocNode::FAsString f_as_string); | ||
/*! | ||
* \brief Create a postprocessor that checks if all loops are static | ||
* \return The postprocessor created | ||
*/ | ||
TVM_DLL static Postproc DisallowDynamicLoop(); | ||
/*! | ||
* \brief Create a postprocessor that rewrites the cooperative fetch annotation to | ||
* actual vectorized cooperative fetching in loop bindings. | ||
* \return The postprocessor created. | ||
*/ | ||
TVM_DLL static Postproc RewriteCooperativeFetch(); | ||
/*! | ||
* \brief Creates a postprocessor that applies parallelization, vectorization and auto unrolling | ||
* according to the annotation of each block | ||
* \return The postprocessor created | ||
*/ | ||
TVM_DLL static Postproc RewriteParallelVectorizeUnroll(); | ||
/*! | ||
* \brief Create a postprocessor that rewrites reduction block by moving the init block out. | ||
* \return The postprocessor created. | ||
*/ | ||
TVM_DLL static Postproc RewriteReductionBlock(); | ||
/*! | ||
* \brief Create a postprocessor that adds thread binding to unbound blocks | ||
* \return The postprocessor created. | ||
*/ | ||
TVM_DLL static Postproc RewriteUnboundBlock(); | ||
/*! | ||
* \brief Create a postprocessor that tensorize Tensor Core related components | ||
* \return The postprocessor created. | ||
*/ | ||
TVM_DLL static Postproc RewriteTensorCore(); | ||
|
||
/*! | ||
* \brief Creates a postprocessor that verifies if the GPU code is correct | ||
* \return The postprocessor created | ||
*/ | ||
TVM_DLL static Postproc VerifyGPUCode(); | ||
TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS(Postproc, ObjectRef, PostprocNode); | ||
}; | ||
|
||
} // namespace meta_schedule | ||
} // namespace tvm | ||
|
||
#endif // TVM_META_SCHEDULE_POSTPROC_H_ |
Oops, something went wrong.