| 959 | |
| 960 | template <typename NativeT> |
| 961 | void MutableLiteralBase::PopulateFromArray(const Array<NativeT>& values) { |
| 962 | CHECK(shape().IsArray()); |
| 963 | CHECK_EQ(shape().element_type(), |
| 964 | primitive_util::NativeToPrimitiveType<NativeT>()); |
| 965 | CHECK_EQ(shape().rank(), values.num_dimensions()); |
| 966 | for (int dim = 0; dim < values.num_dimensions(); ++dim) { |
| 967 | CHECK_EQ(values.dim(dim), shape().dimensions(dim)); |
| 968 | } |
| 969 | values.Each([this](absl::Span<const int64> indices, NativeT value) { |
| 970 | this->Set(indices, value); |
| 971 | }); |
| 972 | } |
| 973 | |
| 974 | template <typename NativeT> |
| 975 | void MutableLiteralBase::PopulateR2FromArray2D(const Array2D<NativeT>& values) { |
no test coverage detected