From 9f0b11170d6e88c7afb3b11f6165d21144b0e59b Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Wed, 9 Mar 2016 19:10:03 -0800 Subject: Add MirrorPad op. This op is a variety of Pad op implementing reflect and symmetric modes of Numpy pad. Change: 116828726 --- tensorflow/core/util/mirror_pad_mode.h | 52 ++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tensorflow/core/util/mirror_pad_mode.h (limited to 'tensorflow/core/util/mirror_pad_mode.h') diff --git a/tensorflow/core/util/mirror_pad_mode.h b/tensorflow/core/util/mirror_pad_mode.h new file mode 100644 index 0000000000..ae96fdff73 --- /dev/null +++ b/tensorflow/core/util/mirror_pad_mode.h @@ -0,0 +1,52 @@ +/* Copyright 2016 Google Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_UTIL_MIRROR_PAD_MODE_H_ +#define TENSORFLOW_UTIL_MIRROR_PAD_MODE_H_ + +// This file contains helper routines to deal with padding in various ops and +// kernels. + +#include + +#include "tensorflow/core/lib/core/status.h" + +namespace tensorflow { + +// REFLECT: Border elements are not mirrored to padded regions. +// SYMMETRIC: Border elements are mirrored to padded regions. +// +// For example, if two elements are padded to the right of an array [1, 2, 3], +// then the result is [1, 2, 3, 2, 1] for REFLECT mode, and is [1, 2, 3, 3, 2] +// for SYMMETRIC mode. +enum class MirrorPadMode { + REFLECT = 1, + SYMMETRIC = 2, +}; + +// Return the string containing the list of valid padding modes, that can be +// used as an Attr() in REGISTER_OP. +string GetMirrorPadModeAttrString(); + +// Forward declaration to avoid including core/framework/graph.pb.h. +class NodeDef; + +// Specialization to parse an attribute directly into a MirrorPadMode enum. +Status GetNodeAttr(const NodeDef& node_def, const string& attr_name, + MirrorPadMode* value); + +} // end namespace tensorflow + +#endif // TENSORFLOW_UTIL_MIRROR_PAD_MODE_H_ -- cgit v1.2.3