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

[compiler/circle-input-names] Introduce a new tool displaying input names #14472

Merged
merged 8 commits into from
Dec 18, 2024

Conversation

batcheu
Copy link
Contributor

@batcheu batcheu commented Dec 18, 2024

The new tool 'circle_input_names' displays the all input names of each operator in JSON format.
This will be used to generate input metadata in Model Explorer.


…ames

The new tool 'circle_input_names' displays the all input names of
each operator in JSON format.

ONE-DCO-1.0-Signed-off-by: Jonghwa Lee <[email protected]>
template <> struct is_VariadicOut<CircleIf> : std::true_type {};
template <> struct is_VariadicOut<CircleWhile> : std::true_type {};
// clang-format on

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note

Here, SFINAE is used to create CircleNode depending on default contructor for each.

file(GLOB SOURCES "src/*.cpp")

add_executable(circle_input_names ${SOURCES})
target_include_directories(circle_input_names PUBLIC include)
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not see include folder (in also draft). can we remove this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I'll remove it.
Thanks ;)

@seanshpark
Copy link
Contributor

I can see circle-input-names-test module in draft.
If possible can we add test codes in this module too, if there is no particular reason to split two.

@batcheu
Copy link
Contributor Author

batcheu commented Dec 18, 2024

I can see circle-input-names-test module in draft. If possible can we add test codes in this module too, if there is no particular reason to split two.

Okay, I'll revise it too.

It removes a unnecessary line in CMakeLists by the comment.

ONE-DCO-1.0-Signed-off-by: Jonghwa Lee <[email protected]>
{
std::string lookup(const loco::Node *) const override { return ""; }
};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note

In fact, this tool is nothing but prints all input names defined in CircleNodeSummaryBuilder.
However, it requires some hacks to instantiate the builder outside of the module.
All above codes are the Hacks.

It introduces a test to check the result of circle-input-names.

ONE-DCO-1.0-Signed-off-by: Jonghwa Lee <[email protected]>
// "{"
json_export.open_brace();
#define CIRCLE_NODE(OP, CIRCLE_OP) \
{ \
Copy link
Contributor

Choose a reason for hiding this comment

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

As I said in the offline, it's a bit hard to know why these are needed. Therefore, adding a comment about why dummy values are set would be helpful.

Moreover, functions that fill with dummy data can be made into a single function, too. The function name would show what it does.

void populate_dummy_data(/*..*/):
{
  add_fused_actfn_option(&node);              
  add_padding_option(&node);                  
  add_mode_option(&node); 
}

The name candidates are follows.

  • fill_with_dummy_data
  • initialize_with_defaults
  • mock_data_setup
  • prepare_mock_values
  • set_dummy_state

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I'll add a wrapper function as you suggested.
Thanks !

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Applied!

@mhs4670go
PTAL if you have a spare time :)

@@ -0,0 +1,3 @@
# circle-input-names

`circle-input-names` is a tool to generate input names of the Circle model's operators in JSON format.
Copy link
Contributor

Choose a reason for hiding this comment

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

How about show a part of expected outputs? This would be helpful to know what it does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion 2.
I'll update it too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Applied!

@mhs4670go
ditto.

It adds a wrapper function for mocking functions which helps to
to create circle node summary. And it also modifies other function
names to make them easier to understand.

ONE-DCO-1.0-Signed-off-by: Jonghwa Lee <[email protected]>
It adds the sample of result to README file.

ONE-DCO-1.0-Signed-off-by: Jonghwa Lee <[email protected]>
Copy link
Contributor

@zetwhite zetwhite left a comment

Choose a reason for hiding this comment

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

I read the code carefully. Short and powerful code 👍
I'd like to leave LGTM after all CI pass.

ONE-DCO-1.0-Signed-off-by: Jonghwa Lee <[email protected]>
ONE-DCO-1.0-Signed-off-by: Jonghwa Lee <[email protected]>
Copy link
Contributor

@seanshpark seanshpark left a comment

Choose a reason for hiding this comment

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

LGTM thank you!

auto summary = create_circle_node_summary(&node); \
get_input_names_from_summary(&node, summary, json_export); \
}
#define CIRCLE_VNODE(_1, _2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curiosity, what does this code mean? What does it do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Defined to ignore CIRCLE_VNODEs in circle_nodes.lst.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I got it. This would be better to be described as a comment. Maybe in the next PR.

throw std::runtime_error("CIRCLE_INPUT_NAMES_PATH is not found");
}

FILE *fp = popen(cmd.c_str(), "r");
Copy link
Contributor

@mhs4670go mhs4670go Dec 18, 2024

Choose a reason for hiding this comment

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

(Optional) Just as a minor comment, I think we can revisit the program not to use popen function in the test by making a function that returns the stringstream. Which makes a test flow simpler and makes a program have higher extensibility.

int main()
{
  #  ..
  auto ss_input_names = # ..
  std::cout << ss_input_names.str();

  return 0;
}

But, this program seems not to have high maintainability. So, it's not that important.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you don't mind, could you elaborate more about it?
Is there a way to redirect forked process standard output to stream buffer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@seanshpark explained about it in offline ;)
Now, I understand what you meant, Thanks 👍

Copy link
Contributor

@mhs4670go mhs4670go left a comment

Choose a reason for hiding this comment

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

LGTM

@seanshpark
Copy link
Contributor

I'd like to leave LGTM after all CI pass.

I'll land with this message. :)

@seanshpark seanshpark merged commit 5887d4c into Samsung:master Dec 18, 2024
8 checks passed
@batcheu batcheu deleted the circle-input-names branch December 18, 2024 10:12
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