Data type conversion control method, device and equipment and computer readable medium
By constructing type grids and controlling data type conversion according to numerical ranges, the problem of data type conversion errors in model simulation is solved, the accuracy and accuracy of data type conversion is achieved, and the accuracy of model simulation is improved.
Patent Information
- Application Number
- CN202411371224.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2024-12-17
AI Technical Summary
During model simulation, data type conversion errors lead to data distortion or reduced accuracy, and existing automatic and cast conversion methods cannot effectively avoid these problems.
By obtaining multiple data types and their numerical ranges of the modeling and simulation tool, building a type grid and sorting it according to the numerical range, traversing the module to control data type conversion, ensuring that the order of data type conversion is from small to large, and avoiding data types Conversion errors and accuracy reduction.
The accuracy and accuracy of data type conversion is achieved, data distortion and accuracy reduction are avoided, and the accuracy and correctness of model simulation are improved.
Smart Images

Figure CN119149621A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to a data type conversion control method, device, equipment and computer-readable medium. Background Art
[0002] At present, with the development of computer technology, model simulation can be performed using embedded software modeling and simulation tools. In the process of model simulation, data interaction is required between modules, and there may be inconsistencies in data types during data interaction. Therefore, a type system needs to be introduced for data interaction between modules to ensure that data interaction between modules does not affect data accuracy. The type system specifies a data type for each variable. Logically speaking, a data type is a set of ranges of values that a variable can represent. Currently, most computer programming languages have two methods: automatic type conversion and forced type conversion.
[0003] Currently, whether it is automatic type conversion or forced type conversion, there may be data type conversion errors when converting data, resulting in data distortion or reduced accuracy. Summary of the invention
[0004] In view of this, the purpose of the present application is to provide a data type conversion control method, device, equipment and computer-readable medium, which can avoid data type conversion errors and avoid data distortion or reduced accuracy.
[0005] The present application provides a data type conversion control method, the method comprising:
[0006] Obtain multiple data types corresponding to the modeling and simulation tool and the value range of each data type;
[0007] Determine the numerical range sorting of multiple data types according to the numerical range of each data type;
[0008] Constructing a plurality of nodes of a type lattice according to a plurality of data types, and sorting a connection sequence of the type lattice according to the numerical range;
[0009] Traverse all modules and control the data type corresponding to each module according to the type grid.
[0010] Optionally, the connection sequence is from small to large;
[0011] The traversing of all modules and controlling the data type corresponding to each module according to the type grid includes:
[0012] All modules are traversed, and the data type corresponding to each module is controlled according to the connection sequence from small to large in the type grid.
[0013] Optionally, the total modules include upstream modules and downstream modules;
[0014] The traversing of all modules and controlling the data type corresponding to each module according to the connection sequence from small to large in the type grid includes:
[0015] All modules are traversed, and the data types corresponding to the upstream modules and the downstream modules are controlled according to the connection sequence from small to large in the type grid, and the numerical range of the data type of the upstream module is smaller than the numerical range of the data type of the downstream module.
[0016] Optionally, the entire modules include a calculation module and a numerical module, the numerical module includes a first numerical module and a second numerical module, and the calculation module is located between the first numerical module and the second numerical module;
[0017] The traversing of all modules and controlling the data type corresponding to each module according to the connection sequence from small to large in the type grid includes:
[0018] Traversing all the numerical modules, obtaining the data type of the first numerical module and the data type of the second numerical module that have been determined, and determining the data type with a larger numerical range of the data types in the first numerical module and the second numerical module according to the connection sequence from small to large in the type grid;
[0019] Based on the data type with a larger numerical range in the first numerical module and the second numerical module, the data type of the output result obtained by the operation of the first numerical module, the second numerical module and the operation module is determined according to the connection sequence from small to large in the type grid.
[0020] Optionally, the numerical ranges of the multiple data types are sorted from small to large;
[0021] The connection sequence of constructing the type grid according to the numerical range includes:
[0022] The connection order of the type grid from small to large is constructed according to the numerical range sorting from small to large and the data type conversion rule, wherein the data type conversion rule is used to indicate whether conversion can be performed between multiple data types.
[0023] Optionally, the method further comprises:
[0024] Get the data type corresponding to each module in multiple modules;
[0025] The data types of the multiple modules are verified according to the connection sequence in the type grid to obtain a verification result.
[0026] Optionally, the multiple modules include an upstream module and a downstream module, and the connection sequence is a connection sequence from small to large;
[0027] The checking of the data types of the multiple modules according to the connection sequence in the type grid to obtain the checking result includes:
[0028] Verify the numerical range corresponding to the data type of the upstream module and the numerical range corresponding to the data type of the downstream module according to the connection sequence from small to large in the type grid;
[0029] If the numerical range corresponding to the data type of the upstream module is larger than the numerical range corresponding to the data type of the downstream module, the verification result is verification failure;
[0030] If the numerical range corresponding to the data type of the upstream module is smaller than the numerical range corresponding to the data type of the downstream module, the verification result is verification passed.
[0031] The present application provides a data type conversion control device, the device comprising:
[0032] An acquisition unit, used to acquire multiple data types corresponding to the modeling and simulation tool and a value range of each data type;
[0033] A determination unit, used to determine the numerical range order of multiple data types according to the numerical range of each data type;
[0034] A construction unit, used to construct a plurality of nodes of a type lattice according to a plurality of data types, and to sort a connection sequence of the constructed type lattice according to the numerical range;
[0035] The control unit is used to traverse all modules and control the data type corresponding to each module according to the type grid.
[0036] The present application provides a data type conversion control device, the device comprising: a processor and a memory;
[0037] The memory is used to store instructions;
[0038] The processor is used to execute the instructions in the memory and perform any of the methods described above.
[0039] The present application provides a computer-readable medium, characterized in that it includes instructions, which, when executed on a computer, enable the computer to execute the method described above.
[0040] The present application provides a data type conversion control method, which includes: obtaining multiple data types corresponding to a modeling and simulation tool and a numerical range of each data type, determining a numerical range sorting of multiple data types according to the numerical range of each data type, constructing multiple nodes of a type grid according to the multiple data types, and constructing a connection order of the type grid according to the numerical range sorting, that is, sorting the multiple data types using the data ranges of the multiple data types to obtain a numerical range sorting, thereby constructing a type grid using the multiple data types and the numerical range sorting, the type grid can reflect whether data type conversion can be performed between multiple data types and the order of data type conversion, and can achieve smooth data type conversion of multiple data types according to the type grid by traversing all modules and controlling the data type corresponding to each module according to the type grid, thereby avoiding data type conversion errors and avoiding data distortion or reduced accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The above and other features, advantages and aspects of the embodiments of the present application will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0042] Figure 1 A schematic diagram of a data type conversion control method provided in an embodiment of the present application is shown;
[0043] Figure 2 A schematic diagram of a type of grid provided in an embodiment of the present application is shown;
[0044] Figure 3 A structural schematic diagram of a data type conversion control device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0045] The embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be construed as being limited to the embodiments described herein. Instead, these embodiments are provided to provide a more thorough and complete understanding of the present application. It should be understood that the drawings and embodiments of the present application are only for exemplary purposes and are not intended to limit the scope of protection of the present application.
[0046] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0047] It should be noted that the concepts such as "first" and "second" mentioned in this application are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0048] It should be noted that the modifications of "one" and "plurality" mentioned in the present application are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0049] At present, most computer programming languages have two types of conversion: automatic type conversion and forced type conversion. Automatic type conversion is the data type conversion performed silently, implicitly, and secretly by the compiler. This conversion does not require the intervention of the programmer and will occur automatically. Automatic type conversion occurs when data of one data type is assigned to a variable of another data type. Forced type conversion is to perform data type conversion explicitly. For example, it is necessary to convert the data type generated by the calculation of the upstream module from the first type to the second type, and send the second type of data to the downstream module as the input data of the downstream module. After the downstream module receives the second type of data, it will convert the second type of data into the data type required by the downstream module. This conversion process is mandatory and the data will not be verified.
[0050] During the forced type conversion process, although the engineer has explicitly converted the data type, the actual model simulation cannot be carried out completely as the engineer imagined. If the value size changes, it is difficult to find the problem in the type conversion. Engineers need to conduct a lot of tests and verifications to find the problem, and it is difficult to solve the problem.
[0051] In addition, whether it is automatic type conversion or forced type conversion, when performing data conversion, the data type may be explicitly forced to be modified, and the data cannot be verified during the simulation process, resulting in the simulation results not being consistent with the expected results. That is, there is a data type conversion error, which leads to data distortion or reduced accuracy.
[0052] Based on this, the present application provides a data type conversion control method, the method comprising: obtaining multiple data types corresponding to a modeling and simulation tool and a numerical range of each data type, determining a numerical range sorting of multiple data types according to the numerical range of each data type, constructing multiple nodes of a type grid according to the multiple data types, and constructing a connection order of the type grid according to the numerical range sorting, that is, sorting the multiple data types using the data ranges of the multiple data types to obtain a numerical range sorting, thereby constructing a type grid using the multiple data types and the numerical range sorting, the type grid can reflect whether data type conversion can be performed between multiple data types and the order of data type conversion, and can achieve smooth data type conversion of multiple data types according to the type grid by traversing all modules and controlling the data type corresponding to each module according to the type grid, thereby avoiding data type conversion errors and avoiding data distortion or reduced accuracy.
[0053] In order to better understand the technical solution and technical effects of the present application, specific embodiments will be described in detail below with reference to the accompanying drawings.
[0054] See also Figure 1 , which is a flow chart of a data type conversion control method provided in an embodiment of the present application.
[0055] The data type conversion control method provided in the embodiment of the present application includes the following steps:
[0056] S101, obtaining multiple data types corresponding to a modeling and simulation tool and a value range of each data type.
[0057] In an embodiment of the present application, when a model simulation is performed using a modeling and simulation tool, multiple data types that the modeling and simulation tool needs to use are obtained. In addition to obtaining multiple data types corresponding to the modeling and simulation tool, the numerical range of each data type is also obtained so as to be used as the data basis for subsequent data type conversion. Different data types have different numerical ranges. Therefore, when converting data types, if the data type conversion is wrong, data distortion or reduced accuracy may be caused by mismatching the numerical range of the data type.
[0058] As an example, the multiple data types corresponding to the modeling and simulation tool are double-precision floating point type (double), single-precision floating point type (float), integer type (int), short integer type (short) and byte type (byte). The value range of double is -1.7E308 to 1.7E+308, the value range of float is -3.4028235E38 to 3.4028235E38, the value range of int is -2147483648 to 2147483647, the value range of short is -32768 to 32767, and the value range of byte is -128 to 127.
[0059] S102: Determine a numerical range sorting of multiple data types according to the numerical range of each data type.
[0060] In an embodiment of the present application, after obtaining the data range of each of the multiple data types, the numerical range sorting of the multiple data types can be determined according to the numerical range of each data type. The data range sorting is to sort the multiple data types, that is, to determine the order of the multiple data types according to the data range sorting, so that the data type conversion can be performed subsequently according to the order.
[0061] As a possible implementation method, the numerical ranges of multiple data types are sorted in ascending order, that is, multiple data types are sorted in order of numerical range from small to large, so as to facilitate subsequent data type conversion in order from small to large, thereby reducing data distortion or reduction in accuracy.
[0062] S103, constructing a plurality of nodes of a type lattice according to a plurality of data types, and constructing a connection sequence of the type lattice according to the numerical range sorting.
[0063] In the embodiments of the present application, a type lattice can be constructed according to the data type and the numerical range. Among them, the lattice is a set with a specific order relationship related to the completely partially ordered set (CPO). The lattice based on the data type is called a type lattice, and the type lattice can effectively solve the problem of data type constraints. A total order refers to an ordered set S, represented by ≤, in which any two elements in the set are ordered. In particular, for any x, y∈S, x≤y or y≤x (or both are satisfied, that is, x=y). For example, assuming that the set S is an integer set, ≤ represents the ordinary arithmetic order, then (S, ≤) is a total order. The partial order stipulates that any two elements in the set can be in order, which is not as strict as the total order. For example, the partial order (S, ≤), where S is a subset of a set, ≤ is the relationship between subsets, usually expressed as In particular, if A, B are sets in S, then Not true. This is not true either.
[0064] If we regard the int type as a partial order (S, ≤), then there exists a minimum upper bound x of the int type such that any value in the short type satisfies u≤x, and there exists a maximum lower bound x such that any value in the short type satisfies x≤u. Therefore, the mathematical structure of data types and lattices is combined to give the definition of type lattices. Type lattices are constructed based on the principle of lossless conversion. As long as important information of the data is not lost, conversion is automatically allowed. Such conversion is similar to widening conversion in Java, and data type conversion that loses important information will not be performed automatically. It can be seen that since the type lattice is a set based on a partial order, the type lattice can be used to implement data type inference, control, and detection.
[0065] Considering that the type lattice includes nodes and the order between multiple nodes, multiple data types can be constructed as multiple nodes of the type lattice, and the connection order of the type lattice can be constructed according to the sorting of the value range.
[0066] When constructing a type lattice, a data type can be directly determined as a node of the type lattice. When constructing the connection order of the type lattice according to the numerical range sorting, the connection order of the type lattice from small to large can be constructed according to the numerical range sorting from small to large and the data type conversion rule, wherein the data type conversion rule is used to indicate whether multiple data types can be converted, and whether the multiple data types can be converted includes conversions with data distortion or precision loss. In other words, the multiple data type conversions in the data type conversion rule can be screened by numerical range sorting, so as to obtain the connection order of the type lattice with a one-way conversion order.
[0067] refer to Figure 2 As shown, Figure 2 A schematic diagram of a type of grid provided in an embodiment of the present application is shown. Figure 2 Each node in the grid represents a data type, and the connection line represents the relationship between two nodes, that is, the two nodes can perform data type conversion. According to the definition of the type grid, the connection lines are ordered, that is, the connection sequence has a direction, and the direction of the connection sequence can be from bottom to top, that is, the value range of the data type at the bottom is smaller, and the value range of the data type at the top is larger, and the data type at the bottom can be converted to the data type at the top.
[0068] by Figure 2For example, if there is an ascending path from the first data type to the second data type, then conversion from the first data type to the second data type is allowed. This relationship is a partial order, and if the value range of the first data type is less than or equal to the value range of the second data type, then data type conversion is allowed. Therefore, using type lattice can provide efficient data type inference and data type checking.
[0069] As an example, define partial orders of char, short, int, long, float, and double, sort all partial orders by numerical range, and obtain a schematic diagram of the type grid. Figure 2 As shown. According to the definition of partial order of different data types and the type grid, char can be automatically converted into short, int, long, float, double; short can be automatically converted into int, long, float, double; int can be automatically converted into long, double; float can be automatically converted into double; other data type conversion methods are not feasible, and there will be data loss, especially boolean type and other data types cannot be automatically converted.
[0070] S104, traverse all modules and control the data type corresponding to each module according to the type grid.
[0071] In an embodiment of the present application, after the type is constructed by sorting and constructing multiple types of data and data ranges, since the type lattice includes the connection order between different data types, the connection order has a connection direction, converting the data type according to the connection order will not cause data distortion or precision loss. Therefore, all modules can be traversed, and the data type corresponding to each module can be controlled according to the type lattice. Based on the fact that the type lattice is a plurality of ordered data types, the order can be followed when controlling the data type corresponding to each module, and finally lossless conversion of the data type can be achieved.
[0072] Specifically, considering that the connection sequence in the type grid is from small to large, that is, multiple data types are from a smaller numerical range to a larger numerical range, the data type corresponding to each module can be controlled according to the connection sequence from small to large in the type grid, that is, when controlling the data type conversion, the data type can also be from a smaller numerical range to a larger numerical range.
[0073] Data type conversion usually occurs in data transmission between modules and mixed operations of multiple data types, which are described in detail below.
[0074] First, the data type conversion that occurs during the data transmission process between modules is introduced. All modules can include upstream modules and downstream modules, and the upstream module transmits data to the downstream module. Therefore, after traversing all modules, the data type corresponding to the upstream module and the data type corresponding to the downstream module can be controlled according to the connection sequence from small to large in the type grid. Since the upstream module transmits data to the downstream module, in order to avoid data conversion loss, according to the connection direction of the type grid, the numerical range of the data type of the upstream module is controlled to be smaller than the numerical range of the data type of the downstream module.
[0075] That is, when an upstream module retrieves data from its input port, the data type of the port is determined by the previous execution, and the runtime type check ensures that the data sent through the output port of the upstream module is compatible with the data type of the input port of the downstream module. Data type control is to impose some data type constraints on the model for data type inference. Constraints can be understood as an unequal relationship between the data types of two ports, which requires that the data type of one port is less than or equal to the data type of the other port. Data type control requires that the data type of the output port of the upstream module is less than or equal to the data type of the input port of all downstream modules connected to the output port of the upstream module, that is: outType≤inType. This constraint ensures that automatic conversion is allowed to occur during data type conversion. Each connection between the output port and the input port establishes a type constraint to perform this data type control, thereby avoiding distortion and precision loss of data type conversion.
[0076] Next, the data type conversion in the mixed operation of multiple data types is introduced. All modules may include operation modules and value modules. The value modules include a first value module and a second value module. The operation module is between the first value module and the second value module. That is, the first value module and the second value module use the operation module to perform operations and finally obtain output results. All value modules can be traversed to obtain the data type of the first value module and the data type of the second value module that have been determined. According to the connection sequence from small to large in the type grid, the data type with a larger numerical range of the data type in the first value module and the second value module is determined. Based on the data type with a larger numerical range of the data type in the first value module and the second value module, the data type of the output result obtained by the operation of the first value module, the second value module and the operation module is determined according to the connection sequence from small to large in the type grid. That is to say, the data type of the output result can be controlled based on the data type with a larger numerical range on both sides of the operation module and combined with the connection sequence of the type grid. Taking into account that the data type with a larger numerical range is the basis, the numerical range of the data type of the output result is larger than the numerical range of the data type with a larger numerical range in the first numerical module or the second numerical module, and the numerical range of the data type of the output result must also be larger than the numerical range of the data type with a smaller numerical range in the first numerical module or the second numerical module, which is equivalent to the numerical range of the data type of the output result being larger than the numerical range of the data type of the numerical module, and there will be no data type conversion loss.
[0077] As an example, the first numerical module is 1, the data type of the first numerical module is char, the second numerical module is 2, the data type of the second numerical module is short, and the operation module is addition. The output results of the first numerical module, the second numerical module and the operation module are 1+2=3. The numerical range of short is larger than the numerical range of char. Based on the data type of the second numerical module and the type grid, the data type of the output result is controlled to int, float, long or double. The numerical range of int, float, long or double is not only larger than the numerical range of short, but also larger than the numerical range of char.
[0078] That is to say, in mixed operations of multiple data types, operations are performed in the order of the syntax tree, and the data type of the output result obtained by the first operation is controlled according to the data type with the larger numerical range of the two data types of the operation module or operator in combination with the type grid; after obtaining the output result of the first operation, the output results of the subsequent operations are obtained in sequence according to the syntax tree order, and the output results of the subsequent operations are continued to be controlled in combination with the type grid; the data type of the output result of the last operation is assigned to the variable, and finally the data types of the variable assignments are compared to obtain the data type of the final output result of the mixed operation.
[0079] In the embodiment of the present application, in addition to controlling the data types of all modules according to the type grid, the type grid can also be used to verify multiple modules that have set data types, so as to check whether there is data distortion or precision loss when multiple modules perform data conversion. In other words, the data type corresponding to each module in the multiple modules can be obtained, and the data types of the multiple modules can be verified according to the connection order in the type grid to obtain the verification result.
[0080] Specifically, the multiple modules include upstream modules and downstream modules, and the connection sequence of the type grid can be a connection sequence from small to large. Then, the data types of the multiple modules are checked according to the connection sequence in the type grid, and the verification result can be obtained by checking the numerical range corresponding to the data type of the upstream module and the numerical range corresponding to the data type of the downstream module according to the connection sequence from small to large in the type grid. If the numerical range corresponding to the data type of the upstream module is larger than the numerical range corresponding to the data type of the downstream module, the verification result is that the verification fails; if the numerical range corresponding to the data type of the upstream module is smaller than the numerical range corresponding to the data type of the downstream module, the verification result is that the verification passes. Among them, if the numerical range corresponding to the data type of the upstream module is smaller than the numerical range corresponding to the data type of the downstream module, it means that the data type of the output port of the upstream module is larger than the data type of the input port of the downstream module, and an alarm signal can be generated to adjust the data type of the upstream module or the downstream module later.
[0081] It can be seen that the data type conversion control method provided in the embodiment of the present application can control the data type to be automatically converted from small to large based on the type grid technology when data is transmitted or calculated between modules, but cannot be automatically converted from large to small, and the data types of multiple modules are checked before the simulation is run to avoid data distortion or precision loss caused by data type conversion during simulation, thereby improving the accuracy and correctness of model simulation.
[0082] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0083] In some embodiments, the server can communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and can be interconnected with 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"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0084] Although operations are depicted in a particular order, this should not be understood as requiring that the operations be performed in the particular order shown or in a sequential order.Multitasking and parallel processing may be advantageous under certain circumstances.
[0085] It should be understood that the various steps described in the method implementation of the present application can be performed in different orders and / or performed in parallel. In addition, the method implementation may include additional steps and / or omit the steps shown. The scope of the present application is not limited in this respect.
[0086] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0087] Based on a data type conversion control method provided in the above embodiment, an embodiment of the present application further provides a data type conversion control device, and its working principle is described in detail below in conjunction with the accompanying drawings.
[0088] See also Figure 3 , which is a structural schematic diagram of a data type conversion control device provided in an embodiment of the present application.
[0089] The data type conversion control device 300 provided in this embodiment includes:
[0090] An acquisition unit 310 is used to acquire multiple data types corresponding to the modeling and simulation tool and a value range of each data type;
[0091] A determining unit 320, configured to determine a numerical range order of multiple data types according to a numerical range of each data type;
[0092] A construction unit 330, configured to construct a plurality of nodes of a type lattice according to a plurality of data types, and to sort a connection sequence of the type lattice according to the numerical range;
[0093] The control unit 340 is used to traverse all modules and control the data type corresponding to each module according to the type grid.
[0094] In some embodiments, the connection sequence is from small to large;
[0095] The control unit 340 is used to:
[0096] All modules are traversed, and the data type corresponding to each module is controlled according to the connection sequence from small to large in the type grid.
[0097] In some embodiments, the total modules include upstream modules and downstream modules;
[0098] The control unit 340 is used to:
[0099] All modules are traversed, and the data types corresponding to the upstream modules and the downstream modules are controlled according to the connection sequence from small to large in the type grid, and the numerical range of the data type of the upstream module is smaller than the numerical range of the data type of the downstream module.
[0100] In some embodiments, the entire modules include a calculation module and a numerical module, the numerical module includes a first numerical module and a second numerical module, and the calculation module is between the first numerical module and the second numerical module;
[0101] The control unit 340 is used to:
[0102] Traversing all the numerical modules, obtaining the data type of the first numerical module and the data type of the second numerical module that have been determined, and determining the data type with a larger numerical range of the data types in the first numerical module and the second numerical module according to the connection sequence from small to large in the type grid;
[0103] Based on the data type with a larger numerical range in the first numerical module and the second numerical module, the data type of the output result obtained by the operation of the first numerical module, the second numerical module and the operation module is determined according to the connection sequence from small to large in the type grid.
[0104] In some embodiments, the numerical ranges of the plurality of data types are sorted in an ascending numerical range order;
[0105] The construction unit 330 is used to:
[0106] The connection order of the type grid from small to large is constructed according to the numerical range sorting from small to large and the data type conversion rule, wherein the data type conversion rule is used to indicate whether conversion can be performed between multiple data types.
[0107] In some embodiments, the device further comprises a verification unit; the verification unit is configured to:
[0108] Get the data type corresponding to each module in multiple modules;
[0109] The data types of the multiple modules are verified according to the connection sequence in the type grid to obtain a verification result.
[0110] In some embodiments, the plurality of modules include an upstream module and a downstream module, and the connection sequence is a connection sequence from small to large;
[0111] The verification unit is used for:
[0112] Verify the numerical range corresponding to the data type of the upstream module and the numerical range corresponding to the data type of the downstream module according to the connection sequence from small to large in the type grid;
[0113] If the numerical range corresponding to the data type of the upstream module is larger than the numerical range corresponding to the data type of the downstream module, the verification result is verification failure;
[0114] If the numerical range corresponding to the data type of the upstream module is smaller than the numerical range corresponding to the data type of the downstream module, the verification result is verification passed.
[0115] The units involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of a unit does not, in some cases, constitute a limitation on the unit itself.
[0116] The names of the messages or information exchanged between multiple units in the embodiments of the present application are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0117] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.
[0118] Based on the data type conversion control method provided in the above embodiment, the embodiment of the present application further provides a data type conversion control device, the data type conversion control device comprising:
[0119] The processor and the memory may be one or more processors. In some embodiments of the present application, the processor and the memory may be connected via a bus or other means.
[0120] The memory may include a read-only memory and a random access memory, and provides instructions and data to the processor. A portion of the memory may also include an NVRAM. The memory stores an operating system and operating instructions, executable modules or data structures, or a subset thereof, or an extended set thereof, wherein the operating instructions may include various operating instructions for implementing various operations. The operating system may include various system programs for implementing various basic services and processing hardware-based tasks.
[0121] The processor controls the operation of the terminal device and may also be referred to as a CPU.
[0122] The method disclosed in the above embodiment of the present application can be applied to a processor or implemented by a processor. The processor can be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor can be a general-purpose processor, DSP, ASIC, FPGA or other programmable logic device, discrete gate or transistor logic device, discrete hardware component. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to perform, or the hardware and software modules in the decoding processor can be combined to perform. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0123] The embodiment of the present application also provides a computer-readable medium for storing program code, where the program code is used to execute any one of the methods of the aforementioned embodiments.
[0124] In the context of the present application, a computer-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. A computer-readable 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. A more specific example of a computer-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.
[0125] It should be noted that the computer-readable medium mentioned above in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0126] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0127] The embodiment of the present application further provides a computer program product. When the computer program product is run on a terminal device, the terminal device executes any one of the implementation methods of the aforementioned embodiments.
[0128] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device, or installed from a ROM. When the computer program is executed by a processing device, the above-mentioned functions defined in the method of the embodiment of the present application are executed.
[0129] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
[0130] Although several specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present application. Certain features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination.
[0131] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in this application (but not limited to) by each other to form a technical solution.
Claims
1. A data type conversion control method, characterized in that: The method comprises: Obtain multiple data types corresponding to the modeling and simulation tool and the value range of each data type; Determine the numerical range sorting of multiple data types according to the numerical range of each data type; Constructing a plurality of nodes of a type lattice according to the plurality of data types, and constructing a connection sequence of the type lattice according to the numerical range; Traverse all modules and control the data type corresponding to each module according to the type grid.
2. The method according to claim 1, characterized in that The connection sequence is from small to large; The traversing of all modules and controlling the data type corresponding to each module according to the type grid includes: All modules are traversed, and the data type corresponding to each module is controlled according to the connection sequence from small to large in the type grid.
3. The method according to claim 2, characterized in that The said total modules include upstream modules and downstream modules; The traversing of all modules and controlling the data type corresponding to each module according to the connection sequence from small to large in the type grid includes: All modules are traversed, and the data types corresponding to the upstream modules and the downstream modules are controlled according to the connection sequence from small to large in the type grid, and the numerical range of the data type of the upstream module is smaller than the numerical range of the data type of the downstream module.
4. The method according to claim 2, characterized in that: The entire modules include a calculation module and a numerical module, the numerical module includes a first numerical module and a second numerical module, and the calculation module is located between the first numerical module and the second numerical module; The traversing of all modules and controlling the data type corresponding to each module according to the connection sequence from small to large in the type grid includes: Traversing all the numerical modules, obtaining the data type of the first numerical module and the data type of the second numerical module that have been determined, and determining the data type with a larger numerical range of the data types in the first numerical module and the second numerical module according to the connection sequence from small to large in the type grid; Based on the data type with a larger numerical range in the first numerical module and the second numerical module, the data type of the output result obtained by the operation of the first numerical module, the second numerical module and the operation module is determined according to the connection sequence from small to large in the type grid.
5. The method according to claim 1, characterized in that The numerical ranges of the multiple data types are sorted in ascending numerical ranges; The connection sequence of constructing the type grid according to the numerical range includes: The connection order of the type grid from small to large is constructed according to the numerical range sorting from small to large and the data type conversion rule, wherein the data type conversion rule is used to indicate whether conversion can be performed between multiple data types.
6. The method according to claim 1, characterized in that The method further comprises: Get the data type corresponding to each module in multiple modules; The data types of the multiple modules are verified according to the connection sequence in the type grid to obtain a verification result.
7. The method according to claim 6, characterized in that The multiple modules include upstream modules and downstream modules, and the connection sequence is from small to large; The checking of the data types of the multiple modules according to the connection sequence in the type grid to obtain the checking result includes: Verify the numerical range corresponding to the data type of the upstream module and the numerical range corresponding to the data type of the downstream module according to the connection sequence from small to large in the type grid; If the numerical range corresponding to the data type of the upstream module is larger than the numerical range corresponding to the data type of the downstream module, the verification result is verification failure; If the numerical range corresponding to the data type of the upstream module is smaller than the numerical range corresponding to the data type of the downstream module, the verification result is verification passed.
8. A data type conversion control device, characterized in that: The device comprises: An acquisition unit, used to acquire multiple data types corresponding to the modeling and simulation tool and a value range of each data type; A determination unit, used to determine the numerical range order of multiple data types according to the numerical range of each data type; A construction unit, used to construct a plurality of nodes of a type lattice according to a plurality of data types, and to sort a connection sequence of the constructed type lattice according to the numerical range; The control unit is used to traverse all modules and control the data type corresponding to each module according to the type grid.
9. A data type conversion control device, characterized in that: The device comprises: a processor and a memory; The memory is used to store instructions; The processor is used to execute the instructions in the memory to perform the method according to any one of claims 1 to 7.
10. A computer-readable medium, characterized in that The method comprises instructions which, when executed on a computer, cause the computer to execute the method according to any one of claims 1 to 7.
