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

Normalization Layer: FP32/FP16 should NOT be determined at compile-time #2408

Open
myungjoo opened this issue Jan 12, 2024 · 5 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@myungjoo
Copy link
Member

Having calculations based on fp16 or fp32 should be determined at run-time based on the model and user's intention, not by the compiler-options.

#ifndef ENABLE_FP16
deviation.pow(2.0f, temp_full_size);
temp_full_size.average(normalize_axes, variance);
variance.add_i(epsilon);
variance.pow(-0.5f, inv_std_dev);
#else
unsigned int axis_dim = deviation.getDim()[normalize_axes[0]];
for (unsigned int i = 0; i < deviation.getDim()[normalize_axes[0] - 1]; ++i) {
float sum = 0.0;
_FP16 *data = deviation.getAddress<_FP16>(0, 0, i, 0);
for (unsigned int j = 0; j < axis_dim; ++j) {
sum += powf(static_cast<float>(data[j]), 2.0f);
}
inv_std_dev.setValue(0, 0, i, 0, 1.0 / sqrt(sum / axis_dim - epsilon));
}
#endif

@myungjoo myungjoo added the bug Something isn't working label Jan 12, 2024
@taos-ci
Copy link
Collaborator

taos-ci commented Jan 12, 2024

:octocat: cibot: Thank you for posting issue #2408. The person in charge will reply soon.

@jijoongmoon
Copy link
Collaborator

People recommand to use FP32 computation for normalization layers like batch normalization, layer normalizaiton or rms normalization, etc. We will check once again.

@Deeksha-20-99
Copy link

Hello could you let us know the progress on this issue.. Since we (from ASU) are also working and facing the same issue.

@myungjoo
Copy link
Member Author

Hello could you let us know the progress on this issue.. Since we (from ASU) are also working and facing the same issue.

It's not refactored, yet. You will need to choose it with build-option for this version. I guess we will update these after the next product release.

@myungjoo
Copy link
Member Author

Hello could you let us know the progress on this issue.. Since we (from ASU) are also working and facing the same issue.

#2549 may be interesting to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants