Allow using C10_DECLARE_TENSOR_TYPE and C10_DEFINE_TENSOR_TYPE from any namespace...
authorSebastian Messmer <messmer@fb.com>
Thu, 21 Mar 2019 21:51:38 +0000 (14:51 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 21 Mar 2019 21:57:32 +0000 (14:57 -0700)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18158

They didn't work when called from other namespaces before because they didn't fully specify the c10 namespace.

Reviewed By: ezyang

Differential Revision: D14512187

fbshipit-source-id: a496b89a1bbe2b56137cfae03ab94a60f38d7068

c10/core/TensorTypeIdRegistration.h

index 1617ea2..dc441af 100644 (file)
@@ -88,11 +88,11 @@ inline c10::TensorTypeId TensorTypeIdRegistrar::id() const noexcept {
 }
 
 #define C10_DECLARE_TENSOR_TYPE(TensorName) \
-  C10_API c10::TensorTypeId TensorName()
+  C10_API ::c10::TensorTypeId TensorName()
 
 #define C10_DEFINE_TENSOR_TYPE(TensorName)          \
-  c10::TensorTypeId TensorName() {                  \
-    static TensorTypeIdRegistrar registration_raii; \
+  ::c10::TensorTypeId TensorName() {                \
+    static ::c10::TensorTypeIdRegistrar registration_raii; \
     return registration_raii.id();                  \
   }