Skip to content

Commit

Permalink
Fix tensor_like for dense
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Holl committed Nov 27, 2024
1 parent d243086 commit 9ec7ae4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion phiml/math/_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ def tensor_like(existing_tensor: Tensor, values: Union[Tensor, Number, bool], va
values = where(existing_tensor._valid_mask(), values, 0)
return existing_tensor._with_values(values)
if not is_sparse(existing_tensor):
return unpack_dim(values, instance, existing_tensor.shape.non_channel.non_batch)
if instance(values):
return unpack_dim(values, instance, existing_tensor.shape.non_batch)
else:
return expand(values, existing_tensor.shape.non_batch)
raise NotImplementedError


Expand Down

0 comments on commit 9ec7ae4

Please sign in to comment.