Commit 8a84761b authored by Catheriany's avatar Catheriany
Browse files

issue/12: 沐曦多卡推理卡死问题修复

parent 1e30fac0
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <algorithm> #include <algorithm>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <mutex>
#include <numeric> #include <numeric>
#include <sstream> #include <sstream>
...@@ -143,8 +144,13 @@ std::shared_ptr<Tensor> Tensor::weight(void *data, infiniDtype_t dtype, ...@@ -143,8 +144,13 @@ std::shared_ptr<Tensor> Tensor::weight(void *data, infiniDtype_t dtype,
tensor->_storage = Storage::create(size); tensor->_storage = Storage::create(size);
tensor->_desc = TensorDesc::create(dtype, shape, strides); tensor->_desc = TensorDesc::create(dtype, shape, strides);
RUN_INFINI(infinirtMemcpy(tensor->_storage->memory(), // NOTE: 为兼容部分平台(沐曦)多线程并发对同一host数据执行memcpy卡死问题
data, size, INFINIRT_MEMCPY_H2D)); static std::mutex mutex;
{
std::lock_guard<std::mutex> lock(mutex);
RUN_INFINI(infinirtMemcpy(tensor->_storage->memory(),
data, size, INFINIRT_MEMCPY_H2D));
}
tensor->_offset = 0; tensor->_offset = 0;
return tensor; return tensor;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment