| 1168 | |
| 1169 | template <typename T> |
| 1170 | string SummarizeArray(int64 limit, int64 num_elts, |
| 1171 | const TensorShape& tensor_shape, const char* data, |
| 1172 | const bool print_v2) { |
| 1173 | string ret; |
| 1174 | const T* array = reinterpret_cast<const T*>(data); |
| 1175 | |
| 1176 | const gtl::InlinedVector<int64, 4> shape = tensor_shape.dim_sizes(); |
| 1177 | if (shape.empty()) { |
| 1178 | for (int64 i = 0; i < limit; ++i) { |
| 1179 | if (i > 0) strings::StrAppend(&ret, " "); |
| 1180 | strings::StrAppend(&ret, PrintOneElement(array[i], print_v2)); |
| 1181 | } |
| 1182 | if (num_elts > limit) strings::StrAppend(&ret, "..."); |
| 1183 | return ret; |
| 1184 | } |
| 1185 | if (print_v2) { |
| 1186 | const int num_dims = tensor_shape.dims(); |
| 1187 | PrintOneDimV2(0, shape, limit, num_dims, array, 0, &ret); |
| 1188 | } else { |
| 1189 | int64 data_index = 0; |
| 1190 | const int shape_size = tensor_shape.dims(); |
| 1191 | PrintOneDim(0, shape, limit, shape_size, array, &data_index, &ret); |
| 1192 | |
| 1193 | if (num_elts > limit) strings::StrAppend(&ret, "..."); |
| 1194 | } |
| 1195 | |
| 1196 | return ret; |
| 1197 | } |
| 1198 | } // namespace |
| 1199 | |
| 1200 | string Tensor::SummarizeValue(int64 max_entries, bool print_v2) const { |
nothing calls this directly
no test coverage detected