Skip to content

Commit 0a1c414

Browse files
committed
Raise not-implemented exception on numpy fallback
1 parent 42ec3a2 commit 0a1c414

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

dpnp/config.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
# *****************************************************************************
3-
# Copyright (c) 2016-2020, Intel Corporation
3+
# Copyright (c) 2016-2022, Intel Corporation
44
# All rights reserved.
55
#
66
# Redistribution and use in source and binary forms, with or without
@@ -52,3 +52,8 @@
5252
'''
5353
Explicitly use SYCL shared memory parameter in DPCtl array constructor for creation functions
5454
'''
55+
56+
__DPNP_RAISE_EXCEPION_ON_NUMPY_FALLBACK__ = int(os.getenv('__DPNP_RAISE_EXCEPION_ON_NUMPY_FALLBACK__', 1))
57+
'''
58+
Trigger non-implemented exception when DPNP fallbacks on NumPy implementation
59+
'''

dpnp/dpnp_utils/dpnp_algo_utils.pyx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# cython: language_level=3
22
# -*- coding: utf-8 -*-
33
# *****************************************************************************
4-
# Copyright (c) 2016-2020, Intel Corporation
4+
# Copyright (c) 2016-2022, Intel Corporation
55
# All rights reserved.
66
#
77
# Redistribution and use in source and binary forms, with or without
@@ -114,6 +114,10 @@ def call_origin(function, *args, **kwargs):
114114
Call fallback function for unsupported cases
115115
"""
116116

117+
if config.__DPNP_RAISE_EXCEPION_ON_NUMPY_FALLBACK__:
118+
raise NotImplementedError(f"Requested funtion={function.__name__} with args={args} and kwargs={kwargs} "
119+
"isn't currently supported, fallback on NumPy implementation.")
120+
117121
dpnp_inplace = kwargs.pop("dpnp_inplace", False)
118122
# print(f"DPNP call_origin(): Fallback called. \n\t function={function}, \n\t args={args}, \n\t kwargs={kwargs}, \n\t dpnp_inplace={dpnp_inplace}")
119123

0 commit comments

Comments
 (0)