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

[Clustering] Fixing the bug in clustering for Conv1D/Conv3D #609

Merged
merged 12 commits into from Jun 22, 2021

Conversation

wwwind
Copy link
Contributor

@wwwind wwwind commented Jan 5, 2021

There is a bug in clustering for Conv1D/Conv3D. We used the layout for Conv2D and this is wrong, because tensors for Conv1D/ Conv3D have different ranks. Tests for both cases are added.

Change-Id: Ic1ee16760d9643b8142e5644d6cb68a6890bc621
@googlebot googlebot added the cla: yes PR contributor has signed CLA label Jan 5, 2021
@wwwind wwwind requested a review from akarmi January 5, 2021 11:22
@github-actions github-actions bot added the technique:clustering Regarding tfmot.clustering.keras APIs and docs label Jan 5, 2021
Copy link
Contributor

@akarmi akarmi left a comment

Choose a reason for hiding this comment

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

Thanks. Looks like we need a similar test and fix for Conv1D.

wwwind and others added 2 commits April 6, 2021 10:46
Change-Id: Ic20345f29b6548e7eabf34fe5488654284987a83
Change-Id: Icd0acb2c5a671d4cafc3222fcc4d8098716b3f73
@wwwind wwwind changed the title [Clustering] Fixing the bug in clustering for Conv3D [Clustering] Fixing the bug in clustering for Conv1D/Conv3D Apr 6, 2021
@wwwind wwwind requested a review from akarmi April 6, 2021 10:31
Change-Id: If55e372e7f13fc032f4b85d7e449ed0ecaf6a873
Change-Id: Ib4331480e2d29a24973a15fb5d2cbcf05e051b91
@akarmi
Copy link
Contributor

akarmi commented Apr 13, 2021

@psunn, please review

@akarmi akarmi assigned akarmi and unassigned akarmi Apr 13, 2021
@wwwind wwwind added the ready to pull Working to get PR submitted to internal repository, after which merging to Github happens. label Apr 13, 2021
@akarmi akarmi removed the ready to pull Working to get PR submitted to internal repository, after which merging to Github happens. label Apr 13, 2021
@psunn
Copy link
Contributor

psunn commented Apr 13, 2021

LGTM, thanks!

@wwwind wwwind added the ready to pull Working to get PR submitted to internal repository, after which merging to Github happens. label Apr 13, 2021
@@ -199,6 +202,54 @@ def testDepthwiseConv2DLayerNonClusterable(self):
wrapped_layer)
self.assertEqual([], wrapped_layer.layer.get_clusterable_weights())

@keras_parameterized.run_all_keras_modes
def testConv1DLayer(self):
"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: """Verifies that we can cluster a Conv1D layer.""" Should be a one-liner

"""
Verifies that we can cluster a Conv3D layer.
"""
input_shape =(4, 28, 28, 28, 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above:

[tf.reshape(self.cluster_centroids, [1 for _ in range(wt_dim-2)] + [clst_num])] *
weight.shape[-2], axis=wt_dim-2),
[i for i in weight.shape[:-2]] + [1, 1])] * weight.shape[-1],
axis=wt_dim-1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems a little clunky with all the list comprehensions, is it possible to make this a bit more readable?

1. Nits: Docstring corrections
2. Simplify clunky code in get_pulling_indices

Change-Id: I3c6818099fab1c9b844620cd1dfad6e97efeb0fd
@wwwind
Copy link
Contributor Author

wwwind commented Apr 19, 2021

Hi @daverim Thanks for the review! Your comments are addressed. Please take a look.

@akarmi akarmi removed the ready to pull Working to get PR submitted to internal repository, after which merging to Github happens. label Apr 21, 2021
Change-Id: I367607cb123404f72da7b4a592a70d154d14ed13
@github-actions github-actions bot added the api-review API review needed label Apr 23, 2021
@daverim
Copy link
Collaborator

daverim commented May 10, 2021

Hey sorry, is this PR still required? Can you rebase?

@google-cla
Copy link

google-cla bot commented May 10, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: no PR contributor has not signed CLA and removed cla: yes PR contributor has signed CLA labels May 10, 2021
Change-Id: Ied79f7dfe484770d41dc9b08ae3b5acdbd970e54
@wwwind wwwind requested a review from akarmi May 10, 2021 15:15
@wwwind
Copy link
Contributor Author

wwwind commented May 10, 2021

@googlebot I signed it!

@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

1 similar comment
@google-cla
Copy link

google-cla bot commented May 10, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@psunn
Copy link
Contributor

psunn commented May 10, 2021

@googlebot I consent.

1 similar comment
@wwwind
Copy link
Contributor Author

wwwind commented May 10, 2021

@googlebot I consent.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes PR contributor has signed CLA and removed cla: no PR contributor has not signed CLA labels May 10, 2021
@google-cla
Copy link

google-cla bot commented May 10, 2021

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@daverim daverim added the ready to pull Working to get PR submitted to internal repository, after which merging to Github happens. label May 11, 2021
@copybara-service copybara-service bot merged commit 3e7f162 into tensorflow:master Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-review API review needed cla: yes PR contributor has signed CLA ready to pull Working to get PR submitted to internal repository, after which merging to Github happens. technique:clustering Regarding tfmot.clustering.keras APIs and docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants