| 655 | // "out" corresponding to type T. |
| 656 | template <typename T> |
| 657 | void ToProtoField(const TensorBuffer& in, int64 n, TensorProto* out) { |
| 658 | const T* data = in.base<const T>(); |
| 659 | // NOTE: T may not the same as |
| 660 | // ProtoHelper<T>::FieldType::value_type. E.g., T==int16, |
| 661 | // ProtoHelper<T>::FieldType::value_type==int32. If performance is |
| 662 | // critical, we can specialize T=float and do memcpy directly. |
| 663 | ProtoHelper<T>::Fill(data, n, out); |
| 664 | } |
| 665 | |
| 666 | void RefIfNonNull(core::RefCounted* buf) { |
| 667 | if (buf) buf->Ref(); |