| 866 | |
| 867 | template <typename SType> |
| 868 | void Tensor::get_value(SType *value, const size_t num) const { |
| 869 | CHECK(device_ == defaultDevice); |
| 870 | Tensor t(shape_, device_, data_type_); |
| 871 | // transform function arrange data in memory considering stride |
| 872 | singa::Transform(*this, &t); |
| 873 | auto ptr = static_cast<const SType *>(t.block()->data()); |
| 874 | for (size_t i = 0; i < num; i++) value[i] = ptr[i]; |
| 875 | } |
| 876 | template void Tensor::get_value<float>(float *value, const size_t num) const; |
| 877 | template void Tensor::get_value<half_float::half>(half_float::half *value, |
| 878 | const size_t num) const; |