diff options
Diffstat (limited to 'tensorflow/cc/ops/array_grad.cc')
-rw-r--r-- | tensorflow/cc/ops/array_grad.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tensorflow/cc/ops/array_grad.cc b/tensorflow/cc/ops/array_grad.cc new file mode 100644 index 0000000000..37ffed9792 --- /dev/null +++ b/tensorflow/cc/ops/array_grad.cc @@ -0,0 +1,32 @@ +#include "tensorflow/core/framework/function.h" +#include "tensorflow/core/lib/core/errors.h" + +namespace tensorflow { + +typedef FunctionDefHelper FDH; + +REGISTER_OP_NO_GRADIENT("Shape"); +REGISTER_OP_NO_GRADIENT("Rank"); +REGISTER_OP_NO_GRADIENT("Size"); + +Status ReshapeGrad(const AttrSlice& attrs, FunctionDef* g) { + // clang-format off + *g = FDH::Define( + // Arg defs + {"x: T", "shape: int32", "dy: T"}, + // Ret val defs + {"dx: T", "dshape: int32"}, + // Attr defs + {{"T: {float, double}"}}, + // Nodes + { + {{"x_shape"}, "Shape", {"x"}, {{"T", "$T"}}}, + {{"dx"}, "Reshape", {"dy", "x_shape"}, {{"T", "$T"}}}, + {{"dshape"}, "ZerosLike", {"shape"}, {{"T", DT_INT32}}}, + }); + // clang-format on + return Status::OK(); +} +REGISTER_OP_GRADIENT("Reshape", ReshapeGrad); + +} // end namespace tensorflow |