Skip to content

Commit

Permalink
Only cast if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentStimper committed Oct 26, 2023
1 parent a2b5805 commit 912891d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions normflows/utils/splines.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ def unconstrained_rational_quadratic_spline(
min_bin_height=min_bin_height,
min_derivative=min_derivative,
)
outputs[inside_interval_mask] = outputs_masked.to(outputs.dtype)
logabsdet[inside_interval_mask] = logabsdet_masked.to(logabsdet.dtype)
if outputs.dtype == outputs_masked.dtype and logabsdet.dtype == logabsdet_masked.dtype:
outputs[inside_interval_mask] = outputs_masked
logabsdet[inside_interval_mask] = logabsdet_masked
else:
outputs[inside_interval_mask] = outputs_masked.to(outputs.dtype)
logabsdet[inside_interval_mask] = logabsdet_masked.to(logabsdet.dtype)

return outputs, logabsdet

Expand Down

0 comments on commit 912891d

Please sign in to comment.