Efficient format conversion method

By replacing complex formulas with lookup table operations for data format conversion, the problems of high hardware resource consumption and accuracy loss are solved, achieving efficient and flexible data format conversion.

CN121742797AActive Publication Date: 2026-03-27METAX INTEGRATED CIRCUITS (SHANGHAI) CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-02-24
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing technologies suffer from excessive hardware resource consumption and loss of computational accuracy in data format conversion, especially when performing complex mathematical operations such as taking reciprocals or powers.

Method used

Instead of complex data format conversion formulas, lookup table operations are used. The target address is determined by coordinate information, cached data is retrieved from the cache, the data type is parsed and converted using a preset lookup table, and the converted data is extracted according to the target bit width.

Benefits of technology

It effectively saves hardware resources, avoids precision loss, supports conversion of various data types and bit widths, and improves the flexibility and scalability of data format conversion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121742797A_ABST
    Figure CN121742797A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data format processing, in particular to an efficient format conversion method, which changes complex calculation of data format conversion into table look-up operation, effectively simplifies hardware implementation logic, saves hardware resource consumption, can avoid precision loss during data format conversion through the table look-up operation, and improves the data format conversion efficiency. According to the data format conversion method and device, data format conversion can be achieved, conversion of multiple data types and bit widths can be supported, the flexibility of data format conversion is higher, expansion can be conducted by introducing a new lookup table when a new data type conversion requirement appears, and the expandability of data format conversion is higher.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data format processing technology, and in particular to an efficient format conversion method. Background Technology

[0002] Currently, in fields such as computer graphics, video processing, and machine learning, different systems and hardware components often use different data representation methods. Therefore, data format conversion is a common and critical operation.

[0003] Current methods typically employ real-time computation via hardware processing units to achieve data format conversion. However, since data format conversion may involve complex mathematical operations, such as taking the reciprocal or exponentiation, it requires a large amount of computing resources, resulting in excessive hardware resource consumption.

[0004] To address the aforementioned issues, existing technologies have proposed using equivalent formulas to replace the actual formulas for data format conversion. However, while this method can save some computational resources, it also results in a loss of computational accuracy.

[0005] Therefore, how to save hardware resources without sacrificing accuracy has become an urgent problem to be solved. Summary of the Invention

[0006] To address the aforementioned technical problems, the technical solution adopted by this invention is as follows: An efficient format conversion method, the method comprising: Based on the received coordinate information, the target address corresponding to the coordinate information is determined in the cache; Based on the target address, retrieve the cached data corresponding to the target address from the cache; Parse the cached data to obtain the first target data type corresponding to the cached data; Based on the first target data type and the second target data type to which the cached data needs to be converted, a target lookup table is determined from a preset lookup table set; The target lookup table is used to determine the intermediate transformed data corresponding to the cached data, and the intermediate transformed data corresponds to the second target data type; Based on the target bit width to which the cached data needs to be converted, the intermediate conversion data is extracted to obtain the target conversion data.

[0007] Compared with the prior art, the present invention has significant advantages. Through the above technical solution, the efficient format conversion method provided by the present invention achieves considerable technological progress and practicality, and has broad industrial application value. It has at least the following advantages: It is evident that changing the complex calculations of data format conversion to table lookup operations effectively simplifies the hardware implementation logic, thereby saving hardware resource consumption. Table lookup operations can also avoid precision loss during data format conversion and support the conversion of multiple data types and bit widths, making data format conversion more flexible. When new data type conversion requirements arise, new lookup tables can be introduced for expansion, making data format conversion more scalable. Attached Figure Description

[0008] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0009] Figure 1 This is a flowchart illustrating an efficient format conversion method provided in an embodiment of the present invention. Detailed Implementation

[0010] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0011] This embodiment provides an efficient format conversion method; see [link to documentation]. Figure 1 This is a flowchart illustrating an efficient format conversion method provided by an embodiment of the present invention. The method includes: S101, Based on the received coordinate information, determine the target address corresponding to the coordinate information in the cache; S102, retrieve the cached data corresponding to the target address from the cache according to the target address; S103, parse the cached data to obtain the first target data type corresponding to the cached data; S104, Based on the first target data type and the second target data type to which the cached data needs to be converted, determine the target lookup table from the preset lookup table set; S105, use the target lookup table to determine the intermediate transformation data corresponding to the cached data, the intermediate transformation data corresponding to the second target data type; S106, according to the target bit width to which the cached data needs to be converted, the intermediate conversion data is extracted to obtain the target conversion data.

[0012] The coordinate information can refer to the pixel position in the texture image during the texture sampling scenario, and the target address can refer to the position of the cached data corresponding to the coordinate information in the cache.

[0013] In data format conversion tasks, cached data can refer to data that needs to be converted in format so that the converted data can be processed by hardware in subsequent operations.

[0014] The first target data type can refer to the data type corresponding to the cached data, that is, the data type that needs to be formatted.

