Skip to content

Commit b4a9b20

Browse files
committed
Remove scalar_ prefix from log1mexp, xlogx, xlogy0 and fix numba imports
1 parent ae24c0b commit b4a9b20

5 files changed

Lines changed: 10 additions & 21 deletions

File tree

pytensor/link/numba/dispatch/elemwise.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ def numba_funcify_Softmax(op, node, **kwargs):
459459
if axis is not None:
460460
axis = normalize_axis_index(axis, x_at.ndim)
461461
reduce_max_py = create_multiaxis_reducer(
462-
scalar_maximum, -np.inf, axis, x_at.ndim, x_dtype, keepdims=True
462+
maximum, -np.inf, axis, x_at.ndim, x_dtype, keepdims=True
463463
)
464464
reduce_sum_py = create_multiaxis_reducer(
465465
add_as, 0.0, (axis,), x_at.ndim, x_dtype, keepdims=True
@@ -523,7 +523,7 @@ def numba_funcify_LogSoftmax(op, node, **kwargs):
523523
if axis is not None:
524524
axis = normalize_axis_index(axis, x_at.ndim)
525525
reduce_max_py = create_multiaxis_reducer(
526-
scalar_maximum,
526+
maximum,
527527
-np.inf,
528528
(axis,),
529529
x_at.ndim,

pytensor/scalar/math.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,7 @@ def c_code(self, node, name, inp, out, sub):
13601360
raise NotImplementedError("only floating point is implemented")
13611361

13621362

1363-
log1mexp = Log1mexp(upgrade_to_float, name="scalar_log1mexp")
1363+
log1mexp = Log1mexp(upgrade_to_float)
13641364

13651365

13661366
class BetaInc(ScalarOp):

pytensor/tensor/xlogx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def c_code(self, node, name, inputs, outputs, sub):
3131
raise NotImplementedError("only floatingpoint is implemented")
3232

3333

34-
scalar_xlogx = XlogX(ps.upgrade_to_float, name="scalar_xlogx")
34+
scalar_xlogx = XlogX(ps.upgrade_to_float)
3535
xlogx = Elemwise(scalar_xlogx, name="xlogx")
3636

3737

@@ -62,5 +62,5 @@ def c_code(self, node, name, inputs, outputs, sub):
6262
raise NotImplementedError("only floatingpoint is implemented")
6363

6464

65-
scalar_xlogy0 = XlogY0(ps.upgrade_to_float, name="scalar_xlogy0")
65+
scalar_xlogy0 = XlogY0(ps.upgrade_to_float)
6666
xlogy0 = Elemwise(scalar_xlogy0, name="xlogy0")

tests/tensor/rewriting/test_math.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3887,10 +3887,7 @@ def check_max_log_sum_exp(x, axis, dimshuffle_op=None):
38873887

38883888
fgraph = f.maker.fgraph.toposort()
38893889
for node in fgraph:
3890-
if (
3891-
hasattr(node.op, "scalar_op")
3892-
and node.op.scalar_op == ps.basic.maximum
3893-
):
3890+
if hasattr(node.op, "scalar_op") and node.op.scalar_op == ps.basic.maximum:
38943891
return
38953892

38963893
# In mode FAST_COMPILE, the rewrites don't replace the

tests/tensor/test_elemwise.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -619,12 +619,8 @@ def test_perform_nan(self):
619619
for dtype in ["floatX", "complex64", "complex128"]:
620620
self.with_mode(Mode(linker="py"), ps.add, dtype=dtype, test_nan=True)
621621
self.with_mode(Mode(linker="py"), ps.mul, dtype=dtype, test_nan=True)
622-
self.with_mode(
623-
Mode(linker="py"), ps.maximum, dtype=dtype, test_nan=True
624-
)
625-
self.with_mode(
626-
Mode(linker="py"), ps.minimum, dtype=dtype, test_nan=True
627-
)
622+
self.with_mode(Mode(linker="py"), ps.maximum, dtype=dtype, test_nan=True)
623+
self.with_mode(Mode(linker="py"), ps.minimum, dtype=dtype, test_nan=True)
628624
self.with_mode(
629625
Mode(linker="py"),
630626
ps.or_,
@@ -678,12 +674,8 @@ def test_c_nan(self):
678674
self.with_mode(Mode(linker="c"), ps.add, dtype=dtype, test_nan=True)
679675
self.with_mode(Mode(linker="c"), ps.mul, dtype=dtype, test_nan=True)
680676
for dtype in ["floatX"]:
681-
self.with_mode(
682-
Mode(linker="c"), ps.minimum, dtype=dtype, test_nan=True
683-
)
684-
self.with_mode(
685-
Mode(linker="c"), ps.maximum, dtype=dtype, test_nan=True
686-
)
677+
self.with_mode(Mode(linker="c"), ps.minimum, dtype=dtype, test_nan=True)
678+
self.with_mode(Mode(linker="c"), ps.maximum, dtype=dtype, test_nan=True)
687679

688680
def test_infer_shape(self, dtype=None, pre_scalar_op=None):
689681
if dtype is None:

0 commit comments

Comments
 (0)