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

Move transpose based on backend from hls4ml/model/layers.py to backend-specific areas #957

Open
2 tasks done
jmitrevs opened this issue Jan 12, 2024 · 0 comments
Open
2 tasks done
Labels

Comments

@jmitrevs
Copy link
Contributor

Prerequisites

  • Test that the bug appears on the current version of the master branch. Make sure to include the commit hash of the commit you checked out.
  • Check that the issue hasn't already been reported, by checking the currently open issues.

Quick summary

Backed-specific code should generally not exist in hls4ml/model/layers.py, so the backend-specific transposing of weights should not be part of the standard internal representation (IR).

Details

For Conv2DBatchnorm in the standard IR there is a different transpose made based on the backend:

if self.model.config.is_resource_strategy(self) and self.model.config.backend.name in [
'Vivado',
'VivadoAccelerator',
]:
self.weights['weight'].data_unquantized = np.transpose(folded_weights, axes=[3, 0, 1, 2])
self.weights['weight'].data = self.get_attr('weight_quantizer')(self.weights['weight'].data_unquantized)
else:
self.weights['weight'].data_unquantized = folded_weights
self.weights['weight'].data = self.get_attr('weight_quantizer')(folded_weights)

The standard IR should not depend on the backend. This logic needs to be moved to backend-specific code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant