Skip to content

Commit 771eeba

Browse files
smessmerfacebook-github-bot
authored andcommitted
Move Layout to c10
Summary: Pull Request resolved: pytorch#14644 Reviewed By: ezyang Differential Revision: D13283493 fbshipit-source-id: bb02f156d6a5b5129db5743c756acc84c38eca83
1 parent 5a40826 commit 771eeba

File tree

2 files changed

+37
-36
lines changed

2 files changed

+37
-36
lines changed

aten/src/ATen/core/Layout.h

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1 @@
1-
#pragma once
2-
3-
#include <c10/core/Backend.h>
4-
#include <c10/util/Exception.h>
5-
6-
#include <iostream>
7-
8-
namespace at {
9-
enum class Layout : int8_t { Strided, Sparse };
10-
11-
constexpr auto kStrided = Layout::Strided;
12-
constexpr auto kSparse = Layout::Sparse;
13-
14-
inline Layout layout_from_backend(Backend backend) {
15-
switch (backend) {
16-
case Backend::SparseCPU:
17-
case Backend::SparseCUDA:
18-
case Backend::SparseHIP:
19-
return Layout::Sparse;
20-
default:
21-
return Layout::Strided;
22-
}
23-
}
24-
25-
inline std::ostream& operator<<(std::ostream& stream, at::Layout layout) {
26-
switch (layout) {
27-
case at::kStrided:
28-
return stream << "Strided";
29-
case at::kSparse:
30-
return stream << "Sparse";
31-
default:
32-
AT_ERROR("Unknown layout");
33-
}
34-
}
35-
36-
} // namespace at
1+
#include <c10/core/Layout.h>

c10/core/Layout.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#pragma once
2+
3+
#include <c10/core/Backend.h>
4+
#include <c10/util/Exception.h>
5+
6+
#include <iostream>
7+
8+
namespace c10 {
9+
enum class Layout : int8_t { Strided, Sparse };
10+
11+
constexpr auto kStrided = Layout::Strided;
12+
constexpr auto kSparse = Layout::Sparse;
13+
14+
inline Layout layout_from_backend(Backend backend) {
15+
switch (backend) {
16+
case Backend::SparseCPU:
17+
case Backend::SparseCUDA:
18+
case Backend::SparseHIP:
19+
return Layout::Sparse;
20+
default:
21+
return Layout::Strided;
22+
}
23+
}
24+
25+
inline std::ostream& operator<<(std::ostream& stream, at::Layout layout) {
26+
switch (layout) {
27+
case at::kStrided:
28+
return stream << "Strided";
29+
case at::kSparse:
30+
return stream << "Sparse";
31+
default:
32+
AT_ERROR("Unknown layout");
33+
}
34+
}
35+
36+
} // namespace c10

0 commit comments

Comments
 (0)