[Pytorch Edge] Move RuntimeCompatibilityInfo Factory Method (#63005)
authorJacob Szwejbka <jakeszwe@fb.com>
Wed, 11 Aug 2021 18:14:25 +0000 (11:14 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 11 Aug 2021 18:15:57 +0000 (11:15 -0700)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/63005

Realized I forgot to move the Runtime half of these functions be within the struct.

Test Plan: ci

Reviewed By: pavithranrao

Differential Revision: D30205521

fbshipit-source-id: ccd87d7d78450dd0dd23ba493bbb9d87be4640a5

test/cpp/jit/test_lite_interpreter.cpp
torch/csrc/jit/mobile/runtime_compatibility.cpp
torch/csrc/jit/mobile/runtime_compatibility.h

index 17c66e2..93e6b40 100644 (file)
@@ -751,7 +751,7 @@ TEST(LiteInterpreterTest, GetRuntimeOpsAndInfo) {
 
 TEST(LiteInterpreterTest, isCompatibleSuccess) {
   // test trivial success case
-  auto runtime_info = get_runtime_compatibility_info();
+  auto runtime_info = RuntimeCompatibilityInfo::get();
   std::unordered_map<std::string, OperatorInfo> model_ops;
   model_ops["aten::add.Scalar"] = OperatorInfo{2};
 
index b2914d2..b560ee3 100644 (file)
@@ -47,7 +47,7 @@ std::unordered_map<std::string, OperatorInfo> _get_runtime_ops_and_info() {
   return result;
 }
 
-RuntimeCompatibilityInfo get_runtime_compatibility_info() {
+RuntimeCompatibilityInfo RuntimeCompatibilityInfo::get() {
   return RuntimeCompatibilityInfo{
       _get_runtime_bytecode_version(), _get_runtime_ops_and_info()};
 }
index a6e01b6..f879d8a 100644 (file)
@@ -18,6 +18,9 @@ struct OperatorInfo {
 struct RuntimeCompatibilityInfo {
   uint64_t bytecode_version;
   std::unordered_map<std::string, OperatorInfo> operator_info;
+
+  // Factory Method
+  static TORCH_API RuntimeCompatibilityInfo get();
 };
 
 TORCH_API uint64_t _get_runtime_bytecode_version();
@@ -25,7 +28,5 @@ TORCH_API uint64_t _get_runtime_bytecode_version();
 TORCH_API std::unordered_map<std::string, OperatorInfo>
 _get_runtime_ops_and_info();
 
-TORCH_API RuntimeCompatibilityInfo get_runtime_compatibility_info();
-
 } // namespace jit
 } // namespace torch