Browse Source

fix unnecessary tensor sync

tags/v1.0.0
kswang 5 years ago
parent
commit
b5e579567c
4 changed files with 3 additions and 4 deletions
  1. +1
    -0
      mindspore/ccsrc/backend/session/executor.cc
  2. +0
    -1
      mindspore/ccsrc/runtime/device/cpu/cpu_kernel_runtime.cc
  3. +0
    -1
      mindspore/core/ir/tensor.cc
  4. +2
    -2
      mindspore/core/ir/tensor.h

+ 1
- 0
mindspore/ccsrc/backend/session/executor.cc View File

@@ -42,6 +42,7 @@ void UpdateOutputTensors(const VectorRef *outputs,
if (tensor->NeedSyncDeviceToHostImmediately()) {
tensor->data_sync();
tensor->set_device_address(nullptr);
tensor->set_sync_status(kNeedSyncHostToDevice);
}
}
}


+ 0
- 1
mindspore/ccsrc/runtime/device/cpu/cpu_kernel_runtime.cc View File

@@ -248,7 +248,6 @@ void CPUKernelRuntime::BindInputOutput(session::KernelGraph *kernel_graph, const
tensor->data_c())) {
MS_LOG(EXCEPTION) << "Parameter node sync host to device failed!";
}
tensor->set_sync_status(kNeedSyncHostToDevice);
}
address->ref_count_ = INIT_NODE_REF;
tensor->set_device_address(address);


+ 0
- 1
mindspore/core/ir/tensor.cc View File

@@ -557,7 +557,6 @@ void Tensor::data_sync() const {
if (!device_sync_->SyncDeviceToHost(shape(), static_cast<size_t>(data().nbytes()), data_type(), data_c())) {
MS_LOG(EXCEPTION) << "SyncDeviceToHost failed.";
}
sync_status_ = kNeedSyncHostToDevice;
}

TypeId Tensor::set_data_type(const TypeId data_type) {


+ 2
- 2
mindspore/core/ir/tensor.h View File

@@ -289,7 +289,7 @@ class Tensor : public MetaTensor {
if (event_ != nullptr) {
event_->Wait();
}
event_ == nullptr;
event_ = nullptr;
}

void set_sync_status(TensorSyncStatus sync_status) { sync_status_ = sync_status; }
@@ -306,7 +306,7 @@ class Tensor : public MetaTensor {
bool init_flag_{false};
TensorDataPtr data_{nullptr};
std::string id_{""};
std::shared_ptr<WaitEvent> event_{nullptr};
mutable std::shared_ptr<WaitEvent> event_{nullptr};
mutable TensorSyncStatus sync_status_{kNeedSyncHostToDevice};
DeviceSyncPtr device_sync_{nullptr};
std::vector<Axis> padding_type_;


Loading…
Cancel
Save