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

Refactoring in Pipeline, old Executor + name lookup improvement in old OpGraph. #5495

Merged
merged 10 commits into from
Jun 4, 2024

Conversation

mzient
Copy link
Contributor

@mzient mzient commented Jun 3, 2024

Category:

Refactoring (Redesign of existing code that doesn't affect functionality)

Description:

This PR does some API adjustments that will work better with the new graph.
There are some name lookup improvements in (old) OpGraph and Pipeline and there's a transition to querying by string_view as opposed to const string & - should work better with new OpGraph and, as a bonus, avoid creating temporary strings in C API.

Additional information:

Affected modules and functionalities:

Key points relevant for the review:

Tests:

  • Existing tests apply
  • New tests added
    • Python tests
    • GTests
    • Benchmark
    • Other
  • N/A

Checklist

Documentation

  • Existing documentation applies
  • Documentation updated
    • Docstring
    • Doxygen
    • RST
    • Jupyter
    • Other
  • N/A

DALI team only

Requirements

  • Implements new requirements
  • Affects existing requirements
  • N/A

REQ IDs: N/A

JIRA TASK: DALI-3974

mzient and others added 4 commits June 3, 2024 14:56
Signed-off-by: Michał Zientkiewicz <mzient@gmail.com>
Signed-off-by: Michał Zientkiewicz <mzient@gmail.com>
Signed-off-by: Michał Zientkiewicz <mzient@gmail.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
@mzient mzient force-pushed the graph_refactor2 branch from cadf3bc to 111cf63 Compare June 3, 2024 16:02
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [15531112]: BUILD STARTED

Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
@mzient mzient changed the title Graph lowering + minor refactoring in Pipeline + name lookup improvement in old OpGraph. Refactoring in Pipeline, old Executor + name lookup improvement in old OpGraph. Jun 3, 2024
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [15531112]: BUILD FAILED

@@ -113,7 +114,7 @@ TensorNode& OpGraph::PlaceNewTensor() {
}


void OpGraph::AddOp(const OpSpec &spec, const std::string &op_name) {
OpNode &OpGraph::AddOp(const OpSpec &spec, const std::string &op_name) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is necessary in a follow-up PR.

Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
@mzient mzient marked this pull request as ready for review June 3, 2024 16:16
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [15531540]: BUILD STARTED

@mzient mzient mentioned this pull request Jun 3, 2024
18 tasks
@NVIDIA NVIDIA deleted a comment from dali-automaton Jun 4, 2024
for (auto &node : op_nodes_) {
if (node.instance_name == name) {
return node;
}
}
DALI_FAIL("Operator node with name " + name + " not found.");
DALI_FAIL(make_string("Operator node with name ", name, " not found."));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For very dubious reasons, C++ doesn't define operator+ for string_view.

@@ -467,8 +469,9 @@ class DLL_PUBLIC OpGraph {
*/
void RemoveOpNode(OpNodeId id);

std::map<std::string, TensorNodeId> tensor_name_to_id_;
std::map<std::string, TensorNodeId, std::less<>> tensor_name_to_id_;
Copy link
Contributor Author

@mzient mzient Jun 4, 2024

Choose a reason for hiding this comment

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

Passing std::less<> allows use of any comparable key for find and operator[] - in this case, a string_view.
See example - look for "transparent comparison".

Comment on lines -86 to -90
template <typename WorkspacePolicy, typename QueuePolicy>
void PipelinedExecutorImpl<WorkspacePolicy, QueuePolicy>::Build(OpGraph *graph,
vector<string> output_names) {
Executor<WorkspacePolicy, QueuePolicy>::Build(graph, output_names);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Useless override removed.

@@ -571,8 +571,6 @@ void Pipeline::Build(std::vector<PipelineOutputDesc> output_descs) {
}
}

graph_.InstantiateOperators();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's the 1st thing that Executor::Build does.

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [15531540]: BUILD PASSED

mzient added 2 commits June 4, 2024 12:27
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [15556390]: BUILD STARTED

Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [15559469]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [15559469]: BUILD PASSED

@mzient mzient merged commit 182f7e4 into NVIDIA:main Jun 4, 2024
5 checks passed
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.

4 participants