| 1105 | } |
| 1106 | |
| 1107 | void LiteralBase::EachCellAsString( |
| 1108 | const std::function<void(absl::Span<const int64> indices, |
| 1109 | const string& value)>& per_cell) const { |
| 1110 | if (ShapeUtil::IsZeroElementArray(shape())) { |
| 1111 | return; |
| 1112 | } |
| 1113 | std::vector<int64> indices = IndexUtil::LinearIndexToMultidimensionalIndex( |
| 1114 | shape(), /*linear_index=*/0); |
| 1115 | do { |
| 1116 | per_cell(indices, GetAsString(indices)); |
| 1117 | } while (IndexUtil::BumpIndices(shape(), absl::MakeSpan(indices))); |
| 1118 | } |
| 1119 | |
| 1120 | namespace { |
| 1121 | template <typename NativeSrcT, typename NativeDestT, typename ConverterType> |