未验证 提交 4f3cd537 编写于 作者: 石晓伟 提交者: GitHub

turn template specializations into instantiations, test=develop (#4015)

上级 de299b9e
...@@ -78,50 +78,28 @@ void Tensor::Resize(const shape_t &shape) { ...@@ -78,50 +78,28 @@ void Tensor::Resize(const shape_t &shape) {
tensor(raw_tensor_)->Resize(shape); tensor(raw_tensor_)->Resize(shape);
} }
// Tensor::data template <typename T>
template <> const T *Tensor::data() const {
const float *Tensor::data() const { return ctensor(raw_tensor_)->data<T>();
return ctensor(raw_tensor_)->data<float>();
}
template <>
const int8_t *Tensor::data() const {
return ctensor(raw_tensor_)->data<int8_t>();
}
template <>
const uint8_t *Tensor::data() const {
return ctensor(raw_tensor_)->data<uint8_t>();
}
template <>
const int64_t *Tensor::data() const {
return ctensor(raw_tensor_)->data<int64_t>();
}
template <>
const int32_t *Tensor::data() const {
return ctensor(raw_tensor_)->data<int32_t>();
} }
// Tensor::mutable_data template <typename T>
template <> T *Tensor::mutable_data(TargetType type) const {
int *Tensor::mutable_data(TargetType type) const { return tensor(raw_tensor_)->mutable_data<T>(type);
return tensor(raw_tensor_)->mutable_data<int>(type);
}
template <>
float *Tensor::mutable_data(TargetType type) const {
return tensor(raw_tensor_)->mutable_data<float>(type);
}
template <>
int8_t *Tensor::mutable_data(TargetType type) const {
return tensor(raw_tensor_)->mutable_data<int8_t>(type);
}
template <>
uint8_t *Tensor::mutable_data(TargetType type) const {
return tensor(raw_tensor_)->mutable_data<uint8_t>(type);
}
template <>
int64_t *Tensor::mutable_data(TargetType type) const {
return tensor(raw_tensor_)->mutable_data<int64_t>(type);
} }
template const float *Tensor::data<float>() const;
template const int8_t *Tensor::data<int8_t>() const;
template const uint8_t *Tensor::data<uint8_t>() const;
template const int64_t *Tensor::data<int64_t>() const;
template const int32_t *Tensor::data<int32_t>() const;
template int *Tensor::mutable_data(TargetType type) const;
template float *Tensor::mutable_data(TargetType type) const;
template int8_t *Tensor::mutable_data(TargetType type) const;
template uint8_t *Tensor::mutable_data(TargetType type) const;
template int64_t *Tensor::mutable_data(TargetType type) const;
template <typename T, TargetType type> template <typename T, TargetType type>
void Tensor::CopyFromCpu(const T *src_data) { void Tensor::CopyFromCpu(const T *src_data) {
T *data = tensor(raw_tensor_)->mutable_data<T>(type); T *data = tensor(raw_tensor_)->mutable_data<T>(type);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册