[0015] The second target data type can refer to the data type to which the cached data needs to be converted.

[0016] Based on the first target data type before conversion and the second target data type after conversion, the target lookup table can be determined. The lookup table set can include multiple lookup tables, each corresponding to the data type before conversion and the data type after conversion, respectively.

[0017] The target lookup table includes the mapping relationship between each piece of data before conversion belonging to the first target data type and each piece of data after conversion belonging to the second target data type.

[0018] The mapping relationship containing cached data is determined from the target lookup table, and the transformed data in this mapping relationship is the intermediate transformed data.

[0019] The target bit width can refer to the data bit width required for hardware processing. The target bit width and the second target data type can be preset by the implementer according to the data format required by the actual hardware.

[0020] It can be understood that, given that the first target data type has been determined, in this embodiment, data formats with different bit widths under the same second target data type all use the same lookup table, thereby reducing the number of lookup tables and improving lookup efficiency.

[0021] Target transformed data can refer to data that conforms to the hardware requirements format obtained by converting cached data.

[0022] In one specific implementation, the lookup table set includes M reference lookup tables, where M is a positive integer. For any given reference lookup table, the construction method of the reference lookup table includes: Retrieve the first and second reference data types corresponding to the reference lookup table; Determine the first maximum bit width corresponding to the first reference data type and the second maximum bit width corresponding to the second reference data type; Based on the first maximum bit width, generate several reference data corresponding to the first reference data type; For any reference data, the reference conversion data corresponding to the reference data is determined by a preset conversion formula between the first reference data type and the second reference data type, wherein the bit width of the reference conversion data is the second maximum bit width; The reference lookup table is formed by all the reference data and the reference transformation data corresponding to each reference data.

[0023] The first reference data type can refer to the original data type of the reference lookup table, and the second reference data type can refer to the converted data type of the reference lookup table.

[0024] The first maximum bit width can refer to the maximum value of each bit width corresponding to the first reference data type. The first maximum bit width is determined according to the data format to which the hardware can receive the data.

[0025] The second maximum bit width can refer to the maximum value of each bit width corresponding to the second reference data type. The second maximum bit width is determined according to the data format of the data required for hardware operation.

[0026] Generating reference data can refer to iterating through all possible values ​​of the first reference data type and the first maximum bit width data format. The preset conversion formula between the first reference data type and the second reference data type can be determined according to the DirectX specification document, and will not be elaborated here.

[0027] By using a preset conversion formula, the corresponding reference conversion data for each reference data can be determined, thereby forming several sets of mapping relationships, and a reference lookup table is formed from all the mapping relationships.

[0028] Reference lookup tables can be stored in Verilog file format.

[0029] As can be seen, for a specific second reference data type, the same lookup table is used for data formats with different bit widths under the same first reference data type in this embodiment, thereby reducing the number of lookup tables and improving lookup efficiency.

[0030] In one specific implementation, the method for determining the first maximum bit width includes: The initial temporary bit width N is set to the initial bit width. Determine the first comprehensive area required when the temporary lookup table corresponding to the temporary bit width and the second maximum bit width is implemented in hardware; The second composite area required when the preset conversion formula between the temporary bit width and the second maximum bit width is implemented in hardware; If the first composite area is less than the second composite area, then update N=N+1 and return to the step of determining the first composite area required by the hardware implementation of the temporary lookup table corresponding to the temporary bit width and the second maximum bit width; otherwise, use N as the first maximum bit width.

[0031] The initial bit width can be a low bit width value, such as 3.

[0032] The first comprehensive area can represent the hardware area required to implement the logic of the temporary lookup table through hardware, and the second comprehensive area can represent the hardware area required to implement the operation logic of the preset conversion formula through hardware.

[0033] When the first comprehensive area is smaller than the second comprehensive area, it means that the lookup table implementation saves more hardware resources than the preset conversion formula implementation.

[0034] In one specific implementation, the first maximum bit width is set to 10 bits.

[0035] Preferably, when the first maximum bit width is 10 bits, the lookup table implementation saves more hardware resources than the preset conversion formula implementation; when the first maximum bit width is 11 bits, the preset conversion formula implementation saves more hardware resources than the lookup table implementation. In one specific implementation, the second maximum bit width is set to 32 bits.

[0036] In this embodiment, the maximum data width required by the hardware can be 32 bits, and the implementer can flexibly determine the second maximum width according to the actual situation.

[0037] In one specific implementation, the target bit width includes at least 16 bits, 17 bits, and 32 bits.

[0038] In this embodiment, the bit width of the hardware requirement data is at least 16 bits, 17 bits, and 32 bits. Implementers can add other bit widths as the target bit width according to the actual situation.

[0039] In one specific implementation, the first target data type includes at least the standard red-green-blue data type, the integer data type, and the normalized data type, and the second target data type includes at least the floating-point data type.

