A method for pre-allocating memory for forward calculation for a neural network, the method (S100) comprising: performing the following calculation operation for each successive layer of the neural network from a first layer of the neural network: attempting(S101), for each output from a current layer, to obtain a memory block identifier from a list of idle memory block identifiers that is used to record idle memory block identifiers; if the memory block identifier is obtained, storing (S102), as mapping relationship, an identifier of the output and the obtained memory block identifier into a mapping table of outputs and memory block identifiers , and deleting the memory block identifier from the list of idle memory block identifiers , wherein the mapping table of outputs and memory block identifiers is used to record an identifier of each output from the layer and the corresponding memory block identifier; or if the memory block identifier is not obtained, creating (S103) a new memory block identifier, storing, as mapping relationship, the identifier of the output and the new memory block identifier into the mapping table of outputs and memory block identifiers , and putting the new memory block identifier into a general list of memory block identifiers that is used to record all of the new memory block identifiers, for creating, according to the general list of memory block identifiers during the forward calculation for the neural network, a memory block required for the forward calculation for the neural network; and for each input to the current layer, putting (S104), into the list of idle memory block identifiers , a memory block identifier corresponding to an output from a previous layer as the input if the output from the previous layer as the input is not used as an input to a subsequent layer of the current layer. attempting(S101), for each output from a current layer, to obtain a memory block identifier from a list of idle memory block identifiers that is used to record idle memory block identifiers; if the memory block identifier is obtained, storing (S102), as mapping relationship, an identifier of the output and the obtained memory block identifier into a mapping table of outputs and memory block identifiers , and deleting the memory block identifier from the list of idle memory block identifiers , wherein the mapping table of outputs and memory block identifiers is used to record an identifier of each output from the layer and the corresponding memory block identifier; or if the memory block identifier is not obtained, creating (S103) a new memory block identifier, storing, as mapping relationship, the identifier of the output and the new memory block identifier into the mapping table of outputs and memory block identifiers , and putting the new memory block identifier into a general list of memory block identifiers that is used to record all of the new memory block identifiers, for creating, according to the general list of memory block identifiers during the forward calculation for the neural network, a memory block required for the forward calculation for the neural network; and for each input to the current layer, putting (S104), into the list of idle memory block identifiers , a memory block identifier corresponding to an output from a previous layer as the input if the output from the previous layer as the input is not used as an input to a subsequent layer of the current layer. <EOS>