Handle the gradient and, if , indices inputs. is an input+output parameter, containing the current known input shape to the gradient.
| 35 | // <s> is an input+output parameter, containing the current known input shape to |
| 36 | // the gradient. |
| 37 | static 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 | |
| 59 | static Status HandleKvGradAndIndicesInputs(InferenceContext* c, bool sparse, |
| 60 | int grad_idx, ShapeHandle* s) { |
no test coverage detected