tensorflow/compiler/mlir/hlo/lib/utils/hlo_utils.cc
/// Computes the memory usage of the given allocations.
Computes the memory usage of the given allocations.
Computes the memory usage of the given allocations .
std::pair<size_t, size_t> computeMemory(const std::vector<Value>& allocs) {
  size_t totalSize = 0;
  size_t allocCounter = 0;
  for (const Value alloc : allocs) {
    auto shape = alloc.getType().cast<ShapedType>();
    size_t shapeBytes = llvm::divideCeil(shape.getSizeInBits(), 8);
    size_t alignFactor = llvm::divideCeil(shapeBytes, kPaddingSize);
    size_t size = alignFactor * kPaddingSize;
    totalSize += size;
    allocCounter++;
  }
  return std::make_pair(totalSize, allocCounter);
}
std :: pair < size_t , size_t > computeMemory ( const std :: vector < Value > & allocs ) { size_t totalSize = 0 ; size_t allocCounter = 0 ; for ( const Value alloc : allocs ) { auto shape = alloc . getType ( ) . cast < ShapedType > ( ) ; size_t shapeBytes = llvm :: divideCeil ( shape . getSizeInBits ( ) , 8 ) ; size_t alignFactor = llvm :: divideCeil ( shapeBytes , kPaddingSize ) ; size_t size = alignFactor * kPaddingSize ; totalSize += size ; allocCounter ++ ; } return std :: make_pair ( totalSize , allocCounter ) ; }
Computes the memory usage of the given allocations.
Computes the memory usage of the given allocations .