MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / half>

Method half>

tensorflow/core/framework/tensor.cc:607–628  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

605// we don't use ProtoHelper<uint16>).
606template <>
607TensorBuffer* FromProtoField<Eigen::half>(Allocator* a, const TensorProto& in,
608 int64 n) {
609 CHECK_GT(n, 0);
610 Buffer<Eigen::half>* buf = new Buffer<Eigen::half>(a, n);
611 uint16* data = buf->template base<uint16>();
612 if (data == nullptr) {
613 buf->Unref();
614 return nullptr;
615 }
616 const int64 in_n = in.half_val().size();
617 auto begin = in.half_val().begin();
618 if (n <= in_n) {
619 std::copy_n(begin, n, data);
620 } else if (in_n > 0) {
621 std::copy_n(begin, in_n, data);
622 const uint16 last = *(data + in_n - 1);
623 std::fill_n(data + in_n, n - in_n, last);
624 } else {
625 std::fill_n(data, n, 0);
626 }
627 return buf;
628}
629
630template <>
631TensorBuffer* FromProtoField<bfloat16>(Allocator* a, const TensorProto& in,

Callers

nothing calls this directly

Calls 3

UnrefMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected