| 281 | ~TensorListPushBack() override {} |
| 282 | |
| 283 | void Compute(OpKernelContext* c) override { |
| 284 | const Tensor& input = c->input(1); |
| 285 | OP_REQUIRES(c, element_dtype_ == input.dtype(), |
| 286 | errors::InvalidArgument("Invalid data types; list elements ", |
| 287 | DataTypeString(element_dtype_), |
| 288 | " but tried to append ", |
| 289 | DataTypeString(input.dtype()))); |
| 290 | |
| 291 | const TensorList* l = nullptr; |
| 292 | OP_REQUIRES_OK(c, GetInputList(c, 0, &l)); |
| 293 | OP_REQUIRES(c, l->element_shape.IsCompatibleWith(input.shape()), |
| 294 | errors::InvalidArgument( |
| 295 | "Tried to append a tensor with incompatible shape to a " |
| 296 | "list. Op element shape: ", |
| 297 | input.shape().DebugString(), |
| 298 | " list shape: ", l->element_shape.DebugString())); |
| 299 | OP_REQUIRES(c, element_dtype_ == l->element_dtype, |
| 300 | errors::InvalidArgument("Invalid data types; op elements ", |
| 301 | DataTypeString(element_dtype_), |
| 302 | " but list elements ", |
| 303 | DataTypeString(l->element_dtype))); |
| 304 | |
| 305 | if (l->max_num_elements != -1) { |
| 306 | OP_REQUIRES( |
| 307 | c, l->tensors().size() < l->max_num_elements, |
| 308 | errors::InvalidArgument("Tried to push item into a full list", |
| 309 | " list size: ", l->tensors().size(), |
| 310 | " max_num_elements: ", l->max_num_elements)); |
| 311 | } |
| 312 | |
| 313 | TensorList* output_list = nullptr; |
| 314 | OP_REQUIRES_OK(c, ForwardInputOrCreateNewList(c, 0, 0, *l, &output_list)); |
| 315 | output_list->tensors().push_back(input); |
| 316 | } |
| 317 | |
| 318 | private: |
| 319 | DataType element_dtype_; |
nothing calls this directly
no test coverage detected