Python Numpy Data Types Performance

后端 未结 2 1377
渐次进展
渐次进展 2020-12-09 16:18

So I did some testing and got odd results.

Code:

import numpy as np
import timeit


setup = \"\"\"
import numpy as np
A = np.ones((1000,1000,3), dtyp         


        
2条回答
  •  甜味超标
    2020-12-09 16:52

    Half precision arithmetic (float16) is something which must be "emulated" by numpy I guess, as there are no corresponding types in the underlying C language (and in the appropriate processor instructions) for it. On the other hand, single precision (float32) and double precision (float64) operations can be done very efficiently using native data types.

    As of the good performance for single precision operations: Modern processors have efficient units for vectorized floating point arithmetics (e.g. AVX) as it is also needed for good multimedia performance.

提交回复
热议问题