| 406 | } |
| 407 | |
| 408 | Status InferenceContext::WithRankAtMost(ShapeHandle shape, int64 rank, |
| 409 | ShapeHandle* out) { |
| 410 | if (rank > kint32max) { |
| 411 | return errors::InvalidArgument("Rank cannot exceed kint32max"); |
| 412 | } |
| 413 | const int32 existing = Rank(shape); |
| 414 | if (existing <= rank || existing == kUnknownRank) { |
| 415 | *out = shape; |
| 416 | return Status::OK(); |
| 417 | } |
| 418 | *out = nullptr; |
| 419 | return errors::InvalidArgument("Shape must be at most rank ", rank, |
| 420 | " but is rank ", existing); |
| 421 | } |
| 422 | |
| 423 | Status InferenceContext::WithValue(DimensionHandle dim, int64 value, |
| 424 | DimensionHandle* out) { |