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

[record-hessian] Introduce Record-hessian #14183

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

Conversation

BLee-bot
Copy link

@BLee-bot BLee-bot commented Oct 8, 2024

This PR introduces Record-hessian

Related Issue : #13480
Draft: #13585

// Never return nullptr
HessianObserver *getObserver() const { return _observer.get(); }

luci::Module *_module;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
luci::Module *_module;
luci::Module *_module = nullptr;

@@ -1,7 +1,7 @@
#!/usr/bin/make -f
export DH_VERBOSE = 1
export NNAS_BUILD_PREFIX = build
export PRESET = 20230907
export PRESET = 20240812
Copy link
Contributor

Choose a reason for hiding this comment

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

plz split infra/* to separate PRs so that compiler/* is not mixed in same PR

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for review.
Splited compiler/record-hessian with infra/*.

endif(NOT ENABLE_TEST)

nnas_find_package(GTest REQUIRED)
set(TEST_SOURCES, "src/MinMaxComputer.cpp")
Copy link
Contributor

Choose a reason for hiding this comment

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

Q) what/where is this file?

Copy link
Author

Choose a reason for hiding this comment

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

It should be "HessianComputer.cpp"

@seanshpark seanshpark requested a review from a team October 10, 2024 08:57
if (_node->opcode() == luci::CircleOpcode::FULLY_CONNECTED ||
_node->opcode() == luci::CircleOpcode::CONV_2D)
{
_hessian_computer.recordHessian(_node, tensor);
Copy link
Contributor

Choose a reason for hiding this comment

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

Q) are you going to support more opcodes ?

Copy link
Author

Choose a reason for hiding this comment

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

Not now, but we plan to add DepthCONV or TCONV later.

buf.swap(unfolded_buf);
}

void HessianComputer::recordHessian(const luci::CircleNode *node,
Copy link
Contributor

Choose a reason for hiding this comment

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

plz add dtype check inside this method

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for your suggestion. I've added a dtype check.

std::vector<float> buf(data, data + num_elements);

// get the size of input channel from weights
if (node->opcode() == luci::CircleOpcode::FULLY_CONNECTED)
Copy link
Contributor

Choose a reason for hiding this comment

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

it would be better to split methods per opcode

Copy link
Author

Choose a reason for hiding this comment

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

I've refactored the code to split the methods based on opcodes.

@seanshpark
Copy link
Contributor

it would be better to split this PR per single purpose.

  • review/update may take more time than you think
  • review is hard to concentrate with lots of changes and different purposes

@@ -0,0 +1,386 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

these are some questions,

  • what is the purpose of this file? or what does this do?
  • what are the tests for the codes in this file?

Copy link
Author

Choose a reason for hiding this comment

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

  1. This file records the Hessian of a model by processing input data and profiling the results. It reads input data, verifies is's type and shape, and calculates the Hessian for each.
  2. Tests for this file are yet to be written, but will be attached soon.


void RecordHessian::initialize(luci::Module *module)
{

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

@seanshpark
Copy link
Contributor

CI shows several failures. plz fix them.

// ready to be consumed by the input circle model without any modification
// TODO reduce duplicate codes with profileRawData
std::unique_ptr<HessianMap>
RecordHessian::profileRawDataDirectory(const std::string &input_data_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

this and profileRawData methods are not called from anywhere.
and also from the draft too.

plz don't put unused codes.

Copy link
Author

Choose a reason for hiding this comment

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

I've removed unused code.

@seanshpark
Copy link
Contributor

I strongly recommend you to post PRs with single context of changes that doens't exceed 100 lines with tests codes.

@seanshpark
Copy link
Contributor

Copy link
Author

@BLee-bot BLee-bot left a comment

Choose a reason for hiding this comment

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

Thank you for suggestions.

endif(NOT ENABLE_TEST)

nnas_find_package(GTest REQUIRED)
set(TEST_SOURCES, "src/MinMaxComputer.cpp")
Copy link
Author

Choose a reason for hiding this comment

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

It should be "HessianComputer.cpp"

if (_node->opcode() == luci::CircleOpcode::FULLY_CONNECTED ||
_node->opcode() == luci::CircleOpcode::CONV_2D)
{
_hessian_computer.recordHessian(_node, tensor);
Copy link
Author

Choose a reason for hiding this comment

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

Not now, but we plan to add DepthCONV or TCONV later.

buf.swap(unfolded_buf);
}

void HessianComputer::recordHessian(const luci::CircleNode *node,
Copy link
Author

Choose a reason for hiding this comment

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

Thank you for your suggestion. I've added a dtype check.

std::vector<float> buf(data, data + num_elements);

// get the size of input channel from weights
if (node->opcode() == luci::CircleOpcode::FULLY_CONNECTED)
Copy link
Author

Choose a reason for hiding this comment

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

I've refactored the code to split the methods based on opcodes.

// ready to be consumed by the input circle model without any modification
// TODO reduce duplicate codes with profileRawData
std::unique_ptr<HessianMap>
RecordHessian::profileRawDataDirectory(const std::string &input_data_path)
Copy link
Author

Choose a reason for hiding this comment

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

I've removed unused code.

@@ -0,0 +1,386 @@
/*
Copy link
Author

Choose a reason for hiding this comment

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

  1. This file records the Hessian of a model by processing input data and profiling the results. It reads input data, verifies is's type and shape, and calculates the Hessian for each.
  2. Tests for this file are yet to be written, but will be attached soon.

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.

2 participants