| 402 | } |
| 403 | |
| 404 | void Compute(OpKernelContext* c) override { |
| 405 | PartialTensorShape element_shape; |
| 406 | OP_REQUIRES_OK(c, TensorShapeFromTensor(c->input(0), &element_shape)); |
| 407 | int32 num_elements = c->input(1).scalar<int32>()(); |
| 408 | OP_REQUIRES(c, num_elements >= 0, |
| 409 | errors::InvalidArgument("The num_elements to reserve must be a " |
| 410 | "non negative number, but got ", |
| 411 | num_elements)); |
| 412 | TensorList output; |
| 413 | output.element_shape = element_shape; |
| 414 | output.element_dtype = element_dtype_; |
| 415 | output.tensors().resize(num_elements, Tensor(DT_INVALID)); |
| 416 | Tensor* result; |
| 417 | AllocatorAttributes attr; |
| 418 | attr.set_on_host(true); |
| 419 | OP_REQUIRES_OK(c, c->allocate_output(0, TensorShape{}, &result, attr)); |
| 420 | result->scalar<Variant>()() = std::move(output); |
| 421 | } |
| 422 | |
| 423 | private: |
| 424 | DataType element_dtype_; |
nothing calls this directly
no test coverage detected