Skip to content

Commit a3d0abf

Browse files
ljk53facebook-github-bot
authored andcommitted
move GetDimFromOrderString to caffe2/core/types.h (#25671)
Summary: Pull Request resolved: #25671 To decouple string_utils.h from types.h and protobuf headers. Logically GetDimFromOrderString seems to be more similiar to StringToStorageOrder comparing to other string_utils functions. Test Plan: - Will check all internal/external CI jobs. Reviewed By: yinghai Differential Revision: D17191912 Pulled By: ljk53 fbshipit-source-id: fe555feef27bfd74c92b6297c12fb668252ca9ff
1 parent a35a63b commit a3d0abf

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

caffe2/core/types.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ inline StorageOrder StringToStorageOrder(const string& str) {
3131
}
3232
}
3333

34+
inline int32_t GetDimFromOrderString(const std::string& str) {
35+
auto order = StringToStorageOrder(str);
36+
switch (order) {
37+
case StorageOrder::NHWC:
38+
return 3;
39+
case StorageOrder::NCHW:
40+
return 1;
41+
default:
42+
CAFFE_THROW("Unsupported storage order: ", str);
43+
return -1;
44+
}
45+
}
46+
3447
inline constexpr char NameScopeSeparator() { return '/'; }
3548

3649
// From TypeMeta to caffe2::DataType protobuffer enum.

caffe2/opt/bound_shape_inferencer.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "bound_shape_inferencer.h"
22
#include "caffe2/core/operator_schema.h"
33
#include "caffe2/core/tensor_impl.h"
4+
#include "caffe2/core/types.h"
45
#include "caffe2/utils/proto_utils.h"
56
#include "caffe2/utils/string_utils.h"
67

caffe2/utils/string_utils.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <vector>
77

88
#include "caffe2/core/common.h"
9-
#include "caffe2/core/types.h"
109

1110
namespace caffe2 {
1211

@@ -35,19 +34,6 @@ CAFFE2_API inline bool EndsWith(
3534
}
3635
}
3736

38-
CAFFE2_API inline int32_t GetDimFromOrderString(const std::string& str) {
39-
auto order = StringToStorageOrder(str);
40-
switch (order) {
41-
case StorageOrder::NHWC:
42-
return 3;
43-
case StorageOrder::NCHW:
44-
return 1;
45-
default:
46-
CAFFE_THROW("Unsupported storage order: ", str);
47-
return -1;
48-
}
49-
}
50-
5137
CAFFE2_API int32_t editDistanceHelper(const char* s1,
5238
size_t s1_len,
5339
const char* s2,

0 commit comments

Comments
 (0)