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

Function RecursiveElementCount

tensorflow/compiler/xla/literal_comparison.cc:203–216  ·  view source on GitHub ↗

Gets the total element count. For tuples, this is not the count of tuple elements, but the sum of elements of each tuple element.

Source from the content-addressed store, hash-verified

201// Gets the total element count. For tuples, this is not the count of tuple
202// elements, but the sum of elements of each tuple element.
203int64 RecursiveElementCount(const Shape& shape) {
204 if (shape.IsTuple()) {
205 const int64 tuple_elements = ShapeUtil::TupleElementCount(shape);
206 int64 total = 0;
207 for (int64 i = 0; i < tuple_elements; ++i) {
208 total += RecursiveElementCount(ShapeUtil::GetTupleElementShape(shape, i));
209 }
210 return total;
211 } else if (shape.IsArray()) {
212 return ShapeUtil::ElementsIn(shape);
213 } else {
214 return 0;
215 }
216}
217
218// Returns whether the given value is infinity.
219template <typename NativeT>

Callers 2

NearHelperFunction · 0.85
ToStringTruncatedFunction · 0.85

Calls 2

IsTupleMethod · 0.45
IsArrayMethod · 0.45

Tested by

no test coverage detected