Skip to content

Specify std::abs overloads in elementwise.cc#95959

Closed
DKLoehr wants to merge 1 commit intotensorflow:masterfrom
DKLoehr:math
Closed

Specify std::abs overloads in elementwise.cc#95959
DKLoehr wants to merge 1 commit intotensorflow:masterfrom
DKLoehr:math

Conversation

@DKLoehr
Copy link

@DKLoehr DKLoehr commented Jun 25, 2025

This is required to build with the most recent version of LLVM's libc++, which moved the abs function from stdlib.h to math.h in llvm/llvm-project#139586. This seems to have affected overload resolution, requiring us to explicitly specify which one to use. The static_cast syntax, though ugly, works with both versions.

@google-ml-butler google-ml-butler bot added the size:XS CL Change Size: Extra Small label Jun 25, 2025
@google-ml-butler google-ml-butler bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Jun 25, 2025
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Jun 25, 2025
copybara-service bot pushed a commit to google-ai-edge/LiteRT that referenced this pull request Jun 25, 2025
Imported from GitHub PR tensorflow/tensorflow#95959

This is required to build with the most recent version of LLVM's libc++, which moved the `abs` function from `stdlib.h` to `math.h` in llvm/llvm-project#139586.
Copybara import of the project:

--
2fa2ab36dae8afc9cf838a5ce1726e4ba48afec6 by Devon Loehr <dloehr@google.com>:

Include math.h in elementwise.cc

Merging this change closes #95959

FUTURE_COPYBARA_INTEGRATE_REVIEW=tensorflow/tensorflow#95959 from DKLoehr:math 2fa2ab36dae8afc9cf838a5ce1726e4ba48afec6
PiperOrigin-RevId: 775719122
copybara-service bot pushed a commit to google-ai-edge/LiteRT that referenced this pull request Jun 25, 2025
Imported from GitHub PR tensorflow/tensorflow#95959

This is required to build with the most recent version of LLVM's libc++, which moved the `abs` function from `stdlib.h` to `math.h` in llvm/llvm-project#139586.
Copybara import of the project:

--
2fa2ab36dae8afc9cf838a5ce1726e4ba48afec6 by Devon Loehr <dloehr@google.com>:

Include math.h in elementwise.cc

Merging this change closes #95959

FUTURE_COPYBARA_INTEGRATE_REVIEW=tensorflow/tensorflow#95959 from DKLoehr:math 2fa2ab36dae8afc9cf838a5ce1726e4ba48afec6
PiperOrigin-RevId: 775719122
Copy link
Contributor

@mihaimaruseac mihaimaruseac left a comment

Choose a reason for hiding this comment

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

From internal review: Need to be and std::abs

@DKLoehr
Copy link
Author

DKLoehr commented Jun 25, 2025

We're already including cmath and using std::abs everywhere, so I'm not actually sure anymore why it's broken in the first place. I'm looking into it.

@google-ml-butler google-ml-butler bot removed the ready to pull PR ready for merge process label Jun 25, 2025
@DKLoehr DKLoehr changed the title Include math.h in elementwise.cc Specify std::abs overloads in elementwise.cc Jun 25, 2025
@DKLoehr
Copy link
Author

DKLoehr commented Jun 25, 2025

Alright, I found a better solution (I hope) that should work for both versions. Please take a look.

@github-project-automation github-project-automation bot moved this to Assigned Reviewer in PR Queue Jun 26, 2025
@keerthanakadiri keerthanakadiri added the comp:lite TF Lite related issues label Jun 26, 2025
@keerthanakadiri
Copy link
Contributor

Hi @DKLoehr , Can you please resolve the conflict? Thanks !

@DKLoehr
Copy link
Author

DKLoehr commented Jun 26, 2025

It looks like #95894 already fixed the problem, so this PR is no longer necessary. Thanks for your help.

@DKLoehr DKLoehr closed this Jun 26, 2025
@github-project-automation github-project-automation bot moved this from Assigned Reviewer to Closed/Rejected in PR Queue Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:lite TF Lite related issues size:XS CL Change Size: Extra Small

Projects

Status: Closed/Rejected

Development

Successfully merging this pull request may close these issues.

5 participants