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

Fix KL error method per-tensor #1041

Merged
merged 2 commits into from
Apr 14, 2024
Merged

Fix KL error method per-tensor #1041

merged 2 commits into from
Apr 14, 2024

Conversation

ofirgo
Copy link
Collaborator

@ofirgo ofirgo commented Apr 14, 2024

Pull Request Description:

KL error method per-tensor didn't work, and we didn't catch it since our selection tests didn't really run per-tensor tests as expected.
Also fixing other configuration tests that didn't check per-channel=False properly.

Checklist before requesting a review:

  • I set the appropriate labels on the pull request.
  • I have added/updated the release note draft (if necessary).
  • I have updated the documentation to reflect my changes (if necessary).
  • All function and files are well documented.
  • All function and classes have type hints.
  • There is a licenses in all file.
  • The function and variable names are informative.
  • I have checked for code duplications.
  • I have added new unittest (if necessary).

@ofirgo ofirgo requested a review from Idan-BenAmi April 14, 2024 09:50
@ofirgo ofirgo requested review from reuvenperetz and removed request for Idan-BenAmi April 14, 2024 09:51
error_list.append(_kl_error_function(x[j], range_min[j], range_max[j], n_bins=n_bins, n_bits=n_bits))
if per_channel:
for j in range(x.shape[0]): # iterate all channels of the tensor.
error_list.append(_kl_error_function(x[j], range_min[j], range_max[j], n_bins=n_bins, n_bits=n_bits))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe this can be done in a vectorial way?

return lambda x, y, threshold: _kl_error_function_wrapper(x, range_min=0 if not signed else -threshold,
range_max=threshold,
n_bits=n_bits,
per_channel=True)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe use variables to pass to _kl_error_function_wrapper to avoid unnecessary duplications?

@ofirgo ofirgo merged commit bfb89bd into sony:main Apr 14, 2024
27 checks passed
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.

2 participants