| 391 | } |
| 392 | |
| 393 | Status InferenceContext::WithRankAtLeast(ShapeHandle shape, int64 rank, |
| 394 | ShapeHandle* out) { |
| 395 | if (rank > kint32max) { |
| 396 | return errors::InvalidArgument("Rank cannot exceed kint32max"); |
| 397 | } |
| 398 | const int32 existing = Rank(shape); |
| 399 | if (existing >= rank || existing == kUnknownRank) { |
| 400 | *out = shape; |
| 401 | return Status::OK(); |
| 402 | } |
| 403 | *out = nullptr; |
| 404 | return errors::InvalidArgument("Shape must be at least rank ", rank, |
| 405 | " but is rank ", existing); |
| 406 | } |
| 407 | |
| 408 | Status InferenceContext::WithRankAtMost(ShapeHandle shape, int64 rank, |
| 409 | ShapeHandle* out) { |