This is an automated email from the ASF dual-hosted git repository.
masahi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new a8663d2 [Metal] Fix run metal model when non first device is selected
(#8261)
a8663d2 is described below
commit a8663d223a163a932b6c5ebe7d21108f98cd7b94
Author: Egor Churaev <[email protected]>
AuthorDate: Wed Jun 16 01:10:22 2021 +0300
[Metal] Fix run metal model when non first device is selected (#8261)
In case when we select non first Metal device, we got problem in
stream, due to we used wrong device_id in CopyDataFromTo.
---
src/runtime/metal/metal_device_api.mm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/runtime/metal/metal_device_api.mm
b/src/runtime/metal/metal_device_api.mm
index 1c5666d..43d8ccd 100644
--- a/src/runtime/metal/metal_device_api.mm
+++ b/src/runtime/metal/metal_device_api.mm
@@ -206,11 +206,11 @@ void MetalWorkspace::CopyDataFromTo(const void* from,
size_t from_offset, void*
AUTORELEASEPOOL {
this->Init();
Device dev = dev_from;
+ if (dev_from.device_type == kDLCPU) dev = dev_to;
Stream* s = GetStream(stream, dev.device_id);
if (s->HasErrorHappened()) {
LOG(FATAL) << "Error! Some problems on GPU happaned! Cannot copy data to
current stream";
}
- if (dev_from.device_type == kDLCPU) dev = dev_to;
id<MTLCommandBuffer> cb = s->GetCommandBuffer();
int from_dev_type = static_cast<int>(dev_from.device_type);
int to_dev_type = static_cast<int>(dev_to.device_type);