@@ -73,7 +73,7 @@ def dot(x1, x2, out=None, **kwargs):
7373 y : dpnp.ndarray
7474 Returns the dot product of `x1` and `x2`.
7575 If `out` is given, then it is returned.
76-
76+
7777 Limitations
7878 -----------
7979 Parameters `x1` and `x2` are supported as either scalar, :class:`dpnp.ndarray`
@@ -298,16 +298,16 @@ def matmul(x1, x2, out=None, **kwargs):
298298 return call_origin (numpy .matmul , x1 , x2 , out = out , ** kwargs )
299299
300300
301- def outer (x1 , x2 , ** kwargs ):
301+ def outer (x1 , x2 , out = None ):
302302 """
303303 Returns the outer product of two arrays.
304304
305305 For full documentation refer to :obj:`numpy.outer`.
306306
307307 Limitations
308308 -----------
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 .
311311 Otherwise the functions will be executed sequentially on CPU.
312312 Input array data types are limited by supported DPNP :ref:`Data types`.
313313
@@ -323,21 +323,26 @@ def outer(x1, x2, **kwargs):
323323 >>> b = np.array([1, 2, 3])
324324 >>> result = np.outer(a, b)
325325 >>> [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]])
327329
328330 """
331+ x1_is_scalar = dpnp .isscalar (x1 )
332+ x2_is_scalar = dpnp .isscalar (x2 )
329333
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 )
339344
340- return call_origin (numpy .outer , x1 , x2 , ** kwargs )
345+ return call_origin (numpy .outer , x1 , x2 , out = out )
341346
342347
343348def tensordot (x1 , x2 , axes = 2 ):
0 commit comments