|
1 | 1 | /* |
2 | | - Copyright (c) 2017-2019, Intel Corporation |
| 2 | + Copyright (c) 2017-2020, Intel Corporation |
3 | 3 |
|
4 | 4 | Redistribution and use in source and binary forms, with or without |
5 | 5 | modification, are permitted provided that the following conditions are met: |
|
35 | 35 | #include <limits.h> |
36 | 36 |
|
37 | 37 | #ifdef DEBUG |
| 38 | +#include <assert.h> |
38 | 39 | #include <stdio.h> |
39 | 40 | #define _debug_print(...) printf(__VA_ARGS__) |
40 | 41 | #else |
@@ -471,6 +472,9 @@ int @name@_mkl_@mode@_in(PyArrayObject* x_inout, npy_intp n, int axis, DftiCache |
471 | 472 | get_basic_array_data(x_inout, &x_rank, &x_shape, |
472 | 473 | &x_strides, &x_itemsize, &x_size); |
473 | 474 |
|
| 475 | + if (x_size == 0) /* nothing to do */ |
| 476 | + return status; |
| 477 | + |
474 | 478 | assert( x_size > 0 ); /* assert that x is non-empty */ |
475 | 479 | assert( 0 <= axis && axis < x_rank ); |
476 | 480 | assert( x_itemsize == sizeof(@MKL_TYPE@) ); |
@@ -625,6 +629,11 @@ int @REALIN@_@COMPLEXOUT@_mkl_@mode@_out( |
625 | 629 |
|
626 | 630 | assert(xout_rank == xin_rank); |
627 | 631 |
|
| 632 | + if (xin_size == 0) { |
| 633 | + /* nothing to do */ |
| 634 | + assert(xin_size == xout_size); |
| 635 | + return status; |
| 636 | + } |
628 | 637 | assert( xin_size > 0 ); /* assert that array is non-empty */ |
629 | 638 | assert(0 <= axis && axis < xin_rank); |
630 | 639 | assert( 0 < n && n <= xin_shape[axis] ); |
@@ -886,6 +895,12 @@ int @COMPLEXIN@_@COMPLEXOUT@_mkl_@mode@_out( |
886 | 895 |
|
887 | 896 | assert(xout_rank == xin_rank); |
888 | 897 |
|
| 898 | + if (xin_size == 0) { |
| 899 | + /* nothing to do */ |
| 900 | + assert(xout_size == 0); |
| 901 | + return status; |
| 902 | + } |
| 903 | + |
889 | 904 | assert( xin_size > 0 ); /* assert that array is non-empty */ |
890 | 905 | assert(0 <= axis && axis < xin_rank); |
891 | 906 | assert( 0 < n && n <= xin_shape[axis] ); |
@@ -1059,6 +1074,9 @@ int @name@_mkl_@mode@_in(PyArrayObject* x_inout, npy_intp n, int axis, DftiCache |
1059 | 1074 | get_basic_array_data(x_inout, &x_rank, &x_shape, |
1060 | 1075 | &x_strides, &x_itemsize, &x_size); |
1061 | 1076 |
|
| 1077 | + if (x_size == 0) /* nothing to do */ |
| 1078 | + return status; |
| 1079 | + |
1062 | 1080 | assert( x_size > 0 ); /* assert that */ |
1063 | 1081 | assert(0 <= axis && axis < x_rank); |
1064 | 1082 | assert(x_itemsize == sizeof(@MKL_TYPE@)); |
@@ -1195,6 +1213,12 @@ int |
1195 | 1213 |
|
1196 | 1214 | assert(xout_rank == xin_rank); |
1197 | 1215 |
|
| 1216 | + if (xin_size == 0) { |
| 1217 | + /* nothing to do */ |
| 1218 | + assert(xout_size == 0); |
| 1219 | + return status; |
| 1220 | + } |
| 1221 | + |
1198 | 1222 | assert( xin_size > 0 ); /* assert that array is non-empty */ |
1199 | 1223 | assert(0 <= axis && axis < xin_rank); |
1200 | 1224 | assert( 0 < n && n <= xout_shape[axis] ); |
@@ -1369,6 +1393,12 @@ int @name@_@name@_mkl_@mode@_out( |
1369 | 1393 |
|
1370 | 1394 | assert(xout_rank == xin_rank); |
1371 | 1395 |
|
| 1396 | + if(xin_size == 0) { |
| 1397 | + /* nothing to do */ |
| 1398 | + assert(xout_size == 0); |
| 1399 | + return status; |
| 1400 | + } |
| 1401 | + |
1372 | 1402 | assert( xin_size > 0 ); /* assert that array is non-empty */ |
1373 | 1403 | assert(0 <= axis && axis < xin_rank); |
1374 | 1404 | assert( 0 < n && n <= xin_shape[axis] ); |
@@ -1543,6 +1573,9 @@ int |
1543 | 1573 | &x_strides, &x_itemsize, &x_size); |
1544 | 1574 |
|
1545 | 1575 |
|
| 1576 | + if (x_size == 0) /* nothing to do */ |
| 1577 | + return status; |
| 1578 | + |
1546 | 1579 | assert(x_size > 0); |
1547 | 1580 | assert(x_itemsize == sizeof(@MKL_IN_TYPE@)); |
1548 | 1581 |
|
@@ -1649,6 +1682,11 @@ int |
1649 | 1682 | get_basic_array_data(x_out, &xout_rank, &xout_shape, |
1650 | 1683 | &xout_strides, &xout_itemsize, &xout_size); |
1651 | 1684 |
|
| 1685 | + if(xin_size == 0) { |
| 1686 | + /* nothing to do */ |
| 1687 | + assert(xout_size == 0); |
| 1688 | + return status; |
| 1689 | + } |
1652 | 1690 |
|
1653 | 1691 | assert(xin_size > 0); |
1654 | 1692 | assert(xin_itemsize == sizeof(@MKL_IN_TYPE@)); |
@@ -1778,6 +1816,11 @@ int |
1778 | 1816 | get_basic_array_data(x_out, &xout_rank, &xout_shape, |
1779 | 1817 | &xout_strides, &xout_itemsize, &xout_size); |
1780 | 1818 |
|
| 1819 | + if(xin_size == 0) { |
| 1820 | + /* nothing to do */ |
| 1821 | + assert(xout_size == 0); |
| 1822 | + return status; |
| 1823 | + } |
1781 | 1824 |
|
1782 | 1825 | assert(xin_size > 0); |
1783 | 1826 | assert(xin_itemsize == sizeof(@MKL_IN_TYPE@)); |
|
0 commit comments