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

[ Layer ] Move the Weight Read Function to Layer object #2856

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jijoongmoon
Copy link
Collaborator

It is more flexible to moe Weight Read Fuction to Layer Object itself,
rather than having layer_node. Sometimes, it is necessary to change
the read weight depending on Layer Type, such as Batch normalization
layer.

This PR move general read implementation to Layer_devel and layer is
able to override it as it needs.

Self evaluation:

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

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

It is more flexible to moe Weight Read Fuction to Layer Object itself,
rather than having layer_node. Sometimes, it is necessary to change
the read weight depending on Layer Type, such as Batch normalization
layer.

This PR move general read implementation to Layer_devel and layer is
able to override it as it needs.

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

Signed-off-by: jijoong.moon <[email protected]>
Copy link
Contributor

@djeong20 djeong20 left a comment

Choose a reason for hiding this comment

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

LGTM overall

} else {
for (unsigned int i = 0; i < run_context.getNumWeights(); ++i) {
/// @note shared weights are only be read at the first acecss
// if (run_context->isGradientLastAccess(i)) {
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
// if (run_context->isGradientLastAccess(i)) {

let's remove this line

Comment on lines +406 to +408
TensorDim dim = run_context.getWeight(i).getDim();
dim.setDataType(definedWeightDataType);
Tensor T_read(dim, true);
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
TensorDim dim = run_context.getWeight(i).getDim();
dim.setDataType(definedWeightDataType);
Tensor T_read(dim, true);
Tensor T_read = run_context.getWeight(i).clone(definedWeightDataType);

we can utilize Tensor::clone here :)

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.

LGTM

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.

3 participants