[go: up one dir, main page]

CN111275197A - Computing method, apparatus, computer equipment and storage medium - Google Patents

Computing method, apparatus, computer equipment and storage medium Download PDF

Info

Publication number
CN111275197A
CN111275197A CN201910625443.2A CN201910625443A CN111275197A CN 111275197 A CN111275197 A CN 111275197A CN 201910625443 A CN201910625443 A CN 201910625443A CN 111275197 A CN111275197 A CN 111275197A
Authority
CN
China
Prior art keywords
scalar
type conversion
machine learning
conversion instruction
module
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201910625443.2A
Other languages
Chinese (zh)
Other versions
CN111275197B (en
Inventor
不公告发明人
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Cambricon Information Technology Co Ltd
Original Assignee
Shanghai Cambricon Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Cambricon Information Technology Co Ltd filed Critical Shanghai Cambricon Information Technology Co Ltd
Priority to PCT/CN2019/110167 priority Critical patent/WO2020073925A1/en
Publication of CN111275197A publication Critical patent/CN111275197A/en
Application granted granted Critical
Publication of CN111275197B publication Critical patent/CN111275197B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30003Arrangements for executing specific machine instructions
    • G06F9/3005Arrangements for executing specific machine instructions to perform operations for flow control
    • G06F9/30058Conditional branch instructions
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Advance Control (AREA)

Abstract

本公开涉及一种运算方法、装置、计算机设备和存储介质。其中的组合处理装置包括:机器学习运算装置、通用互联接口和其他处理装置;机器学习运算装置与其他处理装置进行交互,共同完成用户指定的计算操作,其中,组合处理装置还包括:存储装置,该存储装置分别与机器学习运算装置和其他处理装置连接,用于保存机器学习运算装置和其他处理装置的数据。本公开实施例所提供的运算方法、装置、计算机设备和存储介质的适用范围广,进行运算的处理效率高、处理速度快。

Figure 201910625443

The present disclosure relates to an arithmetic method, an apparatus, a computer device and a storage medium. The combined processing device includes: a machine learning computing device, a general interconnection interface and other processing devices; the machine learning computing device interacts with other processing devices to jointly complete the computing operation specified by the user, wherein the combined processing device further includes: a storage device, The storage device is respectively connected with the machine learning computing device and other processing devices, and is used for saving the data of the machine learning computing device and other processing devices. The computing method, device, computer equipment and storage medium provided by the embodiments of the present disclosure have a wide range of applications, and have high processing efficiency and high processing speed for computing.

Figure 201910625443

Description

运算方法、装置、计算机设备和存储介质Computing method, apparatus, computer equipment and storage medium

技术领域technical field

本公开涉及计算机技术领域,尤其涉及一种标量类型转换指令运算方法、装置、计算机设备和存储介质。The present disclosure relates to the field of computer technology, and in particular, to a scalar type conversion instruction operation method, apparatus, computer device and storage medium.

背景技术Background technique

随着科技的不断发展,机器学习,尤其是神经网络算法的使用越来越广泛。其在图像识别、语音识别、自然语言处理等领域中都得到了良好的应用。但由于神经网络算法的复杂度越来越高,所涉及的数据运算种类和数量不断增大。相关技术中,在对标量数据进行标量类型转换运算的效率低、速度慢。With the continuous development of science and technology, the use of machine learning, especially neural network algorithms, is becoming more and more extensive. It has been well used in image recognition, speech recognition, natural language processing and other fields. However, due to the increasing complexity of neural network algorithms, the types and quantities of data operations involved continue to increase. In the related art, the scalar type conversion operation on scalar data is inefficient and slow.

发明内容SUMMARY OF THE INVENTION

有鉴于此,本公开提出了一种运算方法、装置、计算机设备和存储介质,以提高对标量数据进行标量类型转换运算的效率和速度。In view of this, the present disclosure proposes an operation method, apparatus, computer device and storage medium to improve the efficiency and speed of scalar type conversion operation on scalar data.

根据本公开的第一方面,提供了一种标量类型转换指令处理装置,所述装置包括:According to a first aspect of the present disclosure, there is provided an apparatus for processing a scalar type conversion instruction, the apparatus comprising:

控制模块,用于对获取到的标量类型转换指令进行解析,得到标量类型转换指令的操作码和操作域,并根据所述操作码和所述操作域获取执行标量类型转换指令所需的待运算标量和目标地址,以及确定目标数据类型和所述待运算标量的初始数据类型;The control module is used to parse the acquired scalar type conversion instruction, obtain the operation code and operation field of the scalar type conversion instruction, and obtain the pending operation required to execute the scalar type conversion instruction according to the operation code and the operation field scalar and target address, and determine the target data type and the initial data type of the scalar to be operated;

运算模块,用于根据所述目标数据类型对初始数据类型的所述待运算标量进行标量类型转换运算,获得运算结果,并将所述运算结果存入所述目标地址中,所述运算结果的数据类型为所述目标数据类型,The operation module is configured to perform a scalar type conversion operation on the to-be-operated scalar of the initial data type according to the target data type, obtain an operation result, and store the operation result in the target address. the data type is the target data type,

其中,所述操作码用于指示所述标量类型转换指令对数据所进行的运算为标量类型转换运算,所述操作域包括待运算标量地址和所述目标地址。The operation code is used to indicate that the operation performed by the scalar type conversion instruction on the data is a scalar type conversion operation, and the operation field includes the scalar address to be operated and the target address.

根据本公开的第二方面,提供了一种机器学习运算装置,所述装置包括:According to a second aspect of the present disclosure, there is provided a machine learning computing device, the device comprising:

一个或多个上述第一方面所述的标量类型转换指令处理装置,用于从其他处理装置中获取待运算标量和控制信息,并执行指定的机器学习运算,将执行结果通过I/O接口传递给其他处理装置;One or more scalar type conversion instruction processing devices described in the first aspect above are used to obtain the scalar to be calculated and control information from other processing devices, and execute the specified machine learning operation, and transmit the execution result through the I/O interface. to other processing devices;

当所述机器学习运算装置包含多个所述标量类型转换指令处理装置时,所述多个所述标量类型转换指令处理装置间可以通过特定的结构进行连接并传输数据;When the machine learning computing device includes a plurality of the scalar type conversion instruction processing devices, the plurality of the scalar type conversion instruction processing devices can be connected through a specific structure and data can be transmitted;

其中,多个所述标量类型转换指令处理装置通过快速外部设备互连总线PCIE总线进行互联并传输数据,以支持更大规模的机器学习的运算;多个所述标量类型转换指令处理装置共享同一控制系统或拥有各自的控制系统;多个所述标量类型转换指令处理装置共享内存或者拥有各自的内存;多个所述标量类型转换指令处理装置的互联方式是任意互联拓扑。Wherein, a plurality of the scalar type conversion instruction processing devices are interconnected and transmit data through the fast peripheral device interconnection bus PCIE bus to support larger-scale machine learning operations; a plurality of the scalar type conversion instruction processing devices share the same The control system may have its own control system; a plurality of the scalar type conversion instruction processing devices share memory or have their own memory; the interconnection mode of the plurality of scalar type conversion instruction processing devices is any interconnection topology.

根据本公开的第三方面,提供了一种组合处理装置,所述装置包括:According to a third aspect of the present disclosure, there is provided a combined processing device, the device comprising:

上述第二方面所述的机器学习运算装置、通用互联接口和其他处理装置;The machine learning computing device, universal interconnection interface, and other processing devices described in the second aspect above;

所述机器学习运算装置与所述其他处理装置进行交互,共同完成用户指定的计算操作。The machine learning computing device interacts with the other processing devices to jointly complete the computing operation specified by the user.

根据本公开的第四方面,提供了一种机器学习芯片,所述机器学习芯片包括上述第二方面所述的机器学习运算装置或上述第三方面所述的组合处理装置。According to a fourth aspect of the present disclosure, there is provided a machine learning chip, where the machine learning chip includes the machine learning computing device described in the second aspect or the combined processing device described in the third aspect.

根据本公开的第五方面,提供了一种机器学习芯片封装结构,该机器学习芯片封装结构包括上述第四方面所述的机器学习芯片。According to a fifth aspect of the present disclosure, a machine learning chip packaging structure is provided, and the machine learning chip packaging structure includes the machine learning chip described in the fourth aspect.

根据本公开的第六方面,提供了一种板卡,该板卡包括上述第五方面所述的机器学习芯片封装结构。According to a sixth aspect of the present disclosure, there is provided a board card including the machine learning chip packaging structure described in the fifth aspect.

根据本公开的第七方面,提供了一种电子设备,所述电子设备包括上述第四方面所述的机器学习芯片或上述第六方面所述的板卡。According to a seventh aspect of the present disclosure, an electronic device is provided, and the electronic device includes the machine learning chip described in the fourth aspect or the board card described in the sixth aspect.

根据本公开的第八方面,提供了一种标量类型转换指令处理方法,所述方法应用于标量类型转换指令处理装置,所述方法包括:According to an eighth aspect of the present disclosure, a method for processing a scalar type conversion instruction is provided. The method is applied to an apparatus for processing a scalar type conversion instruction, and the method includes:

对获取到的标量类型转换指令进行解析,得到标量类型转换指令的操作码和操作域,并根据所述操作码和所述操作域获取执行标量类型转换指令所需的待运算标量和目标地址,以及确定目标数据类型和所述待运算标量的初始数据类型;Analyzing the acquired scalar type conversion instruction to obtain the operation code and operation field of the scalar type conversion instruction, and obtaining the scalar to be operated and the target address required for executing the scalar type conversion instruction according to the operation code and the operation field, and determining the target data type and the initial data type of the to-be-operated scalar;

根据所述目标数据类型对初始数据类型的所述待运算标量进行标量类型转换运算,获得运算结果,并将所述运算结果存入所述目标地址中,所述运算结果的数据类型为所述目标数据类型,Perform a scalar type conversion operation on the to-be-operated scalar of the initial data type according to the target data type, obtain an operation result, and store the operation result in the target address, where the data type of the operation result is the target data type,

其中,所述操作码用于指示所述标量类型转换指令对数据所进行的运算为标量类型转换运算,所述操作域包括待运算标量地址和所述目标地址。The operation code is used to indicate that the operation performed by the scalar type conversion instruction on the data is a scalar type conversion operation, and the operation field includes the scalar address to be operated and the target address.

根据本公开的第九方面,提供了一种非易失性计算机可读存储介质,其上存储有计算机程序指令,所述计算机程序指令被处理器执行时实现上述标量类型转换指令处理方法。According to a ninth aspect of the present disclosure, there is provided a non-volatile computer-readable storage medium having computer program instructions stored thereon, the computer program instructions implementing the above-described scalar type conversion instruction processing method when executed by a processor.

在一些实施例中,所述电子设备包括数据处理装置、机器人、电脑、打印机、扫描仪、平板电脑、智能终端、手机、行车记录仪、导航仪、传感器、摄像头、服务器、云端服务器、相机、摄像机、投影仪、手表、耳机、移动存储、可穿戴设备、交通工具、家用电器、和/或医疗设备。In some embodiments, the electronic device includes a data processing device, a robot, a computer, a printer, a scanner, a tablet computer, a smart terminal, a mobile phone, a driving recorder, a navigator, a sensor, a camera, a server, a cloud server, a camera, Cameras, projectors, watches, headphones, mobile storage, wearables, vehicles, home appliances, and/or medical equipment.

在一些实施例中,所述交通工具包括飞机、轮船和/或车辆;所述家用电器包括电视、空调、微波炉、冰箱、电饭煲、加湿器、洗衣机、电灯、燃气灶、油烟机;所述医疗设备包括核磁共振仪、B超仪和/或心电图仪。In some embodiments, the vehicles include airplanes, ships and/or vehicles; the household appliances include televisions, air conditioners, microwave ovens, refrigerators, rice cookers, humidifiers, washing machines, electric lights, gas stoves, and range hoods; the medical Equipment includes MRI machines, ultrasound machines and/or electrocardiographs.

本公开实施例所提供的标量类型转换指令处理方法、装置、计算机设备和存储介质,该装置包括控制模块和运算模块。控制模块用于对获取到的标量类型转换指令进行解析,得到标量类型转换指令的操作码和操作域,并根据操作码和操作域获取执行标量类型转换指令所需的待运算标量和目标地址,以及确定目标数据类型和待运算标量的初始数据类型。运算模块用于根据目标数据类型对初始数据类型的待运算标量进行标量类型转换运算,获得运算结果,并将运算结果存入目标地址中。本公开实施例所提供的标量类型转换指令处理方法、装置、计算机设备和存储介质的适用范围广,对标量类型转换指令的处理效率高、处理速度快,进行标量类型转换的处理效率高、处理速度快。In the scalar type conversion instruction processing method, apparatus, computer equipment and storage medium provided by the embodiments of the present disclosure, the apparatus includes a control module and an operation module. The control module is used to parse the acquired scalar type conversion instruction, obtain the operation code and operation field of the scalar type conversion instruction, and obtain the scalar to be operated and the target address required to execute the scalar type conversion instruction according to the operation code and operation field, As well as determining the target data type and the initial data type of the scalar to be operated on. The operation module is used to perform scalar type conversion operation on the scalar to be operated on the initial data type according to the target data type, obtain the operation result, and store the operation result in the target address. The scalar type conversion instruction processing method, device, computer equipment and storage medium provided by the embodiments of the present disclosure have a wide range of applications, high processing efficiency and fast processing speed for scalar type conversion instructions, and high processing efficiency and processing speed for scalar type conversion. high speed.

根据下面参考附图对示例性实施例的详细说明,本公开的其它特征及方面将变得清楚。Other features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments with reference to the accompanying drawings.

附图说明Description of drawings

包含在说明书中并且构成说明书的一部分的附图与说明书一起示出了本公开的示例性实施例、特征和方面,并且用于解释本公开的原理。The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate exemplary embodiments, features, and aspects of the disclosure, and together with the description, serve to explain the principles of the disclosure.

图1示出根据本公开一实施例的标量类型转换指令处理装置的框图。FIG. 1 shows a block diagram of a scalar type conversion instruction processing apparatus according to an embodiment of the present disclosure.

图2a-图2f示出根据本公开一实施例的标量类型转换指令处理装置的框图。2a-2f show block diagrams of a scalar type conversion instruction processing apparatus according to an embodiment of the present disclosure.

图3示出根据本公开一实施例的标量类型转换指令处理装置的应用场景的示意图。FIG. 3 shows a schematic diagram of an application scenario of an apparatus for processing a scalar type conversion instruction according to an embodiment of the present disclosure.

图4a、图4b示出根据本公开一实施例的组合处理装置的框图。4a and 4b illustrate block diagrams of a combined processing apparatus according to an embodiment of the present disclosure.

图5示出根据本公开一实施例的板卡的结构示意图。FIG. 5 shows a schematic structural diagram of a board according to an embodiment of the present disclosure.

图6示出根据本公开一实施例的标量类型转换指令处理方法的流程图。FIG. 6 shows a flowchart of a method for processing a scalar type conversion instruction according to an embodiment of the present disclosure.

具体实施方式Detailed ways

下面将结合本披露实施例中的附图,对本披露实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本披露一部分实施例,而不是全部的实施例。基于本披露中的实施例,本领域技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本披露保护的范围。The technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, but not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work fall within the protection scope of the present disclosure.

应当理解,本披露的权利要求、说明书及附图中的术语“第零”、“第一”、“第二”等是用于区别不同对象,而不是用于描述特定顺序。本披露的说明书和权利要求书中使用的术语“包括”和“包含”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。It should be understood that the terms "zeroth", "first", "second" and the like in the claims, description and drawings of the present disclosure are used to distinguish different objects, rather than to describe a specific order. The terms "comprising" and "comprising" as used in the specification and claims of this disclosure indicate the presence of the described features, integers, steps, operations, elements and/or components, but do not exclude one or more other features, integers , step, operation, element, component and/or the presence or addition of a collection thereof.

还应当理解,在此本披露说明书中所使用的术语仅仅是出于描述特定实施例的目的,而并不意在限定本披露。如在本披露说明书和权利要求书中所使用的那样,除非上下文清楚地指明其它情况,否则单数形式的“一”、“一个”及“该”意在包括复数形式。还应当进一步理解,在本披露说明书和权利要求书中使用的术语“和/或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。It should also be understood that the terminology used in the present disclosure is for the purpose of describing particular embodiments only and is not intended to limit the present disclosure. As used in this disclosure and the claims, the singular forms "a," "an," and "the" are intended to include the plural unless the context clearly dictates otherwise. It should further be understood that, as used in this disclosure and the claims, the term "and/or" refers to and including any and all possible combinations of one or more of the associated listed items.

如在本说明书和权利要求书中所使用的那样,术语“如果”可以依据上下文被解释为“当...时”或“一旦”或“响应于确定”或“响应于检测到”。类似地,短语“如果确定”或“如果检测到[所描述条件或事件]”可以依据上下文被解释为意指“一旦确定”或“响应于确定”或“一旦检测到[所描述条件或事件]”或“响应于检测到[所描述条件或事件]”。As used in this specification and in the claims, the term "if" may be contextually interpreted as "when" or "once" or "in response to determining" or "in response to detecting". Similarly, the phrases "if it is determined" or "if the [described condition or event] is detected" may be interpreted, depending on the context, to mean "once it is determined" or "in response to the determination" or "once the [described condition or event] is detected. ]" or "in response to detection of the [described condition or event]".

由于神经网络算法的广泛使用,计算机硬件运算人能力的不断提升,实际应用中所涉及到的数据运算的种类和数量不断提高。由于编程语言的种类多样,在不同的语言环境下,为实现标量运算的运算过程,相关技术中,由于现阶段没有能广泛适用于各类编程语言的标量类型转换指令,技术人员需要自定义对应其编程语言环境的多条指令来实现标量的类型转换,导致进行类型转换的效率低、速度慢。本公开提供一种类型转换指令处理方法、装置、计算机设备和存储介质,仅用一个指令即可以实现标量类型转换,能够显著提高进行标量类型转换的效率和速度。Due to the widespread use of neural network algorithms and the continuous improvement of computer hardware computing capabilities, the types and quantities of data operations involved in practical applications continue to increase. Due to the variety of programming languages, in order to realize the operation process of scalar operations in different language environments, in the related art, since there are no scalar type conversion instructions that can be widely applied to various programming languages at this stage, technicians need to customize corresponding The type conversion of scalar is realized by multiple instructions of its programming language environment, resulting in low efficiency and slow speed of type conversion. The present disclosure provides a type conversion instruction processing method, device, computer equipment and storage medium, which can realize scalar type conversion with only one instruction, and can significantly improve the efficiency and speed of scalar type conversion.

图1示出根据本公开一实施例的标量类型转换指令处理装置的框图。如图1所示,该装置包括控制模块11和运算模块12。FIG. 1 shows a block diagram of a scalar type conversion instruction processing apparatus according to an embodiment of the present disclosure. As shown in FIG. 1 , the device includes a control module 11 and an arithmetic module 12 .

控制模块11,用于对获取到的标量类型转换指令进行解析,得到标量类型转换指令的操作码和操作域,并根据操作码和操作域获取执行标量类型转换指令所需的待运算标量和目标地址,以及确定目标数据类型和待运算标量的初始数据类型。其中,操作码用于指示标量类型转换指令对数据所进行的运算为标量类型转换运算,操作域包括待运算标量地址和目标地址。The control module 11 is used to parse the acquired scalar type conversion instruction, obtain the operation code and operation field of the scalar type conversion instruction, and obtain the scalar to be operated and the target required for executing the scalar type conversion instruction according to the operation code and operation field address, and determine the destination data type and the initial data type of the scalar to be operated on. The operation code is used to indicate that the operation performed by the scalar type conversion instruction on the data is a scalar type conversion operation, and the operation domain includes the scalar address to be operated and the target address.

运算模块12,用于根据目标数据类型对初始数据类型的待运算标量进行标量类型转换运算,获得运算结果,并将运算结果存入目标地址中。其中,运算结果的数据类型为目标数据类型。The operation module 12 is configured to perform scalar type conversion operation on the scalar to be operated on the initial data type according to the target data type, obtain the operation result, and store the operation result in the target address. The data type of the operation result is the target data type.

在本实施例中,控制模块可以从待运算标量地址中获取待运算标量。控制模块可以通过数据输入输出单元获得标量类型转换指令和待运算标量,该数据输入输出单元可以为一个或多个数据I/O接口或I/O引脚。In this embodiment, the control module may acquire the scalar to be calculated from the address of the scalar to be calculated. The control module can obtain the scalar type conversion instruction and the to-be-operated scalar through the data input and output unit, and the data input and output unit can be one or more data I/O interfaces or I/O pins.

在本实施例中,操作码可以是计算机程序中所规定的要执行操作的那一部分指令或字段(通常用代码表示),是指令序列号,用来告知执行指令的装置具体需要执行哪一条指令。操作域可以是执行对应的指令所需的所有数据的来源,执行对应的指令所需的所有数据包括参数数据、待运算标量、对应的运算方法等等。对于一个标量类型转换指令其必须包括操作码和操作域,其中操作域至少包括待运算标量地址和目标地址。In this embodiment, the operation code may be the part of the instruction or field (usually represented by code) specified in the computer program to perform the operation, and the instruction sequence number, which is used to inform the device that executes the instruction which instruction needs to be executed. . The operation domain may be the source of all data required to execute the corresponding instruction, and all the data required to execute the corresponding instruction includes parameter data, scalar to be operated, corresponding operation method, and so on. For a scalar type conversion instruction, it must include an operation code and an operation field, wherein the operation field at least includes the address of the scalar to be operated and the target address.

应当理解的是,本领域技术人员可以根据需要对标量类型转换指令的指令格式以及所包含的操作码和操作域进行设置,本公开对此不作限制。It should be understood that those skilled in the art can set the instruction format of the scalar type conversion instruction and the included operation codes and operation fields as required, which is not limited in the present disclosure.

在本实施例中,该装置可以包括一个或多个控制模块,以及一个或多个运算模块,可以根据实际需要对控制模块和运算模块的数量进行设置,本公开对此不作限制。在装置包括一个控制模块时,该控制模块可以接收标量类型转换指令,并控制一个或多个运算模块进行标量类型转换运算。在装置包括多个控制模块时,多个控制模块可以分别接收标量类型转换指令,并控制对应的一个或多个运算模块进行标量类型转换运算。In this embodiment, the device may include one or more control modules and one or more operation modules, and the number of control modules and operation modules may be set according to actual needs, which is not limited in the present disclosure. When the device includes a control module, the control module can receive a scalar type conversion instruction, and control one or more operation modules to perform a scalar type conversion operation. When the apparatus includes multiple control modules, the multiple control modules can respectively receive scalar type conversion instructions, and control one or more corresponding operation modules to perform scalar type conversion operations.

本公开实施例所提供的标量类型转换指令处理装置,该装置包括控制模块和运算模块。控制模块用于对获取到的标量类型转换指令进行解析,得到标量类型转换指令的操作码和操作域,并根据操作码和操作域获取执行标量类型转换指令所需的待运算标量和目标地址,以及确定目标数据类型和待运算标量的初始数据类型。运算模块用于根据目标数据类型对初始数据类型的待运算标量进行标量类型转换运算,获得运算结果,并将运算结果存入目标地址中。本公开实施例所提供的标量类型转换指令处理装置的适用范围广,对标量类型转换指令的处理效率高、处理速度快,进行标量类型转换的处理效率高、处理速度快。The apparatus for processing a scalar type conversion instruction provided by an embodiment of the present disclosure includes a control module and an operation module. The control module is used to parse the acquired scalar type conversion instruction, obtain the operation code and operation field of the scalar type conversion instruction, and obtain the scalar to be operated and the target address required to execute the scalar type conversion instruction according to the operation code and operation field, As well as determining the target data type and the initial data type of the scalar to be operated on. The operation module is used to perform scalar type conversion operation on the scalar to be operated on the initial data type according to the target data type, obtain the operation result, and store the operation result in the target address. The scalar type conversion instruction processing device provided by the embodiment of the present disclosure has a wide range of applications, and has high processing efficiency and fast processing speed for scalar type conversion instructions, and high processing efficiency and fast processing speed for scalar type conversion.

图2a示出根据本公开一实施例的标量类型转换指令处理装置的框图。在一种可能的实现方式中,如图2a所示,运算模块12可以包括多个标量运算器120,用于执行标量类型转换运算。Fig. 2a shows a block diagram of a scalar type conversion instruction processing apparatus according to an embodiment of the present disclosure. In a possible implementation manner, as shown in FIG. 2a, the operation module 12 may include a plurality of scalar operators 120 for performing scalar type conversion operations.

在该实现方式中,运算模块也可以包括一个标量运算器。可以根据所需进行标量类型转换运算的数据量的大小、对标量类型转换运算的处理速度、效率等要求对标量运算器的数量进行设置,本公开对此不作限制。In this implementation manner, the operation module may also include a scalar operator. The number of scalar operators may be set according to the size of the data required to perform the scalar type conversion operation, the processing speed and efficiency of the scalar type conversion operation, etc., which is not limited in the present disclosure.

图2b示出根据本公开一实施例的标量类型转换指令处理装置的框图。在一种可能的实现方式中,如图2b所示,运算模块12可以包括主运算子模块121和多个从运算子模块122。主运算子模块121可以包括多个标量运算器120(图中未示出)。FIG. 2b shows a block diagram of a scalar type conversion instruction processing apparatus according to an embodiment of the present disclosure. In a possible implementation manner, as shown in FIG. 2 b , the operation module 12 may include a master operation sub-module 121 and a plurality of slave operation sub-modules 122 . The main operation sub-module 121 may include a plurality of scalar operators 120 (not shown in the figure).

主运算子模块121,用于利用多个标量运算器120执行标量类型转换运算,得到运算结果,并将运算结果存入目标地址中。The main operation sub-module 121 is configured to use a plurality of scalar operators 120 to perform a scalar type conversion operation, obtain an operation result, and store the operation result in a target address.

在一种可能的实现方式中,控制模块11,还用于对获取到的计算指令进行解析,得到计算指令的操作域和操作码,并根据操作域和操作码获取执行计算指令所需的待运算数据。运算模块12,还用于根据计算指令对待运算数据进行运算,得到计算指令的计算结果。其中,运算模块可以包括多个运算器,用于执行与计算指令的运算类型相对应的运算。In a possible implementation manner, the control module 11 is further configured to parse the acquired calculation instruction, obtain the operation domain and operation code of the calculation instruction, and obtain the waiting list required to execute the calculation instruction according to the operation domain and the operation code. Operational data. The operation module 12 is further configured to perform operation on the data to be operated according to the calculation instruction to obtain the calculation result of the calculation instruction. Wherein, the operation module may include a plurality of operators for executing operations corresponding to the operation types of the calculation instructions.

在该实现方式中,计算指令可以是其他对标量、向量、矩阵、张量等数据进行算术运算、逻辑运算等运算的指令,本领域技术人员可以根据实际需要对计算指令进行设置,本公开对此不作限制。In this implementation manner, the calculation instructions may be other instructions for performing arithmetic operations, logical operations and other operations on data such as scalars, vectors, matrices, and tensors. Those skilled in the art can set the calculation instructions according to actual needs. This is not limited.

该实现方式中,运算器可以包括加法器、除法器、乘法器、比较器等能够对数据进行算术运算、逻辑运算等运算的运算器。可以根据所需进行的运算的数据量的大小、运算类型、对数据进行运算的处理速度、效率等要求对运算器的种类及数量进行设置,本公开对此不作限制。In this implementation manner, the operator may include an operator, such as an adder, a divider, a multiplier, and a comparator, that can perform arithmetic operations, logical operations, and other operations on data. The type and quantity of arithmetic units can be set according to the size of the data volume of the operation to be performed, the type of operation, the processing speed and efficiency of the operation on the data, etc., which are not limited in the present disclosure.

在一种可能的实现方式中,控制模块11,还用于解析计算指令得到多个运算指令,并将待运算数据和多个运算指令发送至主运算子模块121。In a possible implementation manner, the control module 11 is further configured to parse the calculation instruction to obtain multiple operation instructions, and send the data to be calculated and the multiple operation instructions to the main operation sub-module 121 .

主运算子模块121,用于对待运算数据执行前序处理,以及与多个从运算子模块122进行数据和运算指令的传输。The master operation sub-module 121 is used to perform pre-order processing on the data to be operated, and transmit data and operation instructions with a plurality of slave operation sub-modules 122 .

从运算子模块122,用于根据从主运算子模块121传输的数据和运算指令并行执行中间运算得到多个中间结果,并将多个中间结果传输给主运算子模块122。The slave operation sub-module 122 is configured to perform intermediate operations in parallel according to the data and operation instructions transmitted from the master operation sub-module 121 to obtain multiple intermediate results, and transmit the multiple intermediate results to the master operation sub-module 122 .

主运算子模块121,还用于对多个中间结果执行后续处理,得到计算指令的计算结果,并将计算结果存入对应的地址中。The main operation sub-module 121 is further configured to perform subsequent processing on a plurality of intermediate results, obtain the calculation result of the calculation instruction, and store the calculation result in the corresponding address.

在该实现方式中,在计算指令为针对标量、向量数据所进行的运算时,装置可以控制主运算子模块利用其中的运算器进行与计算指令相对应的运算。在计算指令为针对矩阵、张量等维度大于或等于2的数据进行运算时,装置可以控制从运算子模块利用其中的运算器进行与计算指令相对应的运算。In this implementation manner, when the calculation instruction is an operation performed on scalar or vector data, the apparatus can control the main operation sub-module to use the operator therein to perform an operation corresponding to the calculation instruction. When the calculation instruction is to perform operations on data whose dimensions are greater than or equal to 2, such as matrices and tensors, the apparatus may control the operation sub-module to perform operations corresponding to the calculation instructions using the operators therein.

需要说明的是,本领域技术人员可以根据实际需要对主运算子模块和多个从运算子模块之间的连接方式进行设置,以实现对运算模块的架构设置,例如,运算模块的架构可以是“H”型架构、阵列型架构、树型架构等,本公开对此不作限制。It should be noted that those skilled in the art can set the connection mode between the main operation sub-module and multiple slave operation sub-modules according to actual needs, so as to realize the architecture setting of the operation module. For example, the architecture of the operation module can be "H"-type architecture, array-type architecture, tree-type architecture, etc., are not limited in the present disclosure.

图2c示出根据本公开一实施例的标量类型转换指令处理装置的框图。在一种可能的实现方式中,如图2c所示,运算模块12还可以包括一个或多个分支运算子模块123,该分支运算子模块123用于转发主运算子模块121和从运算子模块122之间的数据和/或运算指令。其中,主运算子模块121与一个或多个分支运算子模块123连接。这样,运算模块中的主运算子模块、分支运算子模块和从运算子模块之间采用“H”型架构连接,通过分支运算子模块转发数据和/或运算指令,节省了对主运算子模块的资源占用,进而提高指令的处理速度。FIG. 2c shows a block diagram of a scalar type conversion instruction processing apparatus according to an embodiment of the present disclosure. In a possible implementation manner, as shown in FIG. 2c, the operation module 12 may further include one or more branch operation sub-modules 123, and the branch operation sub-module 123 is used for forwarding the master operation sub-module 121 and the slave operation sub-module 122 between data and/or operation instructions. Wherein, the main operation sub-module 121 is connected with one or more branch operation sub-modules 123 . In this way, the main operation sub-module, the branch operation sub-module and the slave operation sub-module in the operation module are connected by an "H" type structure, and data and/or operation instructions are forwarded through the branch operation sub-module, saving the need for the main operation sub-module. resource consumption, thereby improving the processing speed of instructions.

图2d示出根据本公开一实施例的标量类型转换指令处理装置的框图。在一种可能的实现方式中,如图2d所示,多个从运算子模块122呈阵列分布。FIG. 2d shows a block diagram of a scalar type conversion instruction processing apparatus according to an embodiment of the present disclosure. In a possible implementation manner, as shown in FIG. 2d , a plurality of slave operation sub-modules 122 are distributed in an array.

每个从运算子模块122与相邻的其他从运算子模块122连接,主运算子模块121连接多个从运算子模块122中的k个从运算子模块122,k个从运算子模块122为:第1行的n个从运算子模块122、第m行的n个从运算子模块122以及第1列的m个从运算子模块122。Each slave operation sub-module 122 is connected to other adjacent slave operation sub-modules 122, the master operation sub-module 121 is connected to k slave operation sub-modules 122 in the plurality of slave operation sub-modules 122, and the k slave operation sub-modules 122 are : n slave operation submodules 122 in the first row, n slave operation submodules 122 in the mth row, and m slave operation submodules 122 in the first column.

其中,如图2d所示,k个从运算子模块仅包括第1行的n个从运算子模块、第m行的n个从运算子模块以及第1列的m个从运算子模块,即该k个从运算子模块为多个从运算子模块中直接与主运算子模块连接的从运算子模块。其中,k个从运算子模块,用于在主运算子模块以及多个从运算子模块之间的数据以及指令的转发。这样,多个从运算子模块呈阵列分布,可以提高主运算子模块向从运算子模块发送数据和/或运算指令速度,进而提高指令的处理速度。Among them, as shown in Figure 2d, the k slave operation submodules only include n slave operation submodules in the first row, n slave operation submodules in the mth row, and m slave operation submodules in the first column, that is, The k slave operation submodules are slave operation submodules that are directly connected to the master operation submodule among the plurality of slave operation submodules. The k slave operation submodules are used for data and instruction forwarding between the master operation submodule and a plurality of slave operation submodules. In this way, the plurality of slave operation sub-modules are distributed in an array, which can improve the speed at which the master operation sub-module sends data and/or operation instructions to the slave operation sub-modules, thereby increasing the instruction processing speed.

图2e示出根据本公开一实施例的标量类型转换指令处理装置的框图。在一种可能的实现方式中,如图2e所示,运算模块还可以包括树型子模块124。该树型子模块124包括一个根端口401和多个支端口402。根端口401与主运算子模块121连接,多个支端口402与多个从运算子模块122分别连接。其中,树型子模块124具有收发功能,用于转发主运算子模块121和从运算子模块122之间的数据和/或运算指令。这样,通过树型子模块的作用使得运算模块呈树型架构连接,并利用树型子模块的转发功能,可以提高主运算子模块向从运算子模块发送数据和/或运算指令速度,进而提高指令的处理速度。FIG. 2e shows a block diagram of a scalar type conversion instruction processing apparatus according to an embodiment of the present disclosure. In a possible implementation manner, as shown in FIG. 2e , the operation module may further include a tree-type sub-module 124 . The tree-type sub-module 124 includes a root port 401 and a plurality of branch ports 402 . The root port 401 is connected to the master operation sub-module 121 , and the multiple branch ports 402 are respectively connected to the multiple slave operation sub-modules 122 . The tree-type sub-module 124 has the function of sending and receiving, and is used to forward data and/or operation instructions between the master operation sub-module 121 and the slave operation sub-module 122 . In this way, the operation modules are connected in a tree structure through the function of the tree-type sub-module, and the forwarding function of the tree-type sub-module can be used to improve the speed at which the master operation sub-module sends data and/or operation instructions to the slave operation sub-module, thereby improving the The processing speed of the instruction.

在一种可能的实现方式中,树型子模块124可以为该装置的可选结果,其可以包括至少一层节点。节点为具有转发功能的线结构,节点本身不具备运算功能。最下层的节点与从运算子模块连接,以转发主运算子模块121和从运算子模块122之间的数据和/或运算指令。特殊地,如树型子模块具有零层节点,该装置则无需树型子模块。In a possible implementation manner, the tree-type sub-module 124 may be an optional result of the apparatus, which may include at least one level of nodes. The node is a line structure with forwarding function, and the node itself does not have the computing function. The node at the lowest level is connected to the slave operation sub-module to forward data and/or operation instructions between the master operation sub-module 121 and the slave operation sub-module 122 . In particular, if the tree-type sub-module has zero-level nodes, the device does not need the tree-type sub-module.

在一种可能的实现方式中,树型子模块124可以包括n叉树结构的多个节点,n叉树结构的多个节点可以具有多个层。In a possible implementation manner, the tree sub-module 124 may include multiple nodes in an n-ary tree structure, and the multiple nodes in the n-ary tree structure may have multiple layers.

举例来说,图2f示出根据本公开一实施例的标量类型转换指令处理装置的框图。如图2f所示,n叉树结构可以是二叉树结构,树型子模块包括2层节点01。最下层节点01与从运算子模块122连接,以转发主运算子模块121和从运算子模块122之间的数据和/或运算指令。For example, FIG. 2f shows a block diagram of a scalar type conversion instruction processing apparatus according to an embodiment of the present disclosure. As shown in FIG. 2f , the n-ary tree structure may be a binary tree structure, and the tree-type sub-module includes 2-layer nodes 01 . The lowermost node 01 is connected to the slave operation sub-module 122 to forward data and/or operation instructions between the master operation sub-module 121 and the slave operation sub-module 122 .

在该实现方式中,n叉树结构还可以是三叉树结构等,n为大于或等于2的正整数。本领域技术人员可以根据需要对n叉树结构中的n以及n叉树结构中节点的层数进行设置,本公开对此不作限制。In this implementation manner, the n-ary tree structure may also be a ternary tree structure, etc., and n is a positive integer greater than or equal to 2. Those skilled in the art can set n in the n-ary tree structure and the number of layers of nodes in the n-ary tree structure as required, which is not limited in the present disclosure.

在一种可能的实现方式中,操作域还可以包括初始数据类型和目标数据类型。控制模块11,还用于根据操作域确定目标数据类型和待运算标量的初始数据类型。In a possible implementation manner, the operation domain may further include an initial data type and a target data type. The control module 11 is further configured to determine the target data type and the initial data type of the to-be-operated scalar according to the operation domain.

在一种可能的实现方式中,操作码还可以用于指示初始数据类型和目标数据类型。控制模块11,还用于根据操作码确定目标数据类型和待运算标量的初始数据类型。In one possible implementation, the opcode can also be used to indicate the initial data type and the target data type. The control module 11 is further configured to determine the target data type and the initial data type of the to-be-operated scalar according to the operation code.

在一种可能的实现方式中,在根据操作码或者操作域均不能确定初始数据类型和/或目标数据类型时,可以根据预先设置的默认初始数据类型和默认目标数据类型确定初始数据类型和/或目标数据类型。可以将预先设置的默认初始数据类型确定为当前该标量类型转换指令的初始数据类型,可以将预先设置的默认目标数据类型确定为当前该标量类型转换指令的目标数据类型。本领域技术人员可以根据实际需要对目标数据类型和初始数据类型的确定方式进行设置,本公开对此不作限制。In a possible implementation manner, when the initial data type and/or target data type cannot be determined according to either the operation code or the operation domain, the initial data type and/or target data type may be determined according to the preset default initial data type and default target data type. or the target data type. The preset default initial data type may be determined as the initial data type of the current scalar type conversion instruction, and the preset default target data type may be determined as the current target data type of the scalar type conversion instruction. Those skilled in the art can set the determination manner of the target data type and the initial data type according to actual needs, which is not limited in the present disclosure.

在一种可能的实现方式中,目标数据类型可以包括16位浮点数、32位浮点数、48位浮点数、16位整数、32位整数和48位整数中的任意一种,初始数据类型可以包括16位有符号数、32位有符号数、48位有符号数、16位无符号数、32位无符号数、48位无符号数和指针数据类型中的任意一种。In a possible implementation manner, the target data type may include any one of 16-bit floating point numbers, 32-bit floating point numbers, 48-bit floating point numbers, 16-bit integers, 32-bit integers, and 48-bit integers, and the initial data type may be Including any one of 16-bit signed number, 32-bit signed number, 48-bit signed number, 16-bit unsigned number, 32-bit unsigned number, 48-bit unsigned number and pointer data types.

在该实现方式中,目标数据类型和初始数据类型还可以是如64位整数等数据类型,本领域技术人员可以根据实际需要对目标数据类型和初始数据类型进行设置,只要保证目标数据类型与初始数据类型所指示的数据类型不同即可,本公开对此不作限制。In this implementation manner, the target data type and the initial data type can also be data types such as 64-bit integers. Those skilled in the art can set the target data type and initial data type according to actual needs, as long as the target data type and the initial data type are ensured The data types indicated by the data types only need to be different, which is not limited in the present disclosure.

在该实现方式中,可以对上述目标数据类型和初始数据类型的编号、名称等标识(或代码)进行设置,以根据标量转换指令中的标识(或代码)确定标量类型转换指令所指示的目标数据类型和初始数据类型。例如,可以将16位浮点数的标识设置为cvtf16、32位浮点数的标识设置为cvtf32、48位浮点数的标识设置为cvtf48、16位整数的标识设置为cvti16、32位整数的标识设置为cvti32以及将48位整数的标识设置为cvti48。可以将16位有符号数的标识设置为s16、32位有符号数的标识设置为s32、48位有符号数的标识设置为s48、16位无符号数的标识设置为u16、32位无符号数的标识设置为u32、48位无符号数的标识设置为u48和指针数据类型的标识设置为ptr。本领域技术人员可以根据实际需要对目标数据类型和初始数据类型的标识进行设置,本公开对此不作限制。In this implementation manner, identifiers (or codes) such as the number and name of the target data type and initial data type can be set to determine the target indicated by the scalar type conversion instruction according to the identifier (or code) in the scalar type conversion instruction Data types and initial data types. For example, you can set the identity of 16-bit floating-point numbers to cvtf16, the identity of 32-bit floating-point numbers to cvtf32, the identity of 48-bit floating-point numbers to cvtf48, the identity of 16-bit integers to be set to cvti16, and the identity of 32-bit integers to be set to cvti32 and set the identity of the 48-bit integer to cvti48. You can set the 16-bit signed number to s16, 32-bit signed number to s32, 48-bit signed number to s48, 16-bit unsigned number to u16, 32-bit unsigned The identifier of the number is set to u32, the identifier of the 48-bit unsigned number is set to u48 and the identifier of the pointer data type is set to ptr. Those skilled in the art can set the identifiers of the target data type and the initial data type according to actual needs, which is not limited in the present disclosure.

在一种可能的实现方式中,如图2a-图2f所示,该装置还可以包括存储模块13。存储模块13用于存储待运算标量。In a possible implementation manner, as shown in FIGS. 2 a to 2 f , the apparatus may further include a storage module 13 . The storage module 13 is used for storing the scalar to be calculated.

在该实现方式中,存储模块可以包括缓存和寄存器中的一种或多种,缓存可以包括速暂存缓存,还可以包括至少一个NRAM(Neuron Random Access Memory,神经元随机存取存储器)。缓存可以用于存储待运算数据,寄存器可以用于存储待运算标量。In this implementation manner, the storage module may include one or more of a cache and a register, the cache may include a temporary cache, and may also include at least one NRAM (Neuron Random Access Memory, neuron random access memory). The cache can be used to store the data to be calculated, and the register can be used to store the scalar to be calculated.

在一种可能的实现方式中,缓存可以包括神经元缓存。神经元缓存也即上述神经元随机存取存储器,可以用于存储待运算数据中的神经元数据,神经元数据可以包括神经元向量数据。其中,待运算数据包括与进行标量类型转换相关的数据、和/或与其他计算指令的运算相关的数据。In one possible implementation, the cache may include a neuron cache. The neuron cache, that is, the above-mentioned neuron random access memory, may be used to store neuron data in the data to be operated, and the neuron data may include neuron vector data. The data to be operated includes data related to scalar type conversion, and/or data related to operations of other computing instructions.

在一种可能的实现方式中,该装置还可以包括直接内存访问模块,用于从存储模块中读取或者存储数据。In a possible implementation manner, the apparatus may further include a direct memory access module for reading or storing data from the storage module.

在一种可能的实现方式中,如图2a-图2f所示,控制模块11可以包括指令存储子模块111、指令处理子模块112和队列存储子模块113。In a possible implementation manner, as shown in FIGS. 2 a to 2 f , the control module 11 may include an instruction storage sub-module 111 , an instruction processing sub-module 112 and a queue storage sub-module 113 .

指令存储子模块111用于存储标量类型转换指令。The instruction storage sub-module 111 is used for storing scalar type conversion instructions.

指令处理子模块112用于对标量类型转换指令进行解析,得到标量类型转换指令的操作码和操作域。The instruction processing sub-module 112 is configured to parse the scalar type conversion instruction to obtain the operation code and operation field of the scalar type conversion instruction.

队列存储子模块113用于存储指令队列,指令队列包括按照执行顺序依次排列的多个待执行指令,多个待执行指令可以包括标量类型转换指令。The queue storage sub-module 113 is used to store an instruction queue, and the instruction queue includes a plurality of instructions to be executed sequentially arranged in an execution order, and the multiple instructions to be executed may include scalar type conversion instructions.

在该实现方式中,待执行指令还可以包括与标量类型转换指令有一定相关性、或者不相关的计算指令,本领域技术人员可以根据实际需要进行设置,本公开对此不作限制。可以根据待执行指令的接收时间、优先级别等对多个待执行指令的执行顺序进行排列获得指令队列,以便于根据指令队列依次执行多个待执行指令。In this implementation manner, the to-be-executed instruction may also include a calculation instruction that is related to or irrelevant to the scalar type conversion instruction, which can be set by those skilled in the art according to actual needs, which is not limited in the present disclosure. An instruction queue can be obtained by arranging the execution order of multiple instructions to be executed according to the receiving time, priority level, etc. of the instructions to be executed, so as to execute the multiple instructions to be executed in sequence according to the instruction queue.

在一种可能的实现方式中,如图2a-图2f所示,控制模块11可以包括依赖关系处理子模块114。In a possible implementation manner, as shown in FIGS. 2 a to 2 f , the control module 11 may include a dependency relationship processing sub-module 114 .

依赖关系处理子模块114,用于在确定多个待执行指令中的第一待执行指令与第一待执行指令之前的第零待执行指令存在关联关系时,将第一待执行指令缓存在指令存储子模块111中,在第零待执行指令执行完毕后,从指令存储子模块111中提取第一待执行指令发送至运算模块12。其中,第一待执行指令和第零待执行指令是多个待执行指令中的指令。The dependency relationship processing sub-module 114 is configured to cache the first to-be-executed instruction in the In the storage sub-module 111 , after the execution of the zeroth to-be-executed instruction is completed, the first to-be-executed instruction is extracted from the instruction storage sub-module 111 and sent to the operation module 12 . Wherein, the first to-be-executed instruction and the zeroth to-be-executed instruction are instructions in a plurality of to-be-executed instructions.

其中,第一待执行指令与第一待执行指令之前的第零待执行指令存在关联关系包括:存储第一待执行指令所需数据的第一存储地址区间与存储第零待执行指令所需数据的第零存储地址区间具有重叠的区域。反之,第一待执行指令与第零待执行指令之间没有关联关系可以是第一存储地址区间与第零存储地址区间没有重叠区域。Wherein, the relationship between the first instruction to be executed and the zeroth instruction to be executed before the first instruction to be executed includes: a first storage address range for storing data required by the first instruction to be executed and data required for storing the zeroth instruction to be executed The zeroth memory address range of has overlapping regions. Conversely, if there is no association between the first instruction to be executed and the zeroth instruction to be executed, it may be that the first storage address interval and the zeroth storage address interval have no overlapping area.

通过这种方式,可以根据待执行指令之间的依赖关系,使得在先的待执行指令执行完毕之后,再执行在后的待执行指令,保证运算结果的准确性。In this way, according to the dependencies between the to-be-executed instructions, after the previous to-be-executed instruction is executed, the subsequent to-be-executed instruction is executed to ensure the accuracy of the operation result.

在一种可能的实现方式中,标量类型转换指令的指令格式可以是:In a possible implementation, the instruction format of the scalar type conversion instruction may be:

scalar dst src0 opcode.typescalar dst src0 opcode.type

其中,scalar是标量类型转换指令的操作码,dst、src0、opcode.type是标量类型转换指令的操作域。其中,dst是目标地址。src0是待运算标量地址。opcode.type中的opcode是目标数据类型,opcode.type中的type是待运算标量的初始数据类型。Among them, scalar is the opcode of the scalar type conversion instruction, and dst, src0, and opcode.type are the operation fields of the scalar type conversion instruction. where dst is the destination address. src0 is the scalar address to be operated on. The opcode in opcode.type is the target data type, and the type in opcode.type is the initial data type of the scalar to be operated.

在一种可能的实现方式中,标量类型转换指令的指令格式还可以是:In a possible implementation manner, the instruction format of the scalar type conversion instruction may also be:

opcode.scalar.type dstsrc0opcode.scalar.type dstsrc0

其中,opcode.scalar.type是标量类型转换指令的操作码,dst、src0是标量类型转换指令的操作域。其中,opcode.scalar.type中的opcode用于指示目标数据类型,opcode.scalar.type中的type用于指示待运算标量的初始数据类型,opcode.scalar.type中的scalar用于指示该指令为标量类型转换指令。dst是目标地址,src0是待运算标量地址。Among them, opcode.scalar.type is the opcode of the scalar type conversion instruction, and dst and src0 are the operation fields of the scalar type conversion instruction. Among them, opcode in opcode.scalar.type is used to indicate the target data type, type in opcode.scalar.type is used to indicate the initial data type of the scalar to be operated, and scalar in opcode.scalar.type is used to indicate that the instruction is Scalar type conversion instructions. dst is the destination address, and src0 is the address of the scalar to be computed.

应当理解的是,本领域技术人员可以根据需要对标量类型转换指令的操作码、指令格式中操作码和操作域的位置进行设置,本公开对此不作限制。It should be understood that those skilled in the art can set the operation code of the scalar type conversion instruction, the location of the operation code and the operation field in the instruction format as required, which is not limited in the present disclosure.

在一种可能的实现方式中,该装置可以设置于图形处理器(Graphics ProcessingUnit,简称GPU)、中央处理器(Central Processing Unit,简称CPU)和嵌入式神经网络处理器(Neural-network Processing Unit,简称NPU)的一种或多种之中。In a possible implementation manner, the apparatus may be provided in a graphics processing unit (Graphics Processing Unit, GPU for short), a central processing unit (Central Processing Unit, CPU for short), and an embedded neural-network processing unit (Neural-network Processing Unit, abbreviated as NPU) among one or more of them.

需要说明的是,尽管以上述实施例作为示例介绍了标量类型转换指令处理装置如上,但本领域技术人员能够理解,本公开应不限于此。事实上,用户完全可根据个人喜好和/或实际应用场景灵活设定各模块,只要符合本公开的技术方案即可。It should be noted that although the above-mentioned embodiment is used as an example to describe the scalar type conversion instruction processing apparatus as above, those skilled in the art can understand that the present disclosure should not be limited thereto. In fact, the user can flexibly set each module according to personal preferences and/or actual application scenarios, as long as it conforms to the technical solutions of the present disclosure.

应用示例Application example

以下结合“利用标量类型转换指令处理装置进行标量类型转换运算”作为一个示例性应用场景,给出根据本公开实施例的应用示例,以便于理解标量类型转换指令处理装置的流程。本领域技术人员应理解,以下应用示例仅仅是出于便于理解本公开实施例的目的,不应视为对本公开实施例的限制。In the following, an application example according to the embodiment of the present disclosure is given in conjunction with "using a scalar type conversion instruction processing apparatus to perform a scalar type conversion operation" as an exemplary application scenario, so as to facilitate the understanding of the flow of the scalar type conversion instruction processing apparatus. Those skilled in the art should understand that the following application examples are only for the purpose of facilitating the understanding of the embodiments of the present disclosure, and should not be regarded as limitations of the embodiments of the present disclosure.

图3示出根据本公开一实施例的标量类型转换指令处理装置的应用场景的示意图。如图3所示,标量类型转换指令处理装置对标量类型转换指令进行处理的过程如下:FIG. 3 shows a schematic diagram of an application scenario of an apparatus for processing a scalar type conversion instruction according to an embodiment of the present disclosure. As shown in FIG. 3 , the process of processing the scalar type conversion instruction by the scalar type conversion instruction processing device is as follows:

控制模块11对获取到的标量类型转换指令1(如标量类型转换指令1为scalar 500100 cvtf16.u32)进行解析,得到标量类型转换指令1的操作码和操作域。其中,标量类型转换指令1的操作码为scalar,目标地址为500,待运算标量地址为100,目标数据类型为cvtf16(也即16为浮点数),待运算标量的初始数据类型为u32(也即32位无符号数)。控制模块11从待运算标量地址100获取待运算标量。The control module 11 parses the acquired scalar type conversion instruction 1 (for example, the scalar type conversion instruction 1 is scalar 500100 cvtf16.u32), and obtains the operation code and operation field of the scalar type conversion instruction 1. Among them, the opcode of the scalar type conversion instruction 1 is scalar, the target address is 500, the address of the scalar to be operated is 100, the target data type is cvtf16 (that is, 16 is a floating-point number), and the initial data type of the scalar to be operated is u32 (also i.e. 32-bit unsigned number). The control module 11 acquires the scalar to be calculated from the address 100 of the scalar to be calculated.

运算模块12根据目标数据类型对初始数据类型的待运算标量进行标量类型转换运算(也即将32位无符号数的待运算标量的数据类型转换为16为浮点数),得到运算结果,并将运算结果存入目标地址500中。The operation module 12 performs a scalar type conversion operation on the scalar to be operated on the initial data type according to the target data type (that is, converts the data type of the 32-bit unsigned scalar to be operated into a floating-point number of 16), obtains the operation result, and calculates the operation result. The result is stored in target address 500.

以上各模块的工作过程可参考上文的相关描述。For the working process of the above modules, reference may be made to the above related descriptions.

这样,标量类型转换指令处理装置可以高效、快速地对标量类型转换指令进行处理,进行标量类型转换的处理效率高、处理速度快。In this way, the scalar type conversion instruction processing device can efficiently and quickly process the scalar type conversion instruction, and the processing efficiency and processing speed of the scalar type conversion are high.

本公开提供一种机器学习运算装置,该机器学习运算装置可以包括一个或多个上述标量类型转换指令处理装置,用于从其他处理装置中获取待运算标量和控制信息,执行指定的机器学习运算。该机器学习运算装置可以从其他机器学习运算装置或非机器学习运算装置中获得标量类型转换指令,并将执行结果通过I/O接口传递给外围设备(也可称其他处理装置)。外围设备譬如摄像头,显示器,鼠标,键盘,网卡,wifi接口,服务器。当包含一个以上标量类型转换指令处理装置时,标量类型转换指令处理装置间可以通过特定的结构进行链接并传输数据,譬如,通过PCIE总线进行互联并传输数据,以支持更大规模的神经网络的运算。此时,可以共享同一控制系统,也可以有各自独立的控制系统;可以共享内存,也可以每个加速器有各自的内存。此外,其互联方式可以是任意互联拓扑。The present disclosure provides a machine learning computing device. The machine learning computing device may include one or more of the above-mentioned scalar type conversion instruction processing devices, which are used to obtain the scalar to be computed and control information from other processing devices, and execute specified machine learning operations. . The machine learning computing device can obtain scalar type conversion instructions from other machine learning computing devices or non-machine learning computing devices, and transmit the execution results to peripheral devices (also called other processing devices) through the I/O interface. Peripherals such as camera, monitor, mouse, keyboard, network card, wifi interface, server. When more than one scalar type conversion instruction processing device is included, the scalar type conversion instruction processing devices can be linked through a specific structure and transmit data, for example, interconnect and transmit data through the PCIE bus to support larger-scale neural networks operation. At this time, the same control system can be shared, or there can be independent control systems; memory can be shared, or each accelerator can have its own memory. In addition, the interconnection method can be any interconnection topology.

该机器学习运算装置具有较高的兼容性,可通过PCIE接口与各种类型的服务器相连接。The machine learning computing device has high compatibility and can be connected with various types of servers through the PCIE interface.

图4a示出根据本公开一实施例的组合处理装置的框图。如图4a所示,该组合处理装置包括上述机器学习运算装置、通用互联接口和其他处理装置。机器学习运算装置与其他处理装置进行交互,共同完成用户指定的操作。FIG. 4a shows a block diagram of a combined processing apparatus according to an embodiment of the present disclosure. As shown in Fig. 4a, the combined processing device includes the above-mentioned machine learning computing device, a general interconnection interface and other processing devices. The machine learning computing device interacts with other processing devices to jointly complete the operation specified by the user.

其他处理装置,包括中央处理器CPU、图形处理器GPU、神经网络处理器等通用/专用处理器中的一种或以上的处理器类型。其他处理装置所包括的处理器数量不做限制。其他处理装置作为机器学习运算装置与外部数据和控制的接口,包括数据搬运,完成对本机器学习运算装置的开启、停止等基本控制;其他处理装置也可以和机器学习运算装置协作共同完成运算任务。Other processing devices include one or more processor types among general-purpose/special-purpose processors such as a central processing unit (CPU), a graphics processing unit (GPU), and a neural network processor. The number of processors included in other processing devices is not limited. Other processing devices serve as the interface between the machine learning computing device and external data and control, including data transfer, to complete the basic control of starting and stopping the machine learning computing device; other processing devices can also cooperate with the machine learning computing device to complete computing tasks.

通用互联接口,用于在机器学习运算装置与其他处理装置间传输数据和控制指令。该机器学习运算装置从其他处理装置中获取所需的输入数据,写入机器学习运算装置片上的存储装置;可以从其他处理装置中获取控制指令,写入机器学习运算装置片上的控制缓存;也可以读取机器学习运算装置的存储模块中的数据并传输给其他处理装置。A universal interconnect interface for transferring data and control instructions between machine learning computing devices and other processing devices. The machine learning computing device obtains required input data from other processing devices, and writes it into a storage device on-chip of the machine learning computing device; it can obtain control instructions from other processing devices and write it into the control cache on the machine learning computing device chip; The data in the storage module of the machine learning computing device can be read and transmitted to other processing devices.

图4b示出根据本公开一实施例的组合处理装置的框图。在一种可能的实现方式中,如图4b所示,该组合处理装置还可以包括存储装置,存储装置分别与机器学习运算装置和所述其他处理装置连接。存储装置用于保存在机器学习运算装置和所述其他处理装置的数据,尤其适用于所需要运算的数据在本机器学习运算装置或其他处理装置的内部存储中无法全部保存的数据。FIG. 4b shows a block diagram of a combined processing apparatus according to an embodiment of the present disclosure. In a possible implementation manner, as shown in FIG. 4b, the combined processing device may further include a storage device, and the storage device is respectively connected to the machine learning computing device and the other processing devices. The storage device is used to save data in the machine learning computing device and the other processing devices, and is especially suitable for data that cannot be fully stored in the internal storage of the machine learning computing device or other processing devices.

该组合处理装置可以作为手机、机器人、无人机、视频监控设备等设备的SOC片上系统,有效降低控制部分的核心面积,提高处理速度,降低整体功耗。此情况时,该组合处理装置的通用互联接口与设备的某些部件相连接。某些部件譬如摄像头,显示器,鼠标,键盘,网卡,wifi接口。The combined processing device can be used as an SOC system for mobile phones, robots, drones, video surveillance equipment and other equipment, effectively reducing the core area of the control part, improving the processing speed and reducing the overall power consumption. In this case, the general interconnection interface of the combined processing device is connected to certain components of the apparatus. Some components such as camera, monitor, mouse, keyboard, network card, wifi interface.

本公开提供一种机器学习芯片,该芯片包括上述机器学习运算装置或组合处理装置。The present disclosure provides a machine learning chip, which includes the above-mentioned machine learning computing device or combined processing device.

本公开提供一种机器学习芯片封装结构,该机器学习芯片封装结构包括上述机器学习芯片。The present disclosure provides a machine learning chip packaging structure, and the machine learning chip packaging structure includes the above-mentioned machine learning chip.

本公开提供一种板卡,图5示出根据本公开一实施例的板卡的结构示意图。如图5所示,该板卡包括上述机器学习芯片封装结构或者上述机器学习芯片。板卡除了包括机器学习芯片389以外,还可以包括其他的配套部件,该配套部件包括但不限于:存储器件390、接口装置391和控制器件392。The present disclosure provides a board, and FIG. 5 shows a schematic structural diagram of the board according to an embodiment of the present disclosure. As shown in FIG. 5 , the board includes the above-mentioned machine learning chip packaging structure or the above-mentioned machine learning chip. In addition to the machine learning chip 389 , the board may also include other supporting components, including but not limited to: a storage device 390 , an interface device 391 and a control device 392 .

存储器件390与机器学习芯片389(或者机器学习芯片封装结构内的机器学习芯片)通过总线连接,用于存储数据。存储器件390可以包括多组存储单元393。每一组存储单元393与机器学习芯片389通过总线连接。可以理解,每一组存储单元393可以是DDR SDRAM(英文:Double Data Rate SDRAM,双倍速率同步动态随机存储器)。The storage device 390 is connected to the machine learning chip 389 (or the machine learning chip in the machine learning chip package structure) through a bus for storing data. The memory device 390 may include groups of memory cells 393 . Each group of storage units 393 is connected to the machine learning chip 389 through a bus. It can be understood that each group of storage units 393 may be DDR SDRAM (English: Double Data Rate SDRAM, double-rate synchronous dynamic random access memory).

DDR不需要提高时钟频率就能加倍提高SDRAM的速度。DDR允许在时钟脉冲的上升沿和下降沿读出数据。DDR的速度是标准SDRAM的两倍。DDR does not need to increase the clock frequency to double the speed of SDRAM. DDR allows data to be read out on both the rising and falling edges of the clock pulse. DDR is twice as fast as standard SDRAM.

在一个实施例中,存储器件390可以包括4组存储单元393。每一组存储单元393可以包括多个DDR4颗粒(芯片)。在一个实施例中,机器学习芯片389内部可以包括4个72位DDR4控制器,上述72位DDR4控制器中64bit用于传输数据,8bit用于ECC校验。可以理解,当每一组存储单元393中采用DDR4-3200颗粒时,数据传输的理论带宽可达到25600MB/s。In one embodiment, the memory device 390 may include four sets of memory cells 393 . Each set of memory cells 393 may include a plurality of DDR4 particles (chips). In one embodiment, the machine learning chip 389 may include four 72-bit DDR4 controllers inside, where 64 bits of the 72-bit DDR4 controllers are used for data transmission and 8 bits are used for ECC verification. It can be understood that when DDR4-3200 particles are used in each group of storage units 393, the theoretical bandwidth of data transmission can reach 25600MB/s.

在一个实施例中,每一组存储单元393包括多个并联设置的双倍速率同步动态随机存储器。DDR在一个时钟周期内可以传输两次数据。在机器学习芯片389中设置控制DDR的控制器,用于对每个存储单元393的数据传输与数据存储的控制。In one embodiment, each set of memory cells 393 includes a plurality of double-rate synchronous dynamic random access memories arranged in parallel. DDR can transfer data twice in one clock cycle. A controller for controlling the DDR is provided in the machine learning chip 389 for controlling data transmission and data storage of each storage unit 393 .

接口装置391与机器学习芯片389(或者机器学习芯片封装结构内的机器学习芯片)电连接。接口装置391用于实现机器学习芯片389与外部设备(例如服务器或计算机)之间的数据传输。例如在一个实施例中,接口装置391可以为标准PCIE接口。比如,待处理的数据由服务器通过标准PCIE接口传递至机器学习芯片289,实现数据转移。优选的,当采用PCIE 3.0X 16接口传输时,理论带宽可达到16000MB/s。在另一个实施例中,接口装置391还可以是其他的接口,本公开并不限制上述其他的接口的具体表现形式,接口装置能够实现转接功能即可。另外,机器学习芯片的计算结果仍由接口装置传送回外部设备(例如服务器)。The interface device 391 is electrically connected to the machine learning chip 389 (or the machine learning chip within the machine learning chip package structure). The interface device 391 is used to realize data transmission between the machine learning chip 389 and an external device (such as a server or a computer). For example, in one embodiment, the interface device 391 may be a standard PCIE interface. For example, the data to be processed is transmitted by the server to the machine learning chip 289 through a standard PCIE interface to realize data transfer. Preferably, when the PCIE 3.0X 16 interface is used for transmission, the theoretical bandwidth can reach 16000MB/s. In another embodiment, the interface device 391 may also be other interfaces, and the present disclosure does not limit the specific expression forms of the other interfaces, as long as the interface device can realize the switching function. In addition, the calculation result of the machine learning chip is still transmitted back to the external device (such as a server) by the interface device.

控制器件392与机器学习芯片389电连接。控制器件392用于对机器学习芯片389的状态进行监控。具体的,机器学习芯片389与控制器件392可以通过SPI接口电连接。控制器件392可以包括单片机(Micro Controller Unit,MCU)。如机器学习芯片389可以包括多个处理芯片、多个处理核或多个处理电路,可以带动多个负载。因此,机器学习芯片389可以处于多负载和轻负载等不同的工作状态。通过控制器件可以实现对机器学习芯片中多个处理芯片、多个处理和/或多个处理电路的工作状态的调控。The control device 392 is electrically connected to the machine learning chip 389 . The control device 392 is used to monitor the state of the machine learning chip 389 . Specifically, the machine learning chip 389 and the control device 392 may be electrically connected through an SPI interface. The control device 392 may include a Micro Controller Unit (MCU). For example, the machine learning chip 389 may include multiple processing chips, multiple processing cores or multiple processing circuits, and may drive multiple loads. Therefore, the machine learning chip 389 can be in different working states such as multi-load and light-load. The control device can realize the regulation of the working states of multiple processing chips, multiple processing and/or multiple processing circuits in the machine learning chip.

本公开提供一种电子设备,该电子设备包括上述机器学习芯片或板卡。The present disclosure provides an electronic device including the above-mentioned machine learning chip or board.

电子设备可以包括数据处理装置、计算机设备、机器人、电脑、打印机、扫描仪、平板电脑、智能终端、手机、行车记录仪、导航仪、传感器、摄像头、服务器、云端服务器、相机、摄像机、投影仪、手表、耳机、移动存储、可穿戴设备、交通工具、家用电器、和/或医疗设备。Electronic equipment may include data processing devices, computer equipment, robots, computers, printers, scanners, tablet computers, smart terminals, mobile phones, driving recorders, navigators, sensors, cameras, servers, cloud servers, cameras, video cameras, and projectors , watches, headphones, mobile storage, wearables, vehicles, home appliances, and/or medical equipment.

交通工具可以包括飞机、轮船和/或车辆。家用电器可以包括电视、空调、微波炉、冰箱、电饭煲、加湿器、洗衣机、电灯、燃气灶、油烟机。医疗设备可以包括核磁共振仪、B超仪和/或心电图仪。Vehicles may include aircraft, ships and/or vehicles. Household appliances may include televisions, air conditioners, microwave ovens, refrigerators, rice cookers, humidifiers, washing machines, electric lights, gas stoves, and range hoods. Medical equipment may include MRI machines, ultrasound machines and/or electrocardiographs.

图6示出根据本公开一实施例的标量类型转换指令处理方法的流程图。该方法可以应用于包含存储器和处理器的如计算机设备等,其中,存储器用于存储执行方法过程中所使用的数据;处理器用于执行相关的处理、运算步骤,如执行下述步骤S51和步骤S52。如图6所示,该方法应用于上述标量类型转换指令处理装置,该方法包括步骤S51和步骤S52。FIG. 6 shows a flowchart of a method for processing a scalar type conversion instruction according to an embodiment of the present disclosure. The method can be applied to a computer device that includes a memory and a processor, wherein the memory is used to store data used in the process of executing the method; the processor is used to execute related processing and operation steps, such as executing the following steps S51 and steps S52. As shown in FIG. 6, the method is applied to the above-mentioned scalar type conversion instruction processing apparatus, and the method includes step S51 and step S52.

在步骤S51中,利用控制模块对获取到的标量类型转换指令进行解析,得到标量类型转换指令的操作码和操作域,并根据操作码和操作域获取执行标量类型转换指令所需的待运算标量和目标地址,以及确定目标数据类型和待运算标量的初始数据类型。其中,操作码用于指示标量类型转换指令对数据所进行的运算为标量类型转换运算,操作域包括待运算标量地址和目标地址。In step S51, the acquired scalar type conversion instruction is parsed by the control module, the operation code and operation field of the scalar type conversion instruction are obtained, and the scalar to be operated required for executing the scalar type conversion instruction is obtained according to the operation code and operation field and the destination address, as well as determine the destination data type and the initial data type of the scalar to be operated on. The operation code is used to indicate that the operation performed by the scalar type conversion instruction on the data is a scalar type conversion operation, and the operation domain includes the scalar address to be operated and the target address.

在步骤S52中,利用运算模块根据目标数据类型对初始数据类型的待运算标量进行标量类型转换运算,获得运算结果,并将运算结果存入目标地址中,运算结果的数据类型为目标数据类型。In step S52, use the operation module to perform scalar type conversion operation on the scalar to be operated on the initial data type according to the target data type, obtain the operation result, and store the operation result in the target address, and the data type of the operation result is the target data type.

在一种可能的实现方式中,根据目标数据类型对初始数据类型的待运算标量进行标量类型转换运算,可以包括:In a possible implementation manner, performing a scalar type conversion operation on the scalar to be operated on the initial data type according to the target data type, which may include:

利用运算模块中的多个标量运算器执行标量类型转换运算。Use multiple scalar operators in the operation module to perform scalar type conversion operations.

在一种可能的实现方式中,运算模块包括主运算子模块和多个从运算子模块,主运算子模块包括多个标量运算器。其中,步骤S52可以包括:In a possible implementation manner, the operation module includes a master operation submodule and multiple slave operation submodules, and the master operation submodule includes multiple scalar operators. Wherein, step S52 may include:

利用主运算子模块中的多个标量运算器执行标量类型转换运算,得到运算结果,并将运算结果存入目标地址中。Use multiple scalar operators in the main operation sub-module to perform scalar type conversion operation, obtain the operation result, and store the operation result in the target address.

在一种可能的实现方式中,操作域还可以包括初始数据类型和目标数据类型,步骤S51可以包括:根据操作域确定目标数据类型和待运算标量的初始数据类型。In a possible implementation manner, the operation domain may further include an initial data type and a target data type, and step S51 may include: determining the target data type and the initial data type of the scalar to be operated according to the operation domain.

在一种可能的实现方式中,操作码还用于指示初始数据类型和目标数据类型,步骤S51可以包括:根据操作码确定目标数据类型和待运算标量的初始数据类型In a possible implementation manner, the operation code is also used to indicate the initial data type and the target data type, and step S51 may include: determining the target data type and the initial data type of the scalar to be operated according to the operation code

在一种可能的实现方式中,目标数据类型可以包括16位浮点数、32位浮点数、48位浮点数、16位整数、32位整数和48位整数中的任意一种,初始数据类型可以包括16位有符号数、32位有符号数、48位有符号数、16位无符号数、32位无符号数、48位无符号数和指针数据类型中的任意一种。In a possible implementation manner, the target data type may include any one of 16-bit floating point numbers, 32-bit floating point numbers, 48-bit floating point numbers, 16-bit integers, 32-bit integers, and 48-bit integers, and the initial data type may be Including any one of 16-bit signed number, 32-bit signed number, 48-bit signed number, 16-bit unsigned number, 32-bit unsigned number, 48-bit unsigned number and pointer data types.

在一种可能的实现方式中,该方法还可以包括:利用装置的存储模块存储待运算标量,In a possible implementation manner, the method may further include: using a storage module of the device to store the scalar to be calculated,

其中,存储模块包括寄存器和缓存中的至少一种,Wherein, the storage module includes at least one of a register and a cache,

缓存,用于存储待运算数据,缓存包括至少一个神经元缓存NRAM;The cache is used to store the data to be operated, and the cache includes at least one neuron cache NRAM;

寄存器,用于存储待运算标量;Register, used to store the scalar to be operated;

神经元缓存,用于存储待运算数据中的神经元数据,神经元数据包括神经元向量数据。The neuron cache is used to store neuron data in the data to be operated, and the neuron data includes neuron vector data.

在一种可能的实现方式中,步骤S51可以包括:In a possible implementation, step S51 may include:

存储标量类型转换指令;Store scalar type conversion instructions;

对标量类型转换指令进行解析,得到标量类型转换指令的操作码和操作域;Parse the scalar type conversion instruction to obtain the opcode and operation field of the scalar type conversion instruction;

存储指令队列,指令队列包括按照执行顺序依次排列的多个待执行指令,多个待执行指令可以包括标量类型转换指令。An instruction queue is stored, and the instruction queue includes multiple instructions to be executed sequentially arranged in an execution order, and the multiple instructions to be executed may include scalar type conversion instructions.

在一种可能的实现方式中,该方法还可以包括:In a possible implementation, the method may further include:

在确定多个待执行指令中的第一待执行指令与第一待执行指令之前的第零待执行指令存在关联关系时,缓存第一待执行指令,并在确定第零待执行指令执行完毕后,控制进行第一待执行指令的执行,When it is determined that the first to-be-executed instruction in the plurality of to-be-executed instructions has an associated relationship with the zeroth to-be-executed instruction before the first to-be-executed instruction, the first to-be-executed instruction is cached, and after it is determined that the zeroth to-be-executed instruction is executed , control the execution of the first instruction to be executed,

其中,第一待执行指令与第一待执行指令之前的第零待执行指令存在关联关系包括:Wherein, the relationship between the first instruction to be executed and the zeroth instruction to be executed before the first instruction to be executed includes:

存储第一待执行指令所需数据的第一存储地址区间与存储第零待执行指令所需数据的第零存储地址区间具有重叠的区域。The first storage address interval storing the data required by the first instruction to be executed and the zeroth storage address interval storing the data required by the zeroth instruction to be executed have an overlapping area.

需要说明的是,尽管以上述实施例作为示例介绍了标量类型转换指令处理方法如上,但本领域技术人员能够理解,本公开应不限于此。事实上,用户完全可根据个人喜好和/或实际应用场景灵活设定各步骤,只要符合本公开的技术方案即可。It should be noted that although the above-mentioned embodiment is used as an example to describe the processing method of a scalar type conversion instruction as above, those skilled in the art can understand that the present disclosure should not be limited thereto. In fact, the user can flexibly set each step according to personal preference and/or actual application scenarios, as long as it conforms to the technical solutions of the present disclosure.

本公开实施例所提供的标量类型转换指令处理方法的适用范围广,对标量类型转换指令的处理效率高、处理速度快,进行标量类型转换的处理效率高、处理速度快。The scalar type conversion instruction processing method provided by the embodiment of the present disclosure has a wide range of applications, and has high processing efficiency and fast processing speed for scalar type conversion instructions, and high processing efficiency and fast processing speed for scalar type conversion.

本公开还提供一种非易失性计算机可读存储介质,其上存储有计算机程序指令,所述计算机程序指令被处理器执行时实现上述标量类型转换指令处理方法。The present disclosure also provides a non-volatile computer-readable storage medium on which computer program instructions are stored, and when the computer program instructions are executed by a processor, implement the above-mentioned scalar type conversion instruction processing method.

需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本披露并不受所描述的动作顺序的限制,因为依据本披露,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于可选实施例,所涉及的动作和模块并不一定是本披露所必须的。It should be noted that, for the sake of simple description, the foregoing method embodiments are all expressed as a series of action combinations, but those skilled in the art should know that the present disclosure is not limited by the described action sequence. As in accordance with the present disclosure, certain steps may be performed in other orders or concurrently. Secondly, those skilled in the art should also know that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present disclosure.

进一步需要说明的是,虽然图6的流程图中的各个步骤按照箭头的指示依次显示,但是这些步骤并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些步骤的执行并没有严格的顺序限制,这些步骤可以以其它的顺序执行。而且,图6中的至少一部分步骤可以包括多个子步骤或者多个阶段,这些子步骤或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些子步骤或者阶段的执行顺序也不必然是依次进行,而是可以与其它步骤或者其它步骤的子步骤或者阶段的至少一部分轮流或者交替地执行。It should be further noted that although the steps in the flowchart of FIG. 6 are displayed in sequence according to the arrows, these steps are not necessarily executed in the sequence indicated by the arrows. Unless explicitly stated herein, the execution of these steps is not strictly limited to the order, and these steps may be performed in other orders. Moreover, at least a part of the steps in FIG. 6 may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed and completed at the same time, but may be executed at different times. The execution of these sub-steps or stages The sequence is also not necessarily sequential, but may be performed alternately or alternately with other steps or sub-steps of other steps or at least a portion of a phase.

应该理解,上述的装置实施例仅是示意性的,本披露的装置还可通过其它的方式实现。例如,上述实施例中所述单元/模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。例如,多个单元、模块或组件可以结合,或者可以集成到另一个系统,或一些特征可以忽略或不执行。It should be understood that the above device embodiments are only illustrative, and the device of the present disclosure can also be implemented in other ways. For example, the division of units/modules described in the above embodiments is only a logical function division, and other division methods may be used in actual implementation. For example, multiple units, modules or components may be combined, or may be integrated into another system, or some features may be omitted or not implemented.

另外,若无特别说明,在本披露各个实施例中的各功能单元/模块可以集成在一个单元/模块中,也可以是各个单元/模块单独物理存在,也可以两个或两个以上单元/模块集成在一起。上述集成的单元/模块既可以采用硬件的形式实现,也可以采用软件程序模块的形式实现。In addition, unless otherwise specified, each functional unit/module in each embodiment of the present disclosure may be integrated into one unit/module, or each unit/module may exist physically alone, or two or more units/modules may exist. modules are integrated together. The above-mentioned integrated units/modules can be implemented in the form of hardware, or can be implemented in the form of software program modules.

所述集成的单元/模块如果以硬件的形式实现时,该硬件可以是数字电路,模拟电路等等。硬件结构的物理实现包括但不局限于晶体管,忆阻器等等。若无特别说明,若无特别说明,上述存储模块可以是任何适当的磁存储介质或者磁光存储介质,比如,阻变式存储器RRAM(Resistive Random Access Memory)、动态随机存取存储器DRAM(Dynamic RandomAccess Memory)、静态随机存取存储器SRAM(Static Random-Access Memory)、增强动态随机存取存储器EDRAM(Enhanced Dynamic Random Access Memory)、高带宽内存HBM(High-Bandwidth Memory)、混合存储立方HMC(Hybrid Memory Cube)等等。If the integrated unit/module is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, or the like. Physical implementations of hardware structures include, but are not limited to, transistors, memristors, and the like. Unless otherwise specified, the above-mentioned storage module can be any suitable magnetic storage medium or magneto-optical storage medium, for example, resistive random access memory (RRAM), dynamic random access memory (DRAM) Memory), static random access memory SRAM (Static Random-Access Memory), enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), high bandwidth memory HBM (High-Bandwidth Memory), hybrid storage cube HMC (Hybrid Memory) Cube) and so on.

