Comments (2)
This is a known issue and it happens due to the optimization of 1x1 Conv1D/2D to PointwiseConv1D/2D. However, even if you anticipate that and try to change the layers
parameter to include PointwiseConv1D
(or the name of the layer, q_conv1d
) it won't affect the outcome due to the order in which the optimizers are applied. I hope to get rid of the output_rounding_saturation_mode
in the future as this was a workaround to increase the compatibility with QKeras when we didn't have enough flexibility with other optimizers.
A solution that I suggest in this case is to change the hls_config
that you pass to the converter. In your example that could be:
config = hls4ml.utils.config_from_keras_model(model, granularity='name')
config['LayerName']['q_conv1d']['Precision']['result'] = 'fixed<16,6, RND_CONV, SAT>'
You can do this for other layers as well and avoid using the optimizer at all. To avoid guessing the name of the layer, you can name them in Keras, a nice practice regardless. Similar can be achieved with granularity='type'
if you want to type less, that would be a more direct equivalent to what you were doing with the optimizer.
from hls4ml.
Thanks @vloncar, this is helpful.
I forgot to mention in the issue that I am already explicitly defining the precision for each named layer as a workaround (I my project, not in this example code). Setting the default precision to fixed<16,6, RND_CONV, SAT>
also works but is even less flexible than the optimizer pass.
I noticed the conversion of 1x1 Conv1D/2D to PointwiseConv1D/2D, but looking at this optimizer code I don't understand why the initial precision is not transferred to the new layer and this appeared to me as a bug. But I agree that it is not that important once known (Maybe could be mentioned in the doc/code/tutorial?) as the optimizer pass is useful during exploration when the model structure is changing a lot, less when the structure is fixed and explicit layer config can be defined.
IMO this issue can be closed if there is plan for a better solution in the future.
from hls4ml.
Related Issues (20)
- "warning: integer constant is so large that it is unsigned" causes hls_model.compile() to fail
- CNN Synthesis fail : ERROR: [XFORM 203-504] Stop unrolling loop 'Product1' (firmware/nnet_utils/nnet_dense_latency.h:37) in function 'nnet::dense_latency<ap_fixed<2, 1, (ap_q_mode)5, (ap_o_mode)3, 0>, ap_fixed<2, 1, (ap_q_mode)5, (ap_o_mode)3, 0>, config6>' because it may cause large runtime and excessive memory usage due to increase in code size. Please avoid unrolling the loop or form sub-functions for code in the loop body. ERROR: [HLS 200-70] Pre-synthesis failed. HOT 13
- VIVADO HLS INSTALLATION INSTALLATION NOT FOUND MAKE SURE VIVADO HLS ON PATH
- [XFORM 203-502] HOT 6
- Non-quantized QKeras layers break conversion
- Concatenation Layer Issue with PyTorch ResNet
- Keras Reshape Layer is Built with Error HOT 1
- vivadoaccelerator backend : bit file note generated HOT 5
- About QBatchNormalization is not support QKeras po2 quantizer HOT 1
- ERROR: [XFORM 203-504] Stop unrolling loop 'Product1' (firmware/nnet_utils/nnet_dense_latency.h:37) in function 'nnet::dense_latency<ap_fixed<16, 6, (ap_q_mode)5, (ap_o_mode)3, 0>, ap_fixed<16, 6, (ap_q_mode)5, (ap_o_mode)3, 0>, config42_mult>' because it may cause large runtime and excessive memory usage due to increase in code size. Please avoid unrolling the loop or form sub-functions for code in the loop body. myproject_prj:solution1 Dec 27, 2023 6:47:26 PM
- Failure at converters.convert_from_pytorch_model . compile/build()
- Move transpose based on backend from hls4ml/model/layers.py to backend-specific areas
- Problem tracing binary CNN model after recent tracing optimization HOT 8
- Wrong prediction of C Simulation compared to QKeras? HOT 3
- The hls4ml transformation successful, however, the result of inference all zeros. HOT 1
- Issue with ModelGraph function during ONNX model synthesis HOT 4
- TypeError: 'NoneType' object is not subscriptable HOT 7
- SR backend doesn't work with Vitis HLS
- Incorrect hls4ml results for AveragePooling2D/MaxPooling2D Keras layer
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hls4ml.