未验证 提交 360b54be 编写于 作者: myq406450149's avatar myq406450149 提交者: GitHub

fix bugs about cuda context and CopyToCpu func (#2465)

上级 d8ddbcc6
...@@ -93,7 +93,7 @@ void Tensor::CopyFromCpu(const T *src_data) { ...@@ -93,7 +93,7 @@ void Tensor::CopyFromCpu(const T *src_data) {
} }
} }
template <typename T> template <typename T>
void Tensor::CopyToCpu(T *data) { void Tensor::CopyToCpu(T *data) const {
const T *src_data = tensor(raw_tensor_)->data<T>(); const T *src_data = tensor(raw_tensor_)->data<T>();
int64_t num = tensor(raw_tensor_)->numel(); int64_t num = tensor(raw_tensor_)->numel();
CHECK(num > 0) << "You should call Resize interface first"; CHECK(num > 0) << "You should call Resize interface first";
...@@ -124,9 +124,9 @@ template void Tensor::CopyFromCpu<int, TargetType::kCUDA>(const int *); ...@@ -124,9 +124,9 @@ template void Tensor::CopyFromCpu<int, TargetType::kCUDA>(const int *);
template void Tensor::CopyFromCpu<float, TargetType::kCUDA>(const float *); template void Tensor::CopyFromCpu<float, TargetType::kCUDA>(const float *);
template void Tensor::CopyFromCpu<int8_t, TargetType::kCUDA>(const int8_t *); template void Tensor::CopyFromCpu<int8_t, TargetType::kCUDA>(const int8_t *);
template void Tensor::CopyToCpu(int8_t *); template void Tensor::CopyToCpu(int8_t *) const;
template void Tensor::CopyToCpu(float *); template void Tensor::CopyToCpu(float *) const;
template void Tensor::CopyToCpu(int *); template void Tensor::CopyToCpu(int *) const;
shape_t Tensor::shape() const { shape_t Tensor::shape() const {
return ctensor(raw_tensor_)->dims().Vectorize(); return ctensor(raw_tensor_)->dims().Vectorize();
......
...@@ -49,7 +49,7 @@ struct LITE_API Tensor { ...@@ -49,7 +49,7 @@ struct LITE_API Tensor {
void CopyFromCpu(const T* data); void CopyFromCpu(const T* data);
template <typename T> template <typename T>
void CopyToCpu(T* data); void CopyToCpu(T* data) const;
/// Shape of the tensor. /// Shape of the tensor.
shape_t shape() const; shape_t shape() const;
TargetType target() const; TargetType target() const;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册