| 386 | } |
| 387 | |
| 388 | Status CapturedFunction::AddToGraph( |
| 389 | SerializationContext* ctx, DatasetBase::DatasetGraphDefBuilder* b, |
| 390 | std::vector<Node*>* other_arguments, |
| 391 | DataTypeVector* other_arguments_types) const { |
| 392 | other_arguments->reserve(captured_inputs_.size()); |
| 393 | other_arguments_types->reserve(captured_inputs_.size()); |
| 394 | for (const Tensor& t : captured_inputs_) { |
| 395 | Node* node; |
| 396 | DatasetBase* input; |
| 397 | Status s = GetDatasetFromVariantTensor(t, &input); |
| 398 | if (s.ok()) { |
| 399 | TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input, &node)); |
| 400 | } else { |
| 401 | TF_RETURN_IF_ERROR(b->AddTensor(t, &node)); |
| 402 | } |
| 403 | other_arguments->emplace_back(node); |
| 404 | other_arguments_types->emplace_back(t.dtype()); |
| 405 | } |
| 406 | TF_RETURN_IF_ERROR( |
| 407 | b->AddFunction(ctx, metadata_->func().name(), *metadata_->lib_def())); |
| 408 | return Status::OK(); |
| 409 | } |
| 410 | |
| 411 | Status CapturedFunction::Instantiate( |
| 412 | IteratorContext* ctx, std::unique_ptr<InstantiatedCapturedFunction>* |