[go: up one dir, main page]

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

clean up mult-dimensional dense #1042

Merged
merged 2 commits into from
Jul 24, 2024
Merged

clean up mult-dimensional dense #1042

merged 2 commits into from
Jul 24, 2024

Conversation

jmitrevs
Copy link
Contributor

Description

Multidimensional Dense was broken for cases where any dimensions had size 1, and for Quartus parallel. I believe it was also broken for the resource strategy.

I made the change for ReplaceMultidimensionalDenseWithConv to convert Dense to Conv1D or 2D instead of directly to PointwiseConv1D or 2D, since pointwise is not required to be implemented in all cases. The conv to pointwise optimizer is backend-specific, while this is a backend-agnostic optimizer. This keeps the separation clear. Of course, the conv to pointwise optimizer usually runs after this, so in the end you still end up with a pointwise convolution (if it exists).

Also, the reshaping of the weights is now done once, in the ReplaceMultidimensionalDenseWithConv optimizer, instead of incorrectly there (I think it was correct originally but from before some code modernization) and also in the pointwise optimizers.

Type of change

  • Bug fix (non-breaking change that fixes an issue)

Tests

The existing test_multi_dense.py was expanded to cover the broken cases.

Checklist

  • I have read the guidelines for contributing.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have installed and run pre-commit on the files I edited or added.
  • I have added tests that prove my fix is effective or that my feature works.

@jmitrevs jmitrevs added the bug label Jul 24, 2024
@jmitrevs jmitrevs added this to the v1.0.0 milestone Jul 24, 2024
@@ -58,11 +58,8 @@ def transform(self, model, node):
else:
raise Exception('Cannot replace Dense over {dim}D tensor with Conv{dim}D.'.format(dim=dim))

class_name = 'PointwiseConv' + str(dim) + 'D'
class_name = 'Conv' + str(dim) + 'D'
pw_node = model.make_node(class_name, node.name, pointwise_attrs, node.inputs.copy())
Copy link
Contributor

Choose a reason for hiding this comment

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

pw_codecould be renamed to conv_node, and similar things throughout the file, to get rid of the pointwise-related nomenclature.

('Vivado', 'io_stream'),
('Vivado', 'io_stream'),
('Vitis', 'io_stream'),
('Vitis', 'Latency'),
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need to test Vivado anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder if I got ahead of myself. I was thinking to keep the tests shorter, since Vivado support will soon be on the way out, and it shares things with Vitis, but maybe it shouldn't be just yet. The tests aren't very long. I can add it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was mostly curious if we are starting to phase out Vivado. Still catching up on the status and plans for things :) I guess it makes sense, so I don't think you necessarily need to add them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the plan was that after 1.0 we make Vitis the default backend and restructure the code a bit. I think it makes sense to add Vivado. (There's a similar Quartus -> oneAPI evolution that will happen.)

@jmitrevs jmitrevs merged commit ba08ca1 into main Jul 24, 2024
5 checks passed
@jmitrevs jmitrevs deleted the multi_dense branch July 24, 2024 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants