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

Method GetAsString

tensorflow/compiler/xla/literal.cc:782–826  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

780}
781
782string LiteralBase::GetAsString(absl::Span<const int64> multi_index,
783 const ShapeIndex& shape_index) const {
784 const Shape& subshape = ShapeUtil::GetSubshape(shape(), shape_index);
785 CHECK(LayoutUtil::IsDenseArray(subshape));
786 switch (subshape.element_type()) {
787 case PRED:
788 return Get<bool>(multi_index, shape_index) ? "true" : "false";
789 case S8:
790 return StrCat(Get<int8>(multi_index, shape_index));
791 case S16:
792 return StrCat(Get<int16>(multi_index, shape_index));
793 case S32:
794 return StrCat(Get<int32>(multi_index, shape_index));
795 case S64:
796 return StrCat(Get<int64>(multi_index, shape_index));
797 case U8:
798 return StrCat(Get<uint8>(multi_index, shape_index));
799 case U16:
800 return StrCat(Get<uint16>(multi_index, shape_index));
801 case U32:
802 return StrCat(Get<uint32>(multi_index, shape_index));
803 case U64:
804 return StrCat(Get<uint64>(multi_index, shape_index));
805 case F16:
806 return RoundTripFpToString(Get<half>(multi_index, shape_index));
807 case F32:
808 return RoundTripFpToString(Get<float>(multi_index, shape_index));
809 case BF16:
810 return RoundTripFpToString(Get<bfloat16>(multi_index, shape_index));
811 case F64:
812 return RoundTripFpToString(Get<double>(multi_index, shape_index));
813 case C64: {
814 complex64 c = Get<complex64>(multi_index, shape_index);
815 return StrCat("(", RoundTripFpToString(c.real()), ", ",
816 RoundTripFpToString(c.imag()), ")");
817 }
818 case C128: {
819 complex128 c = Get<complex128>(multi_index, shape_index);
820 return StrCat("(", RoundTripFpToString(c.real()), ", ",
821 RoundTripFpToString(c.imag()), ")");
822 }
823 default:
824 LOG(FATAL) << PrimitiveType_Name(subshape.element_type());
825 }
826}
827
828absl::optional<int64> LiteralBase::GetIntegralAsS64(
829 absl::Span<const int64> multi_index) const {

Callers 1

DenseArrayToStringHelperFunction · 0.45

Calls 4

RoundTripFpToStringFunction · 0.85
shapeFunction · 0.50
StrCatFunction · 0.50
element_typeMethod · 0.45

Tested by

no test coverage detected