Skip to content
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
13 changes: 13 additions & 0 deletions stubs/tensorflow/tensorflow/config/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from _typeshed import Incomplete
from typing import NamedTuple

from tensorflow.config import experimental as experimental

class PhysicalDevice(NamedTuple):
name: str
device_type: str

def list_physical_devices(device_type: None | str = None) -> list[PhysicalDevice]: ...
def get_visible_devices(device_type: None | str = None) -> list[PhysicalDevice]: ...
def set_visible_devices(devices: list[PhysicalDevice] | PhysicalDevice, device_type: None | str = None) -> None: ...
def __getattr__(name: str) -> Incomplete: ...
17 changes: 17 additions & 0 deletions stubs/tensorflow/tensorflow/config/experimental.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import typing_extensions
from _typeshed import Incomplete
from typing import TypedDict

from tensorflow.config import PhysicalDevice

class _MemoryInfo(TypedDict):
current: int
peak: int

def get_memory_info(device: str) -> _MemoryInfo: ...
def reset_memory_stats(device: str) -> None: ...
@typing_extensions.deprecated("This function is deprecated in favor of tf.config.experimental.get_memory_info")
def get_memory_usage(device: PhysicalDevice) -> int: ...
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this is deprecated:

@deprecation.deprecated(
    None,
    "Use tf.config.experimental.get_memory_info(device)['current'] instead.")

Consider marking it with @typing_extensions.deprecated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 9898dc7

def get_memory_growth(device: PhysicalDevice) -> bool: ...
def set_memory_growth(device: PhysicalDevice, enable: bool) -> None: ...
def __getattr__(name: str) -> Incomplete: ...