| 122 | explicit WrapDatasetVariantOp(OpKernelConstruction* ctx) : OpKernel(ctx) {} |
| 123 | |
| 124 | void Compute(OpKernelContext* ctx) override { |
| 125 | const Tensor& tensor = ctx->input(0); |
| 126 | OP_REQUIRES(ctx, |
| 127 | tensor.dtype() == DT_VARIANT && |
| 128 | TensorShapeUtils::IsScalar(tensor.shape()), |
| 129 | errors::InvalidArgument( |
| 130 | "Dataset tensor must be a scalar of dtype DT_VARIANT.")); |
| 131 | DatasetBase* unused; |
| 132 | OP_REQUIRES_OK(ctx, GetDatasetFromVariantTensor(tensor, &unused)); |
| 133 | Tensor* output = nullptr; |
| 134 | OP_REQUIRES_OK(ctx, ctx->allocate_output(0, TensorShape({}), &output)); |
| 135 | output->scalar<Variant>()() = WrappedDatasetVariantWrapper(tensor); |
| 136 | } |
| 137 | }; |
| 138 | |
| 139 | REGISTER_KERNEL_BUILDER(Name("WrapDatasetVariant").Device(DEVICE_CPU), |
nothing calls this directly
no test coverage detected