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)
| 1825 | |
| 1826 | |
| 1827 | def _gen_alignment_data(dtype=float32, type='binary', max_size=24): |
| 1828 | """ |
| 1829 | generator producing data with different alignment and offsets |
| 1830 | to test simd vectorization |
| 1831 | |
| 1832 | Parameters |
| 1833 | ---------- |
| 1834 | dtype : dtype |
| 1835 | data type to produce |
| 1836 | type : string |
| 1837 | 'unary': create data for unary operations, creates one input |
| 1838 | and output array |
| 1839 | 'binary': create data for unary operations, creates two input |
| 1840 | and output array |
| 1841 | max_size : integer |
| 1842 | maximum size of data to produce |
| 1843 | |
| 1844 | Returns |
| 1845 | ------- |
| 1846 | if type is 'unary' yields one output, one input array and a message |
| 1847 | containing information on the data |
| 1848 | if type is 'binary' yields one output array, two input array and a message |
| 1849 | containing information on the data |
| 1850 | |
| 1851 | """ |
| 1852 | ufmt = 'unary offset=(%d, %d), size=%d, dtype=%r, %s' |
| 1853 | bfmt = 'binary offset=(%d, %d, %d), size=%d, dtype=%r, %s' |
| 1854 | for o in range(3): |
| 1855 | for s in range(o + 2, max(o + 3, max_size)): |
| 1856 | if type == 'unary': |
| 1857 | inp = lambda: arange(s, dtype=dtype)[o:] |
| 1858 | out = empty((s,), dtype=dtype)[o:] |
| 1859 | yield out, inp(), ufmt % (o, o, s, dtype, 'out of place') |
| 1860 | d = inp() |
| 1861 | yield d, d, ufmt % (o, o, s, dtype, 'in place') |
| 1862 | yield out[1:], inp()[:-1], ufmt % \ |
| 1863 | (o + 1, o, s - 1, dtype, 'out of place') |
| 1864 | yield out[:-1], inp()[1:], ufmt % \ |
| 1865 | (o, o + 1, s - 1, dtype, 'out of place') |
| 1866 | yield inp()[:-1], inp()[1:], ufmt % \ |
| 1867 | (o, o + 1, s - 1, dtype, 'aliased') |
| 1868 | yield inp()[1:], inp()[:-1], ufmt % \ |
| 1869 | (o + 1, o, s - 1, dtype, 'aliased') |
| 1870 | if type == 'binary': |
| 1871 | inp1 = lambda: arange(s, dtype=dtype)[o:] |
| 1872 | inp2 = lambda: arange(s, dtype=dtype)[o:] |
| 1873 | out = empty((s,), dtype=dtype)[o:] |
| 1874 | yield out, inp1(), inp2(), bfmt % \ |
| 1875 | (o, o, o, s, dtype, 'out of place') |
| 1876 | d = inp1() |
| 1877 | yield d, d, inp2(), bfmt % \ |
| 1878 | (o, o, o, s, dtype, 'in place1') |
| 1879 | d = inp2() |
| 1880 | yield d, inp1(), d, bfmt % \ |
| 1881 | (o, o, o, s, dtype, 'in place2') |
| 1882 | yield out[1:], inp1()[:-1], inp2()[:-1], bfmt % \ |
| 1883 | (o + 1, o, o, s - 1, dtype, 'out of place') |
| 1884 | yield out[:-1], inp1()[1:], inp2()[:-1], bfmt % \ |