Skip to content
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

I 73 #2

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

I 73 #2

wants to merge 4 commits into from

Conversation

thomaskleiven
Copy link

@thomaskleiven thomaskleiven commented May 31, 2024

Summary by CodeRabbit

  • New Features

    • Introduced logging functionality with various log levels.
    • Added a utility timer class for measuring elapsed time.
    • Included utility functions for file operations and CUDA error checking.
    • Implemented int8 calibration for neural network inference.
  • Refactor

    • Restructured project to improve organization by moving implementation details to separate files.
    • Enhanced engine functionalities by splitting them into dedicated inline files.
  • Documentation

    • Updated README to reflect the new project structure and file organization.

Copy link

coderabbitai bot commented May 31, 2024

Walkthrough

The project underwent significant restructuring, moving core implementations from src to include/engine and adding new utility and logging functionalities. The CMakeLists.txt was updated to incorporate these changes, including the addition of new source files and include directories. The changes enhance modularity, improve organization, and introduce new capabilities for logging, error checking, and performance measurement.

Changes

Files/Directories Change Summary
CMakeLists.txt Added logger.cpp to tensorrt_cpp_api library and included include directory in target_include_directories.
README.md Updated project structure to reflect the new organization under include/engine.
include/Int8Calibrator.h Introduced Int8EntropyCalibrator2 class for int8 calibration.
include/engine/EngineBuildLoadNetwork.inl Added methods for building and loading neural network engines using TensorRT.
include/engine/EngineRunInference.inl Introduced runInference template function for performing model inference.
include/engine/EngineUtilities.inl Added utility functions for data transformation, image resizing, and GPU buffer management.
include/logger.h Introduced logging functionalities including log levels and conversion to spdlog levels.
include/macros.h Added CHECK macro for runtime condition checks with logging.
include/util/Stopwatch.h Introduced Stopwatch class for measuring elapsed time.
include/util/Util.h Added utility functions for file operations, CUDA error checking, and directory listing.
include/util/Util.inl Inline implementations of utility functions in Util.h.
src/engine.cpp Removed Util::getFilesInDirectory function and modified Logger::log function to take a Severity parameter directly.
src/engine.h Major restructuring, removing utility methods and adding new headers for calibration, utility functions, stopwatch, and macros.
src/logger.cpp Updated to include logger.h and removed redundant functions and enum declarations.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant Engine
    participant Logger
    participant Util

    User->>Engine: buildLoadNetwork(onnxModelPath, subVals, divVals, normalize)
    Engine->>Logger: log("Building network...")
    Engine->>Util: doesFileExist(onnxModelPath)
    Util-->>Engine: fileExists
    Engine->>Engine: build(onnxModelPath, subVals, divVals, normalize)
    Engine->>Logger: log("Network built successfully")

    User->>Engine: runInference(inputData)
    Engine->>Logger: log("Running inference...")
    Engine->>Engine: preprocess(inputData)
    Engine->>Engine: executeInference(preprocessedData)
    Engine->>Engine: postprocess(inferenceResults)
    Engine-->>User: inferenceResults
    Engine->>Logger: log("Inference completed")
Loading

Poem

In the land of code, a rabbit hops,
Through headers and inlines, it never stops.
With logs and checks, it keeps things right,
Building networks, day and night.
Utilities and stopwatch, all in queue,
For a smoother run, just for you. 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5e2fd37 and 0adfb3c.

Files selected for processing (14)
  • CMakeLists.txt (1 hunks)
  • README.md (1 hunks)
  • include/Int8Calibrator.h (1 hunks)
  • include/engine/EngineBuildLoadNetwork.inl (1 hunks)
  • include/engine/EngineRunInference.inl (1 hunks)
  • include/engine/EngineUtilities.inl (1 hunks)
  • include/logger.h (1 hunks)
  • include/macros.h (1 hunks)
  • include/util/Stopwatch.h (1 hunks)
  • include/util/Util.h (1 hunks)
  • include/util/Util.inl (1 hunks)
  • src/engine.cpp (1 hunks)
  • src/engine.h (4 hunks)
  • src/logger.cpp (3 hunks)
