From d8b2aa325c91b524bec22dc1ec2fc52c9f060fce Mon Sep 17 00:00:00 2001 From: Masahiro Masuda Date: Thu, 7 Apr 2022 17:09:32 +0900 Subject: [PATCH] clean up using namespace --- .../schedule_rule/multi_level_tiling.cc | 13 +++++++++---- .../schedule_rule/multi_level_tiling.h | 19 +++++++------------ .../schedule_rule/multi_level_tiling_vnni.cc | 13 +++++-------- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/meta_schedule/schedule_rule/multi_level_tiling.cc b/src/meta_schedule/schedule_rule/multi_level_tiling.cc index d1dcce9e8dcbd..b662c8a177ec2 100644 --- a/src/meta_schedule/schedule_rule/multi_level_tiling.cc +++ b/src/meta_schedule/schedule_rule/multi_level_tiling.cc @@ -52,6 +52,11 @@ std::vector GetReadBufferNDims(const StmtSRef& block_sref) { namespace tvm { namespace meta_schedule { +using tir::BlockRV; +using tir::IterVarType; +using tir::LoopRV; +using tir::Schedule; + // Do nothing; Inherited from ScheduleRuleNode void MultiLevelTilingNode::InitializeWithTuneContext(const TuneContext& context) { if (Optional v = context->target.value()->GetAttr("max_threads_per_block")) { @@ -163,12 +168,12 @@ std::vector MultiLevelTilingNode::TileLoopNest(State state) const { } // Do the split int n_tiles = idx->size(); - Array factors = sch->SamplePerfectTile( + Array factors = sch->SamplePerfectTile( /*loop=*/loop, /*n=*/n_tiles, /*max_innermost_factor=*/max_innermost_factor); - Array splits = sch->Split(/*loop=*/loop, - /*factors=*/{factors.begin(), factors.end()}); + Array splits = sch->Split(/*loop=*/loop, + /*factors=*/{factors.begin(), factors.end()}); // Put every tile to its slot for (int j = 0; j < n_tiles; ++j) { tiles[idx->at(j)].push_back(splits[j]); @@ -230,7 +235,7 @@ std::vector MultiLevelTilingNode::AddReadReuse(State state) const { if (!vector_load_lens.empty()) { int n = vector_load_lens.size(); double prob = 1.0 / n; - ExprRV vector_load_len = + tir::ExprRV vector_load_len = sch->SampleCategorical(support::AsArray(vector_load_lens), Array(n, FloatImm(DataType::Float(64), prob))); sch->Annotate(cache_read_block, tir::attr::meta_schedule_cooperative_fetch, diff --git a/src/meta_schedule/schedule_rule/multi_level_tiling.h b/src/meta_schedule/schedule_rule/multi_level_tiling.h index 4339358626aec..ac2bda83c66cb 100644 --- a/src/meta_schedule/schedule_rule/multi_level_tiling.h +++ b/src/meta_schedule/schedule_rule/multi_level_tiling.h @@ -23,12 +23,6 @@ namespace tvm { namespace meta_schedule { -using tir::BlockRV; -using tir::ExprRV; -using tir::IterVarType; -using tir::LoopRV; -using tir::Schedule; - /*! * \brief Configuration of data reuse type: * 0) kNoReuse: no reuse is allowed, then no cache_read/write is performed. @@ -83,15 +77,16 @@ struct ReuseConfig { /*! \brief The state of auto scheduling for the multi-level tiling rule */ struct State { /*! \brief The schedule to date */ - Schedule sch; + tir::Schedule sch; /*! \brief The block to be tiled */ - BlockRV block_rv; + tir::BlockRV block_rv; /*! \brief The loop tiles */ - Array> tiles; + Array> tiles; /*! \brief Default constructor */ - explicit State(Schedule sch, BlockRV block_rv, Optional write_cache = NullOpt, - bool write_cache_is_added = false, Array> tiles = {}) + explicit State(tir::Schedule sch, tir::BlockRV block_rv, + Optional write_cache = NullOpt, bool write_cache_is_added = false, + Array> tiles = {}) : sch(sch), block_rv(block_rv), tiles(tiles) {} }; @@ -131,7 +126,7 @@ class MultiLevelTilingNode : public ScheduleRuleNode { void InitializeWithTuneContext(const TuneContext& context) final; // Entry of the mega rule; Inherited from ScheduleRuleNode - Array Apply(const Schedule& sch, const BlockRV& block_rv) final; + Array Apply(const tir::Schedule& sch, const tir::BlockRV& block_rv) final; protected: virtual std::vector ApplySubRules(std::vector states); diff --git a/src/meta_schedule/schedule_rule/multi_level_tiling_vnni.cc b/src/meta_schedule/schedule_rule/multi_level_tiling_vnni.cc index 91d85aeda6eda..45fb14fb4b757 100644 --- a/src/meta_schedule/schedule_rule/multi_level_tiling_vnni.cc +++ b/src/meta_schedule/schedule_rule/multi_level_tiling_vnni.cc @@ -24,6 +24,8 @@ namespace tvm { namespace meta_schedule { +using tir::LoopRV; + /*! \brief Necessary information used for tensorization */ class TensorizeInfoNode : public Object { public: @@ -182,7 +184,7 @@ Optional GetTensorizeLoopMapping(const tir::ScheduleState& self, return TensorizeInfo(ret); } -Optional TilingwithTensorIntrin(const Schedule& sch, const BlockRV& block_rv, +Optional TilingwithTensorIntrin(const tir::Schedule& sch, const tir::BlockRV& block_rv, const String& intrin_name) { Optional opt_tensorize_info = GetTensorizeLoopMapping( sch->state(), sch->GetSRef(block_rv), tir::TensorIntrin::Get(intrin_name)->desc); @@ -244,15 +246,12 @@ Optional TilingwithTensorIntrin(const Schedule& sch, const BlockRV& bloc } std::vector TileForVNNI(State state) { - std::vector result; - BlockRV block_rv = state.block_rv; const std::string intrin_name = "dot_16x4_vnni"; - Optional tiled_loop_rv = TilingwithTensorIntrin(state.sch, block_rv, intrin_name); + Optional tiled_loop_rv = TilingwithTensorIntrin(state.sch, state.block_rv, intrin_name); ICHECK(tiled_loop_rv.defined()); state.block_rv = state.sch->Blockize(tiled_loop_rv.value()); state.sch->Annotate(state.block_rv, tir::attr::meta_schedule_auto_tensorize, String(intrin_name)); - result.push_back(state); - return result; + return {state}; } class MultiLevelTilingVNNINode : public MultiLevelTilingNode { @@ -267,8 +266,6 @@ class MultiLevelTilingVNNINode : public MultiLevelTilingNode { TVM_DECLARE_FINAL_OBJECT_INFO(MultiLevelTilingVNNINode, MultiLevelTilingNode); }; -// Constructor - ScheduleRule ScheduleRule::MultiLevelTilingVNNI(String structure, Optional> tile_binds, Optional max_innermost_factor,