Skip to content
Open
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
6 changes: 3 additions & 3 deletions eagerpy/tensor/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def index_update(
x = self.raw
if isinstance(indices, int):
if isinstance(values_, int) or isinstance(values_, float):
values_ = tf.fill(x.shape[-1:], values_)
values_ = tf.cast(tf.fill(x.shape[-1:], values_), x.dtype)
return type(self)(
tf.tensor_scatter_nd_update(x, [[indices]], values_[None])
)
Expand All @@ -350,7 +350,7 @@ def index_update(
):
x = tf.transpose(x)
if isinstance(values_, int) or isinstance(values_, float):
values_ = tf.fill(x.shape[-1:], values_)
values_ = tf.cast(tf.fill(x.shape[-1:], values_), x.dtype)
result = tf.tensor_scatter_nd_update(x, [[indices[-1]]], values_[None])
return type(self)(tf.transpose(result))
else:
Expand All @@ -363,7 +363,7 @@ def index_update(
]
indices = tf.stack(indices, axis=-1)
if isinstance(values_, int) or isinstance(values_, float):
values_ = tf.fill((indices.shape[0],), values_)
values_ = tf.cast(tf.fill((indices.shape[0],), values_), x.dtype)
return type(self)(tf.tensor_scatter_nd_update(x, indices, values_))
else:
raise ValueError # pragma: no cover
Expand Down