diff --git a/tensorflow/compiler/xla/service/hlo_rematerialization.cc b/tensorflow/compiler/xla/service/hlo_rematerialization.cc index 21be4216469..bfc6769660a 100644 --- a/tensorflow/compiler/xla/service/hlo_rematerialization.cc +++ b/tensorflow/compiler/xla/service/hlo_rematerialization.cc @@ -1648,6 +1648,8 @@ StatusOr HloRematerialization::RematerializeComputation( } else { // Found a valid block. Reset to start looking for single instructions // again. + max_rematerialized_block_size_ = + std::max(max_rematerialized_block_size_, max_block_size); changed = true; min_block_size = 1; max_block_size = 1; diff --git a/tensorflow/compiler/xla/service/hlo_rematerialization.h b/tensorflow/compiler/xla/service/hlo_rematerialization.h index d1c4b8b5e7b..72221fa8a32 100644 --- a/tensorflow/compiler/xla/service/hlo_rematerialization.h +++ b/tensorflow/compiler/xla/service/hlo_rematerialization.h @@ -180,6 +180,10 @@ class HloRematerialization : public HloModulePass { // dead. Hence, no net instructions were added. int64 net_instructions_added_ = 0; + // Size of the largest block that has been rematerialized. This is actually an + // upper bound (within a factor of 2) on the block size. + int max_rematerialized_block_size_ = 0; + RematerializationMode mode_; };