| 75 | } |
| 76 | |
| 77 | void ConvertToHalfValue(const Tensor& in_tensor, const string name, |
| 78 | BundleWriter& writer) { |
| 79 | auto in_data = in_tensor.flat<float>(); |
| 80 | Tensor out_tensor(DataTypeToEnum<Eigen::half>::v(), in_tensor.shape()); |
| 81 | auto out_data = out_tensor.flat<Eigen::half>(); |
| 82 | #if INTEL_MKL |
| 83 | #pragma omp parallel for num_threads(omp_get_num_procs()) |
| 84 | #endif // INTEL_MKL |
| 85 | for (size_t i = 0; i < out_tensor.NumElements(); ++i) { |
| 86 | out_data(i) = static_cast<Eigen::half>(in_data(i)); |
| 87 | } |
| 88 | writer.Add(name, out_tensor); |
| 89 | } |
| 90 | |
| 91 | void ConvertToInt8Value(const Tensor& in_tensor, const string name, |
| 92 | const string scale_name, BundleWriter& writer) { |
no test coverage detected