| 100 | } |
| 101 | |
| 102 | Result<std::shared_ptr<Buffer>> MemoryManager::ViewBuffer( |
| 103 | const std::shared_ptr<Buffer>& buf, const std::shared_ptr<MemoryManager>& to) { |
| 104 | if (buf->memory_manager() == to) { |
| 105 | return buf; |
| 106 | } |
| 107 | const auto& from = buf->memory_manager(); |
| 108 | auto maybe_buffer = to->ViewBufferFrom(buf, from); |
| 109 | COPY_BUFFER_RETURN(maybe_buffer, to); |
| 110 | // `to` doesn't support viewing from `from`, try the other way |
| 111 | maybe_buffer = from->ViewBufferTo(buf, to); |
| 112 | COPY_BUFFER_RETURN(maybe_buffer, to); |
| 113 | |
| 114 | return Status::NotImplemented("Viewing buffer from ", from->device()->ToString(), |
| 115 | " on ", to->device()->ToString(), " not supported"); |
| 116 | } |
| 117 | |
| 118 | Status MemoryManager::CopyBufferSliceToCPU(const std::shared_ptr<Buffer>& buf, |
| 119 | int64_t offset, int64_t length, |
nothing calls this directly
no test coverage detected