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

[Wait for #2849] [ Context ] Add Engine Class to manage Contexts #2848

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

Conversation

jijoongmoon
Copy link
Collaborator

Add Engine and Context Class

In order to extend the Context more easily, this PR adds Engine Class
to manage the Contexts. It adds Context Class as well which is base
class of all the Context.
. add Engine Class
. add Context Class
. set default Context is app contexts
. Pluggable support in Engine
. some more code optimization & test codes requires.

Self evaluation:

  1. Build test: [X]Passed [ ]Failed [ ]Skipped
  2. Run test: [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: jijoong.moon [email protected]

This PR add ComputeEngine Enum Property.
Enum elements are "cpu", "gpu", "qnn" for now.
The property format is "engine=qnn".

**Self evaluation:**
1. Build test:	 [X]Passed [ ]Failed [ ]Skipped
2. Run test:	 [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: jijoong.moon <[email protected]>
@jijoongmoon jijoongmoon changed the title [ Context ] Add Engine Class to manage Contexts [Wait for #2849] [ Context ] Add Engine Class to manage Contexts Dec 30, 2024
@jijoongmoon jijoongmoon force-pushed the engine_class branch 2 times, most recently from 9d38a3a to a2e6707 Compare December 30, 2024 04:57
Copy link
Contributor

@EunjuYang EunjuYang left a comment

Choose a reason for hiding this comment

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

This PR implements Engine and Context class to support multiple compute engines. I have some comments and a question on this PR below.

createLayerObject(const std::string &type,
const std::vector<std::string> &properties = {}) const {
auto ct = getRegisteredContext(parseComputeEngine(properties));
ct->getName();
Copy link
Contributor

@EunjuYang EunjuYang Dec 31, 2024

Choose a reason for hiding this comment

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

This line (L132) seems redundant. The return value is not used.

@@ -37,6 +37,7 @@
#include <common_properties.h>
#include <compiler_fwd.h>
#include <dynamic_training_optimization.h>
#include <engine.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove #include <app_contxt.h> as well.

#include <app_context.h>

if (!(options & LayerCreateSetPropertyOptions::AVAILABLE_FROM_APP_CONTEXT)) {
ac.registerFactory<nntrainer::Layer>(std::get<0>(GetParam()));
ac->registerFactory<nntrainer::Layer>(std::get<0>(GetParam()));
Copy link
Contributor

Choose a reason for hiding this comment

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

I have a question.
In this PR, createOptimizerObject is implemented as an interface for engine, but registerFactory is not.
I guess registerFactory can also be an another common function used in various contexts; in this sense, it might be better to be implemented in Context class and called at the Engine according to its property. By doing so, only the engine header will be explosed to the outside. Could you share your idea on this? I couldn't catch what is the standard allowing to access via engine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes. it should be. this should be done in later PR. I will leave the todo comments.

In order to extend the Context more easily, this PR adds Engine Class
to manage the Contexts. It adds Context Class as well which is base
class of all the Context.
 . add Engine Class
 . add Context Class
 . set default Context is app contexts
 . Pluggable support in Engine
 . some more code optimization & test codes requires.

**Self evaluation:**
1. Build test:	 [X]Passed [ ]Failed [ ]Skipped
2. Run test:	 [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: jijoong.moon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants