From bdeb479c0edd1ab9bb5f696df3573dad63d67885 Mon Sep 17 00:00:00 2001 From: Chen Weihang Date: Sat, 12 Feb 2022 14:44:03 +0800 Subject: [PATCH] unify naming style (#39481) --- paddle/pten/core/infermeta_utils.cc | 4 ++-- paddle/pten/core/infermeta_utils.h | 12 ++++++------ paddle/pten/tests/core/test_meta_fn_utils.cc | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/paddle/pten/core/infermeta_utils.cc b/paddle/pten/core/infermeta_utils.cc index 326f9aa720b..da2f0c92aa5 100644 --- a/paddle/pten/core/infermeta_utils.cc +++ b/paddle/pten/core/infermeta_utils.cc @@ -83,8 +83,8 @@ MetaTensor* InferMetaContext::MutableOutputAt(size_t idx) { return outputs_.at(idx).get(); } -MetaFunctionMap& MetaFunctionMap::Instance() { - static MetaFunctionMap g_meta_fn_map; +MetaFnFactory& MetaFnFactory::Instance() { + static MetaFnFactory g_meta_fn_map; return g_meta_fn_map; } diff --git a/paddle/pten/core/infermeta_utils.h b/paddle/pten/core/infermeta_utils.h index aed1fc2b77f..0c95b204abf 100644 --- a/paddle/pten/core/infermeta_utils.h +++ b/paddle/pten/core/infermeta_utils.h @@ -194,9 +194,9 @@ struct InferMetaFnImpl { }; }; -class MetaFunctionMap { +class MetaFnFactory { public: - static MetaFunctionMap& Instance(); + static MetaFnFactory& Instance(); bool Contains(const std::string& kernel_name_prefix) const { return meta_fn_map_.count(kernel_name_prefix) > 0; @@ -225,7 +225,7 @@ class MetaFunctionMap { } private: - MetaFunctionMap() = default; + MetaFnFactory() = default; /** * [ Why use kernel name prefix? ] @@ -243,14 +243,14 @@ class MetaFunctionMap { */ paddle::flat_hash_map meta_fn_map_; - DISABLE_COPY_AND_ASSIGN(MetaFunctionMap); + DISABLE_COPY_AND_ASSIGN(MetaFnFactory); }; struct InferMetaFnRegistrar { InferMetaFnRegistrar(const char* kernel_name_prefix, InferMetaFn infer_meta_fn) { - MetaFunctionMap::Instance().Insert(kernel_name_prefix, - std::move(infer_meta_fn)); + MetaFnFactory::Instance().Insert(kernel_name_prefix, + std::move(infer_meta_fn)); } }; diff --git a/paddle/pten/tests/core/test_meta_fn_utils.cc b/paddle/pten/tests/core/test_meta_fn_utils.cc index c7d092c468f..3cde1cfb5dc 100644 --- a/paddle/pten/tests/core/test_meta_fn_utils.cc +++ b/paddle/pten/tests/core/test_meta_fn_utils.cc @@ -22,7 +22,7 @@ limitations under the License. */ namespace pten { namespace tests { -TEST(MetaFunctionMap, InferMetaFnExists) { +TEST(MetaFnFactory, InferMetaFnExists) { pten::DenseTensor dense_x; dense_x.Resize(pten::framework::make_ddim({3, 4})); @@ -38,7 +38,7 @@ TEST(MetaFunctionMap, InferMetaFnExists) { ctx.EmplaceBackInput(shared_meat_x); ctx.EmplaceBackOutput(shared_meta_out); ctx.SetMetaConfig(/*is_runtime=*/true); - pten::MetaFunctionMap::Instance().Get("sign")(&ctx); + pten::MetaFnFactory::Instance().Get("sign")(&ctx); EXPECT_EQ(dense_out1.dims().size(), dense_out2.dims().size()); EXPECT_EQ(dense_out1.dims()[0], dense_out2.dims()[0]); -- GitLab