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

Method BitcastFrom

tensorflow/core/framework/tensor.cc:725–748  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

723}
724
725Status Tensor::BitcastFrom(const Tensor& other, DataType dtype,
726 const TensorShape& shape) {
727 int in_size = DataTypeSize(other.dtype());
728 int out_size = DataTypeSize(dtype);
729 if (in_size == 0) {
730 return errors::InvalidArgument("other tensor has zero-sized data type");
731 }
732 if (out_size == 0) {
733 return errors::InvalidArgument("specified output type is zero-sized");
734 }
735 if (shape.num_elements() * out_size !=
736 other.shape().num_elements() * in_size) {
737 return errors::InvalidArgument(
738 "input and output shapes/data type sizes are not compatible");
739 }
740 shape_ = shape;
741 shape_.set_data_type(dtype);
742 if (buf_ != other.buf_) {
743 UnrefIfNonNull(buf_);
744 buf_ = other.buf_;
745 RefIfNonNull(buf_);
746 }
747 return Status::OK();
748}
749
750// Notice that buf_ either points to a regular TensorBuffer or a SubBuffer.
751// For the latter case, we have to make sure that the refcount is

Callers 5

AllocateOutputTensorMethod · 0.80
AllocateOutputTensorMethod · 0.80
ComputeMethod · 0.80
ComputeMethod · 0.80
TF_TensorBitcastFromFunction · 0.80

Calls 8

DataTypeSizeFunction · 0.85
InvalidArgumentFunction · 0.85
UnrefIfNonNullFunction · 0.85
RefIfNonNullFunction · 0.85
dtypeMethod · 0.45
num_elementsMethod · 0.45
shapeMethod · 0.45
set_data_typeMethod · 0.45

Tested by

no test coverage detected