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

tensorflow: add a few TensorFlow functions #13364

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

hoel-bagard
Copy link
Contributor

This PR adds the tf.round, tf.pad, tf.shape, tf.where, tf.gather_nd and tf.signal.hamming_window functions.

This comment has been minimized.

@hoel-bagard hoel-bagard marked this pull request as ready for review January 5, 2025 03:49

This comment has been minimized.

@@ -403,4 +413,22 @@ def ones_like(
input: RaggedTensor, dtype: DTypeLike | None = None, name: str | None = None, layout: Layout | None = None
) -> RaggedTensor: ...
def reshape(tensor: TensorCompatible, shape: ShapeLike | Tensor, name: str | None = None) -> Tensor: ...
def pad(
tensor: TensorCompatible,
paddings: Tensor | IntArray | Iterable[Iterable[int]],
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are the last two necessary? The docs just specify A Tensor of type int32.

https://www.tensorflow.org/api_docs/python/tf/pad#args

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The documentation is more restrictive than what is actually accepted by the function. Removing the last two will likely cause a lot of false positives.
I opened three of the example links, and all 3 of them use lists instead of Tensors.

) -> Tensor: ...
def gather_nd(
params: TensorCompatible,
indices: UIntTensorCompatible,
Copy link
Contributor

@yangdanny97 yangdanny97 Jan 29, 2025

Choose a reason for hiding this comment

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

Should this be TensorCompatible?

A Tensor. Must be one of the following types: int32, int64. Index tensor.

https://www.tensorflow.org/api_docs/python/tf/gather_nd#args

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TensorCompatible contains str, which is not a valid type for indices.

Copy link
Contributor

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

@yangdanny97
Copy link
Contributor

In that case this LGTM

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