|
31 | 31 |
|
32 | 32 | """
|
33 | 33 |
|
34 |
| -from pytensor import scalar as ps |
35 |
| -from pytensor.graph.rewriting.basic import copy_stack_trace, node_rewriter |
| 34 | +from pytensor.graph.rewriting.basic import node_rewriter |
36 | 35 | from pytensor.tensor.basic import Alloc, alloc, constant
|
37 |
| -from pytensor.tensor.elemwise import CAReduce, DimShuffle |
38 |
| -from pytensor.tensor.math import Min, neg |
| 36 | +from pytensor.tensor.elemwise import DimShuffle |
39 | 37 | from pytensor.tensor.rewriting.basic import register_uncanonicalize
|
40 | 38 | from pytensor.tensor.shape import Reshape, reshape
|
41 | 39 | from pytensor.tensor.subtensor import Subtensor
|
42 | 40 |
|
43 | 41 |
|
44 |
| -@register_uncanonicalize |
45 |
| -@node_rewriter([neg]) |
46 |
| -def local_max_to_min(fgraph, node): |
47 |
| - """ |
48 |
| - Change -(max(-x)) to min. |
49 |
| -
|
50 |
| - This is tested in tensor/tests/test_basic.py:test_min_max. |
51 |
| -
|
52 |
| - Notes |
53 |
| - ----- |
54 |
| - We don't need an opt that will do the reverse as by default |
55 |
| - the interface put only Max into the graph. |
56 |
| -
|
57 |
| - """ |
58 |
| - if node.op == neg and node.inputs[0].owner: |
59 |
| - max = node.inputs[0] |
60 |
| - if ( |
61 |
| - max.owner |
62 |
| - and isinstance(max.owner.op, CAReduce) |
63 |
| - and max.owner.op.scalar_op == ps.scalar_maximum |
64 |
| - ): |
65 |
| - neg_node = max.owner.inputs[0] |
66 |
| - if neg_node.owner and neg_node.owner.op == neg: |
67 |
| - new = Min(max.owner.op.axis)(neg_node.owner.inputs[0]) |
68 |
| - return [copy_stack_trace(node.outputs[0], new)] |
69 |
| - |
70 |
| - return False |
71 |
| - |
72 |
| - |
73 | 42 | @register_uncanonicalize
|
74 | 43 | @node_rewriter([Alloc])
|
75 | 44 | def local_alloc_dimshuffle(fgraph, node):
|
|
0 commit comments