| 258 | } |
| 259 | |
| 260 | Status MutableLiteralBase::CopyElementFrom(const LiteralSlice& src_literal, |
| 261 | absl::Span<const int64> src_index, |
| 262 | absl::Span<const int64> dest_index) { |
| 263 | DCHECK_EQ(shape().element_type(), src_literal.shape().element_type()); |
| 264 | const int64 src_linear_index = IndexUtil::MultidimensionalIndexToLinearIndex( |
| 265 | src_literal.shape(), src_index); |
| 266 | const int64 dest_linear_index = |
| 267 | IndexUtil::MultidimensionalIndexToLinearIndex(shape(), dest_index); |
| 268 | const int64 primitive_size = |
| 269 | ShapeUtil::ByteSizeOfPrimitiveType(shape().element_type()); |
| 270 | |
| 271 | char* dest_address = |
| 272 | static_cast<char*>(untyped_data()) + dest_linear_index * primitive_size; |
| 273 | const char* source_address = |
| 274 | static_cast<const char*>(src_literal.untyped_data()) + |
| 275 | src_linear_index * primitive_size; |
| 276 | if (dest_address != source_address) { |
| 277 | memcpy(dest_address, source_address, primitive_size); |
| 278 | } |
| 279 | return Status::OK(); |
| 280 | } |
| 281 | |
| 282 | /* static */ StatusOr<Literal> MutableLiteralBase::CreateFromProto( |
| 283 | const LiteralProto& proto, bool prohibit_empty_literal) { |
no test coverage detected