[0040] The second target data type may also include integer data types.

[0041] As can be seen, this embodiment avoids performing complex preset conversion formulas on each pixel, and instead uses only lookup tables to achieve format conversion, thereby greatly improving the efficiency of format conversion processing.

[0042] In one specific implementation, when the first target data type is the integer data type, parsing the cached data to obtain the first target data type corresponding to the cached data includes: Parse the cached data to obtain the first target data type corresponding to the cached data and the input coefficients corresponding to the cached data; Accordingly, determining the intermediate transformation data corresponding to the cached data using the target lookup table includes: The target lookup table is used to determine the intermediate transformation data corresponding to the product of the cached data and the input coefficients.

[0043] For cached data that is an integer data type, it supports conversion after multiplying the input coefficients. The input coefficients can be integers or fractions.

[0044] In this embodiment, the complex calculation of data format conversion is changed to a table lookup operation, which effectively simplifies the hardware implementation logic and saves hardware resources. The table lookup operation can also avoid precision loss during data format conversion and can support the conversion of multiple data types and bit widths, making the data format conversion more flexible. When new data type conversion needs arise, new lookup tables can be introduced to expand the data format conversion, making the data format conversion more scalable.

[0045] While specific embodiments of the invention have been described in detail by way of example, those skilled in the art should understand that the examples are for illustrative purposes only and not intended to limit the scope of the invention. Those skilled in the art should also understand that various modifications can be made to the embodiments without departing from the scope and spirit of the invention. The scope of this invention is defined by the appended claims.

Claims

1. An efficient format conversion method, characterized in that, The method includes: Based on the received coordinate information, the target address corresponding to the coordinate information is determined in the cache; Based on the target address, retrieve the cached data corresponding to the target address from the cache; Parse the cached data to obtain the first target data type corresponding to the cached data; Based on the first target data type and the second target data type to which the cached data needs to be converted, a target lookup table is determined from a preset lookup table set. The lookup table set includes M reference lookup tables, where M is a positive integer. For any reference lookup table, the construction method of the reference lookup table includes: Retrieve the first and second reference data types corresponding to the reference lookup table; Determine the first maximum bit width corresponding to the first reference data type and the second maximum bit width corresponding to the second reference data type; Based on the first maximum bit width, generate several reference data corresponding to the first reference data type; For any reference data, the reference conversion data corresponding to the reference data is determined by a preset conversion formula between the first reference data type and the second reference data type, wherein the bit width of the reference conversion data is the second maximum bit width; This reference lookup table is formed by all the reference data and the reference transformation data corresponding to each reference data. The methods for determining the first maximum bit width include: The initial temporary bit width N is set to the initial bit width. Determine the first comprehensive area required when the temporary lookup table corresponding to the temporary bit width and the second maximum bit width is implemented in hardware; The second composite area required when the preset conversion formula between the temporary bit width and the second maximum bit width is implemented in hardware; If the first composite area is less than the second composite area, then update N=N+1 and return to the step of determining the first composite area required by the temporary lookup table corresponding to the temporary bit width and the second maximum bit width when implemented in hardware; otherwise, use N as the first maximum bit width. The target lookup table is used to determine the intermediate transformed data corresponding to the cached data, and the intermediate transformed data corresponds to the second target data type; Based on the target bit width to which the cached data needs to be converted, the intermediate conversion data is extracted to obtain the target conversion data.

2. The efficient format conversion method according to claim 1, characterized in that, The first maximum bit width is set to 10 bits.

3. The efficient format conversion method according to claim 1, characterized in that, The second maximum bit width is set to 32 bits.

4. The efficient format conversion method according to claim 1, characterized in that, The target bit width includes at least 16 bits, 17 bits, and 32 bits.

5. The efficient format conversion method according to claim 1, characterized in that, The first target data type includes at least the standard red-green-blue data type, the integer data type, and the normalized data type, and the second target data type includes at least the floating-point data type.

6. The efficient format conversion method according to claim 5, characterized in that, When the first target data type is the integer data type, parsing the cached data to obtain the first target data type corresponding to the cached data includes: Parse the cached data to obtain the first target data type corresponding to the cached data and the input coefficients corresponding to the cached data; Accordingly, determining the intermediate transformation data corresponding to the cached data using the target lookup table includes: The target lookup table is used to determine the intermediate transformation data corresponding to the product of the cached data and the input coefficients.

Citation Information

Patent Citations

  • Methods and systems for selecting number formats for deep neural networks based on network sensitivity and quantisation error

    CN113822413A

  • Embedded AI power grid waveform dynamic bit width adaptive preprocessing method and system and medium

    CN120045163A

  • Floating point data precision conversion method and device and computer equipment

    CN120353433A

  • Pseudo-LRU cache line replacement for a high-speed cache

    US20090204761A1

  • Processing data using a neural network implemented in hardware

    US20240135153A1