Add Cropping layers support#1309
Merged
Merged
Conversation
Contributor
Author
|
pre-commit.ci autofix |
JanFSchulte
approved these changes
Jun 26, 2025
JanFSchulte
left a comment
Contributor
There was a problem hiding this comment.
Test error are unrelated to this PR. Looks good to me.
Contributor
|
@calad0i Do you think this needs to be included explicitly also in the keras v3 parser, or should we let the fallback take care of it? |
Contributor
|
As discussed in today's dev meeting, we are merging this PR now with the understanding that it might be good to generalize in the future as to not have separate implementations for 1D and 2D cases, as well as adding a dedicated layer handler to the keras v3 parser. |
calad0i
pushed a commit
to calad0i/hls4ml
that referenced
this pull request
Jul 2, 2025
* added Cropping1D and Cropping2D keras layers support * removed .bak templates files * added cropping layers tests for vivado and vitis * [pre-commit.ci] auto fixes from pre-commit hooks --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
vloncar
pushed a commit
that referenced
this pull request
Jul 3, 2025
…1191) * skip oneapi test if icpx doesnt exist * bit-exact-possible multidim softmax * softmax fix softmax fix fix softmax parsing issue ckpt softmax fix fix table size after overriding inv_inp_t * move softmax attr to fpga backend, post rebase fix * add keras v3 object parser * add keras v3 layer handlers * einsumdense and einsum * add einsum templates * bit-exact-possible multidim softmax * symbolic bitwidth infer util * add qinterval test * keras v2-v3 reshape fn compability patch * hgq2 layer handlers * add bit-exact enforcement pass * fix softmax accum fractional bits derivation * add qeinsum test * env update * remove hgq v1 rewire behavier (superseded) * fix del method in config class * distributed arithmetic impl * distributed arithmetic impl w/ conv * distributed arithmetic templates * prevent pointwise override for DA strategy * add test for DA * update proj conf * disable delay_constraint in da4ml * add hgq2 mha test * update ci template * require da4ml version * pre-commit fix * proper skip qeinsum test when condition not met * softmax and activation fix * hgq2 api change, prevent zero bw activation crash syn * qinterval and bn bit-exactness fix * fix einsum ax expansion and 0d output handling * fix merge templates * converter and bit-exact pass for ops layers * use pointwise 2d for conv2d due to unknown flow changing * fix einsum dense da impl corner case * qinterval type fix * fix corner case in qkeras converted proxy * support mha def in (q,v) format * update da4ml binding syntax * update da4ml binding syntax x2 * use fixedvararr obj for da codegen * more general build_lib script * bring back hgq proxy embedded properties excl. pecision * fix streaming conv1/2d da regression * streaming template support for DA fix * allow non-po-2 avg pooling * ignore batch dim in parse_data_format * keras v3 native pooling layer parser * globalpooling handler fix * unary lut bw derivation update * keras 3.10 api change * namespace fix for pointwise conv * use constexpr for dim def * conv pf handling * keras v3 api change * quality-of-life changes * kv3 parser update * shut up! * post-rebase import conflicts * remaining post-rebase fix * bit-exactness corner case * quantizer shrink corner case fix (sign bit) * allow 0 bit activation... * template and test fix * intel/ac_types/ac_int.hpp:156:30: error: unsigned _BitInt must have a bit size of at least 1 * static_cast<typename ExtractPipeType<res_pipe>::value_type::value_type> * doc leftover * comment * style * [pre-commit.ci] auto fixes from pre-commit hooks * model opt pass fix and avg pool fix * squashed cosmetic and minor changes * multi graph dimname fix * Add Cropping layers support (#1309) * added Cropping1D and Cropping2D keras layers support * removed .bak templates files * added cropping layers tests for vivado and vitis * [pre-commit.ci] auto fixes from pre-commit hooks --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * bump da4ml version * bit-exact algorithm minor change --------- Co-authored-by: Jan-Frederik Schulte <jschulte@cern.ch> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Hamza Ezzaoui Rahali <hamzaezzaouirahali@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds support for Keras' Cropping1D and Cropping2D layers with Vivado and Vitis backend in both
io_parallelandio_streammodes.The implementation is straightforward and follows a similar style to zero-padding implementations. I added tests for Vivado and Vitis backends.
I have yet to run this on a board, but implementation was successful targeting a ZCU102, using Vivado 2019.1. Although this type of layer has a fairly niche usage, I still found a use case for it, and it could benefit the community.
Linked Issue: #1308
Type of change
Tests
I added unit tests in
test/pytest/test_cropping.pyTest Configuration:
io_type:["io_stream", "io_parallel"]backend:["Vivado", "Vitis"]model_type:["1d", "2d"]Checklist
pre-commiton the files I edited or added.