Caffe2 - C++ API
A deep learning, cross platform ML framework
Layout.h
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
Backend
This legacy enum class defines the set of backends supported by old school, code generated Type-based...
Definition: Backend.h:23
TensorOptions layout(Layout layout)
Convenience function that returns a TensorOptions object with the layout set to the given one...
To register your own kernel for an operator, do in one (!) cpp file: C10_REGISTER_KERNEL(OperatorHand...
Definition: alias_info.h:7