所述集成的单元/模块如果以软件程序模块的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储器中。基于这样的理解,本披露的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储器中,包括若干指令用以使得一台计算机设备(可为个人计算机、服务器或者网络设备等)执行本披露各个实施例所述方法的全部或部分步骤。而前述的存储器包括:U盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。The integrated unit/module, if implemented in the form of a software program module and sold or used as a stand-alone product, may be stored in a computer readable memory. Based on this understanding, the technical solutions of the present disclosure essentially or the part that contributes to the prior art or the whole or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory, Several instructions are included to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present disclosure. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.

在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。上述实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。In the above-mentioned embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference may be made to the relevant descriptions of other embodiments. The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, it should be It is considered to be the range described in this specification.

依据以下条款可以更好的理解前述内容:The foregoing can be better understood in accordance with the following terms:

条款A1、一种标量类型转换指令处理装置,所述装置包括:Clause A1. A scalar type conversion instruction processing apparatus, the apparatus comprising:

控制模块,用于对获取到的标量类型转换指令进行解析,得到标量类型转换指令的操作码和操作域,并根据所述操作码和所述操作域获取执行标量类型转换指令所需的待运算标量和目标地址,以及确定目标数据类型和所述待运算标量的初始数据类型;The control module is used to parse the acquired scalar type conversion instruction, obtain the operation code and operation field of the scalar type conversion instruction, and obtain the pending operation required to execute the scalar type conversion instruction according to the operation code and the operation field scalar and target address, and determine the target data type and the initial data type of the scalar to be operated;

运算模块,用于根据所述目标数据类型对初始数据类型的所述待运算标量进行标量类型转换运算,获得运算结果,并将所述运算结果存入所述目标地址中,所述运算结果的数据类型为所述目标数据类型,The operation module is configured to perform a scalar type conversion operation on the to-be-operated scalar of the initial data type according to the target data type, obtain an operation result, and store the operation result in the target address. the data type is the target data type,

其中,所述操作码用于指示所述标量类型转换指令对数据所进行的运算为标量类型转换运算,所述操作域包括待运算标量地址和所述目标地址。The operation code is used to indicate that the operation performed by the scalar type conversion instruction on the data is a scalar type conversion operation, and the operation field includes the scalar address to be operated and the target address.

条款A2、根据条款A1所述的装置,所述运算模块,包括:Clause A2. The device according to Clause A1, the operation module, comprising:

多个标量运算器,用于执行所述标量类型转换运算。a plurality of scalar operators for performing the scalar type conversion operation.

条款A3、根据条款A2所述的装置,所述运算模块包括主运算子模块和多个从运算子模块,所述主运算子模块包括所述多个标量运算器,Clause A3. The apparatus of Clause A2, the operation module comprising a master operation sub-module and a plurality of slave operation sub-modules, the master operation sub-module including the plurality of scalar operators,

所述主运算子模块,用于利用所述多个标量运算器执行所述标量类型转换运算,得到运算结果,并将所述运算结果存入所述目标地址中。The main operation submodule is configured to use the plurality of scalar operators to perform the scalar type conversion operation, obtain an operation result, and store the operation result in the target address.

条款A4、根据条款A1所述的装置,所述操作域还包括初始数据类型和目标数据类型,Clause A4. The apparatus according to Clause A1, wherein the operation domain further includes an initial data type and a target data type,

其中,所述控制模块,还用于根据所述操作域确定目标数据类型和所述待运算标量的初始数据类型。Wherein, the control module is further configured to determine the target data type and the initial data type of the to-be-operated scalar according to the operation domain.

条款A5、根据条款A1所述的装置,所述操作码还用于指示初始数据类型和目标数据类型,Clause A5. The apparatus of Clause A1, wherein the opcode is further used to indicate an initial data type and a target data type,

其中,所述控制模块,还用于根据所述操作码确定目标数据类型和所述待运算标量的初始数据类型。Wherein, the control module is further configured to determine the target data type and the initial data type of the to-be-operated scalar according to the operation code.

条款A6、根据条款A1所述的装置,所述目标数据类型包括16位浮点数、32位浮点数、48位浮点数、16位整数、32位整数和48位整数中的任意一种,所述初始数据类型包括16位有符号数、32位有符号数、48位有符号数、16位无符号数、32位无符号数、48位无符号数和指针数据类型中的任意一种。Clause A6. The apparatus according to Clause A1, wherein the target data type includes any one of 16-bit floating-point numbers, 32-bit floating-point numbers, 48-bit floating-point numbers, 16-bit integers, 32-bit integers, and 48-bit integers, so The initial data type includes any one of 16-bit signed number, 32-bit signed number, 48-bit signed number, 16-bit unsigned number, 32-bit unsigned number, 48-bit unsigned number and pointer data types.

条款A7、根据条款A1所述的装置,所述装置还包括:Clause A7. The apparatus of clause A1, further comprising:

存储模块,用于存储所述待运算标量,a storage module for storing the to-be-operated scalar,

其中,所述存储模块包括寄存器和缓存中的至少一种,Wherein, the storage module includes at least one of a register and a cache,

所述缓存,用于存储所述待运算数据,所述缓存包括至少一个神经元缓存NRAM;The cache is used to store the data to be calculated, and the cache includes at least one neuron cache NRAM;

所述寄存器,用于存储所述待运算标量;the register for storing the to-be-operated scalar;

所述神经元缓存,用于存储所述待运算数据中的神经元数据,所述神经元数据包括神经元向量数据。The neuron cache is used to store neuron data in the data to be operated, and the neuron data includes neuron vector data.

条款A8、根据条款A1所述的装置,所述控制模块包括:Clause A8. The apparatus of clause A1, the control module comprising:

指令存储子模块,用于存储所述标量类型转换指令;an instruction storage submodule for storing the scalar type conversion instruction;

指令处理子模块,用于对所述标量类型转换指令进行解析,得到标量类型转换指令的操作码和操作域;an instruction processing submodule, used for parsing the scalar type conversion instruction to obtain the operation code and operation domain of the scalar type conversion instruction;

队列存储子模块,用于存储指令队列,所述指令队列包括按照执行顺序依次排列的多个待执行指令,所述多个待执行指令包括所述标量类型转换指令。The queue storage submodule is used to store an instruction queue, where the instruction queue includes a plurality of instructions to be executed sequentially arranged in an execution order, and the multiple instructions to be executed include the scalar type conversion instruction.

条款A9、根据条款A8所述的装置,所述控制模块,还包括:Clause A9. The apparatus according to Clause A8, the control module, further comprising:

依赖关系处理子模块,用于在确定所述多个待执行指令中的第一待执行指令与所述第一待执行指令之前的第零待执行指令存在关联关系时,将所述第一待执行指令缓存在所述指令存储子模块中,在所述第零待执行指令执行完毕后,从所述指令存储子模块中提取所述第一待执行指令发送至所述运算模块,The dependency relationship processing submodule is configured to, when it is determined that the first to-be-executed instruction in the plurality of to-be-executed instructions has an associated relationship with the zeroth to-be-executed instruction before the first to-be-executed instruction, to process the first to-be-executed instruction The execution instruction is cached in the instruction storage sub-module, and after the execution of the zeroth instruction to be executed is completed, the first instruction to be executed is extracted from the instruction storage sub-module and sent to the operation module,

其中,所述第一待执行指令与所述第一待执行指令之前的第零待执行指令存在关联关系包括:Wherein, the relationship between the first instruction to be executed and the zeroth instruction to be executed before the first instruction to be executed includes:

存储所述第一待执行指令所需数据的第一存储地址区间与存储所述第零待执行指令所需数据的第零存储地址区间具有重叠的区域。The first storage address interval storing the data required by the first instruction to be executed and the zeroth storage address interval storing the data required by the zeroth instruction to be executed have an overlapping area.

条款A10、一种机器学习运算装置,所述装置包括:Clause A10. A machine learning computing device, the device comprising:

一个或多个如条款A1-条款A9任一项所述的标量类型转换指令处理装置,用于从其他处理装置中获取待运算标量和控制信息,并执行指定的机器学习运算,将执行结果通过I/O接口传递给其他处理装置;One or more scalar type conversion instruction processing devices as described in any one of Clause A1 to Clause A9, used to obtain the scalar to be calculated and control information from other processing means, and execute the specified machine learning operation, and pass the execution result through. The I/O interface is passed to other processing devices;

当所述机器学习运算装置包含多个所述标量类型转换指令处理装置时,所述多个所述标量类型转换指令处理装置间可以通过特定的结构进行连接并传输数据;When the machine learning computing device includes a plurality of the scalar type conversion instruction processing devices, the plurality of the scalar type conversion instruction processing devices can be connected through a specific structure and data can be transmitted;

其中,多个所述标量类型转换指令处理装置通过快速外部设备互连总线PCIE总线进行互联并传输数据,以支持更大规模的机器学习的运算;多个所述标量类型转换指令处理装置共享同一控制系统或拥有各自的控制系统;多个所述标量类型转换指令处理装置共享内存或者拥有各自的内存;多个所述标量类型转换指令处理装置的互联方式是任意互联拓扑。Wherein, a plurality of the scalar type conversion instruction processing devices are interconnected and transmit data through the fast peripheral device interconnection bus PCIE bus to support larger-scale machine learning operations; a plurality of the scalar type conversion instruction processing devices share the same The control system may have its own control system; a plurality of the scalar type conversion instruction processing devices share memory or have their own memory; the interconnection mode of the plurality of scalar type conversion instruction processing devices is any interconnection topology.

条款A11、一种组合处理装置,所述组合处理装置包括:Clause A11. A combined processing device, the combined processing device comprising:

如条款A10所述的机器学习运算装置、通用互联接口和其他处理装置;Machine learning computing devices, general interconnection interfaces and other processing devices as described in Clause A10;

所述机器学习运算装置与所述其他处理装置进行交互,共同完成用户指定的计算操作,The machine learning computing device interacts with the other processing devices to jointly complete the computing operation specified by the user,

其中,所述组合处理装置还包括:存储装置,该存储装置分别与所述机器学习运算装置和所述其他处理装置连接,用于保存所述机器学习运算装置和所述其他处理装置的数据。Wherein, the combined processing device further includes: a storage device, the storage device is respectively connected to the machine learning computing device and the other processing device, and is used for saving the data of the machine learning computing device and the other processing device.

条款A12、一种机器学习芯片,所述机器学习芯片包括:Clause A12. A machine learning chip, the machine learning chip comprising:

如条款A10所述的机器学习运算装置或如条款A11所述的组合处理装置。The machine learning computing device as described in Item A10 or the combined processing device as described in Item A11.

条款A13、一种电子设备,所述电子设备包括:Clause A13, an electronic device, the electronic device comprising:

如条款A12所述的机器学习芯片。A machine learning chip as described in Item A12.

条款A14、一种板卡,所述板卡包括:存储器件、接口装置和控制器件以及如条款A12所述的机器学习芯片;Item A14. A board, the board comprising: a storage device, an interface device and a control device, and the machine learning chip as described in Item A12;

其中,所述机器学习芯片与所述存储器件、所述控制器件以及所述接口装置分别连接;Wherein, the machine learning chip is connected to the storage device, the control device and the interface device respectively;

所述存储器件,用于存储数据;the storage device for storing data;

所述接口装置,用于实现所述机器学习芯片与外部设备之间的数据传输;The interface device is used to realize data transmission between the machine learning chip and an external device;

所述控制器件,用于对所述机器学习芯片的状态进行监控。The control device is used for monitoring the state of the machine learning chip.

条款A15、一种标量类型转换指令处理方法,所述方法应用于标量类型转换指令处理装置,所述装置包括控制模块和运算模块,所述方法包括:Clause A15. A scalar type conversion instruction processing method, the method is applied to a scalar type conversion instruction processing apparatus, the apparatus includes a control module and an operation module, and the method includes:

利用控制模块对获取到的标量类型转换指令进行解析,得到标量类型转换指令的操作码和操作域,并根据所述操作码和所述操作域获取执行标量类型转换指令所需的待运算标量和目标地址,以及确定目标数据类型和所述待运算标量的初始数据类型;Use the control module to parse the acquired scalar type conversion instruction, obtain the operation code and operation field of the scalar type conversion instruction, and obtain the scalar to be calculated and the operation field required to execute the scalar type conversion instruction according to the operation code and the operation field target address, and determine the target data type and the initial data type of the to-be-operated scalar;

利用运算模块根据所述目标数据类型对初始数据类型的所述待运算标量进行标量类型转换运算,获得运算结果,并将所述运算结果存入所述目标地址中,所述运算结果的数据类型为所述目标数据类型,The operation module is used to perform a scalar type conversion operation on the to-be-operated scalar of the initial data type according to the target data type, obtain an operation result, and store the operation result in the target address. The data type of the operation result is for the target data type,

其中,所述操作码用于指示所述标量类型转换指令对数据所进行的运算为标量类型转换运算,所述操作域包括待运算标量地址和所述目标地址。The operation code is used to indicate that the operation performed by the scalar type conversion instruction on the data is a scalar type conversion operation, and the operation field includes the scalar address to be operated and the target address.

条款A16、根据条款A15所述的方法,根据所述目标数据类型对初始数据类型的所述待运算标量进行标量类型转换运算,包括:Item A16. The method according to Item A15, performing a scalar type conversion operation on the to-be-operated scalar of the initial data type according to the target data type, including:

利用所述运算模块中的多个标量运算器执行所述标量类型转换运算。The scalar type conversion operation is performed by using a plurality of scalar operators in the operation module.

条款A17、根据条款A16所述的方法,所述运算模块包括主运算子模块和多个从运算子模块,所述主运算子模块包括所述多个标量运算器,Clause A17. The method according to Clause A16, wherein the operation module includes a master operation submodule and a plurality of slave operation submodules, the master operation submodule includes the plurality of scalar operators,

其中,根据所述目标数据类型对初始数据类型的所述待运算标量进行标量类型转换运算,获得运算结果,并将所述运算结果存入所述目标地址中,包括:Wherein, performing a scalar type conversion operation on the to-be-operated scalar of the initial data type according to the target data type, obtaining an operation result, and storing the operation result in the target address, including:

利用所述主运算子模块中的多个标量运算器执行所述标量类型转换运算,得到运算结果,并将所述运算结果存入所述目标地址中。The scalar type conversion operation is performed by using a plurality of scalar operators in the main operation submodule to obtain an operation result, and the operation result is stored in the target address.

条款A18、根据条款A15所述的方法,所述操作域还包括初始数据类型和目标数据类型,Clause A18. The method according to Clause A15, wherein the operation domain further includes an initial data type and a target data type,

其中,确定目标数据类型和所述待运算标量的初始数据类型,包括:Wherein, determining the target data type and the initial data type of the to-be-operated scalar includes:

根据所述操作域确定目标数据类型和所述待运算标量的初始数据类型。The target data type and the initial data type of the to-be-operated scalar are determined according to the operation domain.

条款A19、根据条款A15所述的方法,所述操作码还用于指示初始数据类型和目标数据类型,Clause A19. The method of clause A15, wherein the opcode is further used to indicate an initial data type and a target data type,

其中,确定目标数据类型和所述待运算标量的初始数据类型,包括:Wherein, determining the target data type and the initial data type of the to-be-operated scalar includes:

根据所述操作码确定目标数据类型和所述待运算标量的初始数据类型。The target data type and the initial data type of the to-be-operated scalar are determined according to the operation code.

条款A20、根据条款A15所述的方法,所述目标数据类型包括16位浮点数、32位浮点数、48位浮点数、16位整数、32位整数和48位整数中的任意一种,所述初始数据类型包括16位有符号数、32位有符号数、48位有符号数、16位无符号数、32位无符号数、48位无符号数和指针数据类型中的任意一种。Clause A20. The method according to Clause A15, wherein the target data type includes any one of 16-bit floating-point numbers, 32-bit floating-point numbers, 48-bit floating-point numbers, 16-bit integers, 32-bit integers, and 48-bit integers, so The initial data type includes any one of 16-bit signed number, 32-bit signed number, 48-bit signed number, 16-bit unsigned number, 32-bit unsigned number, 48-bit unsigned number and pointer data types.

条款A21、根据条款A16所述的方法,所述方法还包括:Clause A21. The method according to Clause A16, the method further comprising:

利用所述装置的存储模块存储所述待运算标量,Using the storage module of the device to store the to-be-operated scalar,

其中,所述存储模块包括寄存器和缓存中的至少一种,Wherein, the storage module includes at least one of a register and a cache,

所述缓存,用于存储所述待运算数据,所述缓存包括至少一个神经元缓存NRAM;The cache is used to store the data to be calculated, and the cache includes at least one neuron cache NRAM;

所述寄存器,用于存储所述待运算标量;the register for storing the to-be-operated scalar;

所述神经元缓存,用于存储所述待运算数据中的神经元数据,所述神经元数据包括神经元向量数据。The neuron cache is used to store neuron data in the data to be operated, and the neuron data includes neuron vector data.

条款A22、根据条款A15所述的方法,对所述标量类型转换指令进行解析,得到标量类型转换指令的操作码和操作域,包括:Item A22. According to the method described in Item A15, parse the scalar type conversion instruction to obtain the operation code and operation domain of the scalar type conversion instruction, including:

存储所述标量类型转换指令;storing the scalar type conversion instruction;

对所述标量类型转换指令进行解析,得到标量类型转换指令的操作码和操作域;Analyzing the scalar type conversion instruction to obtain the operation code and operation domain of the scalar type conversion instruction;

存储指令队列,所述指令队列包括按照执行顺序依次排列的多个待执行指令,所述多个待执行指令包括所述标量类型转换指令。An instruction queue is stored, where the instruction queue includes a plurality of instructions to be executed sequentially arranged in an execution order, and the multiple instructions to be executed include the scalar type conversion instruction.

条款A23、根据条款A22所述的方法,所述方法还包括:Clause A23. The method according to Clause A22, the method further comprising:

在确定所述多个待执行指令中的第一待执行指令与所述第一待执行指令之前的第零待执行指令存在关联关系时,缓存所述第一待执行指令,并在确定所述第零待执行指令执行完毕后,控制进行所述第一待执行指令的执行,When it is determined that the first to-be-executed instruction in the plurality of to-be-executed instructions has an associated relationship with the zeroth to-be-executed instruction before the first to-be-executed instruction, the first to-be-executed instruction is cached, and the first to-be-executed instruction is determined when the After the execution of the zeroth instruction to be executed is completed, the execution of the first instruction to be executed is controlled to be executed,

其中,所述第一待执行指令与所述第一待执行指令之前的第零待执行指令存在关联关系包括:Wherein, the relationship between the first instruction to be executed and the zeroth instruction to be executed before the first instruction to be executed includes:

存储所述第一待执行指令所需数据的第一存储地址区间与存储所述第零待执行指令所需数据的第零存储地址区间具有重叠的区域。The first storage address interval storing the data required by the first instruction to be executed and the zeroth storage address interval storing the data required by the zeroth instruction to be executed have an overlapping area.

条款A24、一种非易失性计算机可读存储介质,其上存储有计算机程序指令,所述计算机程序指令被处理器执行时实现条款A15至条款A23任一项所述的方法。Clause A24. A non-transitory computer-readable storage medium having stored thereon computer program instructions that, when executed by a processor, implement the method of any one of clauses A15 to A23.

以上对本申请实施例进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的一般技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。The embodiments of the present application have been introduced in detail above, and the principles and implementations of the present application are described in this paper by using specific examples. The descriptions of the above embodiments are only used to help understand the methods and core ideas of the present application; at the same time, for Persons of ordinary skill in the art, based on the idea of the present application, will have changes in the specific implementation manner and application scope. In summary, the contents of this specification should not be construed as limitations on the present application.

Claims (10)

1. An apparatus for processing scalar type conversion instructions, the apparatus comprising:
the control module is used for analyzing the obtained scalar type conversion instruction to obtain an operation code and an operation domain of the scalar type conversion instruction, obtaining a scalar to be operated and a target address which are required by executing the scalar type conversion instruction according to the operation code and the operation domain, and determining a target data type and an initial data type of the scalar to be operated;
the operation module is used for carrying out scalar type conversion operation on the scalar to be operated of the initial data type according to the target data type to obtain an operation result and storing the operation result into the target address, wherein the data type of the operation result is the target data type,
the operation code is used for indicating that the operation performed on data by the scalar type conversion instruction is a scalar type conversion operation, and the operation domain comprises a scalar address to be operated on and the target address.
2. The apparatus of claim 1, wherein the computing module comprises:
a plurality of scalar operators for performing the scalar type conversion operations.
3. The apparatus of claim 2, wherein the operation module comprises a master operation submodule and a plurality of slave operation submodule, the master operation submodule comprising the plurality of scalar operators,
and the main operation sub-module is used for executing the scalar type conversion operation by utilizing the scalar operators to obtain an operation result and storing the operation result into the target address.
4. A machine learning arithmetic device, the device comprising:
one or more scalar type conversion instruction processing devices according to any one of claims 1 to 3, for obtaining scalar to be operated and control information from other processing devices, executing a specified machine learning operation, and transmitting the execution result to other processing devices through an I/O interface;
when the machine learning operation device comprises a plurality of scalar type conversion instruction processing devices, the scalar type conversion instruction processing devices can be connected through a specific structure and transmit data;
the scalar type conversion instruction processing devices are interconnected through a Peripheral Component Interface Express (PCIE) bus and transmit data so as to support larger-scale machine learning operation; a plurality of scalar type conversion instruction processing devices share the same control system or own respective control systems; the scalar type conversion instruction processing devices share a memory or own respective memories; the interconnection mode of the scalar type conversion instruction processing devices is any interconnection topology.
5. A combined processing apparatus, characterized in that the combined processing apparatus comprises:
the machine learning computing device, the universal interconnect interface, and the other processing device of claim 4;
the machine learning arithmetic device interacts with the other processing devices to jointly complete the calculation operation designated by the user,
wherein the combination processing apparatus further comprises: and a storage device connected to the machine learning arithmetic device and the other processing device, respectively, for storing data of the machine learning arithmetic device and the other processing device.
6. A machine learning chip, the machine learning chip comprising:
the machine learning arithmetic device according to claim 4 or the combined processing device according to claim 5.
7. An electronic device, characterized in that the electronic device comprises:
the machine learning chip of claim 6.
8. The utility model provides a board card, its characterized in that, the board card includes: a memory device, an interface device and a control device and a machine learning chip according to claim 6;
wherein the machine learning chip is connected with the storage device, the control device and the interface device respectively;
the storage device is used for storing data;
the interface device is used for realizing data transmission between the machine learning chip and external equipment;
and the control device is used for monitoring the state of the machine learning chip.
9. A scalar type conversion instruction processing method is applied to a scalar type conversion instruction processing apparatus including a control module and an operation module, and includes:
analyzing the obtained scalar type conversion instruction by using a control module to obtain an operation code and an operation domain of the scalar type conversion instruction, obtaining a scalar to be operated and a target address required by executing the scalar type conversion instruction according to the operation code and the operation domain, and determining a target data type and an initial data type of the scalar to be operated;
performing scalar type conversion operation on the scalar to be operated of the initial data type by using an operation module according to the target data type to obtain an operation result, storing the operation result into the target address, wherein the data type of the operation result is the target data type,
the operation code is used for indicating that the operation performed on data by the scalar type conversion instruction is a scalar type conversion operation, and the operation domain comprises a scalar address to be operated on and the target address.
10. A non-transitory computer readable storage medium having computer program instructions stored thereon, wherein the computer program instructions, when executed by a processor, implement the method of claim 9.
CN201910625443.2A 2018-10-09 2019-07-11 Computing methods, devices, computer equipment and storage media Active CN111275197B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/CN2019/110167 WO2020073925A1 (en) 2018-10-09 2019-10-09 Operation method and apparatus, computer device and storage medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201811481630 2018-12-05
CN201811481630X 2018-12-05

Publications (2)

Publication Number Publication Date
CN111275197A true CN111275197A (en) 2020-06-12
CN111275197B CN111275197B (en) 2023-11-10

Family

ID=71002923

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910625443.2A Active CN111275197B (en) 2018-10-09 2019-07-11 Computing methods, devices, computer equipment and storage media

Country Status (1)

Country Link
CN (1) CN111275197B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114281468A (en) * 2020-09-28 2022-04-05 中科寒武纪科技股份有限公司 Apparatus, related method and readable storage medium for implementing thermal migration

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090198977A1 (en) * 2008-01-31 2009-08-06 Gschwind Michael K Sharing Data in Internal and Memory Representations with Dynamic Data-Driven Conversion
CN101620589A (en) * 2008-06-30 2010-01-06 英特尔公司 Efficient parallel floating point exception handling in a processor
US20130073838A1 (en) * 2011-09-16 2013-03-21 International Business Machines Corporation Multi-addressable register files and format conversions associated therewith
WO2017185418A1 (en) * 2016-04-29 2017-11-02 北京中科寒武纪科技有限公司 Device and method for performing neural network computation and matrix/vector computation
CN107608715A (en) * 2017-07-20 2018-01-19 上海寒武纪信息科技有限公司 For performing the device and method of artificial neural network forward operation
CN107832844A (en) * 2017-10-30 2018-03-23 上海寒武纪信息科技有限公司 A kind of information processing method and Related product
CN107861757A (en) * 2017-11-30 2018-03-30 上海寒武纪信息科技有限公司 Arithmetic unit and Related product
CN108009126A (en) * 2017-12-15 2018-05-08 北京中科寒武纪科技有限公司 A kind of computational methods and Related product
US20180329868A1 (en) * 2016-01-20 2018-11-15 Cambricon Technologies Corporation Limited Vector and Matrix Computing Device

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090198977A1 (en) * 2008-01-31 2009-08-06 Gschwind Michael K Sharing Data in Internal and Memory Representations with Dynamic Data-Driven Conversion
CN101620589A (en) * 2008-06-30 2010-01-06 英特尔公司 Efficient parallel floating point exception handling in a processor
US20130073838A1 (en) * 2011-09-16 2013-03-21 International Business Machines Corporation Multi-addressable register files and format conversions associated therewith
US20180329868A1 (en) * 2016-01-20 2018-11-15 Cambricon Technologies Corporation Limited Vector and Matrix Computing Device
WO2017185418A1 (en) * 2016-04-29 2017-11-02 北京中科寒武纪科技有限公司 Device and method for performing neural network computation and matrix/vector computation
CN107608715A (en) * 2017-07-20 2018-01-19 上海寒武纪信息科技有限公司 For performing the device and method of artificial neural network forward operation
CN107992329A (en) * 2017-07-20 2018-05-04 上海寒武纪信息科技有限公司 A calculation method and related products
CN107832844A (en) * 2017-10-30 2018-03-23 上海寒武纪信息科技有限公司 A kind of information processing method and Related product
CN108874444A (en) * 2017-10-30 2018-11-23 上海寒武纪信息科技有限公司 Machine learning processor and the method for executing Outer Product of Vectors instruction using processor
CN107861757A (en) * 2017-11-30 2018-03-30 上海寒武纪信息科技有限公司 Arithmetic unit and Related product
CN108009126A (en) * 2017-12-15 2018-05-08 北京中科寒武纪科技有限公司 A kind of computational methods and Related product

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
杨一晨;梁峰;张国和;何平;吴斌;高震霆;: "一种基于可编程逻辑器件的卷积神经网络协处理器设计" *
赵秀娟;詹春;郎长胜;: "基于微程序控制模型机的设计与实现" *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114281468A (en) * 2020-09-28 2022-04-05 中科寒武纪科技股份有限公司 Apparatus, related method and readable storage medium for implementing thermal migration

Also Published As

Publication number Publication date
CN111275197B (en) 2023-11-10

Similar Documents

Publication Publication Date Title
CN110096309B (en) Computing method, apparatus, computer equipment and storage medium
CN110096310B (en) Operation method, operation device, computer equipment and storage medium
CN110119807B (en) Operation method, operation device, computer equipment and storage medium
CN110096283A (en) Operation method, device, computer equipment and storage medium
CN111381871B (en) Computing method, device and related products
CN111047005A (en) Operation method, operation device, computer equipment and storage medium
CN111353124A (en) Computing method, apparatus, computer equipment and storage medium
CN111340202B (en) Operation method, device and related product
CN111061507A (en) Operation method, operation device, computer equipment and storage medium
CN111047030A (en) Computing method, apparatus, computer equipment and storage medium
CN111275197B (en) Computing methods, devices, computer equipment and storage media
CN111026440B (en) Operation method, operation device, computer equipment and storage medium
CN111381873A (en) Computing method, device and related products
CN111290789B (en) Operation method, operation device, computer equipment and storage medium
CN111813449A (en) Computing method, device and related products
CN111353595A (en) Operation method, device and related product
CN111339060B (en) Computing methods, devices, computer equipment and storage media
CN111338694B (en) Operation method, device, computer equipment and storage medium
CN111290788B (en) Operation method, operation device, computer equipment and storage medium
CN111353125B (en) Operation method, operation device, computer equipment and storage medium
CN111966402A (en) Instruction processing method and device and related product
CN111124497B (en) Operation method, operation device, computer equipment and storage medium
CN111966401A (en) Instruction processing method, device and related products
CN111382390A (en) Computing method, device and related products
CN111382851A (en) Operation method, device and related product

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TG01 Patent term adjustment
TG01 Patent term adjustment