Move Layout to c10
authorSebastian Messmer <messmer@fb.com>
Tue, 4 Dec 2018 05:48:46 +0000 (21:48 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 4 Dec 2018 05:53:20 +0000 (21:53 -0800)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/14644

Reviewed By: ezyang

Differential Revision: D13283493

fbshipit-source-id: bb02f156d6a5b5129db5743c756acc84c38eca83

aten/src/ATen/core/Layout.h
c10/core/Layout.h [new file with mode: 0644]

index 14b204e..f5b4fb5 100644 (file)
@@ -1,36 +1 @@
-#pragma once
-
-#include <c10/core/Backend.h>
-#include <c10/util/Exception.h>
-
-#include <iostream>
-
-namespace at {
-enum class Layout : int8_t { Strided, Sparse };
-
-constexpr auto kStrided = Layout::Strided;
-constexpr auto kSparse = Layout::Sparse;
-
-inline Layout layout_from_backend(Backend backend) {
-  switch (backend) {
-    case Backend::SparseCPU:
-    case Backend::SparseCUDA:
-    case Backend::SparseHIP:
-      return Layout::Sparse;
-    default:
-      return Layout::Strided;
-  }
-}
-
-inline std::ostream& operator<<(std::ostream& stream, at::Layout layout) {
-  switch (layout) {
-    case at::kStrided:
-      return stream << "Strided";
-    case at::kSparse:
-      return stream << "Sparse";
-    default:
-      AT_ERROR("Unknown layout");
-  }
-}
-
-} // namespace at
+#include <c10/core/Layout.h>
diff --git a/c10/core/Layout.h b/c10/core/Layout.h
new file mode 100644 (file)
index 0000000..9d5f628
--- /dev/null
@@ -0,0 +1,36 @@
+#pragma once
+
+#include <c10/core/Backend.h>
+#include <c10/util/Exception.h>
+
+#include <iostream>
+
+namespace c10 {
+enum class Layout : int8_t { Strided, Sparse };
+
+constexpr auto kStrided = Layout::Strided;
+constexpr auto kSparse = Layout::Sparse;
+
+inline Layout layout_from_backend(Backend backend) {
+  switch (backend) {
+    case Backend::SparseCPU:
+    case Backend::SparseCUDA:
+    case Backend::SparseHIP:
+      return Layout::Sparse;
+    default:
+      return Layout::Strided;
+  }
+}
+
+inline std::ostream& operator<<(std::ostream& stream, at::Layout layout) {
+  switch (layout) {
+    case at::kStrided:
+      return stream << "Strided";
+    case at::kSparse:
+      return stream << "Sparse";
+    default:
+      AT_ERROR("Unknown layout");
+  }
+}
+
+} // namespace c10