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

Method CopyFrom

tensorflow/compiler/xla/literal.cc:383–421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

381} // namespace
382
383Status LiteralBase::Piece::CopyFrom(const LiteralBase::Piece& src) {
384 CHECK(subshape_ != nullptr);
385 CHECK(src.subshape_ != nullptr);
386 if (ShapeUtil::Equal(subshape(), src.subshape())) {
387 // If the layouts are equal it's faster just to memcpy.
388 memcpy(buffer(), src.buffer(), src.size_bytes());
389 } else {
390 TF_RET_CHECK(ShapeUtil::Compatible(src.subshape(), subshape()));
391 std::vector<int64> origin(subshape().rank(), 0);
392 switch (subshape().element_type()) {
393#define COPY_ELEMENTS(XLA_T, NATIVE_T) \
394 case (XLA_T): \
395 CopyElementsBetween<NATIVE_T>(data<NATIVE_T>(), src.data<NATIVE_T>(), \
396 subshape(), src.subshape()); \
397 break;
398 COPY_ELEMENTS(U8, uint8);
399 COPY_ELEMENTS(U16, uint16);
400 COPY_ELEMENTS(U32, uint32);
401 COPY_ELEMENTS(U64, uint64);
402 COPY_ELEMENTS(S8, int8);
403 COPY_ELEMENTS(S16, int16);
404 COPY_ELEMENTS(S32, int32);
405 COPY_ELEMENTS(S64, int64);
406 COPY_ELEMENTS(F16, half);
407 COPY_ELEMENTS(BF16, bfloat16);
408 COPY_ELEMENTS(F32, float);
409 COPY_ELEMENTS(F64, double);
410 COPY_ELEMENTS(C64, complex64);
411 COPY_ELEMENTS(C128, complex128);
412 COPY_ELEMENTS(PRED, bool);
413#undef COPY_ELEMENTS
414 default:
415 return Unimplemented(
416 "Copying a Literal object with element type %s is not implemented.",
417 PrimitiveType_Name(subshape().element_type()));
418 }
419 }
420 return Status::OK();
421}
422
423Status MutableLiteralBase::CopyFrom(const LiteralSlice& src_literal,
424 const ShapeIndex& dest_shape_index,

Callers 15

RunMethod · 0.45
demo.pyFile · 0.45
process_test_logsFunction · 0.45
mainFunction · 0.45
_FilterGoldenProtoDictFunction · 0.45
testTransformGraphMethod · 0.45
setup_tpu_sessionFunction · 0.45
fuse_opFunction · 0.45

Calls 15

bufferFunction · 0.85
CompatibleClass · 0.85
UnimplementedFunction · 0.85
InvalidArgumentFunction · 0.85
EqualClass · 0.70
shapeFunction · 0.50
bufferMethod · 0.45
size_bytesMethod · 0.45
rankMethod · 0.45
element_typeMethod · 0.45
shapeMethod · 0.45