| 42 | } |
| 43 | |
| 44 | void DatasetToGraphOp::Compute(OpKernelContext* ctx) { |
| 45 | DatasetBase* dataset; |
| 46 | OP_REQUIRES_OK(ctx, GetDatasetFromVariantTensor(ctx->input(0), &dataset)); |
| 47 | std::vector<int> whitelist_indices_to_remove; |
| 48 | for (int i = 0; i < whitelisted_stateful_ops_.size(); ++i) { |
| 49 | const string stateful_op = whitelisted_stateful_ops_[i]; |
| 50 | if (!WhitelistedStatefulOpRegistry::Global()->Contains(stateful_op)) { |
| 51 | whitelist_indices_to_remove.push_back(i); |
| 52 | // Make sure op is registered first. We maybe don't need this check? |
| 53 | const OpDef* op_def; |
| 54 | OP_REQUIRES_OK(ctx, |
| 55 | OpRegistry::Global()->LookUpOpDef(stateful_op, &op_def)); |
| 56 | OP_REQUIRES_OK(ctx, |
| 57 | WhitelistedStatefulOpRegistry::Global()->Add(stateful_op)); |
| 58 | } |
| 59 | } |
| 60 | GraphDef graph_def; |
| 61 | OP_REQUIRES_OK( |
| 62 | ctx, AsGraphDef(ctx, dataset, SerializationContext({}), &graph_def)); |
| 63 | Tensor* result; |
| 64 | OP_REQUIRES_OK(ctx, ctx->allocate_output(0, TensorShape({}), &result)); |
| 65 | result->scalar<tstring>()() = graph_def.SerializeAsString(); |
| 66 | for (int index : whitelist_indices_to_remove) { |
| 67 | OP_REQUIRES_OK(ctx, WhitelistedStatefulOpRegistry::Global()->Remove( |
| 68 | whitelisted_stateful_ops_[index])); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | void DatasetCardinalityOp::Compute(OpKernelContext* ctx) { |
| 73 | DatasetBase* dataset; |
nothing calls this directly
no test coverage detected