Skip to content

Commit

Permalink
Memory space related copies should not be normalized.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 675755862
  • Loading branch information
Google-ML-Automation committed Sep 17, 2024
1 parent 2b1c609 commit 6673589
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions xla/service/host_offload_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,5 +244,17 @@ bool IsHostAsyncStart(const HloInstruction* instruction) {
instruction->async_execution_thread() == HloInstruction::kHostThread;
}

bool IsSynchronousCopyFromOrToHost(const HloInstruction* instruction) {
if (instruction->opcode() != HloOpcode::kCopy) {
return false;
}
return (instruction->shape().has_layout() &&
instruction->shape().layout().memory_space() ==
Layout::kHostMemorySpace) ||
(instruction->operand(0)->shape().has_layout() &&
instruction->operand(0)->shape().layout().memory_space() ==
Layout::kHostMemorySpace);
}

} // namespace host_offload_utils
} // namespace xla
3 changes: 3 additions & 0 deletions xla/service/host_offload_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ bool IsValidDuringPureMemoryOffload(const HloInstruction* instruction);
// Returns true if the instruction is an async-start with host thread.
bool IsHostAsyncStart(const HloInstruction* instruction);

// Returns true if the copy is from or to host memory space.
bool IsSynchronousCopyFromOrToHost(const HloInstruction* instruction);

} // namespace host_offload_utils
} // namespace xla

Expand Down

0 comments on commit 6673589

Please sign in to comment.