Skip to content

Small optimization for tfa.image.transform_ops.angles_to_projective_transforms#2056

Merged
WindQAQ merged 1 commit intotensorflow:masterfrom
Smankusors:master
Jul 29, 2020
Merged

Small optimization for tfa.image.transform_ops.angles_to_projective_transforms#2056
WindQAQ merged 1 commit intotensorflow:masterfrom
Smankusors:master

Conversation

@Smankusors
Copy link
Contributor

Description

Brief Description of the PR:

Fixes #2054.

Type of change

Checklist:

  • I've properly formatted my code according to the guidelines
    • By running Black + Flake8
    • By running pre-commit hooks
  • This PR addresses an already submitted issue for TensorFlow Addons
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • This PR contains modifications to C++ custom-ops

How Has This Been Tested?

I tested this on Google Colab environment. Well here's the result :

# CPU (Run 1)
angles_to_projective_transforms     0065868
angles_to_projective_transforms2    0069990
angles_to_projective_transforms_tf  0257738
angles_to_projective_transforms2_tf 0260291
# CPU (Run 2)
angles_to_projective_transforms     0065672
angles_to_projective_transforms2    0069954
angles_to_projective_transforms_tf  0261689
angles_to_projective_transforms2_tf 0254197
# CPU (Run 3)
angles_to_projective_transforms     0066451
angles_to_projective_transforms2    0070442
angles_to_projective_transforms_tf  0264665
angles_to_projective_transforms2_tf 0262863
# CPU (Run 4)
angles_to_projective_transforms     0071835
angles_to_projective_transforms2    0076597
angles_to_projective_transforms_tf  0294059
angles_to_projective_transforms2_tf 0286251

# GPU
angles_to_projective_transforms     0029724
angles_to_projective_transforms2    0033601
angles_to_projective_transforms_tf  0230617
angles_to_projective_transforms2_tf 0230509

# TPU
angles_to_projective_transforms     0058424
angles_to_projective_transforms2    0061462
angles_to_projective_transforms_tf  0293018
angles_to_projective_transforms2_tf 0302889

(The higher the number, the better)

Description about each row :

  • angles_to_projective_transforms : is the original function
  • angles_to_projective_transforms2 : is after the small optimization
  • angles_to_projective_transforms_tf : is the original function with tf.function decoration
  • angles_to_projective_transforms2_tf : is after the small optimization with tf.function decoration

Calling it directly seems have a performance increase. But if decorated with tf.function, it seems like it's already optimized by Tensorflow, so not really seeing performance increase there.

The full benchmark script is here

for tfa.image.transform_ops.angles_to_projective_transforms
@boring-cyborg boring-cyborg bot added the image label Jul 29, 2020
@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.

@bot-of-gabrieldemarmiesse

@mels630

You are owner of some files modified in this pull request.
Would you kindly review the changes whenever you have the time to?
Thank you very much.

@Smankusors
Copy link
Contributor Author

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@WindQAQ WindQAQ self-requested a review July 29, 2020 17:01
Copy link
Member

@WindQAQ WindQAQ left a comment

Choose a reason for hiding this comment

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

Thanks :-)

@WindQAQ WindQAQ merged commit 6ec6e54 into tensorflow:master Jul 29, 2020
jrruijli pushed a commit to jrruijli/addons that referenced this pull request Dec 23, 2020
for tfa.image.transform_ops.angles_to_projective_transforms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

About cos sin at tfa.image.transform_ops.angles_to_projective_transforms

4 participants