From 3f03480efe345992f8bacfa33f16310fed9da1e9 Mon Sep 17 00:00:00 2001 From: caifubi Date: Wed, 15 Jul 2020 16:14:03 +0800 Subject: [PATCH] fix dump device address cannot access --- mindspore/ccsrc/runtime/device/ascend/dump/data_dumper.cc | 6 +++--- mindspore/ccsrc/runtime/device/device_address.h | 1 + mindspore/core/ir/device_sync.h | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mindspore/ccsrc/runtime/device/ascend/dump/data_dumper.cc b/mindspore/ccsrc/runtime/device/ascend/dump/data_dumper.cc index ab2c6b274..ca9a74022 100644 --- a/mindspore/ccsrc/runtime/device/ascend/dump/data_dumper.cc +++ b/mindspore/ccsrc/runtime/device/ascend/dump/data_dumper.cc @@ -107,9 +107,9 @@ void DataDumper::SetOpMappingInfo(NotNull dump_inf MS_EXCEPTION_IF_NULL(currnet_epoch_tensor->device_address()); MS_EXCEPTION_IF_NULL(steps_per_epoch_tensor->device_address()); - void *current_step = current_step_tensor->device_address()->ptr_; - void *current_epoch = currnet_epoch_tensor->device_address()->ptr_; - void *steps_per_epoch = steps_per_epoch_tensor->device_address()->ptr_; + void *current_step = current_step_tensor->device_address()->GetMutablePtr(); + void *current_epoch = currnet_epoch_tensor->device_address()->GetMutablePtr(); + void *steps_per_epoch = steps_per_epoch_tensor->device_address()->GetMutablePtr(); if (current_epoch != nullptr && current_step != nullptr && steps_per_epoch != nullptr) { dump_info->set_step_id_addr(reinterpret_cast(current_epoch)); diff --git a/mindspore/ccsrc/runtime/device/device_address.h b/mindspore/ccsrc/runtime/device/device_address.h index 32f5fcced..fb3cf6348 100644 --- a/mindspore/ccsrc/runtime/device/device_address.h +++ b/mindspore/ccsrc/runtime/device/device_address.h @@ -65,6 +65,7 @@ class DeviceAddress : public mindspore::DeviceSync { virtual void set_status(DeviceAddressStatus status) {} virtual DeviceAddressStatus status() const { return DeviceAddressStatus::kInDevice; } virtual DeviceAddressType DeviceType() const { return DeviceAddressType::kUnknown; } + void *GetMutablePtr() const override { return ptr_; } protected: const void *ptr() const { return ptr_; } diff --git a/mindspore/core/ir/device_sync.h b/mindspore/core/ir/device_sync.h index a6bbe9223..708b6b0e5 100644 --- a/mindspore/core/ir/device_sync.h +++ b/mindspore/core/ir/device_sync.h @@ -32,6 +32,7 @@ class DeviceSync { virtual bool SyncDeviceToHost(const std::vector &shape, size_t size, TypeId type, void *host_ptr) const = 0; virtual bool SyncHostToDevice(const std::vector &shape, size_t size, TypeId type, const void *host_ptr) const = 0; + virtual void *GetMutablePtr() const = 0; }; using DeviceSyncPtr = std::shared_ptr; } // namespace mindspore -- GitLab