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

Function TensorListBinaryAdd

tensorflow/core/kernels/list_kernels.h:968–1002  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

966
967template <typename Device>
968Status TensorListBinaryAdd(OpKernelContext* c, const TensorList& a,
969 const TensorList& b, TensorList* out) {
970 if (a.element_dtype != b.element_dtype) {
971 return errors::InvalidArgument(
972 "Trying to add two lists of tensors of different dtypes. One is ",
973 DataTypeString(a.element_dtype), " and the other is ",
974 DataTypeString(b.element_dtype));
975 }
976 out->element_dtype = a.element_dtype;
977 if (!a.element_shape.IsCompatibleWith(b.element_shape)) {
978 return errors::InvalidArgument(
979 "Trying to add two lists of tensors with incompatible element shapes. "
980 "One is ",
981 a.element_shape.DebugString(), " and the other is ",
982 b.element_shape.DebugString());
983 }
984
985 TF_RETURN_IF_ERROR(
986 a.element_shape.MergeWith(b.element_shape, &out->element_shape));
987 if (a.tensors().size() != b.tensors().size()) {
988 return errors::InvalidArgument(
989 "Trying to add two lists of tensors with different lengths. One is ",
990 a.tensors().size(), " and the other is ", b.tensors().size());
991 }
992 out->tensors().reserve(a.tensors().size());
993 for (int i = 0; i < a.tensors().size(); ++i) {
994 const Tensor& a_tensor = a.tensors()[i];
995 const Tensor& b_tensor = b.tensors()[i];
996 Tensor out_tensor;
997 TF_RETURN_IF_ERROR(
998 BinaryAddTensors<Device>(c, a_tensor, b_tensor, &out_tensor));
999 out->tensors().push_back(out_tensor);
1000 }
1001 return Status::OK();
1002}
1003
1004template <typename Device>
1005Status TensorListZerosLike(OpKernelContext* c, const TensorList& x,

Callers

nothing calls this directly

Calls 9

InvalidArgumentFunction · 0.85
MergeWithMethod · 0.80
tensorsMethod · 0.80
DataTypeStringFunction · 0.50
IsCompatibleWithMethod · 0.45
DebugStringMethod · 0.45
sizeMethod · 0.45
reserveMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected