| 367 | } |
| 368 | |
| 369 | Status DatasetBase::DatasetGraphDefBuilder::AddInputDataset( |
| 370 | SerializationContext* ctx, const DatasetBase* dataset, Node** output) { |
| 371 | Status status = dataset->AsGraphDefInternal(ctx, this, output); |
| 372 | if (errors::IsUnimplemented(status) && !ctx->fail_if_unimplemented()) { |
| 373 | Tensor t(DT_VARIANT, TensorShape({})); |
| 374 | // `StoreDatasetInVariantTensor` will transfer ownership of `dataset`. We |
| 375 | // increment the refcount of `dataset` here to retain ownership. |
| 376 | dataset->Ref(); |
| 377 | TF_RETURN_IF_ERROR( |
| 378 | StoreDatasetInVariantTensor(const_cast<DatasetBase*>(dataset), &t)); |
| 379 | TF_RETURN_IF_ERROR(AddPlaceholder(t, output)); |
| 380 | DCHECK_NE(ctx->input_list(), nullptr); |
| 381 | ctx->input_list()->emplace_back((*output)->name(), std::move(t)); |
| 382 | LOG(WARNING) |
| 383 | << "Input of " << dataset->DebugString() |
| 384 | << " will not be optimized because the dataset does not implement the " |
| 385 | "AsGraphDefInternal() method needed to apply optimizations."; |
| 386 | return Status::OK(); |
| 387 | } |
| 388 | return status; |
| 389 | } |
| 390 | |
| 391 | Status DatasetBaseIterator::GetNext(IteratorContext* ctx, |
| 392 | std::vector<Tensor>* out_tensors, |