MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / FillGrad

Function FillGrad

tensorflow/cc/gradients/array_grad.cc:137–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135REGISTER_GRADIENT_OP("SplitV", SplitVGrad);
136
137Status FillGrad(const Scope& scope, const Operation& op,
138 const std::vector<Output>& grad_inputs,
139 std::vector<Output>* grad_outputs) {
140 // y = fill(fill_shape, x)
141 // No gradient returned for the fill_shape argument.
142 grad_outputs->push_back(NoGradient());
143 // The gradient for x (which must be a scalar) is just the sum of
144 // all the gradients from the shape it fills.
145 // We use ReduceSum to implement this, which needs an argument providing
146 // the indices of all the dimensions of the incoming gradient.
147 // grad(x) = reduce_sum(grad(y), [0..rank(grad(y))])
148 auto all_dims = Range(scope, Const(scope, 0), Rank(scope, grad_inputs[0]),
149 Const(scope, 1));
150 grad_outputs->push_back(ReduceSum(scope, grad_inputs[0], all_dims));
151 return scope.status();
152}
153REGISTER_GRADIENT_OP("Fill", FillGrad);
154
155Status DiagGrad(const Scope& scope, const Operation& op,

Callers

nothing calls this directly

Calls 6

NoGradientFunction · 0.85
RangeClass · 0.50
ConstFunction · 0.50
RankFunction · 0.50
push_backMethod · 0.45
statusMethod · 0.45

Tested by

no test coverage detected