Skip to content

Commit

Permalink
unify naming style
Browse files Browse the repository at this point in the history
  • Loading branch information
chenwhql committed Feb 11, 2022
1 parent 63d2333 commit 887892c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions paddle/pten/core/infermeta_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,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;
}

Expand Down
12 changes: 6 additions & 6 deletions paddle/pten/core/infermeta_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,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;
Expand Down Expand Up @@ -192,7 +192,7 @@ class MetaFunctionMap {
}

private:
MetaFunctionMap() = default;
MetaFnFactory() = default;

/**
* [ Why use kernel name prefix? ]
Expand All @@ -210,14 +210,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));
}
};

Expand Down
4 changes: 2 additions & 2 deletions paddle/pten/tests/core/test_meta_fn_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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}));

Expand All @@ -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]);
Expand Down

0 comments on commit 887892c

Please sign in to comment.