MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / SetIteratorFromDataset

Method SetIteratorFromDataset

tensorflow/core/kernels/data/iterator_ops.cc:138–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138Status IteratorResource::SetIteratorFromDataset(OpKernelContext* ctx,
139 DatasetBase* dataset) {
140 std::shared_ptr<State> new_state;
141 {
142 tf_shared_lock l(mu_);
143 new_state = std::make_shared<State>(
144 iterator_state_->flib_def, iterator_state_->pflr, iterator_state_->flr,
145 /*iterator=*/nullptr);
146 }
147 // Create new iterator.
148 std::unique_ptr<IteratorBase> iterator;
149 IteratorContext::Params params(ctx);
150 params.flr = new_state->flr;
151 params.function_handle_cache = new_state->function_handle_cache.get();
152 params.resource_mgr = &new_state->resource_mgr;
153 params.thread_factory = unbounded_thread_pool_.get_thread_factory();
154 params.thread_pool = &unbounded_thread_pool_;
155 params.cancellation_manager = &new_state->cancellation_manager;
156 std::function<void()> deregister_fn;
157 TF_RETURN_IF_ERROR(ConnectCancellationManagers(ctx->cancellation_manager(),
158 params.cancellation_manager,
159 &deregister_fn));
160 {
161 auto cleanup = gtl::MakeCleanup(std::move(deregister_fn));
162 TF_RETURN_IF_ERROR(dataset->MakeIterator(IteratorContext(std::move(params)),
163 "Iterator", &iterator));
164 TF_RETURN_IF_ERROR(
165 VerifyTypesMatch(output_dtypes_, iterator->output_dtypes()));
166 TF_RETURN_IF_ERROR(
167 VerifyShapesCompatible(output_shapes_, iterator->output_shapes()));
168 std::swap(new_state->iterator, iterator);
169 }
170
171 mutex_lock l(mu_);
172 std::swap(iterator_state_, new_state);
173 return Status::OK();
174}
175
176namespace {
177

Callers 2

ComputeAsyncMethod · 0.80
TryInitMethod · 0.80

Calls 10

VerifyTypesMatchFunction · 0.85
VerifyShapesCompatibleFunction · 0.85
get_thread_factoryMethod · 0.80
IteratorContextClass · 0.50
getMethod · 0.45
cancellation_managerMethod · 0.45
MakeIteratorMethod · 0.45
output_dtypesMethod · 0.45
output_shapesMethod · 0.45

Tested by

no test coverage detected