gpt4 book ai didi

python - numpy 的基本操作是否矢量化,即它们是否使用 SIMD 操作?

转载 作者:太空狗 更新时间:2023-10-29 20:16:28 24 4
gpt4 key购买 nike

我正在做一些性能分析,我想知道,当数据类型已知( double )时,numpy 是否对其标准数组操作进行矢量化。

a, b = (some numpy arrays)
c = a + b #Is this vectorized?

编辑:此操作是否矢量化,即计算是否包含 SIMD 操作?

最佳答案

是的,他们是。

/*
* This file is for the definitions of simd vectorized operations.
*
* Currently contains sse2 functions that are built on amd64, x32 or
* non-generic builds (CFLAGS=-march=...)
* In future it may contain other instruction sets like AVX or NEON detected
* at runtime in which case it needs to be included indirectly via a file
* compiled with special options (or use gcc target attributes) so the binary
* stays portable.
*/

链接:Numpy simd.inc.src on github.

关于python - numpy 的基本操作是否矢量化,即它们是否使用 SIMD 操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44944367/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com