1 | /* Copyright 2020 The TensorFlow Authors. All Rights Reserved. |
2 | |
3 | Licensed under the Apache License, Version 2.0 (the "License"); |
4 | you may not use this file except in compliance with the License. |
5 | You may obtain a copy of the License at |
6 | |
7 | http://www.apache.org/licenses/LICENSE-2.0 |
8 | |
9 | Unless required by applicable law or agreed to in writing, software |
10 | distributed under the License is distributed on an "AS IS" BASIS, |
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | See the License for the specific language governing permissions and |
13 | limitations under the License. |
14 | ==============================================================================*/ |
15 | |
16 | #include "tensorflow/cc/framework/grad_op_registry.h" |
17 | #include "tensorflow/cc/framework/gradients.h" |
18 | #include "tensorflow/cc/ops/manip_ops.h" |
19 | #include "tensorflow/cc/ops/standard_ops.h" |
20 | |
21 | namespace tensorflow { |
22 | namespace ops { |
23 | namespace { |
24 | |
25 | Status RollGrad(const Scope& scope, const Operation& op, |
26 | const std::vector<Output>& grad_inputs, |
27 | std::vector<Output>* grad_outputs) { |
28 | auto shift = op.input(1); |
29 | auto axis = op.input(2); |
30 | auto grad_op = Roll(scope, grad_inputs[0], Neg(scope, shift), axis); |
31 | grad_outputs->push_back(grad_op); |
32 | grad_outputs->push_back(NoGradient()); |
33 | grad_outputs->push_back(NoGradient()); |
34 | return scope.status(); |
35 | } |
36 | REGISTER_GRADIENT_OP("Roll" , RollGrad); |
37 | |
38 | } // namespace |
39 | } // namespace ops |
40 | } // namespace tensorflow |
41 | |