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

Function RemoveDocs

tensorflow/core/api_def/update_api_def.cc:189–224  ·  view source on GitHub ↗

Remove .Doc calls that follow REGISTER_OP calls for the given ops. We search for REGISTER_OP calls in the given op_files list.

Source from the content-addressed store, hash-verified

187// Remove .Doc calls that follow REGISTER_OP calls for the given ops.
188// We search for REGISTER_OP calls in the given op_files list.
189void RemoveDocs(const std::vector<const OpDef*>& ops,
190 const std::vector<string>& op_files) {
191 // Set of ops that we already found REGISTER_OP calls for.
192 std::set<string> processed_ops;
193
194 for (const auto& file : op_files) {
195 string file_contents;
196 bool file_contents_updated = false;
197 TF_CHECK_OK(ReadFileToString(Env::Default(), file, &file_contents));
198
199 for (auto op : ops) {
200 if (processed_ops.find(op->name()) != processed_ops.end()) {
201 // We already found REGISTER_OP call for this op in another file.
202 continue;
203 }
204 string register_call =
205 strings::Printf("REGISTER_OP(\"%s\")", op->name().c_str());
206 const auto register_call_location = file_contents.find(register_call);
207 // Find REGISTER_OP(OpName) call.
208 if (register_call_location == string::npos) {
209 continue;
210 }
211 std::cout << "Removing .Doc call for " << op->name() << " from " << file
212 << "." << std::endl;
213 file_contents = RemoveDoc(*op, file_contents, register_call_location);
214 file_contents_updated = true;
215
216 processed_ops.insert(op->name());
217 }
218 if (file_contents_updated) {
219 TF_CHECK_OK(WriteStringToFile(Env::Default(), file, file_contents))
220 << "Could not remove .Doc calls in " << file
221 << ". Make sure the file is writable.";
222 }
223 }
224}
225} // namespace
226
227// Returns ApiDefs text representation in multi-line format

Callers 1

CreateApiDefsFunction · 0.85

Calls 10

ReadFileToStringFunction · 0.85
DefaultFunction · 0.85
PrintfFunction · 0.85
RemoveDocFunction · 0.85
WriteStringToFileFunction · 0.85
c_strMethod · 0.80
nameMethod · 0.65
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected