| 234 | } |
| 235 | |
| 236 | void Compute(OpKernelContext* ctx) override { |
| 237 | const Tensor& max_num_elements_t = ctx->input(1); |
| 238 | OP_REQUIRES( |
| 239 | ctx, TensorShapeUtils::IsScalar(max_num_elements_t.shape()), |
| 240 | errors::InvalidArgument( |
| 241 | "max_num_elements expected to be a scalar ", |
| 242 | "but got shape: ", max_num_elements_t.shape().DebugString())); |
| 243 | Tensor* result; |
| 244 | AllocatorAttributes attr; |
| 245 | attr.set_on_host(true); |
| 246 | OP_REQUIRES_OK(ctx, ctx->allocate_output(0, TensorShape{}, &result, attr)); |
| 247 | TensorList empty; |
| 248 | empty.element_dtype = element_dtype_; |
| 249 | empty.max_num_elements = max_num_elements_t.scalar<int32>()(); |
| 250 | PartialTensorShape element_shape; |
| 251 | OP_REQUIRES_OK(ctx, TensorShapeFromTensor(ctx->input(0), &element_shape)); |
| 252 | empty.element_shape = element_shape; |
| 253 | result->scalar<Variant>()() = std::move(empty); |
| 254 | } |
| 255 | |
| 256 | private: |
| 257 | DataType element_dtype_; |
nothing calls this directly
no test coverage detected