-
Notifications
You must be signed in to change notification settings - Fork 1
[FRONT-5] fix readme #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
492bab5
[FRONT-5] add img
a-palonskaa 2cd64d6
[FRONT-5] fiz
a-palonskaa 1e4318c
[FRONT-5] add img
a-palonskaa df7af07
[FRONT-5] add img
a-palonskaa c581bf0
[FRONT-5] fix logger
a-palonskaa 44c4705
[FRONT-5] fucking ci
a-palonskaa 9f2d45e
[FRONT-5] fucking ci
a-palonskaa c718da3
[FRONT-5] str
a-palonskaa 31e009c
[FRONT-5] remove
a-palonskaa 9326511
[FRONT-5] main
a-palonskaa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,5 +4,5 @@ logs/ | |
| .vscode | ||
| *.out | ||
| *.dot | ||
| *.png | ||
| *.proto | ||
| .DS_Store | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,43 +19,61 @@ std::string replace_extension(const std::string& filename, | |
|
|
||
| } // namespace | ||
|
|
||
| namespace Config { | ||
| constexpr char LOGS_DIR[] = "./logs/"; | ||
| constexpr char IMG_DIR[] = "./images/"; | ||
| constexpr char MODELS[] = "./models/"; | ||
|
|
||
| constexpr char DOT_EXT[] = ".dot"; | ||
| constexpr char PNG_EXT[] = ".png"; | ||
| constexpr char LOG_EXT[] = ".log"; | ||
|
|
||
| constexpr char LOGFILE[] = "frontend.log"; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. добавитть пустую строку после 31 |
||
| } // namespace Config | ||
|
|
||
| int main(int argc, const char* argv[]) { | ||
| if (argc != 2) { | ||
| std::cerr << "Usage: " << argv[0] << " <model.onnx>" << '\n'; | ||
| return 1; | ||
| if ((argc < 2) || (argc > 3) || | ||
| (argc == 3 && argv[2] && strcmp(argv[2], "-d") != 0)) { | ||
| std::cerr << "Usage: " << argv[0] << " <model.onnx>" << "[optional -d]" | ||
| << '\n'; | ||
| return 0; | ||
| } | ||
|
|
||
| std::filesystem::create_directories("./logs"); | ||
| std::filesystem::create_directories("./images"); | ||
|
|
||
| if (!Logger::getInstance().setlogFile("./logs/frontend.log")) { | ||
| std::cout << "Failed to open log file, logs will be printd out to " | ||
| "std::cerr only \n"; | ||
| if (!Logger::getInstance().setLogFile(std::string(Config::LOGS_DIR) + | ||
| std::string(Config::LOGFILE))) { | ||
| LOG(INFO, "logs will be printed to std::cerr\n"); | ||
| } | ||
|
|
||
| TensorCompiler::ONNXParser parser; | ||
| std::filesystem::create_directories(Config::LOGS_DIR); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. не логичнее ли поставить их до строки 42? |
||
| std::filesystem::create_directories(Config::IMG_DIR); | ||
|
|
||
| std::string path = std::string("./models/") + argv[1]; | ||
| std::string dot_filename = | ||
| Config::IMG_DIR + replace_extension(argv[1], Config::DOT_EXT); | ||
| std::string png_filename = | ||
| Config::IMG_DIR + replace_extension(argv[1], Config::PNG_EXT); | ||
|
|
||
| TensorCompiler::ONNXParser parser; | ||
| std::string path = std::string(Config::MODELS) + argv[1]; | ||
| if (!parser.load(path)) { | ||
| std::cerr << "Failed to parse ONNX model\n"; | ||
| LOG(ERROR, "Failed to parse ONNX model\n"); | ||
| return 1; | ||
| } | ||
|
|
||
| const auto& graph = parser.ParseGraph(); | ||
| std::string dot_filename = "./images/" + replace_extension(argv[1], ".dot"); | ||
| std::string png_filename = "./images/" + replace_extension(argv[1], ".png"); | ||
|
|
||
| std::cout << "\nParsed graph with " << graph.nodes().size() << " nodes and " | ||
| << graph.tensors().size() << " tensors.\n\n"; | ||
| parser.dump(); | ||
| << graph.tensors().size() << " tensors.\n"; | ||
|
|
||
| if (argc == 3 && strcmp(argv[2], "-d") == 0) { | ||
| parser.dump(); | ||
| } | ||
|
|
||
| graph.ToGraphViz(dot_filename); | ||
|
|
||
| std::string cmd = "dot -Tpng " + dot_filename + " -o " + png_filename; | ||
| int ret = std::system(cmd.c_str()); | ||
| if (ret != 0) { | ||
| std::cerr << "Error: failed to render PNG (dot returned " << ret | ||
| << ").\n"; | ||
| LOG(WARNING, "Failed to render PNG (dot returned " + | ||
| std::to_string(ret) + ").\n"); | ||
| } else { | ||
| std::cout << "\nGraph rendered to " << png_filename << '\n'; | ||
| } | ||
|
|
||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
добавить пустую строку после namespace