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

Method NumElements

tensorflow/core/framework/shape_inference.cc:313–333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

311}
312
313DimensionHandle InferenceContext::NumElements(ShapeHandle s) {
314 const auto rank = Rank(s);
315 if (rank == kUnknownRank) return UnknownDim();
316 bool found_unknown = false;
317 int64 size = 1;
318 for (int i = 0; i < rank; ++i) {
319 int64 dim_val = Value(Dim(s, i));
320 if (dim_val == kUnknownDim) {
321 found_unknown = true;
322 } else if (dim_val == 0) {
323 return MakeDim(0);
324 } else {
325 size *= dim_val;
326 }
327 }
328 if (found_unknown) {
329 return UnknownDim();
330 } else {
331 return MakeDim(size);
332 }
333}
334
335string InferenceContext::DebugString(ShapeHandle s) {
336 if (RankKnown(s)) {

Callers

nothing calls this directly

Calls 2

ValueClass · 0.70
RankFunction · 0.50

Tested by

no test coverage detected