Skip to content

tensorflow: Add some tf.raw_ops members.#11387

Merged
JelleZijlstra merged 3 commits intopython:mainfrom
hoel-bagard:hoel/add_tf_raw_ops
Feb 17, 2024
Merged

tensorflow: Add some tf.raw_ops members.#11387
JelleZijlstra merged 3 commits intopython:mainfrom
hoel-bagard:hoel/add_tf_raw_ops

Conversation

@hoel-bagard
Copy link
Copy Markdown
Contributor

Stubs taken from here.

@github-actions

This comment has been minimized.

@hoel-bagard hoel-bagard marked this pull request as ready for review February 9, 2024 17:03
Comment thread stubs/tensorflow/tensorflow/raw_ops.pyi Outdated
Comment on lines +22 to +23
lr: TensorCompatible,
epsilon: TensorCompatible,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These two must be scalars, so perhaps we can give narrower type (optional)

Copy link
Copy Markdown
Contributor Author

@hoel-bagard hoel-bagard Feb 17, 2024

Choose a reason for hiding this comment

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

I don't have code to run this function, so I can't check, but very often the TensorFlow doc says that the input must be a scalar, but anything that can be converted to a scalar will do. So for example it will say that a float32 is required but "1.2" would work. However that behavior isn't consistent, so we can't know without testing.

For example:

import tensorflow as tf
tf.keras.optimizers.Adam(learning_rate="1.0")   # Raises ValueError
tf.keras.optimizers.Adam(epsilon="1.0")   # Works

So far I think most of the typing for TensorFlow is using overly lax typing for the inputs in order to avoid false positives, so I would leave TensorCompatible.

Comment thread stubs/tensorflow/tensorflow/raw_ops.pyi Outdated
Comment thread stubs/tensorflow/tensorflow/raw_ops.pyi Outdated
@github-actions
Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@JelleZijlstra JelleZijlstra merged commit 0f0e261 into python:main Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants