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

Method Run

tensorflow/cc/training/prefetch_runner.cc:86–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86void PrefetchRunner::Run(size_t index) {
87 Status status;
88
89 // initialize tensor buffer.
90 status = sess_->Run({}, {}, {params_.resume_op()}, nullptr);
91 if (status != Status::OK()) {
92 DealWithCancelledUnexpectedError(status);
93 return;
94 }
95
96 // get value generator
97 auto feed_in_tensors = params_.named_feed_input_tensors();
98 std::vector<std::string> val_consume_ops;
99 std::vector<std::string> val_gen_tensors;
100 val_consume_ops.reserve(feed_in_tensors.size());
101 val_gen_tensors.reserve(feed_in_tensors.size());
102 for (auto iter = feed_in_tensors.begin(); iter != feed_in_tensors.end(); ++iter) {
103 val_consume_ops.emplace_back(iter->first);
104 val_gen_tensors.emplace_back(iter->second);
105 }
106
107 std::vector<Tensor> gen_val;
108 std::vector<std::pair<std::string, Tensor>> gen_inputs;
109 gen_val.reserve(feed_in_tensors.size());
110 gen_inputs.reserve(feed_in_tensors.size());
111 while (true) {
112 if (TF_PREDICT_FALSE(coord_ && coord_->ShouldStop())) {
113 mutex_lock l (mu_);
114 thread_nums_--;
115 return;
116 }
117
118 // generate feed tensor
119 if (!val_gen_tensors.empty()) {
120 gen_val.clear();
121 gen_inputs.clear();
122 status = sess_->Run(params_.run_options(), {}, val_gen_tensors, {},
123 &gen_val, nullptr);
124 if (TF_PREDICT_FALSE(status != Status::OK())) {
125 if (!CheckRunErrorStatus(status))
126 return;
127 }
128
129 for (size_t i = 0; i < val_gen_tensors.size(); i++) {
130 gen_inputs.emplace_back(val_consume_ops[i], gen_val[i]);
131 }
132 }
133
134 // run prefetch subgraph.
135 status = sess_->Run(params_.run_options(), gen_inputs, {},
136 {params_.fetch_ops(index)}, nullptr, nullptr);
137 if (TF_PREDICT_FALSE(status != Status::OK())) {
138 if (!CheckRunErrorStatus(status))
139 return;
140 }
141 }
142}
143

Callers 2

StopMethod · 0.45
DealWithClosedErrorMethod · 0.45

Calls 8

reserveMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
emplace_backMethod · 0.45
ShouldStopMethod · 0.45
emptyMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected