@@ -73,7 +73,7 @@ def dot(x1, x2, out=None, **kwargs):
73
73
y : dpnp.ndarray
74
74
Returns the dot product of `x1` and `x2`.
75
75
If `out` is given, then it is returned.
76
-
76
+
77
77
Limitations
78
78
-----------
79
79
Parameters `x1` and `x2` are supported as either scalar, :class:`dpnp.ndarray`
@@ -298,16 +298,16 @@ def matmul(x1, x2, out=None, **kwargs):
298
298
return call_origin (numpy .matmul , x1 , x2 , out = out , ** kwargs )
299
299
300
300
301
- def outer (x1 , x2 , ** kwargs ):
301
+ def outer (x1 , x2 , out = None ):
302
302
"""
303
303
Returns the outer product of two arrays.
304
304
305
305
For full documentation refer to :obj:`numpy.outer`.
306
306
307
307
Limitations
308
308
-----------
309
- Parameters `` x1`` and `` x2`` are supported as :obj :`dpnp.ndarray`.
310
- Keyword arguments ``kwargs`` are currently unsupported .
309
+ Parameters `x1` and `x2` are supported as either scalar, :class :`dpnp.ndarray`
310
+ or :class:`dpctl.tensor.usm_ndarray`, but both `x1` and `x2` can not be scalars at the same time .
311
311
Otherwise the functions will be executed sequentially on CPU.
312
312
Input array data types are limited by supported DPNP :ref:`Data types`.
313
313
@@ -323,21 +323,26 @@ def outer(x1, x2, **kwargs):
323
323
>>> b = np.array([1, 2, 3])
324
324
>>> result = np.outer(a, b)
325
325
>>> [x for x in result]
326
- [1, 2, 3, 1, 2, 3, 1, 2, 3]
326
+ array([[1, 2, 3],
327
+ [1, 2, 3],
328
+ [1, 2, 3]])
327
329
328
330
"""
331
+ x1_is_scalar = dpnp .isscalar (x1 )
332
+ x2_is_scalar = dpnp .isscalar (x2 )
329
333
330
- if not kwargs :
331
- if isinstance (x1 , dpnp_array ) and isinstance (x2 , dpnp_array ):
332
- ravel = lambda x : x .flatten () if x .ndim > 1 else x
333
- return ravel (x1 )[:, None ] * ravel (x2 )[None , :]
334
-
335
- x1_desc = dpnp .get_dpnp_descriptor (x1 , copy_when_nondefault_queue = False )
336
- x2_desc = dpnp .get_dpnp_descriptor (x2 , copy_when_nondefault_queue = False )
337
- if x1_desc and x2_desc :
338
- return dpnp_outer (x1_desc , x2_desc ).get_pyobj ()
334
+ if x1_is_scalar and x2_is_scalar :
335
+ pass
336
+ elif not (x1_is_scalar or dpnp .is_supported_array_type (x1 )):
337
+ pass
338
+ elif not (x2_is_scalar or dpnp .is_supported_array_type (x2 )):
339
+ pass
340
+ else :
341
+ x1_in = x1 if x1_is_scalar else (x1 .reshape (- 1 ) if x1 .ndim > 1 else x1 )[:, None ]
342
+ x2_in = x2 if x2_is_scalar else (x2 .reshape (- 1 ) if x2 .ndim > 1 else x2 )[None , :]
343
+ return dpnp .multiply (x1_in , x2_in , out = out )
339
344
340
- return call_origin (numpy .outer , x1 , x2 , ** kwargs )
345
+ return call_origin (numpy .outer , x1 , x2 , out = out )
341
346
342
347
343
348
def tensordot (x1 , x2 , axes = 2 ):
0 commit comments