Creates ApiDef files for any new ops. If op_file_pattern is not empty, then also removes .Doc calls from new op registrations in these files.
| 239 | // If op_file_pattern is not empty, then also removes .Doc calls from |
| 240 | // new op registrations in these files. |
| 241 | void CreateApiDefs(const OpList& ops, const string& api_def_dir, |
| 242 | const string& op_file_pattern) { |
| 243 | auto* excluded_ops = GetExcludedOps(); |
| 244 | std::vector<const OpDef*> new_ops_with_docs; |
| 245 | |
| 246 | for (const auto& op : ops.op()) { |
| 247 | if (excluded_ops->find(op.name()) != excluded_ops->end()) { |
| 248 | continue; |
| 249 | } |
| 250 | // Form the expected ApiDef path. |
| 251 | string file_path = |
| 252 | io::JoinPath(tensorflow::string(api_def_dir), kApiDefFileFormat); |
| 253 | file_path = strings::Printf(file_path.c_str(), op.name().c_str()); |
| 254 | |
| 255 | // Create ApiDef if it doesn't exist. |
| 256 | if (!Env::Default()->FileExists(file_path).ok()) { |
| 257 | std::cout << "Creating ApiDef file " << file_path << std::endl; |
| 258 | const auto& api_def_text = CreateApiDef(op); |
| 259 | TF_CHECK_OK(WriteStringToFile(Env::Default(), file_path, api_def_text)); |
| 260 | |
| 261 | if (OpHasDocs(op)) { |
| 262 | new_ops_with_docs.push_back(&op); |
| 263 | } |
| 264 | } |
| 265 | } |
| 266 | if (!op_file_pattern.empty()) { |
| 267 | std::vector<string> op_files; |
| 268 | TF_CHECK_OK(Env::Default()->GetMatchingPaths(op_file_pattern, &op_files)); |
| 269 | RemoveDocs(new_ops_with_docs, op_files); |
| 270 | } |
| 271 | } |
| 272 | } // namespace tensorflow |
no test coverage detected