未验证 提交 bdeb479c 编写于 作者: C Chen Weihang 提交者: GitHub

unify naming style (#39481)

上级 739da6cb
...@@ -83,8 +83,8 @@ MetaTensor* InferMetaContext::MutableOutputAt(size_t idx) { ...@@ -83,8 +83,8 @@ MetaTensor* InferMetaContext::MutableOutputAt(size_t idx) {
return outputs_.at(idx).get(); return outputs_.at(idx).get();
} }
MetaFunctionMap& MetaFunctionMap::Instance() { MetaFnFactory& MetaFnFactory::Instance() {
static MetaFunctionMap g_meta_fn_map; static MetaFnFactory g_meta_fn_map;
return g_meta_fn_map; return g_meta_fn_map;
} }
......
...@@ -194,9 +194,9 @@ struct InferMetaFnImpl<Return (*)(Args...), infer_meta_fn> { ...@@ -194,9 +194,9 @@ struct InferMetaFnImpl<Return (*)(Args...), infer_meta_fn> {
}; };
}; };
class MetaFunctionMap { class MetaFnFactory {
public: public:
static MetaFunctionMap& Instance(); static MetaFnFactory& Instance();
bool Contains(const std::string& kernel_name_prefix) const { bool Contains(const std::string& kernel_name_prefix) const {
return meta_fn_map_.count(kernel_name_prefix) > 0; return meta_fn_map_.count(kernel_name_prefix) > 0;
...@@ -225,7 +225,7 @@ class MetaFunctionMap { ...@@ -225,7 +225,7 @@ class MetaFunctionMap {
} }
private: private:
MetaFunctionMap() = default; MetaFnFactory() = default;
/** /**
* [ Why use kernel name prefix? ] * [ Why use kernel name prefix? ]
...@@ -243,14 +243,14 @@ class MetaFunctionMap { ...@@ -243,14 +243,14 @@ class MetaFunctionMap {
*/ */
paddle::flat_hash_map<std::string, InferMetaFn> meta_fn_map_; paddle::flat_hash_map<std::string, InferMetaFn> meta_fn_map_;
DISABLE_COPY_AND_ASSIGN(MetaFunctionMap); DISABLE_COPY_AND_ASSIGN(MetaFnFactory);
}; };
struct InferMetaFnRegistrar { struct InferMetaFnRegistrar {
InferMetaFnRegistrar(const char* kernel_name_prefix, InferMetaFnRegistrar(const char* kernel_name_prefix,
InferMetaFn infer_meta_fn) { InferMetaFn infer_meta_fn) {
MetaFunctionMap::Instance().Insert(kernel_name_prefix, MetaFnFactory::Instance().Insert(kernel_name_prefix,
std::move(infer_meta_fn)); std::move(infer_meta_fn));
} }
}; };
......
...@@ -22,7 +22,7 @@ limitations under the License. */ ...@@ -22,7 +22,7 @@ limitations under the License. */
namespace pten { namespace pten {
namespace tests { namespace tests {
TEST(MetaFunctionMap, InferMetaFnExists) { TEST(MetaFnFactory, InferMetaFnExists) {
pten::DenseTensor dense_x; pten::DenseTensor dense_x;
dense_x.Resize(pten::framework::make_ddim({3, 4})); dense_x.Resize(pten::framework::make_ddim({3, 4}));
...@@ -38,7 +38,7 @@ TEST(MetaFunctionMap, InferMetaFnExists) { ...@@ -38,7 +38,7 @@ TEST(MetaFunctionMap, InferMetaFnExists) {
ctx.EmplaceBackInput(shared_meat_x); ctx.EmplaceBackInput(shared_meat_x);
ctx.EmplaceBackOutput(shared_meta_out); ctx.EmplaceBackOutput(shared_meta_out);
ctx.SetMetaConfig(/*is_runtime=*/true); 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().size(), dense_out2.dims().size());
EXPECT_EQ(dense_out1.dims()[0], dense_out2.dims()[0]); EXPECT_EQ(dense_out1.dims()[0], dense_out2.dims()[0]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册