| 167 | } |
| 168 | |
| 169 | void TensorSliceDatasetOp::MakeDataset(OpKernelContext* ctx, |
| 170 | DatasetBase** output) { |
| 171 | OpInputList inputs; |
| 172 | OP_REQUIRES_OK(ctx, ctx->input_list(kComponents, &inputs)); |
| 173 | std::vector<Tensor> components; |
| 174 | components.reserve(inputs.size()); |
| 175 | OP_REQUIRES( |
| 176 | ctx, inputs[0].dims() > 0, |
| 177 | errors::InvalidArgument("All components must be at least 1-dimensional")); |
| 178 | const int64 num_slices = inputs[0].dim_size(0); |
| 179 | for (const Tensor& t : inputs) { |
| 180 | components.push_back(t); |
| 181 | OP_REQUIRES(ctx, t.dims() > 0, |
| 182 | errors::InvalidArgument( |
| 183 | "All components must be at least 1-dimensional")); |
| 184 | OP_REQUIRES( |
| 185 | ctx, t.dim_size(0) == num_slices, |
| 186 | errors::InvalidArgument( |
| 187 | "All components must have the same size in the 0th dimension")); |
| 188 | } |
| 189 | *output = new Dataset(ctx, std::move(components)); |
| 190 | OP_REQUIRES_OK(ctx, |
| 191 | VerifyTypesMatch((*output)->output_dtypes(), output_types_)); |
| 192 | OP_REQUIRES_OK( |
| 193 | ctx, VerifyShapesCompatible((*output)->output_shapes(), output_shapes_)); |
| 194 | } |
| 195 | |
| 196 | namespace { |
| 197 | REGISTER_KERNEL_BUILDER(Name("TensorSliceDataset").Device(DEVICE_CPU), |
nothing calls this directly
no test coverage detected