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

Method WithRank

tensorflow/core/framework/shape_inference.cc:368–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

366}
367
368Status InferenceContext::WithRank(ShapeHandle shape, int64 rank,
369 ShapeHandle* out) {
370 if (rank > kint32max) {
371 return errors::InvalidArgument("Rank cannot exceed kint32max");
372 }
373 const int32 existing = Rank(shape);
374 if (existing == rank) {
375 *out = shape;
376 return Status::OK();
377 }
378 if (existing == kUnknownRank) {
379 std::vector<DimensionHandle> dims;
380 dims.reserve(rank);
381 for (int i = 0; i < rank; ++i) {
382 dims.push_back(UnknownDim());
383 }
384 ShapeHandle shp = shape_manager_.MakeShape(dims);
385 return Merge(shape, shp, out);
386 }
387 *out = nullptr;
388
389 return errors::InvalidArgument("Shape must be rank ", rank, " but is rank ",
390 existing);
391}
392
393Status InferenceContext::WithRankAtLeast(ShapeHandle shape, int64 rank,
394 ShapeHandle* out) {

Callers 15

SetOutputToSizedImageFunction · 0.45
ResizeShapeFnFunction · 0.45
image_ops.ccFile · 0.45
beam_search_ops.ccFile · 0.45
quantile_ops.ccFile · 0.45
training_ops.ccFile · 0.45
model_ops.ccFile · 0.45
skip_gram_ops.ccFile · 0.45

Calls 6

InvalidArgumentFunction · 0.85
RankFunction · 0.50
MergeFunction · 0.50
reserveMethod · 0.45
push_backMethod · 0.45
MakeShapeMethod · 0.45

Tested by 2

RFFTShapeFunction · 0.36
TEST_FFunction · 0.36