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

unify naming style (#39481)

上级 739da6cb
......@@ -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;
}
......
......@@ -194,9 +194,9 @@ struct InferMetaFnImpl<Return (*)(Args...), infer_meta_fn> {
};
};
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<std::string, InferMetaFn> 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));
}
};
......
......@@ -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]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册