diff options
author | Xiaoqiang Zheng <zhengxq@google.com> | 2016-02-19 13:57:54 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2016-02-19 16:11:23 -0800 |
commit | 898d26a1cef46c0848188e22ba4b435846649b6d (patch) | |
tree | f344440864cb52ff0cfe61d110dfeea12598f583 /tensorflow/core/util/tensor_format.cc | |
parent | b0240486be5a8c4286961d1751fe8560e9c6970e (diff) |
Support NCHW in forward and backward convolution op.
Test both layouts in tests.
Change: 115096872
Diffstat (limited to 'tensorflow/core/util/tensor_format.cc')
-rw-r--r-- | tensorflow/core/util/tensor_format.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tensorflow/core/util/tensor_format.cc b/tensorflow/core/util/tensor_format.cc new file mode 100644 index 0000000000..9e29775628 --- /dev/null +++ b/tensorflow/core/util/tensor_format.cc @@ -0,0 +1,32 @@ +#include "tensorflow/core/util/tensor_format.h" + +namespace tensorflow { + +string GetConvnetDataFormatAttrString() { + return "data_format: { 'NHWC', 'NCHW' } = 'NHWC' "; +} + +string ToString(TensorFormat format) { + switch (format) { + case FORMAT_NHWC: + return "NHWC"; + case FORMAT_NCHW: + return "NCHW"; + default: + LOG(FATAL) << "Invalid Format: " << static_cast<int32>(format); + return "INVALID_FORMAT"; + } +} + +bool FormatFromString(const string& format_str, TensorFormat* format) { + if (format_str == "NHWC") { + *format = FORMAT_NHWC; + return true; + } else if (format_str == "NCHW") { + *format = FORMAT_NCHW; + return true; + } + return false; +} + +} // namespace tensorflow |