提交 5e6f84f7 编写于 作者: myq406450149's avatar myq406450149

change CopyToCpu to const func to support const tensor

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