An operator configuration method, device, electronic device and storage medium for a chip
By generating and using configuration files and data packets, the operators of the target chip are automatically configured, which solves the adaptation problems caused by the differences in interfaces of different AI acceleration chip manufacturers, and achieves efficient chip adaptation and reduces workload.
Patent Information
- Application Number
- CN202410064138.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-16
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2044-01-16
AI Technical Summary
There are differences in the implementation of computing library interface functions of different AI acceleration chip manufacturers, which leads to the need to develop a large amount of adaptation logic when connecting with the chip, which increases the workload and technical difficulty.
By determining the target configuration parameters of the target operator and the default configuration parameters of the default operator according to the target chip requirements, a configuration file is generated, and a configuration data packet is generated when the configuration conditions are met, and the target chip is automatically configured.
Automatic configuration of operators for different chips is realized, which reduces adaptation costs, improves user experience, and reduces the workload of business personnel.
Smart Images

Figure CN117891528B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and particularly to an operator configuration method, device, electronic device, and storage medium for a chip. Background Art
[0002] A new round of scientific and technological revolution and industrial transformation are reshaping the global economic structure. As a new productive force in the digital economy era, computing power is a solid foundation for supporting the development of the digital economy, playing an important role in promoting scientific and technological progress, facilitating the digital transformation of industries, and supporting economic and social development. Computing power has become a new focus of global strategic competition and an important engine for national economic development, and there is a significant positive correlation between the level of computing power and the level of economic development.
[0003] During the implementation of the computational library interface functions by different artificial intelligence (AI) acceleration chip manufacturers, according to the characteristics of their chips, the supported data types are different, and the memory layouts of the required tensors (tensors) and whether they support continuity are also different. During the docking process between the training framework and the AI acceleration chip, a set of related logics need to be developed for each AI chip manufacturer's operator interface called by the training framework. There are problems such as a large amount of adaptation work, high technical requirements, and a lot of repetitive work. Therefore, how to configure the operators of the chip more conveniently and simply has become an urgent problem to be solved at present. Summary of the Invention
[0004] The present invention provides an operator configuration method, device, electronic device, and storage medium for a chip to solve the problems of large adaptation workload, high technical requirements, and a lot of repetitive work in the operator configuration for different chips.
[0005] According to one aspect of the present invention, an operator configuration method for a chip is provided, wherein the method includes:
[0006] Determine the target configuration parameters of the target operator and the default configuration parameters of the default operator of the target chip according to the target chip requirements;
[0007] Generate a configuration file for the target operator according to the default configuration parameters and the target configuration parameters;
[0008] When the configuration file meets the configuration conditions, generate a configuration data packet for the target operator according to the configuration file, and configure the target chip according to the configuration data packet.
[0009] In an embodiment, the operator configuration method for a chip further includes:
[0010] When the configuration file does not meet the configuration conditions, determine the configuration items that do not meet the configuration conditions;
[0011] Remove the configuration items that do not meet the configuration conditions from the configuration file, update the configuration file, and generate a configuration data packet for the target operator according to the updated configuration file.
[0012] In one embodiment, the determining the target configuration parameters of the target operator and the default configuration parameters of the default operator of the target chip according to the target chip requirements includes:
[0013] Determine the target operator in the target chip requirements, and read the target configuration parameters of the configuration items of the target operator in the target chip requirements; wherein, the configuration items include at least one of the following: data type object, input continuity, and layout.
[0014] Read the default configuration parameters of each configuration item in the default operator of the target chip.
[0015] In one embodiment, the generating the configuration file of the target operator according to the default configuration parameters and the target configuration parameters includes:
[0016] Read a preset configuration file template, and fill the default configuration parameters and the target configuration parameters into the preset configuration file template according to the configuration items respectively to generate the configuration file of the target operator.
[0017] In one embodiment, the configuration file meets the configuration conditions including: the configuration items of the target operator exist in the parameter list of the function declaration, the target configuration parameters corresponding to each configuration item are within a preset range, and the target configuration parameters and the default configuration parameters corresponding to each configuration item are different.
[0018] In one embodiment, the generating the configuration data packet of the target operator according to the configuration file and configuring the target chip according to the configuration data packet includes:
[0019] Read a preset configuration data packet template, and fill the configuration file into the corresponding positions of the preset configuration data packet template according to the configuration items to generate the configuration data packet of the target operator.
[0020] Call the corresponding operator function according to the configuration data packet, and configure the target operator on the target chip according to the operator function.
[0021] In one embodiment, after generating the configuration data packet of the target operator according to the configuration file, it further includes:
[0022] Save the sub-configuration data packets corresponding to each configuration item of the target operator in the configuration data packet, and use the target configuration parameters and the default configuration parameters of the configuration items as the indexes of the sub-configuration data packets.
[0023] According to another aspect of the present invention, there is provided an operator configuration device for a chip, wherein the device includes:
[0024] A parameter determination module, configured to determine target configuration parameters of a target operator and default configuration parameters of a default operator of a target chip according to target chip requirements;
[0025] A file generation module, configured to generate a configuration file of the target operator according to the default configuration parameters and the target configuration parameters;
[0026] A chip configuration module, configured to generate a configuration data packet of the target operator according to the configuration file when the configuration file meets the configuration conditions, and configure the target chip according to the configuration data packet.
[0027] According to another aspect of the present invention, there is provided an electronic device, where the electronic device includes:
[0028] At least one processor; and
[0029] A memory communicatively connected to the at least one processor; wherein,
[0030] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute an operator configuration method for a chip according to any embodiment of the present invention.
[0031] According to another aspect of the present invention, there is provided a computer-readable storage medium storing computer instructions for causing a processor to implement an operator configuration method for a chip according to any embodiment of the present invention when executed.
[0032] The technical solution of the embodiment of the present invention determines the target configuration parameters of the target operator and the default configuration parameters of the default operator of the target chip according to the target chip requirements, generates a configuration file of the target operator according to the default configuration parameters and the target configuration parameters, and when the configuration file meets the configuration conditions, generates a configuration data packet of the target operator according to the configuration file, and configures the target chip according to the configuration data packet, so as to automatically configure the corresponding target operator for different target chips, reduce the adaptation cost of the target chip, and improve the user experience. At the same time, generating a configuration file of the target operator according to the default configuration parameters and the target configuration parameters facilitates viewing the conversion parameters of each configuration item, and the target configuration parameters corresponding to the target operator can be determined without reading the code, avoiding manually editing the documents required for the configuration data packet, reducing the workload of business personnel, and improving work efficiency.
[0033] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present invention, nor is it used to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for use in the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0035] Figure 1 is a flowchart of a method for configuring operators of a chip according to Embodiment 1 of the present invention;
[0036] Figure 2 is a flowchart of a method for configuring operators of a chip according to Embodiment 2 of the present invention;
[0037] Figure 3 is a schematic structural diagram of an apparatus for configuring operators of a chip according to Embodiment 4 of the present invention;
[0038] Figure 4 is a schematic structural diagram of an electronic device for implementing the method for configuring operators of the chip in the embodiments of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0039] In order to enable those skilled in the art to better understand the solutions of the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only some of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0040] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.
[0041] Example 1
[0042] Figure 1 It is a flowchart of an operator configuration method for a chip provided according to Example 1 of the present invention. This example is applicable to the situation of configuring a target operator for a target chip. This method can be executed by an operator configuration device of the chip. The operator configuration device of the chip can be implemented in the form of hardware and / or software, and the operator configuration device of the chip can be configured in an electronic device. As Figure 1 shown, the method includes:
[0043] S110. Determine the target configuration parameters of the target operator and the default configuration parameters of the default operator of the target chip according to the target chip requirements.
[0044] Among them, the target chip can be understood as the chip to which the target operator is to be converted. In the actual operation process, the target chip can include, but is not limited to, an AI acceleration chip. Different target chips have different requirements for the configuration items of different operators. The target configuration parameters of the target operator and the default configuration parameters of the default operator of the target chip can be obtained in advance according to the target chip requirements. The target chip requirements refer to the requirements of the target chip, and the target configuration parameters of the target operator can be included in the target chip requirements.
[0045] The default configuration parameters can be understood as the configuration parameters of the default operator in the target chip, and can include the default parameters of each configuration item of the default operator configured in the target chip. Exemplarily, the configuration items of the default configuration parameters can include, but are not limited to, data type objects, input continuity, and layout parameters. The target configuration parameters refer to the configuration parameters of the target operator required by the target chip requirements. For the default configuration parameters and the target configuration parameters, there can be the same configuration items. At this time, the same configuration items can be considered as the configuration items that do not need to be reconfigured. Among them, the data object type can include, but is not limited to, uint8, uint8, int16, uint16, int32, uint32, int64, uint64, float16, float32, float64, bool, etc. The input continuity can include that the operator only receives continuous input and output and that the operator receives more than continuous input and output. The layout can include two formats, NHWC and NCHW, where N is Batch, C is Channel, H is Height, and W is Width. HNWC first takes the data in the C direction, then the W direction, then the H direction, and finally the N direction. NCHW first takes the data in the W direction, then the H direction, then the C direction, and finally the N direction.
[0046] In an embodiment of the invention, a target operator can be determined according to the requirements of a target chip, target configuration parameters of each configuration item of the target operator can be determined, a default operator of the target chip can be read, and the configuration parameters of the default operator can be determined as default configuration parameters.
[0047] S120. Generate a configuration file for the target operator according to the default configuration parameters and the target configuration parameters.
[0048] Among them, the configuration file refers to a pre-set visual file storing the correspondence between default configuration parameters and target configuration parameters, and the data stored in the configuration file can be configured and modified according to user requirements. In practical applications, the form of the configuration file can include visual tables, files, etc. Exemplarily, the configuration file can include, but is not limited to, Excel tables, Word documents, and Numbers tables, etc.
[0049] In an embodiment of the invention, a pre-set configuration file template can be read, and a configuration file for the target operator can be generated according to the default configuration parameters and the target configuration parameters. In the actual operation process, the default configuration parameters and the target configuration parameters can be filled into the pre-set configuration file template item by item to generate a configuration file for the target operator. For different configuration items, there can be different pre-set configuration file templates. Exemplarily, for a configuration item of data type object, the default configuration parameter can be placed in front of ->, and the target configuration parameter can be placed behind ->; for configuration items of input continuity and layout parameters, the corresponding parameters in the default configuration parameters and the target configuration parameters can be saved respectively. Among them, when the input continuity is that the operator only receives continuous input and output, it can be recorded as Ture; when the input continuity is that the operator receives more than continuous input and output, it can be recorded as False. Generally, the default configuration parameter corresponding to the input continuity is False. The layout can include two formats, NHWC and NCHW, and the formats supported by the operator can be directly recorded. Generally, the layout supports both NHWC and NCHW formats.
[0050] S130. When the configuration file meets the configuration conditions, generate a configuration data packet for the target operator according to the configuration file, and configure the target chip according to the configuration data packet.
[0051] Among them, the configuration conditions can be pre-set conditions for determining whether the configuration file has an abnormality. The configuration data packet can be understood as a data packet for configuring the target operator for the target chip. In the actual operation process, the configuration data packet is generated according to the configuration file and is a file for running and loading the operator. The configuration data packet can contain the code for loading the target operator.
[0052] In one embodiment, the configuration file meeting the configuration conditions includes: the configuration items of the target operator exist in the parameter list of the function declaration, the target configuration parameters corresponding to each configuration item exist within a preset range, and the target configuration parameters and the default configuration parameters corresponding to each configuration item are different.
[0053] Among them, the function declaration can be understood as notifying the compilation system of the function name, function type, and the type, number, and order of formal parameters, so that the system can perform a check according to this when calling the function (such as whether the function name is correct, and whether the types and numbers of actual and formal parameters are consistent). The parameter list can be understood as a preset standard parameter list, which can include each configuration item that can be converted. The target configuration parameters corresponding to each configuration item existing within a preset range can be understood as the parameters corresponding to each configuration item being within the preset range, that is to say, the parameters corresponding to each configuration item are correct and can be converted.
[0054] In an embodiment of the invention, when the configuration items of the target operator can be queried in the parameter list of the function declaration, the target configuration parameters corresponding to each configuration item exist within a preset range, and the target configuration parameters and the default configuration parameters corresponding to each configuration item are different, it can be considered that the configuration file meets the configuration conditions. At this time, the configuration data packet of the target operator can be generated according to the configuration file. Exemplarily, the configuration data packet can be generated according to a preset configuration data packet template, and the configuration file is filled into the corresponding positions of the preset configuration data packet template according to the configuration items to generate the configuration data packet of the target operator. In the actual operation process, the configuration file can also be generated into a program configuration data packet through a data conversion device. Exemplarily, the data conversion device can include but is not limited to a data converter running on the Xcode development tool, an interface function of api_convert, etc. After determining the configuration data packet, the corresponding operator function can be called according to the configuration data packet, and the target operator can be configured on the target chip according to the operator function.
[0055] In the embodiment of the present invention, by determining the target configuration parameters of the target operator according to the requirements of the target chip and the default configuration parameters of the default operator of the target chip, generating a configuration file of the target operator according to the default configuration parameters and the target configuration parameters, when the configuration file meets the configuration conditions, generating a configuration data packet of the target operator according to the configuration file, and configuring the target chip according to the configuration data packet, it is realized to automatically configure the corresponding target operator for different target chips, reduce the adaptation cost of the target chip. At the same time, generating a configuration file of the target operator according to the default configuration parameters and the target configuration parameters is convenient for viewing the conversion parameters of each configuration item, and the target configuration parameters corresponding to the target operator can be determined without reading the code, avoiding the need to manually edit the documents required for the configuration data packet, reducing the workload of business personnel, and improving work efficiency.
[0056] In one embodiment, the method for configuring operators of a chip further includes:
[0057] When the configuration file does not meet the configuration conditions, determine the configuration items that do not meet the configuration conditions;
[0058] Remove the configuration items that do not meet the configuration conditions from the configuration file to update the configuration file, and generate a configuration data packet for the target operator according to the updated configuration file.
[0059] In an embodiment of the invention, when the configuration file does not meet the configuration conditions, the configuration items that do not meet the configuration conditions can be determined, the corresponding configuration items can be removed from the configuration file, the configuration file can be updated, and a configuration data packet for the target operator can be generated according to the updated configuration file. In the actual operation process, when the configuration file does not meet the configuration conditions, it can be considered that the configuration file does not conform to the regulations. Exemplarily, when the configuration items are repeated or do not exist in the function declaration, the corresponding configuration items can be deleted to reduce the cost of configuring the corresponding configuration items.
[0060] In one embodiment, after generating the configuration data packet for the target operator according to the configuration file, it further includes:
[0061] Save the sub-configuration data packets corresponding to the respective configuration items for the target operator in the configuration data packet, and use the target configuration parameters and default configuration parameters of the configuration items as the indexes of the sub-configuration data packets.
[0062] Among them, the sub-configuration data packet can be understood as a configuration data packet split for each configuration item of the target operator, and the data packet corresponding to each configuration item can be saved. When the parameter conversions of the corresponding configuration items are the same again, the corresponding sub-configuration data packet can be extracted to reduce the configuration time. In one embodiment, the sub-configuration data packets corresponding to the respective configuration items for the target operator can also be understood as the process of converting the default configuration parameters to the target configuration parameters for each configuration item. When the same conversion of the corresponding configuration item appears again, the corresponding sub-configuration data packet can be directly extracted to avoid repeated execution of the same conversion and save the running time.
[0063] In an embodiment of the invention, when generating the configuration data packet for the target operator according to the configuration file, the configuration data packet can be split into corresponding sub-configuration data packets for the respective configuration items of the target operator, and the target configuration parameters and default configuration parameters corresponding to each configuration item are used as the indexes of the sub-configuration data packets. When the configuration item to be converted again is the same as the index, the corresponding self-configuration data packet is directly extracted to save the configuration time.
[0064] Embodiment 2
[0065] Figure 2It is a flowchart of an operator configuration method for a chip provided in Embodiment 2 of the present invention. This embodiment is further optimized and extended based on the above-described implementation manner and can be combined with various optional technical solutions in the above-described implementation manner. As Figure 2 shown, the method includes:
[0066] S210. Determine a target operator according to the target chip requirements, and read the target configuration parameters of the configuration items of the target operator in the target chip requirements; wherein, the configuration items include at least one of the following: data type object, input continuity, and layout.
[0067] Among them, the data type object can be understood as the data types supported by the operator. Exemplarily, the data type object may include but is not limited to the data object type may include but is not limited to uint8, uint8, int16, uint16, int32, uint32, int64, uint64, float16, float32, float64, bool, etc. The input continuity can be understood as whether the operator only receives continuous input and output. The input continuity can include that the operator only receives continuous input and output and that the operator receives more than just continuous input and output. The layout can be understood as the supported data format, and the layout can include two formats: NHWC and NCHW.
[0068] In the embodiment of the invention, a target operator can be determined according to the target chip requirements, and the target configuration parameters of the configuration items of the target operator in the target chip requirements can be determined. That is to say, the data object class input continuity and layout of the target chip requirements can be determined to facilitate the configuration of the target operator for the target chip.
[0069] S220. Read the default configuration parameters of each configuration item in the default operator of the target chip.
[0070] In the embodiment of the invention, the default operator currently configured on the target chip can be read, and the parameters of each configuration item in the default operator can be determined as the default configuration parameters.
[0071] S230. Read a preset configuration file template, and fill the default configuration parameters and the target configuration parameters into the preset configuration file template according to the configuration items respectively to generate a configuration file for the target operator.
[0072] Among them, the preset configuration file template is a template for generating a configuration file. The number of preset configuration file templates can be multiple. For different configuration items, there can be different preset configuration file templates. In the preset configuration file template, the formats of the default configuration parameters and the target configuration parameters can be pre-stored to facilitate storing the default configuration parameters and the target configuration parameters in the configuration parameters in a unified format.
[0073] In the actual operation process, for each configuration item, the corresponding preset configuration file template can be extracted separately, and the parameters of the default configuration parameters and the target configuration parameters corresponding to each configuration item can be determined respectively. Then, fill in the corresponding preset configuration file template according to the configuration item to generate the configuration file of the target operator. In the actual operation process, for the data type object, the default configuration parameter can be placed in front of ->, and the target configuration parameter can be placed behind ->; for the input continuity, when the input continuity is that the operator only receives continuous input and output, it can be recorded as True; when the input continuity is that the operator receives more than continuous input and output, it can be recorded as False. For the layout, the supported formats of the operator can be recorded. Generally, the default configuration parameter corresponding to the input continuity is False, and the default configuration parameters corresponding to the layout support both the NHWC and NCHW formats.
[0074] S240. When the configuration file meets the configuration conditions, read the preset configuration data packet template, and fill in the configuration file at the corresponding position of the preset configuration data packet template according to the configuration item to generate the configuration data packet of the target operator.
[0075] Among them, the preset configuration data packet template is a template for generating the configuration data packet. In the preset configuration data packet template, the format of the configuration file can be pre-stored to facilitate the generation of the configuration data packet of the target operator.
[0076] In the invention embodiment, when the configuration file meets the configuration conditions, the preset configuration data packet template can be read, and each configuration item of the configuration file can be filled in at the corresponding position of the preset configuration data packet template to generate the configuration data packet of the target operator. In the actual operation process, the configuration data packet of the target operator can be generated through the interface function of api_convert.
[0077] S250. Call the corresponding operator function according to the configuration data packet, and configure the target operator on the target chip according to the operator function.
[0078] Among them, the operator function refers to the function that executes the target operator.
[0079] In the invention embodiment, when the configuration data packet is determined, the corresponding operator function can be called according to the configuration data packet, and the operator function corresponding to the configuration data packet can be configured on the target chip to realize the configuration of the target operator in the target chip.
[0080] In an embodiment of the present invention, a target operator is determined based on the target chip requirements, the target configuration parameters of the configuration items of the target operator in the target chip requirements are read, the default configuration parameters of each configuration item in the target operator are read, a preset configuration file template is read, the default configuration parameters and the target configuration parameters are filled into the preset configuration file template according to the configuration items respectively to generate a configuration file for the target operator. When the configuration file meets the configuration conditions, a preset configuration data packet template is read, the configuration file is filled into the corresponding positions of the preset configuration data packet template according to the configuration items to generate a configuration data packet for the target operator. The corresponding operator function is called according to the configuration data packet, and the target operator is configured on the target chip according to the operator function, realizing the rapid conversion of operators in the target chip, facilitating the calling of target chips from different manufacturers, and improving the adaptability of the target chip.
[0081] Embodiment III
[0082] Based on the above embodiment, in this embodiment, an AI acceleration chip is used as the target chip, and the configuration items of the target operator include data type object, input continuity, and layout as examples to further illustrate a method for configuring operators of a chip.
[0083] First, determine the configuration items of the target operator. The configuration items include data type object (dtype), input continuity (contiguous), and layout. Among them, the types not supported by the dtype configuration include the conversion rules for the unsupported types; contiguous indicates whether discontinuous inputs are supported; layout can be configured as NCHW or NHWC.
[0084] The configuration of the operator can be divided into three levels: the configuration common to each device (common_config), which describes the unsupported dtypes and conversion rules, and the received layouts (defaulting to NHWC and NCHW), and this configuration applies to all operators. Each operator can have its own configuration (api_Add), including all input and output parameters, and the default parts follow the common configuration. Each parameter can also have its own configuration (tensor_dtype), and for special parameters, the configuration at the parameter granularity can be configured, which will override the configuration at the operator granularity at this time.
[0085] Among them, the configuration of dtype includes global configuration and configuration within the operator. The globally configurable options include: int8, uint8, int16, uint16, int32, uint32, int64, uint64, float16, float32, float64, bool. The types configurable for each parameter within the operator are all the types supported by the parameter and outside the non-configurable range of the manufacturer. If other types are supported by DIOPI in the future, they can also be configured.
[0086] The specific configuration form is as follows. -> points to the converted type (target configuration parameter). There can be multiple types in dtype, indicating that these types will all be converted to the type after ->. The conversion rule can be not configured, and the default is int64 -> int32, float64 -> float32.
[0087] After the configuration is completed, a configuration check needs to be performed to ensure that the configuration items of the target operator exist in the parameter list declared by the function, the target configuration parameters corresponding to each configuration item exist within the preset range, and the target configuration parameters and default configuration parameters corresponding to each configuration item are different. That is, to ensure that the target configuration parameters are in the parameter list declared by the function, whether the configured type is within the range, the configured conversion rules do not repeat or conflict, and the types before and after conversion are required to be different.
[0088] The configurable options for layout include NHWC and NCHW. Both can be included in the configuration, indicating that both types are supported. The default value is that both are supported, and there are no special requirements for layout. Layout can also be configured for the operator and parameter granularity, and the configuration form is as follows: NHWC and NCHW, NHWC or NCHW.
[0089] contiguous indicates whether the operator only accepts continuous input and output. Here, it means that the memory is continuous, and the default is False. This item can only be configured for the operator granularity, and the configuration form is as follows: Ture or False.
[0090] After parsing the configuration items according to the function declaration and configuration file, before calling the actual operator function, call the conversion code according to the parsed castStrategy, supported layout, and whether it is contiguous. The processing of the output parameters is slightly different because the output needs to be converted to the original type after the operation. Therefore, a Wrapper class is used to complete the conversion of the output in the destructor called after the operation. For the actual tensor conversion operation, an interface function api_convert needs to be abstracted, which can be implemented by AI acceleration training chip manufacturers.
[0091] By programming with a preset data packet template, the resolution of the conversion strategy and the corresponding conversion function can be advanced to the compilation period, which can improve the runtime efficiency.
[0092] In a single calculation, the same tensor may be used as the input of many operators at the same time. A cache index can be established for all input tensors in a single configuration to store the values before and after their type conversion. This can avoid repeated execution of the same conversion and save runtime.
[0093] In an embodiment of the present invention, a configuration file is provided, which contains the configuration of the data type and memory format requirements of the target operator interface. When a manufacturer implements an operator, the requirements for parameters are configured into this file. Each manufacturer has its own configuration file. During compilation, the corresponding configuration file is read according to the current device, compared with the operator declaration file, and personalized processing is performed for each operator to generate processing code. During the running process, before the framework calls the actual implementation of the manufacturer operator call interface, the conversion processing of dtype, contiguous, and channelLast is completed.
[0094] Embodiment 4
[0095] Figure 3 It is a schematic structural diagram of an operator configuration device for a chip provided according to Embodiment 4 of the present invention. As Figure 3 shown, the device includes: a parameter determination module 31, a file generation module 32, and a chip configuration module 33.
[0096] Among them, the parameter determination module 31 is used to determine the target configuration parameters of the target operator and the default configuration parameters of the default operator of the target chip according to the requirements of the target chip.
[0097] The file generation module 32 is used to generate a configuration file for the target operator according to the default configuration parameters and the target configuration parameters.
[0098] The chip configuration module 33 is used to generate a configuration data packet for the target operator according to the configuration file when the configuration file meets the configuration conditions, and configure the target chip according to the configuration data packet.
[0099] In the embodiment of the present invention, the parameter determination module determines the target configuration parameters of the target operator and the default configuration parameters of the default operator of the target chip according to the requirements of the target chip. The file generation module generates a configuration file for the target operator according to the default configuration parameters and the target configuration parameters. The chip configuration module generates a configuration data packet for the target operator according to the configuration file when the configuration file meets the configuration conditions, and configures the target chip according to the configuration data packet, realizing automatic configuration of the corresponding target operator for different target chips, reducing the adaptation cost of the target chip. At the same time, generating a configuration file for the target operator according to the default configuration parameters and the target configuration parameters facilitates viewing the conversion parameters of each configuration item, and the target configuration parameters corresponding to the target operator can be determined without reading the code, avoiding the need to manually edit the documents required for the configuration data packet, reducing the workload of business personnel, and improving work efficiency.
[0100] In an embodiment, the operator configuration device for a chip further includes:
[0101] a configuration item determination module, which is used to determine the configuration items that do not meet the configuration conditions when the configuration file does not meet the configuration conditions;
[0102] The data packet update module is used to remove the configuration items that do not meet the configuration conditions from the configuration file, update the configuration file, and generate a configuration data packet for the target operator according to the updated configuration file.
[0103] In one embodiment, the parameter determination module 31 includes:
[0104] The first parameter determination unit is used to determine the target operator according to the target chip requirements, and read the target configuration parameters of the configuration items of the target operator in the target chip requirements; wherein, the configuration items include at least one of the following: data type object, input continuity, and layout.
[0105] The second parameter determination unit is used to read the default configuration parameters of each configuration item in the default operator of the target chip.
[0106] In one embodiment, the file generation module 32 includes:
[0107] The file generation unit is used to read the preset configuration file template, fill the default configuration parameters and the target configuration parameters into the preset configuration file template according to the configuration items respectively, and generate the configuration file of the target operator.
[0108] In one embodiment, the configuration file in the chip configuration module 33 meets the configuration conditions including: the configuration items of the target operator exist in the parameter list of the function declaration, the target configuration parameters corresponding to each configuration item exist within the preset range, and the target configuration parameters and the default configuration parameters corresponding to each configuration item are different.
[0109] In one embodiment, the chip configuration module 33 includes:
[0110] The template reading unit is used to read the preset configuration data packet template, fill the configuration file into the corresponding position of the preset configuration data packet template according to the configuration items, and generate the configuration data packet of the target operator.
[0111] The chip configuration unit is used to call the corresponding operator function according to the configuration data packet, and configure the target operator on the target chip according to the operator function.
[0112] In one embodiment, the operator configuration device of the chip further includes:
[0113] The data packet storage module is used to store the sub-configuration data packets corresponding to each configuration item of the target operator in the configuration data packet, and use the target configuration parameters and the default configuration parameters of the configuration items as the indexes of the sub-configuration data packets.
[0114] The operator configuration device of the chip provided by the embodiments of the present invention can execute the operator configuration method of the chip provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0115] Embodiment 5
[0116] Figure 4 It is a schematic structural diagram of an electronic device implementing the operator configuration method of the chip in the embodiment of the present invention. The electronic device is intended to represent various forms of digital computers, such as, laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as, personal digital processors, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present invention described and / or claimed herein.
[0117] As Figure 4 shown, the electronic device 10 includes at least one processor 11, and a memory communicatively connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc. Among them, the memory stores a computer program executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. The input / output (I / O) interface 15 is also connected to the bus 14.
[0118] Multiple components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0119] The processor 11 can be various general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include but are not limited to a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the operator configuration method of the chip.
[0120] In some embodiments, the operator configuration method of the chip can be implemented as a computer program tangibly embodied in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the operator configuration method of the chip described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to execute the operator configuration method of the chip by any other suitable means (e.g., by means of firmware).
[0121] The various embodiments of the systems and techniques described above in this document can be implemented in digital electronic circuitry, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on a chip (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special-purpose or general-purpose programmable processor that receives data and instructions from a storage system, at least one input device, and at least one output device, and transmits the data and instructions to the storage system, the at least one input device, and the at least one output device.
[0122] The computer programs for implementing the methods of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to the processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer programs are executed by the processor, the functions / operations specified in the flowchart and / or block diagram are implemented. The computer programs can be executed entirely on the machine, partially on the machine, as a stand-alone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0123] In the context of the present invention, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer-readable storage medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, the computer-readable storage medium can be a machine-readable signal medium. More specific examples of the machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0124] In order to provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, speech input, or tactile input).
[0125] The systems and techniques described herein can be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer having a graphical user interface or a web browser through which the user can interact with an implementation of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local area network (LAN), wide area network (WAN), blockchain network, and the Internet.
[0126] A computing system may include a client and a server. The client and the server are generally far from each other and usually interact via a communication network. The client-server relationship is created by computer programs that run on respective computers and have a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system, solving the defects of difficult management and weak business scalability existing in traditional physical hosts and VPS services.
[0127] It should be understood that various forms of the processes shown above can be used, steps can be reordered, added or deleted. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and no limitation is imposed herein.
[0128] The above specific embodiments do not constitute a limitation on the protection scope of the present invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A chip operator configuration method, characterized in that: include: Determine target configuration parameters of the target operator and default configuration parameters of the default operator of the target chip according to the target chip requirements; Generate a configuration file of the target operator according to the default configuration parameters and the target configuration parameters; When the configuration file meets the configuration condition, generating a configuration data packet of the target operator according to the configuration file, and configuring the target chip according to the configuration data packet; The configuration condition satisfied by the configuration file includes: the configuration item of the target operator exists in the parameter list of the function declaration, the target configuration parameters corresponding to each of the configuration items exist within a preset range, and the target configuration parameters corresponding to each of the configuration items are different from the default configuration parameters.
2. The method according to claim 1, characterized in that Also includes: When the configuration file does not satisfy the configuration condition, determining the configuration item that does not satisfy the configuration condition; The configuration items that do not meet the configuration conditions are removed from the configuration file, the configuration file is updated, and a configuration data packet of the target operator is generated according to the updated configuration file.
3. The method according to claim 1, characterized in that The step of determining the target configuration parameters of the target operator and the default configuration parameters of the default operator of the target chip according to the target chip requirements includes: Determine the target operator in the target chip requirement, and read the target configuration parameters of the configuration items of the target operator in the target chip requirement; wherein the configuration items include at least one of the following: data type object, input continuity, and layout; Read the default configuration parameters of each configuration item in the default operator of the target chip.
4. The method according to claim 1, characterized in that: The generating a configuration file of the target operator according to the default configuration parameters and the target configuration parameters includes: The preset configuration file template is read, and the default configuration parameters and the target configuration parameters are respectively filled into the preset configuration file template according to the configuration items to generate a configuration file for the target operator.
5. The method according to claim 1, characterized in that The step of generating a configuration data packet of the target operator according to the configuration file, and configuring the target chip according to the configuration data packet includes: Reading a preset configuration data packet template, filling the configuration file into the corresponding position of the preset configuration data packet template according to the configuration items, and generating a configuration data packet of the target operator; The corresponding operator function is called according to the configuration data packet, and the target operator is configured on the target chip according to the operator function.
6. The method according to claim 1, characterized in that After generating a configuration data packet of the target operator according to the configuration file, the method further includes: The sub-configuration data packets corresponding to the configuration items of the target operator in the configuration data packet are saved, and the target configuration parameters and the default configuration parameters of the configuration items are used as indexes of the sub-configuration data packets.
7. A chip operator configuration device, characterized in that: include: A parameter determination module, used to determine the target configuration parameters of the target operator and the default configuration parameters of the default operator of the target chip according to the requirements of the target chip; A file generation module, used to generate a configuration file of the target operator according to the default configuration parameters and the target configuration parameters; A chip configuration module, configured to generate a configuration data packet of the target operator according to the configuration file when the configuration file meets the configuration condition, and configure the target chip according to the configuration data packet; The configuration condition satisfied by the configuration file includes: the configuration item of the target operator exists in the parameter list of the function declaration, the target configuration parameters corresponding to each of the configuration items exist within a preset range, and the target configuration parameters corresponding to each of the configuration items are different from the default configuration parameters.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the operator configuration method for a chip according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the operator configuration method for a chip according to any one of claims 1 to 6 when executed.
Citation Information
Patent Citations
Chip and method and device for modifying chip configuration
CN104156221A
Method and apparatus for generating chip-based computing function, device, and storage medium
US20200409662A1