move GetDimFromOrderString to caffe2/core/types.h (#25671)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/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
This commit is contained in:
Jiakai Liu 2019-09-05 04:30:22 -07:00 committed by Facebook Github Bot
parent a35a63b8bd
commit a3d0abf729
3 changed files with 14 additions and 14 deletions

View file

@ -31,6 +31,19 @@ inline StorageOrder StringToStorageOrder(const string& str) {
}
}
inline int32_t GetDimFromOrderString(const std::string& str) {
auto order = StringToStorageOrder(str);
switch (order) {
case StorageOrder::NHWC:
return 3;
case StorageOrder::NCHW:
return 1;
default:
CAFFE_THROW("Unsupported storage order: ", str);
return -1;
}
}
inline constexpr char NameScopeSeparator() { return '/'; }
// From TypeMeta to caffe2::DataType protobuffer enum.

View file

@ -1,6 +1,7 @@
#include "bound_shape_inferencer.h"
#include "caffe2/core/operator_schema.h"
#include "caffe2/core/tensor_impl.h"
#include "caffe2/core/types.h"
#include "caffe2/utils/proto_utils.h"
#include "caffe2/utils/string_utils.h"

View file

@ -6,7 +6,6 @@
#include <vector>
#include "caffe2/core/common.h"
#include "caffe2/core/types.h"
namespace caffe2 {
@ -35,19 +34,6 @@ CAFFE2_API inline bool EndsWith(
}
}
CAFFE2_API inline int32_t GetDimFromOrderString(const std::string& str) {
auto order = StringToStorageOrder(str);
switch (order) {
case StorageOrder::NHWC:
return 3;
case StorageOrder::NCHW:
return 1;
default:
CAFFE_THROW("Unsupported storage order: ", str);
return -1;
}
}
CAFFE2_API int32_t editDistanceHelper(const char* s1,
size_t s1_len,
const char* s2,