MCPcopy Index your code
hub / github.com/numpy/numpy / _gen_alignment_data

Function _gen_alignment_data

numpy/testing/_private/utils.py:2114–2180  ·  view source on GitHub ↗

generator producing data with different alignment and offsets to test simd vectorization Parameters ---------- dtype : dtype data type to produce type : string 'unary': create data for unary operations, creates one input and output array

(dtype=float32, type='binary', max_size=24)

Source from the content-addressed store, hash-verified

2112
2113
2114def _gen_alignment_data(dtype=float32, type='binary', max_size=24):
2115 """
2116 generator producing data with different alignment and offsets
2117 to test simd vectorization
2118
2119 Parameters
2120 ----------
2121 dtype : dtype
2122 data type to produce
2123 type : string
2124 'unary': create data for unary operations, creates one input
2125 and output array
2126 'binary': create data for unary operations, creates two input
2127 and output array
2128 max_size : integer
2129 maximum size of data to produce
2130
2131 Returns
2132 -------
2133 if type is 'unary' yields one output, one input array and a message
2134 containing information on the data
2135 if type is 'binary' yields one output array, two input array and a message
2136 containing information on the data
2137
2138 """
2139 ufmt = 'unary offset=(%d, %d), size=%d, dtype=%r, %s'
2140 bfmt = 'binary offset=(%d, %d, %d), size=%d, dtype=%r, %s'
2141 for o in range(3):
2142 for s in range(o + 2, max(o + 3, max_size)):
2143 if type == 'unary':
2144 inp = lambda: arange(s, dtype=dtype)[o:]
2145 out = empty((s,), dtype=dtype)[o:]
2146 yield out, inp(), ufmt % (o, o, s, dtype, 'out of place')
2147 d = inp()
2148 yield d, d, ufmt % (o, o, s, dtype, 'in place')
2149 yield out[1:], inp()[:-1], ufmt % \
2150 (o + 1, o, s - 1, dtype, 'out of place')
2151 yield out[:-1], inp()[1:], ufmt % \
2152 (o, o + 1, s - 1, dtype, 'out of place')
2153 yield inp()[:-1], inp()[1:], ufmt % \
2154 (o, o + 1, s - 1, dtype, 'aliased')
2155 yield inp()[1:], inp()[:-1], ufmt % \
2156 (o + 1, o, s - 1, dtype, 'aliased')
2157 if type == 'binary':
2158 inp1 = lambda: arange(s, dtype=dtype)[o:]
2159 inp2 = lambda: arange(s, dtype=dtype)[o:]
2160 out = empty((s,), dtype=dtype)[o:]
2161 yield out, inp1(), inp2(), bfmt % \
2162 (o, o, o, s, dtype, 'out of place')
2163 d = inp1()
2164 yield d, d, inp2(), bfmt % \
2165 (o, o, o, s, dtype, 'in place1')
2166 d = inp2()
2167 yield d, inp1(), d, bfmt % \
2168 (o, o, o, s, dtype, 'in place2')
2169 yield out[1:], inp1()[:-1], inp2()[:-1], bfmt % \
2170 (o + 1, o, o, s - 1, dtype, 'out of place')
2171 yield out[:-1], inp1()[1:], inp2()[:-1], bfmt % \

Callers 4

test_blockedMethod · 0.90
test_power_floatMethod · 0.90
test_minmax_blockedMethod · 0.90
test_abs_neg_blockedMethod · 0.90

Calls 2

maxFunction · 0.90
emptyFunction · 0.85

Tested by 4

test_blockedMethod · 0.72
test_power_floatMethod · 0.72
test_minmax_blockedMethod · 0.72
test_abs_neg_blockedMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…