| 966 | |
| 967 | template <typename Device> |
| 968 | Status 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 | |
| 1004 | template <typename Device> |
| 1005 | Status TensorListZerosLike(OpKernelContext* c, const TensorList& x, |
nothing calls this directly
no test coverage detected