aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/compiler/xla/service/heap_simulator.h
diff options
context:
space:
mode:
authorGravatar Dimitris Vardoulakis <dimvar@google.com>2018-10-03 16:47:49 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-10-03 16:56:47 -0700
commit13941241e984e4a4296891f4e61a9ed5b3107b22 (patch)
tree187a641531c02b98eff5f3338bf36615cdb20185 /tensorflow/compiler/xla/service/heap_simulator.h
parentaeb044c9784d30a25c0d15fa31f479001be55052 (diff)
[TF:XLA] Improve the accounting for subcomputations in the heap simulator.
Subtract the size of the aliased buffers from the subcomputation estimate instead of from the current computation. This way, the memory estimate for the current computation is more accurate. For the newly added test, the heap simulation calculates 48 bytes at head instead of the correct 64 bytes. PiperOrigin-RevId: 215653047
Diffstat (limited to 'tensorflow/compiler/xla/service/heap_simulator.h')
-rw-r--r--tensorflow/compiler/xla/service/heap_simulator.h13
1 files changed, 3 insertions, 10 deletions
diff --git a/tensorflow/compiler/xla/service/heap_simulator.h b/tensorflow/compiler/xla/service/heap_simulator.h
index b0295a6163..dbbf43082f 100644
--- a/tensorflow/compiler/xla/service/heap_simulator.h
+++ b/tensorflow/compiler/xla/service/heap_simulator.h
@@ -218,12 +218,6 @@ class HeapAlgorithm {
// Alloc allocates a buffer of 'size' bytes.
virtual void Alloc(const BufferValue* buffer, int64 size) = 0;
- // NoFragmentationStatsHeap overrides this method.
- virtual void Alloc(const BufferValue* buffer, int64 size,
- const HloInstruction* instruction) {
- Alloc(buffer, size);
- }
-
// Takes memory usage of subcomputations into account when calculating the
// memory usage of a computation. Currently, we don't handle buffer aliasing
// between computations entirely correctly. We are careful to not double count
@@ -235,6 +229,8 @@ class HeapAlgorithm {
// analysis, it's not worth making major changes to HeapSimulator now.
virtual void AccountForSubcomputationMemory(
const HloInstruction* instruction,
+ // The total number of bytes allocated by instruction.
+ int64 alloc_size_by_instruction,
const absl::flat_hash_map<const HloComputation*, int64>&
memory_by_computation) {}
@@ -257,11 +253,8 @@ class NoFragmentationStatsHeap : public HeapAlgorithm {
void Alloc(const BufferValue* buffer, int64 size) override;
- void Alloc(const BufferValue* buffer, int64 size,
- const HloInstruction* instruction) override;
-
void AccountForSubcomputationMemory(
- const HloInstruction* instruction,
+ const HloInstruction* instruction, int64 alloc_size_by_instruction,
const absl::flat_hash_map<const HloComputation*, int64>&
memory_by_computation) override;