Files not reviewed due to errors (8)
  • include/util/Util.h (no review received)
  • include/util/Stopwatch.h (no review received)
  • include/macros.h (no review received)
  • include/util/Util.inl (no review received)
  • CMakeLists.txt (no review received)
  • include/engine/EngineRunInference.inl (no review received)
  • include/engine/EngineUtilities.inl (no review received)
  • src/engine.h (no review received)
Additional context used
LanguageTool
README.md

[uncategorized] ~34-~34: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...tes how to use the TensorRT C++ API for high performance GPU inference on image data. It covers ...


[style] ~38-~38: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...pecify a simple optimization profile. - How to run FP32, FP16, or INT8 precision in...


[style] ~39-~39: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ..., FP16, or INT8 precision inference. - How to read / write data from / into GPU me...


[style] ~40-~40: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... GPU memory and work with GPU images. - How to use cuda stream to run async inferen...


[style] ~41-~41: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ync inference and later synchronize. - How to work with models with static and dyn...


[style] ~42-~42: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... with static and dynamic batch sizes. - How to work with models with single or mult...


[style] ~43-~43: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...th single or multiple output tensors. - How to work with models with multiple input...


[uncategorized] ~52-~52: Use a comma before ‘or’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...your own onnx model for this sample code or you can download the sample model (see ...


[uncategorized] ~66-~66: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...ts/`. - If you use the provided script and you have installed cuDNN to a non-stand...


[grammar] ~114-~114: The verb after “to” should be in the base form as part of the to-infinitive. A verb can take many forms, but the base form is always used in the to-infinitive.
Context: ...sing the YoloV8 model, it is advised to used the COCO validation dataset, which can ...


[duplication] ~121-~121: Possible typo: you repeated a word
Context: ...batch can fit in your GPU memory. ### Benchmarks Benchmarks run on RTX 3050 Ti Laptop GPU, 11th Gen...


[style] ~157-~157: The phrase ‘lots of’ might be wordy and overused. Consider using an alternative.
Context: ...ted in include/engine. I have written lots of comments all throughout the code which ...


[uncategorized] ~157-~157: Possible missing comma found.
Context: ...ten lots of comments all throughout the code which should make it easy to understand...


[style] ~165-~165: Consider using a different verb to strengthen your wording.
Context: ...and re-run the application. This should give you more information on where exactly t...


[grammar] ~168-~168: It appears that an object is missing here.
Context: ...his project was helpful to you, I would appreciate if you could give it a star. That will ...


[uncategorized] ~168-~168: It appears that hyphens are missing in the adjective “up-to-date”.
Context: .... That will encourage me to ensure it's up to date and solve issues quickly. I also do con...


[uncategorized] ~199-~199: Use a comma before ‘but’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...if your model has been compiled for FP32 but you try running FP16 inference, it will...


[typographical] ~246-~246: It seems that a comma is missing.
Context: .../in/cyrus-behroozi/ ## Contributors ✨ Thanks goes to these wonderful people ([emoji ...

Markdownlint
README.md

38-38: Expected: 0 or 2; Actual: 1
Trailing spaces


40-40: Expected: 0 or 2; Actual: 1
Trailing spaces


52-52: Expected: 0 or 2; Actual: 1
Trailing spaces


69-69: Expected: 0 or 2; Actual: 1
Trailing spaces


83-83: Expected: 0 or 2; Actual: 1
Trailing spaces


86-86: Expected: 0 or 2; Actual: 1
Trailing spaces


92-92: Expected: 0 or 2; Actual: 5
Trailing spaces


101-101: Expected: 0 or 2; Actual: 1
Trailing spaces


103-103: Expected: 0 or 2; Actual: 1
Trailing spaces


109-109: Expected: 0 or 2; Actual: 1
Trailing spaces


110-110: Expected: 0 or 2; Actual: 1
Trailing spaces


113-113: Expected: 0 or 2; Actual: 1
Trailing spaces


117-117: Expected: 0 or 2; Actual: 1
Trailing spaces


119-119: Expected: 0 or 2; Actual: 1
Trailing spaces


134-134: Expected: 0 or 2; Actual: 1
Trailing spaces


157-157: Expected: 0 or 2; Actual: 1
Trailing spaces


158-158: Expected: 0 or 2; Actual: 1
Trailing spaces


168-168: Expected: 0 or 2; Actual: 1
Trailing spaces


198-198: Expected: 0 or 2; Actual: 1
Trailing spaces


200-200: Expected: 0 or 2; Actual: 1
Trailing spaces


213-213: Expected: 0 or 2; Actual: 1
Trailing spaces


214-214: Expected: 0 or 2; Actual: 1
Trailing spaces


220-220: Expected: 0 or 2; Actual: 1
Trailing spaces


224-224: Expected: 0 or 2; Actual: 1
Trailing spaces


234-234: Expected: 0 or 2; Actual: 1
Trailing spaces


210-210: Expected: 1; Actual: 2
Multiple consecutive blank lines


31-31: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines


50-50: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines


54-54: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines


72-72: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines


78-78: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines


88-88: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines


108-108: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines


121-121: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines


133-133: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines


137-137: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines


156-156: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines


162-162: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines


167-167: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines


104-104: null
Fenced code blocks should be surrounded by blank lines


138-138: null
Fenced code blocks should be surrounded by blank lines


35-35: null
Lists should be surrounded by blank lines


55-55: null
Lists should be surrounded by blank lines


73-73: null
Lists should be surrounded by blank lines


79-79: null
Lists should be surrounded by blank lines


89-89: null
Lists should be surrounded by blank lines


103-103: null
Lists should be surrounded by blank lines


112-112: null
Lists should be surrounded by blank lines


157-157: null
Lists should be surrounded by blank lines


163-163: null
Lists should be surrounded by blank lines


192-192: null
Emphasis used instead of a heading


196-196: null
Emphasis used instead of a heading


202-202: null
Emphasis used instead of a heading


206-206: null
Emphasis used instead of a heading


211-211: null
Emphasis used instead of a heading


218-218: null
Emphasis used instead of a heading


222-222: null
Emphasis used instead of a heading


226-226: null
Emphasis used instead of a heading

Additional comments not posted (11)
include/logger.h (4)

6-15: Enum LogLevel is well-defined and covers a comprehensive range of logging levels.


17-17: Function getLogLevelFromEnvironment provides a dynamic way to set logging levels, which enhances configurability.


18-18: Function parseLogLevel correctly interprets string representations of log levels, which is crucial for user-configurable logging.


19-19: Function toSpdlogLevel effectively bridges the custom LogLevel with spdlog's logging levels, ensuring compatibility.

include/Int8Calibrator.h (1)

4-33: The Int8EntropyCalibrator2 class is well-defined and adheres to modern C++ standards. Good use of default parameter values and consistent override of virtual functions.

src/logger.cpp (1)

1-1: The logging functionality is implemented correctly and effectively using spdlog. Good handling of different log levels and appropriate warnings for unhandled cases.

Also applies to: 3-3, 5-5, 7-7, 9-9, 11-11, 13-13, 15-15, 17-17, 19-19, 21-21, 23-23, 25-25, 27-27, 29-29, 31-31, 33-33, 35-35, 37-37

README.md (3)

137-154: The updated project structure is well-organized and clearly documented.


157-159: The additional resources and explanations provided in this section are helpful for understanding the codebase.


Line range hint 165-165: The debugging tips provided are practical and should help users effectively troubleshoot issues.

include/engine/EngineBuildLoadNetwork.inl (2)

6-31: The buildLoadNetwork function is well-implemented with comprehensive error handling and informative logging.


33-89: The loadNetwork function effectively handles file reading and engine loading with proper error checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant