Tensor-filled storage space compression layout method, device and equipment
By reading and mapping tensor layout data, the mapping of the logical space of tensor fill to physical space is realized, solving the problem of extra time and storage space in tensor fill and subsequent storage procedures in the prior art, and achieving more efficient storage and calculation.
Patent Information
- Application Number
- CN202411987954.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-04-29
AI Technical Summary
The prior art requires additional time and storage space in tensor filling and subsequent storage procedures.
By reading the original tensor layout data of the original tensor data under the physical coordinate system, based on this data and fill length parameters, the mapping tensor layout data is obtained, and the mapping of the mapping tensor element is determined according to the fill tensor element reading instruction, the mapping from logical space to physical space is realized, and the actual generation and storage of filled tensors are avoided.
The data copy time overhead and the physical space overhead of storing fill tensors are reduced, solving the problems of additional time and storage space in the prior art.
Smart Images

Figure CN119902993A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a storage space compression layout method, device and equipment for filling tensors. Background Art
[0002] Existing software fills tensors in the form of operator operations, and the calculated filled tensors exist in physical form in the storage space. The data copying, filling, and storage operations all require additional time and storage space. Summary of the invention
[0003] The present invention provides a storage space compression layout method, device and equipment for filling tensors to solve the problem that the existing tensor filling and subsequent storage require extra time and storage space.
[0004] According to one aspect of the present invention, a storage space compression layout method for padding tensors is provided, comprising:
[0005] Read the original tensor layout data of the original tensor data in the physical coordinate system;
[0006] Based on the original tensor layout data and the padding length parameter, the mapping tensor layout data is obtained;
[0007] The mapping tensor element value is determined according to the fill tensor element read instruction and the mapping tensor layout data.
[0008] According to another aspect of the present invention, a storage space compression layout device for filling tensors is provided, comprising:
[0009] The original tensor layout data reading module is used to read the original tensor layout data of the original tensor data in the physical coordinate system;
[0010] A mapping tensor layout data determination module, used to obtain mapping tensor layout data based on the original tensor layout data and a padding length parameter;
[0011] The mapping tensor element value determination module is used to determine the mapping tensor element value according to the filling tensor element reading instruction and the mapping tensor layout data.
[0012] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0013] at least one processor; and
[0014] a memory communicatively connected to the at least one processor; wherein,
[0015] 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 storage space compression layout method of the padded tensor described in any embodiment of the present invention.
[0016] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the storage space compression layout method of a padding tensor described in any embodiment of the present invention when executed.
[0017] The technical solution of the embodiment of the present invention obtains the mapping tensor layout data based on the original tensor layout data and the filling length parameter by reading the original tensor layout data of the original tensor data in the physical coordinate system, and then determines the mapping tensor element value according to the filling tensor element reading instruction and the mapping tensor layout data. In this solution, the filling tensor is described by mapping the tensor layout data, and a filling tensor is no longer actually generated, and a real physical storage space is not required to store the filled tensor. Therefore, based on the mapping tensor layout data, the specific value of the element in the filling tensor is determined by mapping the logical space to the physical space, which can not only reduce the data copy time overhead, but also reduce the physical space overhead of storing the filling tensor, solving the problem of the existing tensor filling and subsequent storage, which requires extra time and storage space. The technical solution of the embodiment of the present invention does not need to actually generate the filling tensor in the physical storage space, which can greatly reduce the extra time overhead and storage space overhead caused by the filling tensor.
[0018] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended 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
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0020] Figure 1 A schematic diagram of physical space occupancy of an existing tensor filling method provided in the first embodiment of the present invention;
[0021] Figure 2 A schematic diagram of physical space occupation of an improved tensor filling method provided in the first embodiment of the present invention;
[0022] Figure 3 A flowchart of a storage space compression layout method for filling tensors provided in the first embodiment of the present invention;
[0023] Figure 4 A flowchart of a storage space compression layout method for filling tensors provided in Embodiment 2 of the present invention;
[0024] Figure 5 A schematic diagram of a coordinate mapping process of a filling tensor provided in the second embodiment of the present invention;
[0025] Figure 6 A schematic diagram of the relationship between a physical coordinate system and a mapping tensor logical coordinate system provided in the second embodiment of the present invention;
[0026] Figure 7 A schematic diagram of the structure of a storage space compression layout device for filling tensors provided in Embodiment 3 of the present invention;
[0027] Figure 8 A schematic diagram of the structure of an electronic device that can be used to implement an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0028] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, 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 "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0030] Embodiment 1
[0031] The arrangement of a tensor in physical storage space can be expressed using a layout. Therefore, if you only want to change the arrangement position of the elements of the tensor itself, you only need to calculate and modify the shape (equivalent to the length of the tensor) and the stride (equivalent to the distance between the elements of the tensor) on the layout. This solution uses layout instead of operators to complete the filling operation, which can avoid the overhead of additional storage space and data copying operations, and lightly complete the mapping from logical positions to physical positions, using less time and space to complete tensor filling. Filling can be regarded as a mapping function. The filling operation maps the tensor from physical coordinates to logical coordinates, and conversely, the addressing operation maps the filled tensor from logical coordinates to physical coordinates. That is, the original tensor is in the physical space and has physical coordinates, while the filled tensor is in the logical space and has logical coordinates.
[0032] In order to better illustrate the difference in physical storage space occupied by existing tensor filling and this solution, you can compare Figure 1 and Figure 2 The advantage of using layout to characterize the padding tensor is that, although the padding tensor will be larger than the original tensor, it still only occupies the size of the original tensor in physical storage space, which is smaller than the physical storage space used by the operator operation. At the same time, the spatial mapping relationship of each padding element is calculated on the hardware, and there is no need to copy an extra complete non-padding element like the operator operation, which reduces the time of data copying operation.
[0033] Figure 3 This is a flowchart of a storage space compression layout method for filling tensors provided in the first embodiment of the present invention. This embodiment is applicable to the case where no real physical storage space is required to store the filled tensors. The method can be executed by a storage space compression layout device for filling tensors. The storage space compression layout device for filling tensors can be implemented in the form of hardware and / or software. The storage space compression layout device for filling tensors can be configured in an electronic device. Figure 3 As shown, the method includes:
[0034] Step 110: Read original tensor layout data of original tensor data in a physical coordinate system.
[0035] Among them, the physical coordinate system can be a coordinate system that describes the specific position of the tensor in the physical storage space, that is, it is used to describe the arrangement of tensor elements in the physical storage space. The original tensor data can be the initial tensor stored in the physical storage space, that is, the tensor before filling. The original tensor layout data can be data that characterizes the arrangement of tensor elements. Exemplarily, the original tensor layout data can include the length of the original tensor data in each tensor dimension under the physical coordinate system, and the distance between each element in the original tensor data.
[0036] In the embodiment of the present invention, the original tensor data stored in the physical storage space is first determined, and the original tensor layout data of the original tensor data in the physical coordinate system is read.
[0037] Step 120: Obtain mapping tensor layout data based on the original tensor layout data and the padding length parameter.
[0038] The padding length parameter may be a parameter describing the padding length when the tensor is filled. The mapping tensor layout data may be the layout data after the original tensor data is filled in the logical space, that is, the layout data of the filled tensor of the original tensor data in the logical mapping space. Tensor padding is an operation of adding elements to the outer circle of the tensor to make the tensor larger.
[0039] In an embodiment of the present invention, the length of the original tensor data in each tensor dimension can be determined based on the original tensor layout data, and the filling length of the original tensor data in each tensor dimension after tensor filling can be calculated based on the filling length parameter, thereby determining the layout of the original tensor data after tensor filling, that is, obtaining the mapping tensor layout data.
[0040] It should be noted that determining the layout of the original tensor data after tensor filling only determines the layout of the original tensor data after tensor filling. There is no need to clarify the specific values of the positions of each element in the filling tensor after the tensor filling. The entire process does not need to generate a filling tensor, nor does it need to store the filling tensor.
[0041] Step 130: Determine a mapping tensor element value according to the fill tensor element read instruction and the mapping tensor layout data.
[0042] The fill tensor element reading instruction may be an instruction for reading an element in a fill tensor of the original tensor data. The mapped tensor element value may be a numerical value of an element in a fill tensor of the original tensor data.
[0043] In an embodiment of the present invention, when a padding tensor element reading instruction of the original tensor data is detected, the padding tensor element reading instruction is parsed to determine the element to be read in the padding tensor of the original tensor data, and then based on the mapping tensor layout data, the mapping is performed to the physical coordinate system, and the value of the element to be read in the physical coordinate system is determined as the mapping tensor element value. In the process of determining the mapping tensor element value, this solution also does not need to generate a padding tensor, nor does it need to store the padding tensor.
[0044] The technical solution of the embodiment of the present invention obtains the mapping tensor layout data based on the original tensor layout data and the filling length parameter by reading the original tensor layout data of the original tensor data in the physical coordinate system, and then determines the mapping tensor element value according to the filling tensor element reading instruction and the mapping tensor layout data. In this solution, the filling tensor is described by mapping the tensor layout data, and a filling tensor is no longer actually generated, and a real physical storage space is not required to store the filled tensor. Therefore, based on the mapping tensor layout data, the specific value of the element in the filling tensor is determined by mapping the logical space to the physical space, which can not only reduce the data copy time overhead, but also reduce the physical space overhead of storing the filling tensor, solving the problem of the existing tensor filling and subsequent storage, which requires extra time and storage space. The technical solution of the embodiment of the present invention does not need to actually generate the filling tensor in the physical storage space, which can greatly reduce the extra time overhead and storage space overhead caused by the filling tensor.
[0045] Embodiment 2
[0046] Figure 4 This is a flowchart of a storage space compression layout method for a padded tensor provided in the second embodiment of the present invention. This embodiment is specific based on the above embodiment and provides a specific optional implementation method for obtaining the mapped tensor layout data based on the original tensor layout data and the padded length parameter. Figure 4 As shown, the method includes:
[0047] Step 210: Read the original tensor layout data of the original tensor data in the physical coordinate system.
[0048] Step 220: Determine a first padding length and a second padding length for each tensor dimension according to the padding length parameter.
[0049] Among them, the first padding length can be used to describe the length of padding at the head of the tensor dimension of the original tensor data. The second padding length can be used to describe the length of padding at the tail of the tensor dimension of the original tensor data. The first padding length can be understood as the length of low padding in a certain dimension of the original tensor data. The second padding length can be understood as the length of high padding in a certain dimension of the original tensor data.
[0050] In an embodiment of the present invention, the padding length parameter may be parsed to determine a first padding length and a second padding length of the original tensor data in each tensor dimension.
[0051] Step 230: Determine mapping tensor layout data according to the original tensor layout data, the first padding length, and the second padding length.
[0052] In an embodiment of the present invention, the initial tensor length of the original tensor data in each tensor dimension can be determined based on the original tensor layout data, and then the first filling length and the second filling length corresponding to each tensor dimension can be used to determine the layout of the filling tensor of the original tensor data in the logical space, that is, to obtain the mapping tensor layout data.
[0053] Step 240: Determine the mapping tensor element value according to the fill tensor element read instruction and the mapping tensor layout data.
[0054] In an optional embodiment of the present invention, determining the mapping tensor element value according to the filling tensor element reading instruction and the mapping tensor layout data may include: creating a mapping tensor logical coordinate system according to the mapping tensor layout data; determining the logical coordinates of the mapping tensor element to be queried according to the filling tensor element reading instruction and the mapping tensor logical coordinate system; determining the mapping tensor element value according to the logical coordinates of the mapping tensor element to be queried.
[0055] The mapping tensor logical coordinate system may be a logical coordinate system that describes the position of elements in the padding tensor of the original tensor data, and may be used to describe the arrangement of the padding tensor elements of the original tensor data. The mapping tensor element to be queried may be an element to be read in the padding tensor of the original tensor data, determined based on the padding tensor element read instruction.
[0056] In an embodiment of the present invention, a mapping tensor logical coordinate system that describes the position of each tensor element in the filled tensor of the original tensor data can be created in the logical space based on the mapping tensor layout data, and further based on the filling tensor element reading instruction, the position of the element to be read in the filled tensor of the original tensor data in the mapping tensor logical coordinate system is determined to obtain the logical coordinates of the mapping tensor element to be queried, and then mapped to the physical coordinate system according to the logical coordinates of the mapping tensor element to be queried to obtain the mapping tensor element value.
[0057] In an optional embodiment of the present invention, determining the mapping tensor element value according to the logical coordinates of the mapping tensor element to be queried may include: when it is determined that the element type of the mapping tensor element to be queried is a non-filling element according to the logical coordinates of the mapping tensor element to be queried, determining the mapping tensor element value according to the logical coordinates of the mapping tensor element to be queried and the original tensor data; when it is determined that the element type of the mapping tensor element to be queried is a filling element according to the logical coordinates of the mapping tensor element to be queried, determining the mapping tensor element value according to the filling mapping method.
[0058] Wherein, non-filling elements are elements on the original tensor data. Filling elements are elements that do not exist in the original tensor data and are added to the original tensor data based on the filling operation. The filling mapping mode can be the mapping mode of the tensor filling operation.
[0059] In an embodiment of the present invention, it is possible to determine whether the logical coordinates of the mapped tensor element to be queried can be mapped to the physical coordinate system. If it can be mapped to the physical coordinate system, it is determined that the element type of the mapped tensor element to be queried is a non-filling element, thereby determining the mapping tensor element value according to the logical coordinates of the mapped tensor element to be queried, the physical coordinate system and the original tensor data. If the logical coordinates of the mapped tensor element to be queried cannot be mapped to the physical coordinate system, it is determined that the element type of the mapped tensor element to be queried is a filling element, thereby determining the data value mapped to the mapped tensor element to be queried from the original tensor data according to the filling mapping method, and obtaining the mapping tensor element value.
[0060] Optionally, before determining whether the logical coordinates of the mapping tensor element to be queried can be mapped to the physical coordinate system, it can also be determined whether the logical coordinates of the mapping tensor element to be queried belong to the mapping tensor logical coordinate system. If it belongs to the mapping tensor logical coordinate system, the logical coordinates of the mapping tensor element to be queried are determined to be valid coordinates. Then, when it is determined that the logical coordinates of the mapping tensor element to be queried are valid coordinates, it is determined whether the logical coordinates of the mapping tensor element to be queried can be mapped to the physical coordinate system.
[0061] In an optional embodiment of the present invention, determining the mapping tensor element value based on the logical coordinates of the mapping tensor element to be queried and the original tensor data may include: determining the physical coordinates to be queried based on the logical coordinates of the mapping tensor element to be queried and the coordinate deviation value; determining the mapping tensor element value based on the physical coordinates to be queried, the original tensor data and the original tensor layout data.
[0062] The coordinate deviation value can be used to describe the deviation between the physical coordinate system and the mapping tensor logical coordinate system. The physical coordinates to be queried can be coordinates in a physical coordinate system that has a mapping relationship with the logical coordinates of the mapping tensor element to be queried.
[0063] In an embodiment of the present invention, the header padding length value of the original tensor data in the padding dimension can be used as the coordinate deviation value under the padding dimension, and the coordinate value of the logical coordinate of the mapping tensor element to be queried is subtracted from the coordinate deviation value to obtain the physical coordinate to be queried, and then based on the physical coordinate to be queried and the original tensor layout data, the value in the original tensor data that has a mapping relationship with the mapping tensor element to be queried is queried as the mapping tensor element value.
[0064] In an optional embodiment of the present invention, the filling mapping mode may be any one of constant filling, reflection filling, symmetric filling, cyclic filling and copy filling.
[0065] The embodiment of the present invention is based on the above filling mapping method, which saves storage space while retaining the diversity of filling.
[0066] Exemplarily, the layout of the filling tensor and the spatial mapping in this solution, the logical calculation of various filling mapping methods can be implemented on hardware. The following pseudo code is used to explain in detail the mapping of filling elements under various filling mapping methods and the method of calculating physical coordinates, where coord in the pseudo code is the coordinate after deducting the coordinate deviation value from the logical coordinate of the element, dim_size is the shape of the tensor before filling, pad_low is low filling, and pad_high is high filling.
[0067] Constant padding returns the padding constant value (Padding Value) preset by the user. The pseudo code of constant padding is as follows:
[0068] if coord<0or coord>=dim_size:
[0069] / / The logical coordinates are not within the coordinate range of non-filling elements, that is, the fill element returnpadding_value
[0070] Reflection filling will recursively calculate the physical coordinates to which the filling elements are mapped based on the current size of the tensor in a certain dimension. The pseudo code for reflection filling is as follows:
[0071]
[0072]
[0073] Symmetric fill is similar to reflected fill, but the physical coordinates will have a deviation of 1 grid from the reflected coordinates. Based on the physical coordinates calculated by reflected fill, the position of the element with low fill needs to be -1, and the position of the element with high fill needs to be +1.
[0074] The loop filling is to perform modulo operation on the size of each dimension of the original tensor data for the logical coordinates to obtain the physical coordinates to be mapped. The pseudo code of the loop filling is as follows:
[0075]
[0076] Copy fill: Just take the physical coordinates of the nearest non-fill element in each dimension.
[0077]
[0078] In an optional embodiment of the present invention, determining the mapping tensor element value according to the filling mapping mode may include: when the filling mapping mode is constant filling, using the user preset filling value as the mapping tensor element value; when the filling mapping mode is not constant filling, determining the mapping tensor element value according to the logical coordinates of the mapping tensor element to be queried, the filling mapping mode, the original tensor data and the original tensor layout data.
[0079] The user-preset filling value may be a filling constant value preset by the user.
[0080] In the embodiment of the present invention, if the filling mapping mode is constant filling, the user preset filling value is directly used as the mapping tensor element value. If the filling mapping mode is not constant filling, the element value mapped to the mapping tensor element to be queried in the original tensor data is determined according to the logical coordinates of the mapping tensor element to be queried and the original tensor layout data according to the filling mapping mode, and the mapping tensor element value is obtained.
[0081] Constant filling directly reads the preset constant value, while other filling mapping methods first map the filling element to the physical storage location of the non-filling element through the index address space calculated by the hardware to obtain the value. That is, the filling layout operation uses a software method to perform a one-to-many mapping of the physical space to the logical space. Multiple filling elements in the logical space will reuse the value of the same physical storage space, achieving the benefit of data reuse.
[0082] Figure 5 A schematic diagram of a coordinate mapping process of a filling tensor provided in the second embodiment of the present invention. Figure 5 As shown, first obtain the element in the filling tensor under the logical space (i.e., the mapping tensor element to be queried), and then determine whether the element in the filling tensor under the logical space is a filling element. If it is a non-filling element, subtract the coordinate deviation value from the logical coordinate of the mapping tensor element to be queried, obtain the physical coordinate mapped by the mapping tensor element to be queried, access the physical coordinate, and return the mapping tensor element value. If it is a filling element, check whether the filling mapping method set by the user is constant filling. If it is constant filling, obtain the user-preset filling value, and return the user-preset filling value as the mapping tensor element value. If it is a constant filling, determine the physical coordinate mapped by the mapping tensor element to be queried based on the filling mapping method, access the physical coordinate, and obtain the mapping tensor element value.
[0083] The mapping between logical address space and physical address space is called index space mapping. The calculation of index space only involves simple mathematics, so the logical method of this operation can be implemented by hardware. The hardware only needs to have the addressing function to complete this mapping.
[0084] In a specific example, the origin offset between the mapping tensor logical coordinate system and the physical coordinate system is called the coordinate system offset, and the specific offset value is the coordinate deviation value. Figure 6 The relationship between the physical coordinate system and the mapping tensor logical coordinate system is shown. Figure 6 It is referred to as the logical coordinate system in the text. There are two types of elements in a filled tensor: filled elements and non-filled elements. To determine the value of a filled tensor element, you need to first use the logical coordinates of the element to determine whether it is a filled element. If it is a non-filled element, the physical coordinates of the element can be obtained by subtracting the coordinate deviation value from the logical coordinates (that is, the logical coordinates of the mapped tensor element to be queried can be mapped to the physical coordinate system); if it is a filled element, the physical coordinates of the element in the physical storage space must be mapped through the filling mapping method (that is, the logical coordinates of the mapped tensor element to be queried cannot be mapped to the physical coordinate system). Secondly, you can also detect whether the logical coordinates of the element are valid coordinates by judging whether the logical coordinates of the element belong to the logical coordinate system of the mapped tensor.
[0085] The technical solution of the embodiment of the present invention reads the original tensor layout data of the original tensor data in the physical coordinate system, thereby determining the first filling length and the second filling length under each tensor dimension according to the filling length parameter, and then determining the mapping tensor layout data according to the original tensor layout data, the first filling length and the second filling length, and determining the mapping tensor element value according to the filling tensor element reading instruction and the mapping tensor layout data. In this solution, by describing the filling tensor through the mapping tensor layout data, a filling tensor is no longer actually generated, and a real physical storage space is not required to store the filled tensor, so based on the mapping tensor layout data, the specific value of the element in the filling tensor is determined by mapping the logical space to the physical space, which can not only reduce the data copy time overhead, but also reduce the physical space overhead of storing the filling tensor, solving the problem of the existing tensor filling and subsequent storage, which requires extra time and storage space. The technical solution of the embodiment of the present invention does not need to actually generate the filling tensor in the physical storage space, which can greatly reduce the extra time overhead and storage space overhead caused by the filling tensor.
[0086] Embodiment 3
[0087] Figure 7 This is a schematic diagram of the structure of a storage space compression layout device for filling tensors provided in Embodiment 3 of the present invention. Figure 7 As shown, the device comprises:
[0088] The original tensor layout data reading module 310 is used to read the original tensor layout data of the original tensor data in the physical coordinate system;
[0089] A mapping tensor layout data determination module 320, configured to obtain mapping tensor layout data based on the original tensor layout data and a padding length parameter;
[0090] The mapping tensor element value determination module 330 is used to determine the mapping tensor element value according to the filling tensor element reading instruction and the mapping tensor layout data.
[0091] The technical solution of the embodiment of the present invention obtains the mapping tensor layout data based on the original tensor layout data and the filling length parameter by reading the original tensor layout data of the original tensor data in the physical coordinate system, and then determines the mapping tensor element value according to the filling tensor element reading instruction and the mapping tensor layout data. In this solution, the filling tensor is described by mapping the tensor layout data, and a filling tensor is no longer actually generated, and a real physical storage space is not required to store the filled tensor. Therefore, based on the mapping tensor layout data, the specific value of the element in the filling tensor is determined by mapping the logical space to the physical space, which can not only reduce the data copy time overhead, but also reduce the physical space overhead of storing the filling tensor, solving the problem of the existing tensor filling and subsequent storage, which requires extra time and storage space. The technical solution of the embodiment of the present invention does not need to actually generate the filling tensor in the physical storage space, which can greatly reduce the extra time overhead and storage space overhead caused by the filling tensor.
[0092] Optionally, the mapping tensor layout data determination module 320 includes: determining a first filling length and a second filling length under each tensor dimension according to the filling length parameter; and determining the mapping tensor layout data according to the original tensor layout data, the first filling length and the second filling length.
[0093] Optionally, the mapping tensor element value determination module 330 is specifically used to create a mapping tensor logical coordinate system according to the mapping tensor layout data; determine the logical coordinates of the mapping tensor element to be queried according to the filling tensor element reading instruction and the mapping tensor logical coordinate system; and determine the mapping tensor element value according to the logical coordinates of the mapping tensor element to be queried.
[0094] Optionally, the mapping tensor element value determination module 330 is specifically used to determine the mapping tensor element value according to the logical coordinates of the mapping tensor element to be queried and the original tensor data when it is determined that the element type of the mapping tensor element to be queried is a non-filling element according to the logical coordinates of the mapping tensor element to be queried; and to determine the mapping tensor element value according to the filling mapping method when it is determined that the element type of the mapping tensor element to be queried is a filling element according to the logical coordinates of the mapping tensor element to be queried.
[0095] Optionally, the mapping tensor element value determination module 330 is specifically used to determine the physical coordinates to be queried based on the logical coordinates and coordinate deviation value of the mapping tensor element to be queried; and determine the mapping tensor element value based on the physical coordinates to be queried, the original tensor data and the original tensor layout data.
[0096] Optionally, the filling mapping mode is any one of constant filling, reflection filling, symmetric filling, loop filling and copy filling.
[0097] Optionally, the mapping tensor element value determination module 330 is specifically used to use the user preset filling value as the mapping tensor element value when the filling mapping method is constant filling; when the filling mapping method is not constant filling, determine the mapping tensor element value according to the logical coordinates of the mapping tensor element to be queried, the filling mapping method, the original tensor data and the original tensor layout data.
[0098] The storage space compression layout device for padding tensors provided in an embodiment of the present invention can execute the storage space compression layout method for padding tensors provided in any embodiment of the present invention, and has functional modules and beneficial effects corresponding to the execution method.
[0099] Embodiment 4
[0100] Figure 8 A schematic diagram of an electronic device that can be used to implement an embodiment of the present invention is shown. 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 may also represent various forms of mobile devices, such as personal digital assistants, 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 examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0101] like Figure 8As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and 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 to 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. An input / output (I / O) interface 15 is also connected to the bus 14.
[0102] A number of 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 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.
[0103] The processor 11 may be a variety of 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, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 11 performs the various methods and processes described above, such as a storage space compression layout method for filling tensors.
[0104] In some embodiments, the storage space compression layout method for filling tensors may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on 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 storage space compression layout method for filling tensors described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the storage space compression layout method for filling tensors in any other appropriate manner (e.g., by means of firmware).
[0105] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations 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 can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0106] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0107] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0108] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0109] The systems and techniques described herein may 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 with a graphical user interface or a web browser through which a user can interact with implementations 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 may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0110] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may 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 to solve the defects of traditional physical hosts and VPS servers, which are difficult to manage and have weak business scalability.
[0111] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. 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 this document does not limit this.
[0112] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A storage space compression layout method for filling tensors, characterized in that: include: Read the original tensor layout data of the original tensor data in the physical coordinate system; Based on the original tensor layout data and the padding length parameter, obtaining mapping tensor layout data; Determine a mapping tensor element value according to the fill tensor element read instruction and the mapping tensor layout data.
2. The method according to claim 1, characterized in that Based on the original tensor layout data and the padding length parameter, mapping tensor layout data is obtained, including: Determine a first filling length and a second filling length for each tensor dimension according to the filling length parameter; The mapping tensor layout data is determined according to the original tensor layout data, the first padding length, and the second padding length.
3. The method according to claim 1, characterized in that Determining a mapping tensor element value according to the fill tensor element read instruction and the mapping tensor layout data includes: Creating a mapping tensor logical coordinate system according to the mapping tensor layout data; Determine the logical coordinates of the mapping tensor element to be queried according to the filling tensor element reading instruction and the mapping tensor logical coordinate system; Determine the mapping tensor element value according to the logical coordinates of the mapping tensor element to be queried.
4. The method according to claim 3, characterized in that Determining the mapping tensor element value according to the logical coordinates of the mapping tensor element to be queried includes: When it is determined that the element type of the mapping tensor element to be queried is a non-filling element according to the logical coordinates of the mapping tensor element to be queried, determining the mapping tensor element value according to the logical coordinates of the mapping tensor element to be queried and the original tensor data; When it is determined that the element type of the mapping tensor element to be queried is a filling element according to the logical coordinates of the mapping tensor element to be queried, the mapping tensor element value is determined according to the filling mapping mode.
5. The method according to claim 4, characterized in that Determining the mapping tensor element value according to the logical coordinates of the mapping tensor element to be queried and the original tensor data includes: Determine the physical coordinates to be queried according to the logical coordinates and coordinate deviation value of the mapping tensor element to be queried; The mapping tensor element value is determined according to the physical coordinates to be queried, the original tensor data and the original tensor layout data.
6. The method according to claim 4, characterized in that The filling mapping mode is any one of constant filling, reflection filling, symmetric filling, loop filling and copy filling.
7. The method according to claim 6, characterized in that Determining the mapping tensor element value according to the filling mapping mode includes: When the filling mapping mode is constant filling, the user preset filling value is used as the mapping tensor element value; When the filling mapping mode is not constant filling, the mapping tensor element value is determined according to the logical coordinates of the mapping tensor element to be queried, the filling mapping mode, the original tensor data and the original tensor layout data.
8. A storage space compression layout device for filling tensors, characterized in that: include: The original tensor layout data reading module is used to read the original tensor layout data of the original tensor data in the physical coordinate system; A mapping tensor layout data determination module, used to obtain mapping tensor layout data based on the original tensor layout data and a padding length parameter; A mapping tensor element value determination module is used to determine the mapping tensor element value according to the filling tensor element reading instruction and the mapping tensor layout data.
9. 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 to enable the at least one processor to perform the storage space compression layout method of the padded tensor according to any one of claims 1 to 7.
10. 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 storage space compression layout method of a padded tensor according to any one of claims 1 to 7 when executed.
Citation Information
Cited By
Data loading method, data storage method, processor, electronic equipment and medium
CN120123264A
Storage space management method, management device, system and medium
CN120315900A