1
1
"""
2
2
This file contains auxiliary Ops, used during the compilation phase and Ops
3
- building class (:class:`FromFunctionOp`) and decorator (:func:`as_op `) that
3
+ building class (:class:`FromFunctionOp`) and decorator (:func:`wrap_py `) that
4
4
help make new Ops more rapidly.
5
5
6
6
"""
@@ -268,12 +268,12 @@ def __reduce__(self):
268
268
obj = load_back (mod , name )
269
269
except (ImportError , KeyError , AttributeError ):
270
270
raise pickle .PicklingError (
271
- f"Can't pickle as_op (), not found as { mod } .{ name } "
271
+ f"Can't pickle wrap_py (), not found as { mod } .{ name } "
272
272
)
273
273
else :
274
274
if obj is not self :
275
275
raise pickle .PicklingError (
276
- f"Can't pickle as_op (), not the object at { mod } .{ name } "
276
+ f"Can't pickle wrap_py (), not the object at { mod } .{ name } "
277
277
)
278
278
return load_back , (mod , name )
279
279
@@ -282,6 +282,18 @@ def _infer_shape(self, fgraph, node, input_shapes):
282
282
283
283
284
284
def as_op (itypes , otypes , infer_shape = None ):
285
+ import warnings
286
+
287
+ warnings .warn (
288
+ "pytensor.as_op is deprecated and will be removed in a future release. "
289
+ "Please use pytensor.wrap_py instead." ,
290
+ FutureWarning ,
291
+ stacklevel = 2 ,
292
+ )
293
+ return wrap_py (itypes , otypes , infer_shape )
294
+
295
+
296
+ def wrap_py (itypes , otypes , infer_shape = None ):
285
297
"""
286
298
Decorator that converts a function into a basic PyTensor op that will call
287
299
the supplied function as its implementation.
@@ -301,8 +313,8 @@ def infer_shape(fgraph, node, input_shapes):
301
313
302
314
Examples
303
315
--------
304
- @as_op (itypes=[pytensor.tensor.fmatrix, pytensor.tensor.fmatrix],
305
- otypes=[pytensor.tensor.fmatrix])
316
+ @wrap_py (itypes=[pytensor.tensor.fmatrix, pytensor.tensor.fmatrix],
317
+ otypes=[pytensor.tensor.fmatrix])
306
318
def numpy_dot(a, b):
307
319
return numpy.dot(a, b)
308
320
0 commit comments