| 43 | //============================================================================== |
| 44 | |
| 45 | Status RaggedRangeShapeFn(InferenceContext* c) { |
| 46 | // Check that all inputs (starts, limits, and deltas) have rank 0 or 1. |
| 47 | ShapeHandle starts = c->input(0); |
| 48 | ShapeHandle limits = c->input(1); |
| 49 | ShapeHandle deltas = c->input(2); |
| 50 | TF_RETURN_IF_ERROR(c->WithRankAtMost(starts, 1, &starts)); |
| 51 | TF_RETURN_IF_ERROR(c->WithRankAtMost(limits, 1, &limits)); |
| 52 | TF_RETURN_IF_ERROR(c->WithRankAtMost(deltas, 1, &deltas)); |
| 53 | |
| 54 | // For the inputs with rank 1, make sure shapes match. |
| 55 | DimensionHandle dim = c->UnknownDim(); |
| 56 | if (c->Rank(starts) == 1) { |
| 57 | TF_RETURN_IF_ERROR(c->Merge(c->Dim(starts, 0), dim, &dim)); |
| 58 | } |
| 59 | if (c->Rank(limits) == 1) { |
| 60 | TF_RETURN_IF_ERROR(c->Merge(c->Dim(limits, 0), dim, &dim)); |
| 61 | } |
| 62 | if (c->Rank(deltas) == 1) { |
| 63 | TF_RETURN_IF_ERROR(c->Merge(c->Dim(deltas, 0), dim, &dim)); |
| 64 | } |
| 65 | |
| 66 | // If any input shape is known, then calculate `rt_nested_splits` shape. |
| 67 | int64 rt_nested_splits_dim = InferenceContext::kUnknownDim; |
| 68 | if (c->ValueKnown(dim)) { |
| 69 | rt_nested_splits_dim = c->Value(dim) + 1; |
| 70 | } else if (c->Rank(starts) == 0 && c->Rank(limits) == 0 && |
| 71 | c->Rank(deltas) == 0) { |
| 72 | rt_nested_splits_dim = 2; |
| 73 | } |
| 74 | c->set_output(0, c->Vector(rt_nested_splits_dim)); |
| 75 | |
| 76 | // `rt_dense_values` is rank 1, but size can't be calculated statically. |
| 77 | c->set_output(1, c->UnknownShapeOfRank(1)); |
| 78 | return Status::OK(); |
| 79 | } |
| 80 | |
| 81 | } // namespace tensorflow |
nothing calls this directly
no test coverage detected