From 4d27b4cf1631b1cca4c173287e3c2a2f646839b3 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Sat, 29 Apr 2023 14:25:53 +0200 Subject: [PATCH] Added array type check in dpnp.get_usm_ndarray() --- dpnp/dpnp_iface.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dpnp/dpnp_iface.py b/dpnp/dpnp_iface.py index f6aabbb1399..ce3c540539d 100644 --- a/dpnp/dpnp_iface.py +++ b/dpnp/dpnp_iface.py @@ -390,9 +390,18 @@ def get_usm_ndarray(a): out : usm_ndarray A dpctl USM ndarray of input array `a`. + Raises + ------ + TypeError + If input parameter `a` is of unsupported array type. + """ - return a.get_array() if isinstance(a, dpnp_array) else a + if isinstance(a, dpnp_array): + return a.get_array() + if isinstance(a, dpt.usm_ndarray): + return a + raise TypeError("An array must be any of supported type, but got {}".format(type(a))) def is_supported_array_type(a):