|
22 | 22 | import pytensor.tensor as pt
|
23 | 23 | import scipy.sparse as sps
|
24 | 24 |
|
25 |
| -from pytensor import scalar |
26 | 25 | from pytensor.compile import Function, Mode, get_mode
|
27 | 26 | from pytensor.compile.builders import OpFromGraph
|
28 | 27 | from pytensor.gradient import grad
|
|
38 | 37 | from pytensor.graph.fg import FunctionGraph
|
39 | 38 | from pytensor.graph.op import Op
|
40 | 39 | from pytensor.scalar.basic import Cast
|
| 40 | +from pytensor.scalar.basic import identity as scalar_identity |
41 | 41 | from pytensor.scan.op import Scan
|
42 | 42 | from pytensor.tensor.basic import _as_tensor_variable
|
43 | 43 | from pytensor.tensor.elemwise import Elemwise
|
@@ -412,28 +412,6 @@ def hessian_diag(f, vars=None, negate_output=True):
|
412 | 412 | return empty_gradient
|
413 | 413 |
|
414 | 414 |
|
415 |
| -class IdentityOp(scalar.UnaryScalarOp): |
416 |
| - @staticmethod |
417 |
| - def st_impl(x): |
418 |
| - return x |
419 |
| - |
420 |
| - def impl(self, x): |
421 |
| - return x |
422 |
| - |
423 |
| - def grad(self, inp, grads): |
424 |
| - return grads |
425 |
| - |
426 |
| - def c_code(self, node, name, inp, out, sub): |
427 |
| - return f"{out[0]} = {inp[0]};" |
428 |
| - |
429 |
| - def __eq__(self, other): |
430 |
| - return isinstance(self, type(other)) |
431 |
| - |
432 |
| - def __hash__(self): |
433 |
| - return hash(type(self)) |
434 |
| - |
435 |
| - |
436 |
| -scalar_identity = IdentityOp(scalar.upgrade_to_float, name="scalar_identity") |
437 | 415 | identity = Elemwise(scalar_identity, name="identity")
|
438 | 416 |
|
439 | 417 |
|
|
0 commit comments