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 tf.ones, tf.zeros, tf.zeros_like and tf.ones_like functions #11368

Merged
merged 3 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion stubs/tensorflow/tensorflow/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ from tensorflow.core.protobuf import struct_pb2
# is necessary to avoid a crash in pytype.
from tensorflow.dtypes import *
from tensorflow.dtypes import DType as DType
from tensorflow.experimental.dtensor import Layout
from tensorflow.keras import losses as losses

# Most tf.math functions are exported as tf, but sadly not all are.
Expand Down Expand Up @@ -406,7 +407,6 @@ class RaggedTensorSpec(TypeSpec[struct_pb2.TypeSpecProto]):
@classmethod
def from_value(cls, value: RaggedTensor) -> Self: ...

def __getattr__(name: str) -> Incomplete: ...
def convert_to_tensor(
value: TensorCompatible | IndexedSlices,
dtype: DTypeLike | None = None,
Expand Down Expand Up @@ -439,4 +439,23 @@ def cast(x: TensorCompatible, dtype: DTypeLike, name: str | None = None) -> Tens
def cast(x: SparseTensor, dtype: DTypeLike, name: str | None = None) -> SparseTensor: ...
@overload
def cast(x: RaggedTensor, dtype: DTypeLike, name: str | None = None) -> RaggedTensor: ...
def zeros(shape: ShapeLike, dtype: DTypeLike = ..., name: str | None = None, layout: Layout | None = None) -> Tensor: ...
def ones(shape: ShapeLike, dtype: DTypeLike = ..., name: str | None = None, layout: Layout | None = None) -> Tensor: ...
@overload
def zeros_like(
input: TensorCompatible | IndexedSlices, dtype: DTypeLike | None = None, name: str | None = None, layout: Layout | None = None
) -> Tensor: ...
@overload
def zeros_like(
input: RaggedTensor, dtype: DTypeLike | None = None, name: str | None = None, layout: Layout | None = None
) -> RaggedTensor: ...
@overload
def ones_like(
input: TensorCompatible, dtype: DTypeLike | None = None, name: str | None = None, layout: Layout | None = None
) -> Tensor: ...
@overload
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 __getattr__(name: str) -> Incomplete: ...
2 changes: 2 additions & 0 deletions stubs/tensorflow/tensorflow/experimental/dtensor.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ from _typeshed import Incomplete

from tensorflow._aliases import IntArray, IntDataSequence

Layout = Incomplete

class Mesh:
def __init__(
self,
Expand Down
Loading