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

Function HandleGradAndIndicesInputs

tensorflow/core/ops/training_ali_ops.cc:37–57  ·  view source on GitHub ↗

Handle the gradient and, if , indices inputs. is an input+output parameter, containing the current known input shape to the gradient.

Source from the content-addressed store, hash-verified

35// <s> is an input+output parameter, containing the current known input shape to
36// the gradient.
37static Status HandleGradAndIndicesInputs(InferenceContext* c, bool sparse,
38 int grad_idx, ShapeHandle* s) {
39 ShapeHandle grad = ShapeOrHandleShape(c, grad_idx);
40 if (!sparse) {
41 TF_RETURN_IF_ERROR(c->Merge(*s, grad, s));
42 return Status::OK();
43 }
44 // Indices is a vector where indices.dim[0].rank == grad[0].rank.
45 ShapeHandle indices;
46 TF_RETURN_IF_ERROR(c->WithRank(c->input(grad_idx + 1), 1, &indices));
47 DimensionHandle unused;
48 TF_RETURN_IF_ERROR(c->Merge(c->Dim(indices, 0), c->Dim(grad, 0), &unused));
49
50 // Trailing part of grad matches trailing part of *s.
51 ShapeHandle grad_unknown_first;
52 TF_RETURN_IF_ERROR(
53 c->ReplaceDim(grad, 0, c->UnknownDim(), &grad_unknown_first));
54 TF_RETURN_IF_ERROR(c->Merge(*s, grad_unknown_first, s));
55
56 return Status::OK();
57}
58
59static Status HandleKvGradAndIndicesInputs(InferenceContext* c, bool sparse,
60 int grad_idx, ShapeHandle* s) {

Callers 2

ApplyAdagradDecayShapeFnFunction · 0.70
ApplyAdamAsyncShapeFnFunction · 0.70

Calls 7

ReplaceDimMethod · 0.80
UnknownDimMethod · 0.80
ShapeOrHandleShapeFunction · 0.70
MergeMethod · 0.45
WithRankMethod · 0.45
inputMethod · 0.45
DimMethod · 0.45

Tested by

no test coverage detected