|
4 | 4 |
|
5 | 5 | """Contains SPIR-V specific array functions.""" |
6 | 6 |
|
7 | | -import operator |
8 | | -from functools import reduce |
9 | 7 | from typing import Union |
10 | 8 |
|
11 | 9 | import llvmlite.ir as llvmir |
@@ -34,18 +32,21 @@ def require_literal(literal_type: types.Type): |
34 | 32 | ) |
35 | 33 |
|
36 | 34 |
|
37 | | -def make_spirv_array( # pylint: disable=too-many-arguments |
| 35 | +def np_cfarray( # pylint: disable=too-many-arguments |
38 | 36 | context: BaseContext, |
39 | 37 | builder: IRBuilder, |
40 | 38 | ty_array: types.Array, |
41 | 39 | ty_shape: Union[types.IntegerLiteral, types.BaseTuple], |
42 | 40 | shape: llvmir.Value, |
43 | 41 | data: llvmir.Value, |
44 | 42 | ): |
45 | | - """Makes SPIR-V array and fills it data. |
| 43 | + """Makes numpy-like array and fills it's data depending on the context's |
| 44 | + datamodel. |
46 | 45 |
|
47 | 46 | Generic version of numba.np.arrayobj.np_cfarray so that it can be used |
48 | 47 | not only as intrinsic, but inside instruction generation. |
| 48 | +
|
| 49 | + TODO: upstream changes to numba. |
49 | 50 | """ |
50 | 51 | # Create array object |
51 | 52 | ary = context.make_array(ty_array)(context, builder) |
@@ -84,32 +85,3 @@ def make_spirv_array( # pylint: disable=too-many-arguments |
84 | 85 | ) |
85 | 86 |
|
86 | 87 | return ary |
87 | | - |
88 | | - |
89 | | -def allocate_array_data_on_stack( |
90 | | - context: BaseContext, |
91 | | - builder: IRBuilder, |
92 | | - ty_array: types.Array, |
93 | | - ty_shape: Union[types.IntegerLiteral, types.BaseTuple], |
94 | | -): |
95 | | - """Allocates flat array of given shape on the stack.""" |
96 | | - if not isinstance(ty_shape, types.BaseTuple): |
97 | | - ty_shape = (ty_shape,) |
98 | | - |
99 | | - return cgutils.alloca_once( |
100 | | - builder, |
101 | | - context.get_data_type(ty_array.dtype), |
102 | | - size=reduce(operator.mul, [s.literal_value for s in ty_shape]), |
103 | | - ) |
104 | | - |
105 | | - |
106 | | -def make_spirv_generic_array_on_stack( |
107 | | - context: BaseContext, |
108 | | - builder: IRBuilder, |
109 | | - ty_array: types.Array, |
110 | | - ty_shape: Union[types.IntegerLiteral, types.BaseTuple], |
111 | | - shape: llvmir.Value, |
112 | | -): |
113 | | - """Makes SPIR-V array of given shape with empty data.""" |
114 | | - data = allocate_array_data_on_stack(context, builder, ty_array, ty_shape) |
115 | | - return make_spirv_array(context, builder, ty_array, ty_shape, shape, data) |
0 commit comments