keras-team / keras-core

A multi-backend implementation of the Keras API, with support for TensorFlow, JAX, and PyTorch.
Apache License 2.0
1.27k stars 115 forks source link

Export dtype utils in `keras_core.backend` #886

Closed mattdangerw closed 11 months ago

mattdangerw commented 11 months ago

Making multi backend dtype comparisons for code based on keras-core is tricky. Torch has dtype classes such that torch_tensor.dtype is string_dtype will always be false.

We use standardize_dtype extensively in our own code and should expose it to clients. is_float_dtype and is_int_dtype we can include as useful helpers.

codecov[bot] commented 11 months ago

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (e8db3b6) 76.56% compared to head (b4358ca) 76.56%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #886 +/- ## ======================================= Coverage 76.56% 76.56% ======================================= Files 329 329 Lines 31422 31426 +4 Branches 6113 6113 ======================================= + Hits 24057 24061 +4 Misses 5786 5786 Partials 1579 1579 ``` | [Flag](https://app.codecov.io/gh/keras-team/keras-core/pull/886/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | Coverage Δ | | |---|---|---| | [keras_core](https://app.codecov.io/gh/keras-team/keras-core/pull/886/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | `76.46% <100.00%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files Changed](https://app.codecov.io/gh/keras-team/keras-core/pull/886?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | Coverage Δ | | |---|---|---| | [keras\_core/backend/common/variables.py](https://app.codecov.io/gh/keras-team/keras-core/pull/886?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team#diff-a2VyYXNfY29yZS9iYWNrZW5kL2NvbW1vbi92YXJpYWJsZXMucHk=) | `76.10% <100.00%> (+0.33%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.