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

Function HandleKvGradAndIndicesInputs

tensorflow/core/ops/training_ali_ops.cc:59–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59static Status HandleKvGradAndIndicesInputs(InferenceContext* c, bool sparse,
60 int grad_idx, ShapeHandle* s) {
61 ShapeHandle grad = ShapeOrHandleShape(c, grad_idx);
62 if (!sparse) {
63 TF_RETURN_IF_ERROR(c->Merge(*s, grad, s));
64 return Status::OK();
65 }
66 // Indices is a vector where indices.dim[0].rank == grad[0].rank.
67 ShapeHandle indices;
68 TF_RETURN_IF_ERROR(c->WithRank(c->input(grad_idx + 1), 1, &indices));
69 DimensionHandle unused;
70 TF_RETURN_IF_ERROR(c->Merge(c->Dim(indices, 0), c->Dim(grad, 0), &unused));
71
72 // Trailing part of grad matches trailing part of *s.
73 ShapeHandle grad_unknown_first;
74 TF_RETURN_IF_ERROR(
75 c->Subshape(grad, 1, &grad_unknown_first));
76 TF_RETURN_IF_ERROR(c->Merge(*s, grad_unknown_first, s));
77
78 return Status::OK();
79}
80
81static Status KvResourceApplyAdagradShapeFn(InferenceContext* c, bool sparse) {
82 ShapeHandle unused;

Callers 5

KvApplyAdamAsyncShapeFnFunction · 0.85

Calls 6

SubshapeMethod · 0.80
ShapeOrHandleShapeFunction · 0.70
MergeMethod · 0.45
WithRankMethod · 0.45
inputMethod · 0.45
DimMethod · 0.45

Tested by

no test coverage detected