Embodiments of this application provide a code vectorization method and apparatus, relating to the field of computer technologies. The method includes: obtaining attribute information of multidimensional loop code that includes a plurality of pieces of single-level loop code, and determining, based on the attribute information, a hardware logic level corresponding to each level of target loop code in the multidimensional loop code, where one level of target loop code is a piece of single-level loop code to be vectorized; splitting each level of target loop code based on a length upper limit of the hardware logic level corresponding to the level of target loop code to obtain a plurality of code blocks, and combining the plurality of code blocks into a plurality of pieces of multidimensional subloop code based on a level relationship between hardware logic levels corresponding to the plurality of code blocks.
Full Text
What is claimed is: