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
8 changes: 6 additions & 2 deletions deepmd/_vendors/ndtensorflow/_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,11 @@ def take(x: Array, indices: Array, /, *, axis: int | None = None) -> Array:
axis = 0
axis = _normalize_axis(axis, tensor.shape.rank)
indices_ = tf.cast(_unwrap(indices), tf.int64)
dim = tensor.shape[axis]
# ``TensorShape.__getitem__`` returns either ``None`` or
# ``Dimension(None)`` depending on TensorFlow's global v2-shape setting.
# ``as_list`` normalizes both representations, which keeps dynamic-axis
# indexing valid when another test or caller enables legacy TensorShape.
dim = tensor.shape.as_list()[axis]
dim = (
tf.shape(tensor, out_type=tf.int64)[axis]
if dim is None
Expand All @@ -1664,7 +1668,7 @@ def take_along_axis(x: Array, indices: Array, /, *, axis: int = -1) -> Array:
tensor = _unwrap(x)
indices_ = tf.cast(_unwrap(indices), tf.int64)
axis = _normalize_axis(axis, tensor.shape.rank)
dim = tensor.shape[axis]
dim = tensor.shape.as_list()[axis]
dim = (
tf.shape(tensor, out_type=tf.int64)[axis]
if dim is None
Expand Down
Loading
Loading