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

Method CopyElementFrom

tensorflow/compiler/xla/literal.cc:260–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258}
259
260Status 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) {

Callers 3

HandleGatherMethod · 0.80
PerformReductionStepFunction · 0.80

Calls 5

ByteSizeOfPrimitiveTypeFunction · 0.85
untyped_dataMethod · 0.80
shapeFunction · 0.50
element_typeMethod · 0.45
shapeMethod · 0.45

Tested by

no test coverage detected