WO2024061052A1 - 模型的处理方法、基于模型的数据处理方法及相关装置 - Google Patents
模型的处理方法、基于模型的数据处理方法及相关装置 Download PDFInfo
- Publication number
- WO2024061052A1 WO2024061052A1 PCT/CN2023/118186 CN2023118186W WO2024061052A1 WO 2024061052 A1 WO2024061052 A1 WO 2024061052A1 CN 2023118186 W CN2023118186 W CN 2023118186W WO 2024061052 A1 WO2024061052 A1 WO 2024061052A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- expression
- calculation
- branch
- model
- operator
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/10—Protecting distributed programs or content, e.g. vending or licensing of copyrighted material ; Digital rights management [DRM]
- G06F21/12—Protecting executable software
- G06F21/14—Protecting executable software against software analysis or reverse engineering, e.g. by obfuscation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/70—Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer
- G06F21/71—Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer to assure secure computing or processing of information
- G06F21/72—Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer to assure secure computing or processing of information in cryptographic circuits
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N20/00—Machine learning
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/045—Combinations of networks
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/06—Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons
- G06N3/063—Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons using electronic means
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
- G06N3/084—Backpropagation, e.g. using gradient descent
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/10—Interfaces, programming languages or software development kits, e.g. for simulating neural networks
- G06N3/105—Shells for specifying net layout
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N5/00—Computing arrangements using knowledge-based models
- G06N5/01—Dynamic search techniques; Heuristics; Dynamic trees; Branch-and-bound
Definitions
- This application relates to the technical field of Artificial Intelligence (AI), and in particular to a model processing method and related devices.
- AI Artificial Intelligence
- AI technology has ushered in rapid development.
- fields such as computer vision, natural language processing, and speech recognition
- AI systems have been deployed on a large scale, and more and more manufacturers are providing AI services.
- AI service providers complete model training and tuning locally, they deploy the AI model to third-party platforms (such as terminal devices, edge devices, and cloud servers) to provide inference services.
- third-party platforms such as terminal devices, edge devices, and cloud servers
- a model protection solution based on encryption and decryption algorithms uses encryption algorithms to encrypt the AI model during transmission and storage, and decrypts the AI model into memory before performing inference on the AI model.
- this solution can protect the confidentiality of the AI model, the entire AI model needs to be decrypted before each inference of the AI model is performed.
- the computational overhead is huge, which will greatly extend the inference delay of the AI model and severely limit it.
- the application of AI models is very large, which will greatly extend the inference delay of the AI model and severely limit it.
- This application provides a model processing method that can protect the normal execution process of the entire AI model and reduce the additional performance overhead caused by model protection, which is conducive to the promotion and application of AI models.
- the first aspect of this application provides a model processing method, which is applied to physical devices or virtual devices such as servers or terminal devices.
- the method includes: the server obtains a first calculation graph by parsing the model file of the AI model.
- the first calculation graph is used to indicate the execution logic of the AI model, and the first calculation graph includes at least one calculation graph. son. That is, the first calculation graph may implement execution logic indicating the AI model by indicating a dependency relationship between at least one operator.
- the execution logic of the AI model may refer to executing the at least one operator in an orderly manner.
- the server Based on the first calculation graph, the server generates a second calculation graph.
- the second calculation graph includes at least one calculation branch, at least one confusion branch and a first expression.
- the output of the first expression is used to indicate execution of at least one calculation branch. of branches or at least a branch within an obfuscated branch.
- at least one operator in the first calculation graph is included in at least one calculation branch in the second calculation graph, and at least one calculation branch and at least one confusion branch have different calculation logics.
- the confusion branch is a branch with operators, which can calculate the input data of the confusion branch through the operators in the confusion branch to obtain the output data.
- the calculation logic of the confusion branch is different from that of the calculation branch, that is, the operators in the confusion branch are different from the operators in the calculation branch, so for the same input data, the confusion branch and the calculation branch can obtain different output data.
- the server generates execution code corresponding to the AI model based on the second calculation graph.
- the target code in the execution code is configured for encryption protection, and the target code is the code related to the first expression. Since in the second calculation graph, the output of the first expression can affect the execution between the calculation branch and the obfuscation branch in the second calculation graph, by encrypting and protecting the target code of the first expression, it can be achieved Protect the calculation logic of the second calculation graph. To put it simply, even if the attacker steals the AI model by stealing the execution code corresponding to the AI model, since the target code corresponding to the first expression is protected by encryption, the attacker cannot obtain the calculation logic of the first expression. As a result, the correct output value cannot be obtained, and the correct execution logic of the AI model cannot be obtained.
- a confusion branch is added in parallel with the calculation branch in the AI model, and the execution relationship between the calculation branch and the confusion branch is determined through expressions. Only when the output of the expression is correct Only then can the correct calculation branch be executed. In this way, the explicit operator execution order and dependencies in the original model can be blurred through the new confusion branch, and the model structure can be scrambled. Only the newly added expressions need to be encrypted and protected, and the entire expression can be encrypted. The protection of the normal execution process of AI models reduces the additional performance overhead caused by model protection, which is conducive to the promotion and application of AI models.
- the second calculation graph includes only one calculation branch, and the output of the first expression is used to indicate execution of the calculation branch and one of the at least one confusion branch.
- the calculation branch in the second calculation graph includes all operators in the first calculation graph and the dependencies between all operators. Therefore, by executing a calculation branch in the second calculation graph, the first calculation can be realized.
- the first expression may be connected to one calculation branch and at least one confusion branch respectively, and is used to instruct execution of any one of the calculation branch and the at least one confusion branch. Only when the output of the first expression is the preset target value, the calculation branch in the second calculation graph will be executed; otherwise, when the output of the first expression is not the preset target value, the second calculation graph will be executed.
- connecting the first expression to the calculation branch and at least one confusion branch may mean that a jump to the calculation branch and at least one confusion branch based on the output value of the first expression is defined in the code. Therefore, after execution of the first expression, a jump can be made to execution of a calculation branch or at least one obfuscation branch.
- the second calculation graph includes multiple calculation branches, and the second calculation graph further includes a second expression.
- the output of the first expression is used to indicate executing one of the multiple calculation branches and at least one confusion branch;
- the second expression is connected with the multiple calculation branches and at least one confusion branch, and the second expression is used to indicate the third The number of loop executions of an expression where the input of the first expression is related to the last executed branch.
- connection between the second expression and the calculation branch and at least one confusion branch may mean that after executing any one of the multiple calculation branches and at least one confusion branch in the code, it will jump to the execution of the second expression. . Therefore, after executing any one calculation branch or obfuscation branch, it is possible to jump to the second expression, so that the second expression indicates whether to continue the loop execution of the first expression.
- the input of the second expression is related to the last executed branch, and the output of the second expression is used to indicate whether to execute the first expression in a loop.
- the first expression is run based on the input value to obtain the output value of the first expression; then, the execution branch is determined based on the output value of the first expression.
- execute the second expression to determine whether to continue looping execution of the first expression.
- the first expression is continued to be executed to determine the next branch to be executed.
- the initial input of the first expression includes a first value
- the first value is configured for encryption protection.
- the first value is configured to run in a trusted execution environment; or the first value is configured to be encrypted using an encryption algorithm.
- the initial input of the first expression can be fixed. Only when the initial input of the first expression is the first value, the first expression can output the correct value, so that the calculation logic of the second calculation graph and The calculation logic of the first calculation graph is the same.
- the first value as encryption protection, the output of the first expression can be protected. Even if the attacker obtains the entire second calculation graph, he will be unable to obtain the correct input value of the first expression. The correct calculation logic of the second calculation graph cannot be obtained, thereby protecting the confidentiality of the model.
- the target code is configured to run in a trusted execution environment, and/or the target code is configured to perform code obfuscation.
- the terminal device can load the target code into the trusted execution environment.
- the target code is run in a trusted execution environment, thereby realizing encryption protection of the target code based on the trusted execution environment.
- the target code when the target code is configured for code obfuscation, the target code will be converted into a code with the same function but difficult to read and understand, thereby realizing protection of the target code without affecting the normal execution of the target code.
- the target code is configured to be encrypted and protected using an encryption algorithm.
- the terminal device needs to first use a decryption algorithm to decrypt the target code before it can obtain the decrypted code, and thereby obtain the first expression based on the decrypted code.
- the encryption algorithm may be the Advanced Encryption Standard (AES) algorithm, the Data Encryption Standard (DES) algorithm, the International Data Encryption Algorithm (IDEA), and the RSA algorithm.
- the method further includes: the server obtains a third calculation graph, the third calculation graph is used to indicate the execution logic of the AI model, and the third calculation graph includes the first operator.
- the third calculation graph and the above-mentioned first calculation graph can be two different calculation graphs in the AI model; the third calculation graph can also be a sub-calculation graph of the first calculation graph, that is, the third calculation graph includes The first operator belongs to one of a plurality of operators in the first calculation graph.
- the server Based on the third calculation graph, the server generates a fourth calculation graph.
- the fourth calculation graph includes a second operator and a third expression.
- the second operator is obtained by modifying the weight parameter of the first operator.
- the third expression The inputs to include the output of the second operator, and the output of the third expression is the same as the output of the first operator given the same inputs as the second operator.
- the server generates execution code corresponding to the AI model based on the second computation graph and the fourth computation graph.
- the explicit operators in the AI model can be effectively obfuscated, effectively preventing attackers from stealing the AI model by misappropriating the operators in the AI model, and protecting the confidentiality of the AI model.
- the weight parameter of the second operator is obtained by modifying the weight parameter of the first operator based on the second value
- the input of the third expression includes the second value
- the second value is Configured for encryption protection.
- the third expression when the input of the third expression is incorrect, the third expression cannot convert the output of the second operator into the output of the first operator. Therefore, by encrypting and protecting the first value, the calculation logic in the fourth calculation graph can be protected, thereby protecting the normal execution process of the entire AI model and reducing the additional performance overhead caused by model protection. .
- the second aspect of this application provides a model-based data processing method, which is applied to devices deployed with AI models, such as physical devices or virtual devices such as servers or terminal devices.
- the method includes: based on the execution code of the AI model, the terminal device obtains a second calculation graph, the second calculation graph includes at least one calculation branch, at least one confusion branch and a first expression.
- the output of an expression is used to indicate the execution of a branch in at least one calculation branch or a branch in at least one confusion branch.
- the at least one calculation branch includes an operator of at least one AI model.
- the at least one calculation branch has a different value from the at least one confusion branch.
- the target code in the execution code is configured for encryption protection, the target code is the code related to the first expression; the terminal device obtains the input data of the AI model; the terminal device performs the calculation based on the second calculation graph The input data is processed to obtain the output data of the AI model.
- the second calculation graph includes only one calculation branch; the output of the first expression is used to indicate execution of the calculation branch and at least one branch of the confusion branch.
- the second calculation graph includes multiple calculation branches, and the second calculation graph also includes a second expression; the output of the first expression is used to indicate execution of multiple calculation branches and at least one confusion branch.
- a branch in; the second expression is connected with a plurality of calculation branches and at least one confusion branch, and the second expression is used to indicate the number of loop executions of the first expression.
- the input of the second expression is related to the last executed branch, and the output of the second expression is used to indicate whether to execute the first expression in a loop.
- the initial input of the first expression includes a first value
- the first value is configured for encryption protection.
- the target code is configured to run in a trusted execution environment, and/or the target code is configured to perform code obfuscation.
- the target code is configured to be encrypted and protected using an encryption algorithm.
- the terminal device can decrypt the target code in the execution code to obtain the decrypted code; and the terminal device executes the decrypted code to obtain the first expression.
- the method also includes: based on the execution code of the AI model, obtaining a fourth calculation graph.
- the fourth calculation graph includes a second operator and a third expression, and the second operator is a function of the AI model. obtained by modifying the weight parameter of the first operator in , the input of the third expression includes the output of the second operator, and the output of the third expression is the same as the first operator when using the same input as the second operator.
- the output is the same; processing the input data based on the second calculation graph includes: processing the input data based on the second calculation graph and the fourth calculation graph.
- the weight parameter of the second operator is obtained by modifying the weight parameter of the first operator based on the second value
- the input of the third expression includes the second value
- the second value is configured to be encrypted and protected.
- a third aspect of the present application provides a model processing device, including: an acquisition module, configured to acquire a first calculation graph.
- the first calculation graph is used to indicate the execution logic of the artificial intelligence AI model.
- the first calculation graph includes at least one operator; a processing module configured to generate a second calculation graph based on the first calculation graph, the second calculation graph including at least one calculation branch, at least one confusion branch and a first expression, the first The output of the expression is used to indicate execution of a branch in the at least one calculation branch or a branch in the at least one confusion branch, the at least one operator is included in the at least one calculation branch, the at least one calculation branch Having different calculation logic from the at least one confusion branch; a processing module configured to generate execution code corresponding to the AI model according to the second calculation graph, and the target in the execution code related to the first expression
- the code is configured for encryption protection.
- the second computation graph includes only one computation branch; and the output of the first expression is used to indicate the execution of the computation branch and one of the at least one obfuscation branch.
- the second calculation graph includes a plurality of calculation branches, and the second calculation graph further includes a second expression; the output of the first expression is used to indicate execution of the multiple calculation branches. one of the calculation branches and the at least one confusion branch; the second expression is connected to the plurality of calculation branches and the at least one confusion branch, and the second expression is used to indicate the first The number of loop executions of the expression, and the input of the first expression is related to the last executed branch.
- the input of the second expression is related to the last executed branch, and the output of the second expression is used to indicate whether to execute the first expression in a loop.
- the initial input of the first expression includes a first value
- the first value is configured for encryption protection.
- the target code is configured to run in a trusted execution environment, and/or the target code is configured to perform code obfuscation.
- the target code is configured to be encrypted and protected using an encryption algorithm.
- the acquisition module is also used to acquire a third calculation graph.
- the third calculation graph is used to indicate the execution logic of the AI model.
- the third calculation graph includes a first calculation graph. sub; the processing module is further configured to: generate a fourth calculation graph based on the third calculation graph, the fourth calculation graph includes a second operator and a third expression, the second operator is a pair The weight parameters of the first operator are modified, and the input of the third expression includes the output of the second operator, and the output of the third expression is the same as that of the first operator using The output of the same input as the second operator is the same; the execution code corresponding to the AI model is generated according to the second calculation graph and the fourth calculation graph.
- the weight parameter of the second operator is obtained by modifying the weight parameter of the first operator based on the second value, and the input of the third expression includes the third Two values, and the second value is configured for encryption protection.
- a fourth aspect of the present application provides a model-based data processing device, including: an acquisition module, configured to acquire a second calculation graph based on the execution code of the AI model, where the second calculation graph includes at least one calculation branch, at least one confusion a branch and a first expression, the output of which is used to indicate execution of a branch in the at least one computation branch or a branch in the at least one obfuscation branch, the at least one computation branch including at least one of the The operator of the AI model, the at least one calculation branch and the at least one confusion branch have different calculation logic, the target code related to the first expression in the execution code is configured for encryption protection; the acquisition The module is also used to obtain the input data of the AI model; the processing module is also used to process the input data based on the second calculation graph to obtain the output data of the AI model.
- the second calculation graph includes only one calculation branch; the output of the first expression is used to indicate execution of the calculation branch and one of the at least one confusion branches.
- the second calculation graph includes a plurality of calculation branches, and the second calculation graph further includes a second expression; the output of the first expression is used to indicate execution of the multiple calculation branches. one of the calculation branches and the at least one confusion branch; the second expression is connected to the plurality of calculation branches and the at least one confusion branch, and the second expression is used to indicate the first The number of loop executions of the expression, and the input of the first expression is related to the last executed branch.
- the input of the second expression is related to the last executed branch, and the output of the second expression is used to indicate whether to execute the first expression in a loop.
- the initial input of the first expression includes a first value
- the first value is configured for encryption protection.
- the target code is configured to run in a trusted execution environment, and/or the target code is configured to perform code obfuscation.
- the target code is configured to be encrypted and protected by an encryption algorithm; the processing module is also used to decrypt the target code in the execution code to obtain a decrypted code; and execute the decrypted code to obtain the first expression.
- the acquisition module is also used to acquire a fourth calculation graph based on the execution code of the AI model, where the fourth calculation graph includes a second operator and a third expression, so The second operator is obtained by modifying the weight parameter of the first operator in the AI model, the input of the third expression includes the output of the second operator, and the The output is the same as the output of the first operator when using the same input as the second operator; the processing module is also configured to calculate the second calculation graph based on the second calculation graph and the fourth calculation graph. Enter data for processing.
- the weight parameter of the second operator is obtained by modifying the weight parameter of the first operator based on the second value, and the input of the third expression includes the third Two values, and the second value is configured for encryption protection.
- a fifth aspect of the present application provides an electronic device.
- the electronic device includes: a memory and a processor; the memory stores code, the processor is configured to execute the code, and when the code is executed, the The electronic device performs the method in any implementation manner in the first aspect.
- a sixth aspect of the present application provides an electronic device.
- the electronic device includes: a memory and a processor; the memory stores code, and the processor is configured to execute the code. When the code is executed, the The electronic device performs the method in any implementation manner in the second aspect.
- a seventh aspect of this application provides an AI system, which includes: a model processing device as described in any implementation manner of the third aspect, and a model-based data processing device as described in any implementation manner of the fourth aspect.
- An eighth aspect of the present application provides a computer-readable storage medium.
- the computer-readable storage medium stores a computer program that, when run on a computer, causes the computer to execute any one of the first aspect or the second aspect. Ways to implement it.
- a ninth aspect of the present application provides a computer program product that, when run on a computer, causes the computer to execute the method implemented in any one of the first aspect or the second aspect.
- a tenth aspect of this application provides a chip including one or more processors. Part or all of the processor is used to read and execute the computer program stored in the memory to execute the method in any one of the above-mentioned implementations of the first aspect or the second aspect.
- the chip should include a memory, and the memory and the processor are connected to the memory through circuits or wires.
- the chip also includes a communication interface, and the processor is connected to the communication interface.
- the communication interface is used to receive data and/or information that needs to be processed.
- the processor obtains the data and/or information from the communication interface, processes the data and/or information, and outputs the processing results through the communication interface.
- the communication interface may be an input-output interface.
- Figure 1 is a schematic diagram of a clear text deployment of a model file provided by an embodiment of the present application
- Figure 2 is a schematic diagram of a model file encryption deployment provided by an embodiment of the present application.
- Figure 3 is a schematic diagram of an application scenario of a model processing method provided by an embodiment of the present application.
- Figure 4 is a schematic flowchart of a model processing method provided by an embodiment of the present application.
- Figure 5A is a schematic structural diagram of generating a second calculation graph based on a first calculation graph according to an embodiment of the present application
- Figure 5B is another structural schematic diagram of generating a second calculation graph based on a first calculation graph according to an embodiment of the present application
- Figure 6A is another structural schematic diagram of generating a second calculation graph based on a first calculation graph according to an embodiment of the present application
- Figure 6B is a schematic diagram of the operation of a second calculation graph provided by the embodiment of the present application.
- Figure 7A is another structural schematic diagram of generating a second calculation graph based on a first calculation graph according to an embodiment of the present application
- FIG7B is a schematic diagram of executing a second computation graph provided in an embodiment of the present application.
- Figure 8 is another structural schematic diagram of generating a second calculation graph based on a first calculation graph according to an embodiment of the present application
- Figure 9 is a schematic diagram of obtaining a fourth calculation graph based on a third calculation graph provided by an embodiment of the present application.
- Figure 10 is a schematic flow chart of a model-based data processing method provided by an embodiment of the present application.
- Figure 11 is a schematic flow chart of a processing model provided by the embodiment of the present application and data processing based on the model;
- Figure 12 is a schematic structural diagram of a model processing device provided by an embodiment of the present application.
- FIG13 is a schematic diagram of the structure of a model-based data processing device provided in an embodiment of the present application.
- FIG14 is a schematic diagram of a structure of an execution device provided in an embodiment of the present application.
- Figure 15 is a schematic structural diagram of a chip provided by an embodiment of the present application.
- Figure 16 is a schematic structural diagram of a computer-readable storage medium provided by an embodiment of the present application.
- the naming or numbering of steps in this application does not mean that the steps in the method flow must be executed in the time/logical sequence indicated by the naming or numbering.
- the process steps that have been named or numbered can be implemented according to the purpose to be achieved. The order of execution can be changed for technical purposes, as long as the same or similar technical effect can be achieved.
- the division of units presented in this application is a logical division. In actual applications, there may be other divisions. For example, multiple units may be combined or integrated into another system, or some features may be ignored. , or not executed.
- the coupling or direct coupling or communication connection between the units shown or discussed may be through some interfaces, and the indirect coupling or communication connection between units may be electrical or other similar forms. There are no restrictions in the application.
- the units or subunits described as separate components may or may not be physically separated, may or may not be physical units, or may be distributed into multiple circuit units, and some or all of them may be selected according to actual needs. unit to achieve the purpose of this application plan.
- AI is a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
- AI is a comprehensive technology of computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a manner similar to human intelligence.
- AI is the study of the design principles and implementation methods of various intelligent machines, so that the machines have the functions of perception, reasoning and decision-making.
- AI model is a technical means in AI technology used to handle specific tasks.
- an AI model can be a neural network composed of neural units.
- AI models are run on the model owner’s device or platform (e.g., server, virtual machine, VM) or container (container), the trained AI model will be stored in the form of a model file.
- the model user's device such as terminal device, server or edge device, VM or container, etc.
- the model user's device can actively load the model file of the AI model; it can also be owned by the model.
- the user's device actively sends the model file of the AI model to the model user's device, so that the model user's device can load and execute the model file of the AI model.
- the server is a physical machine.
- VMs or containers can be virtualized devices that are divided into virtualized devices on the hardware resources of a physical machine.
- Terminal equipment also called user equipment (UE)
- UE user equipment
- UE user equipment
- the terminal device can be, for example, a smartphone (mobile phone), a tablet computer (pad), a computer with wireless transceiver functions, an Internet of Things device, a virtual reality (VR) terminal, an augmented reality (AR) ) terminal, wireless terminal in industrial control, wireless terminal in self-driving, wireless terminal in remote medical, wireless terminal in smart grid, transportation security Wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, etc.
- a smartphone mobile phone
- a tablet computer pad
- a computer with wireless transceiver functions an Internet of Things device
- VR virtual reality
- AR augmented reality
- wireless terminal in industrial control wireless terminal in self-driving
- wireless terminal in remote medical wireless terminal in smart grid
- transportation security Wireless terminals in transportation safety wireless terminals in smart cities, wireless terminals in smart homes, etc.
- a computational graph is a way to represent mathematical functions using graph theory, that is, to graphically represent the computational process.
- a computational graph is defined as a directed graph consisting of nodes and edges.
- input values and computational functions appear in the form of nodes, and the relationship between the output items of the nodes is represented by directed lines (i.e., edges between nodes).
- An expression is a combination of numbers, operators, number grouping symbols (parentheses), free variables and constraint variables, etc., in a meaningful arrangement that can yield numerical values.
- an expression is a formula composed of operands and operators, and is a computer instruction with complete meaning. For example, the expression could be (x+6)*3*COS(1)/2*8+7.
- An opaque predicate is an expression.
- the value of an opaque predicate is known to the author of the opaque predicate at a certain point in the execution, but the compiler or static analyzer cannot infer this value and can only determine the value of the opaque predicate when the opaque predicate is run.
- Trusted execution environment refers to building a secure area in the central processor through software and hardware methods to ensure that the confidentiality and integrity of the programs and data loaded inside are protected. Simply put, the trusted execution environment is a secure area within the central processor. The central processor is used to ensure that the confidentiality and integrity of the code and data in the trusted execution environment are protected, that is, the code and data running in the trusted execution environment are protected. Code and data are confidential and cannot be tampered with.
- Code obfuscation also known as code obfuscation, is the act of converting computer program code into a form that is functionally equivalent but difficult to read and understand. Code obfuscation can be used for program source code or for intermediate code compiled by the program. Programs that perform code obfuscation are called code obfuscators.
- code obfuscation can refer to rewriting the names of various elements in the code (such as variables, functions, classes) into meaningless names. For example, rewriting the elements in the code into a single letter, or a short meaningless letter combination, or even into a symbol such as "__" makes it impossible for readers to guess its purpose based on the name.
- Code obfuscation can also involve rewriting part of the logic in the code into a form that is functionally equivalent but harder to understand. For example, rewrite the for loop into a while loop, rewrite the loop into recursion, streamline intermediate variables, etc. Code obfuscation can also disrupt the format of the code. For example, remove spaces, squeeze multiple lines of code into one line, or break one line of code into multiple lines, etc.
- AI service providers generally complete the training and tuning of AI models in the local model training environment, obtain the model files corresponding to the AI models, and then deploy the AI models to the model deployment environment of the model users in the form of model files. (such as terminal equipment).
- model files of the AI model are deployed in the model deployment environment in clear text, they are vulnerable to theft by criminals.
- Figure 1 is a schematic diagram of a model file plain text deployment provided by an embodiment of the present application.
- AI service providers The AI model is trained in the model training environment and the model file of the AI model is generated. Then, the AI service provider deploys the clear text model file to the model deployment environment, so that the AI computing framework in the model deployment environment can execute the AI model by importing the model file.
- the model files are deployed in the model deployment environment in clear text, criminals can directly steal the model files from the model deployment environment by attacking the model deployment environment, and then obtain the stolen models.
- Figure 2 is a schematic diagram of a model file encryption deployment provided by an embodiment of the present application.
- the AI service provider trains the AI model in the model training environment and generates the model file of the AI model. Then, the AI service provider uses an encryption algorithm to encrypt the model file, and deploys the encrypted model file to the model deployment environment of the model user.
- the application triggers the decryption of the model file and decrypts the model file into the memory, thereby executing the AI model in the memory.
- the embodiment of the present application provides a model processing method.
- a confusion branch is added in parallel with the calculation branch in the AI model, and the calculation branch and the sum of the calculation branches are determined through expressions. Confusing the execution relationship between branches, the correct calculation branch can only be executed when the output of the expression is correct. In this way, the explicit operator execution order and dependencies in the original model can be blurred through the new confusion branch, and the model structure can be scrambled. Only the newly added expressions need to be encrypted and protected, and the entire expression can be encrypted. The protection of the normal execution process of AI models reduces the additional performance overhead caused by model protection, which is conducive to the promotion and application of AI models.
- Figure 3 is a schematic diagram of an application scenario of a model processing method provided by an embodiment of the present application.
- the calculation graph corresponding to the original model file is obtained by parsing the original model file.
- the obtained calculation graph is processed through the model processing method provided by the embodiment of the present application, and a confusion state model file is generated based on the processed calculation graph.
- the obfuscated model file can be deployed in the model user environment.
- the AI application can obtain the confused model file and inference data, and load the confused model.
- inference can be performed based on the confusion model and inference results can be obtained.
- the model processing method and the model-based data processing method provided by the embodiments of the present application can be applied to electronic devices or virtualization devices.
- the electronic devices are, for example, the above-mentioned servers and terminal devices;
- the virtualization device is, for example, The virtual machines and containers mentioned above.
- the methods provided by the embodiments of the present application will be introduced in sequence from the model processing stage and the model usage stage. Moreover, for the convenience of description, the method provided by the embodiment of the present application will be introduced below by taking the example that the processing phase of the model is executed on the server and the usage phase of the model is executed on the terminal device. In actual applications, the processing phase of the model is not limited to execution on the server, and the use phase of the model is not limited to execution on the terminal device.
- FIG. 4 is a schematic flowchart of a model processing method provided by an embodiment of the present application. As shown in Figure 4, the model processing method includes the following steps 401-403.
- Step 401 Obtain a first calculation graph.
- the first calculation graph is used to indicate the execution logic of the AI model.
- the first calculation graph includes at least one operator.
- the server may obtain the first calculation graph by parsing the model file of the AI model.
- the first calculation graph may indicate part of the execution logic of the AI model, or the first calculation graph may indicate the entire execution logic of the entire AI model.
- an AI model will include multiple computing units, such as convolution units, pooling units or addition units and other types of units used to perform corresponding calculations.
- Each computing unit can be called an operator.
- the execution logic of the AI model is the order in which each computing unit is executed and the dependencies between each computing unit. Therefore, when a calculation graph is used to represent the calculation units in the AI model and the input or output relationships between the calculation units, the above-mentioned first calculation graph can indicate the execution logic of the AI model.
- the first calculation graph may include all operators or some operators in the AI model. Moreover, there may be one or more types of operators in the first calculation graph, and there may also be one or more operators of the same type.
- the type of operator usually represents the computational properties of the operator. properties, such as: convolution type, pooling type, addition type, batch normalization type or linear correction type, etc.
- the convolution type operator refers to the operator used to perform convolution operations
- the pooling type operator refers to the operator used to perform pooling operations
- the addition type operator refers to the operator used to perform pooling operations.
- Operators that perform addition operations batch normalization type operators refer to operators used for batch normalization
- linear correction type operators refer to operators used for linear correction.
- each operator will have a unique identifier or unique name, such as: convolution operator 1, convolution operator 2, pooling operator 1 or addition operator 1, etc.
- the user can specify the operators in the AI model that need to be obfuscated. For example, the user specifies that one or more operators in the AI model need to be obfuscated; or, the user specifies that one or more types of operators in the AI model need to be obfuscated.
- the server parses the model file of the AI model, it can determine the first calculation graph based on the operators that require obfuscation protection specified by the user.
- the first calculation graph includes the operators that require obfuscation protection.
- Step 402 Generate a second calculation graph based on the first calculation graph.
- the second calculation graph includes at least one calculation branch, at least one confusion branch and a first expression.
- the output of the first expression is used to indicate execution of at least one calculation branch or A branch in at least one confusion branch, at least one operator included in at least one calculation branch, at least one calculation branch and at least one confusion branch have different calculation logic.
- the first expression in the second calculation graph, may be connected to at least one calculation branch and at least one confusion branch. Moreover, in the process of executing the second calculation graph, the first expression is first executed, and at least one calculation branch or a branch in at least one confusion branch is selected to be executed according to the output of the first expression. Only when the output of the first expression is the preset target value, at least one of the above calculation branches is executed; when the output of the first expression is not the preset target value, then at least one of the above confusion branches is executed .
- the preset target value may include one or more values.
- At least one operator in the first calculation graph is included in at least one calculation branch of the second calculation graph. Therefore, when the output of the first expression is the preset target value, at least one calculation branch in the second calculation graph is executed, thereby ensuring that the actual calculation logic is the same as that of the original AI model; when the output of the first expression is not When the target value is preset, at least one confusion branch in the second calculation graph is executed, so that the actual calculation logic is different from the calculation logic of the original AI model, thereby realizing the protection of the AI model.
- Step 403 Generate execution code corresponding to the AI model based on the second calculation graph.
- the target code in the execution code is configured for encryption protection, and the target code is the code related to the first expression.
- the server can generate execution code corresponding to the AI model according to the calculation logic of the second calculation graph, so as to facilitate the deployment of the AI model to other devices.
- the target code related to the first expression is configured for encryption protection, while the codes in other parts of the execution code may not be configured for encryption protection.
- the output of the first expression can affect the execution between the calculation branch and the obfuscation branch in the second calculation graph, by encrypting and protecting the target code of the first expression, it can be achieved Protect the calculation logic of the second calculation graph. To put it simply, even if the attacker steals the AI model by stealing the execution code corresponding to the AI model, since the target code corresponding to the first expression is protected by encryption, the attacker cannot obtain the calculation logic of the first expression. As a result, the correct output value cannot be obtained, and the correct execution logic of the AI model cannot be obtained.
- a confusion branch is added in parallel with the calculation branch in the AI model, and the execution relationship between the calculation branch and the confusion branch is determined through expressions. Only when the expression Only when the output of the formula is correct can the correct calculation branch be executed. In this way, the explicit operator execution order and dependencies in the original model can be blurred through the new confusion branch, and the model structure can be scrambled. Only the newly added expressions need to be encrypted and protected, and the entire expression can be encrypted. The protection of the normal execution process of AI models reduces the additional performance overhead caused by model protection, which is conducive to the promotion and application of AI models.
- the target code related to the first expression is configured to run in a trusted execution environment.
- the terminal device loads the target code into a trusted execution environment and runs it, thereby achieving encryption protection of the target code based on the trusted execution environment.
- the trusted execution environment is a safe area built in the central processor based on software and hardware methods, when the target code is configured to run in the trusted execution environment, a model user is required
- the terminal device itself supports a trusted execution environment, that is, it has certain hardware requirements for the terminal device that needs to load the AI model.
- the target code is configured to perform code obfuscation.
- code obfuscation the target code will be converted into code with the same functionality but difficult to read and understand, thereby protecting the target code without affecting the normal execution of the target code.
- the target code is configured to be encrypted and protected using an encryption algorithm.
- the encryption algorithm may be, for example, the Advanced Encryption Standard (AES) algorithm, the Data Encryption Standard (DES) algorithm, the International Data Encryption Algorithm (IDEA), and the RSA algorithm.
- AES Advanced Encryption Standard
- DES Data Encryption Standard
- IDEA International Data Encryption Algorithm
- the server may also use the above-mentioned multiple implementation methods to simultaneously encrypt and protect the target code related to the first expression.
- the target code is configured to run in a trusted execution environment, and the target code is also configured to be encrypted and protected using an encryption algorithm.
- the terminal device can decrypt the target code in a trusted execution environment to obtain the decrypted code, and thereby obtain the first expression based on the decrypted code; or , the terminal device may decrypt the target code and run the decrypted code in a trusted execution environment, thereby obtaining the first expression.
- the first expression itself may also be protected.
- the first expression may be an opaque predicate, and the server uses the opaque predicate as the first expression. In this way, when the target code corresponding to the first expression is obtained, the value of the first expression cannot be inferred through the target code. Instead, the value of the first expression can only be obtained during the process of running the target code, thus Implement hidden protection of the first expression.
- the server there are multiple ways for the server to generate the second calculation graph based on the first calculation graph.
- the server generates a second calculation graph having one calculation branch, at least one confusion branch and the first expression.
- the calculation branch in the second calculation graph includes at least one operator in the first calculation graph, and the output of the first expression is used to indicate execution of the calculation branch and one branch of the at least one confusion branch.
- a calculation branch in the second calculation graph includes all operators in the first calculation graph and the dependencies between all operators.
- the calculation logic in the first calculation graph can be realized.
- the first expression may be connected to one calculation branch and at least one confusion branch respectively, and is used to instruct execution of any one of the calculation branch and the at least one confusion branch. Only when the output of the first expression is correct, the calculation branch in the second calculation graph will be executed; otherwise, when the output of the first expression is wrong, one of at least one confusion branch in the second calculation graph will be executed. branch.
- FIG. 5A is a schematic structural diagram of generating a second calculation graph based on a first calculation graph according to an embodiment of the present application.
- the first calculation graph includes three operators connected in sequence, namely a convolution operator, a batch normalization operator and a linear correction operator.
- the input of the convolution operator is the input of the first calculation graph
- the input of the batch normalization operator is the output of the convolution operator
- the input of the linear correction operator is the output of the batch normalization operator
- the linear correction operator The output of the operator is the output of the first calculation graph.
- the convolution operator, batch normalization operator and linear correction operator connected in sequence become a calculation branch in the second calculation graph.
- the second calculation graph also includes a confusion branch parallel to the calculation branch, and both the calculation branch and the confusion branch are connected to the first expression.
- the executed branch is determined based on the value output by the first expression. Specifically, when the value output by the first expression is the preset target value, the calculation branch is executed to implement the calculation logic as shown in the first calculation graph, so that the output of the second calculation graph is consistent with the first calculation graph. The output of The output of the computational graph is different.
- FIG. 5B is another structural schematic diagram of generating a second calculation graph based on a first calculation graph according to an embodiment of the present application.
- the first calculation graph in Figure 5B is the same as the first calculation graph shown in Figure 5A; and, the calculation branch of the second calculation graph in Figure 5B is the same as the calculation branch of the first calculation graph in Figure 5A
- the difference is that the second calculation graph in Figure 5B includes multiple confusion branches, namely confusion branch 1, confusion branch 2...confusion branch N.
- Implementation 2 The server generates a second calculation graph having multiple calculation branches, at least one confusion branch and the first expression.
- the first expression is connected with a plurality of calculation branches and at least one confusion branch, and is used to indicate orderly execution of a plurality of branches in the plurality of calculation branches and at least one confusion branch.
- the first expression is used to indicate the orderly execution of multiple calculation branches; when the value output by the first expression is not the preset target value, the first expression Expressions are used to indicate the execution of multiple other branches in order or the execution of multiple calculation branches out of order.
- the calculation logic of the second calculation graph is the same as that of the first calculation graph only when the output of the first expression is the preset target value; when the output of the first expression is not the preset target value value, the calculation logic of the second calculation graph is not the same as the calculation logic of the first calculation graph.
- FIG. 6A is another schematic structural diagram of generating a second calculation graph based on a first calculation graph according to an embodiment of the present application.
- the first calculation graph in FIG. 6A is the same as the first calculation graph shown in FIG. 5A.
- the second calculation graph in FIG. 6A includes a plurality of parallel calculation branches and a plurality of confusion branches, and each calculation branch of the plurality of calculation branches includes an operator.
- the first branch is the calculation branch including the convolution operator
- the second branch is the confusion branch 1
- the third branch The first branch is the calculation branch including the batch normalization operator
- the fourth branch is the confusion branch 2
- the fifth branch is the calculation branch including the linear correction operator
- the sixth branch is the confusion branch 3.
- the above six branches are also connected to a judgment expression, which is used to determine the number of executed branches; and the judgment expression is connected to the first expression, and is used to determine each time based on the output value of the first expression. The next branch to continue execution after executing one branch.
- FIG. 6B is a schematic diagram of the operation of a second calculation graph provided by an embodiment of the present application.
- the execution steps of the second calculation graph include a total of 7 steps.
- Step 1 Run the first expression, and determine to execute a calculation branch including a convolution operator based on the output value of the first expression.
- Step 2 Execute the convolution operator and determine whether the three branches have been executed based on the judgment expression.
- Step 3 Based on the output value of the first expression, the judgment formula determines that the second branch to be executed is the calculation branch including the batch normalization operator.
- Step 4 Execute the batch normalization operator and determine whether the three branches have been executed based on the judgment expression.
- Step 5 Based on the output value of the first expression, the judgment expression determines that the third branch to be executed is the calculation branch including the linear correction operator.
- Step 6 Execute the linear correction operator and determine whether the three branches have been executed based on the judgment expression.
- Step 7 The judgment expression outputs the result obtained by executing the linear correction operator as the output value.
- the calculation logic of the second calculation graph is not to execute the first branch, the third branch and the fifth branch in sequence, so that the second calculation The calculation logic of the graph is different from the calculation logic of the first calculation graph.
- the calculation logic of the second calculation graph may be to execute the second branch, the fourth branch and the sixth branch in sequence.
- the calculation logic of the second calculation graph may be to execute the second branch, the third branch and the fourth branch in sequence.
- Implementation manner 3 the server generates a second calculation graph having multiple calculation branches, at least one confusion branch, a first expression and a second expression.
- the output of the first expression is used to indicate executing one of the plurality of calculation branches and at least one confusion branch.
- the second expression is connected with a plurality of calculation branches and at least one confusion branch, and the second expression is used to indicate the number of loop executions of the first expression.
- the input of the first expression is related to the last executed branch.
- the input of the second expression is related to the last executed branch, and the output of the second expression is used to indicate whether to loop the first expression.
- the first expression is run based on the input value to obtain the output value of the first expression; then, the execution branch is determined based on the output value of the first expression.
- the second expression is executed to determine whether to continue looping the first expression.
- the first expression is continued to be executed to determine the next branch to be executed.
- Figure 7A is another method for generating a second calculation graph based on a first calculation graph according to an embodiment of the present application. Schematic. As shown in FIG. 7A, the first calculation graph in FIG. 7A is the same as the first calculation graph shown in FIG. 5A. Moreover, the second calculation graph in FIG. 7A includes a plurality of parallel calculation branches and a plurality of confusion branches, and each calculation branch of the plurality of calculation branches includes an operator. In addition, for each of the multiple calculation branches and the multiple confusion branches, there are calculation expressions within the branch (ie, expressions such as P1, P2, P3, P4, P5, P6, etc.), and these calculation expressions are used to give Variable next is assigned a value.
- branch ie, expressions such as P1, P2, P3, P4, P5, P6, etc.
- the first expression includes two inputs, one input is used as the input of the subsequently executed branch, and the other input is the variable next.
- the first expression is used to obtain the corresponding output based on the value of the variable next.
- the second expression determines whether to continue the first expression based on the value assigned to the variable next in the previously executed branch.
- FIG. 7B is a schematic diagram of executing a second calculation graph provided by an embodiment of the present application.
- the first expression is a selection (switch) operator used to select the corresponding branch based on the value of the variable next.
- the branch When the branch including the convolution operator is executed, the branch also assigns the value of the variable next to the output value of the expression P1.
- the values of expression P1-expression P4 are all less than the value of expression P5, and the value of expression P6 is greater than the value of expression P5.
- the second expression is executed to determine whether the value of next is greater than or equal to the output value of expression P5, and based on the current value of next being less than the output value of expression P5, the loop is selected to execute the second expression. an expression.
- the branch When executing the branch including the batch normalization operator, the branch simultaneously assigns the value of the variable next to the output value of expression P3.
- the second expression is executed to determine whether the value of next is greater than or equal to the output value of expression P5, and based on the current value of next being less than the output value of expression P5, select a loop Execute the first expression.
- the second expression is executed to determine whether the value of next is greater than or equal to the output value of expression P5, and based on the current value of next being equal to the output value of expression P5, choose not to loop again
- the first expression is executed, thereby outputting the output value of the linear correction operator.
- the initial input of the first expression may include the first numerical value, and the first numerical value is configured for encryption protection. That is to say, the initial input of the first expression can be fixed. Only when the initial input of the first expression is the first value, the first expression can output the correct value, so that the calculation logic of the second calculation graph and The calculation logic of the first calculation graph is the same. In addition, by configuring the first value as encryption protection, the output of the first expression can be protected. Even if the attacker obtains the entire second calculation graph, he will be unable to obtain the correct input value of the first expression. The correct calculation logic of the second calculation graph cannot be obtained, thereby protecting the confidentiality of the model.
- the initial input of the first expression may also include an output of a calculation expression, and the output of the calculation expression is obtained by processing the first numerical value.
- the first expression can output the correct value only when the input to the calculation expression is the first numerical value.
- FIG. 8 is another structural schematic diagram of generating a second calculation graph based on a first calculation graph according to an embodiment of the present application.
- the first calculation graph in Figure 8 is the same as the first calculation graph shown in Figure 5A.
- the second calculation graph in Figure 8 includes a calculation branch and a confusion branch, where the first expression includes two inputs, one input is used as the input of the subsequent calculation branch or confusion branch, and the other input is used as the first expression itself. enter.
- the other input may be the first numerical value or the output value obtained by the calculation expression based on the first numerical value.
- the input of the first expression is the first numerical value or the input of the calculation expression is the first numerical value
- the output of the first expression is the preset target value, that is, Only the second calculation graph will be executed to the calculation branch; otherwise, when the input of the first expression is not the first value or the input of the calculation expression is not the first value, the output of the first expression is not the preset target value.
- the second calculation graph will execute the confusion branch, so that the actual calculation logic of the second calculation graph is different from the calculation logic of the first calculation graph. Editing is different.
- the server may scramble and obfuscate the weight parameters of the operators in the AI model to prevent attackers from misappropriating the AI model by misappropriating each operator in the AI model.
- the server may obtain a third computation graph, which is used to indicate the execution logic of the AI model, and includes a first operator.
- the third computation graph and the first computation graph may be two different computation graphs in the AI model; the third computation graph may also be a sub-computation graph of the first computation graph, that is, the first operator included in the third computation graph belongs to one of the multiple operators in the first computation graph.
- a fourth calculation graph is generated.
- the fourth calculation graph includes a second operator and a third expression.
- the second operator is obtained by modifying the weight parameter of the first operator.
- the input of the third expression includes the output of the second operator, and the output of the third expression is the same as the output of the first operator when the same input as the second operator is used.
- the server modifies the weight parameter of the first operator in the third calculation graph and obtains the second operator in the fourth calculation graph.
- the server also inserts the third expression after the second operator so that the output value after the second operator and the third expression are combined can be the same as the output value of the first operator, that is, the calculation result of the fourth calculation graph is maintained unchanged from the calculation result of the third calculation graph.
- the output of the second operator is obtained by modifying the weight parameter of the first operator, based on the same input, the output of the second operator must be different from the output of the first operator. ; therefore, by introducing a third expression, the output of the second operator is converted to the same value as the output of the first operator.
- the server may generate execution code corresponding to the AI model based on the second computation graph and the fourth computation graph.
- the weight parameter of the second operator is obtained by modifying the weight parameter of the first operator based on the second value
- the input of the third expression includes the second value
- the second value is configured for encryption protection. That is, only when the input of the third expression is the second value, the third expression can convert the output of the second operator to be the same as the output of the first operator; otherwise, in the case of the third expression When the input is not the second value, the third expression cannot convert the output of the second operator into the same value as the output of the first operator.
- the way in which the second value is configured for encryption protection may be the same as the way in which the first expression is configured for encryption protection introduced in the above embodiment, that is, the second value is configured to be encrypted using an encryption algorithm and/or Or run in a trusted execution environment. Please refer to the above embodiment for details, which will not be described again here.
- FIG. 9 is a schematic diagram of obtaining a fourth calculation graph based on a third calculation graph according to an embodiment of the present application.
- the third calculation diagram includes convolution operator 1.
- the fourth calculation graph obtained based on the third calculation graph includes convolution operator 2 and a third expression. Among them, convolution operator 2 is obtained by modifying the weight parameter w in convolution operator 1.
- the input of the third expression includes the output of the convolution operator 2 and the first value or the output of the first value after the calculation expression.
- the above describes a method for processing a model provided by the embodiment of the present application.
- the following will introduce a method for processing data based on the model after obtaining the model of the confused state.
- Figure 10 is a schematic flow chart of a model-based data processing method provided by an embodiment of the present application. As shown in Figure 10, the model-based data processing method includes the following steps 1001-1003.
- Step 1001 Based on the execution code of the AI model, obtain a second calculation graph.
- the second calculation graph includes at least one calculation branch, at least A confusion branch and a first expression, the output of the first expression is used to indicate execution of at least one calculation branch or a branch in at least one confusion branch, at least one calculation branch includes at least one operator of the AI model, and at least one calculation branch is related to At least one obfuscated branch has different calculation logic, and the target code related to the first expression in the execution code is configured for encryption protection.
- the execution code of the AI model is obtained based on the model processing method described in the embodiment corresponding to Figure 4. Therefore, the terminal device can obtain the second calculation graph by parsing the execution code of the AI model.
- the second calculation graph described in this embodiment is similar to the second calculation graph described in the embodiment corresponding to Figure 4. For details, please refer to the embodiment corresponding to Figure 4, which will not be described again here.
- Step 1002 Obtain the input data of the AI model.
- the input data of the AI model is the data to be processed.
- the AI model is an image processing model (such as an image classification model or an image segmentation model)
- the input data of the AI model can be image data
- the AI model is a speech processing model (such as a speech recognition model)
- the input data of the AI model can be speech data.
- the input data of the AI model can be determined according to the actual type of the AI model, and this embodiment does not limit the type of the input data of the AI model.
- Step 1003 Process the input data based on the second calculation graph to obtain the output data of the AI model.
- the terminal device may process the input data based on the second calculation graph, thereby obtaining the output data of the AI model.
- the terminal device may also process the input data based on the second calculation graph and other calculation graphs to obtain the output data of the AI model.
- the second computation graph includes only one computation branch; and the output of the first expression is used to indicate the execution of the computation branch and one of the at least one obfuscation branch.
- the second calculation graph includes multiple calculation branches, and the second calculation graph also includes a second expression; the output of the first expression is used to indicate execution of multiple calculation branches and at least one confusion branch. a branch in; the second expression is connected to a plurality of calculation branches and at least one confusion branch, the second expression is used to indicate the number of loop executions of the first expression, and the input of the first expression is consistent with the last executed branch Related.
- the input of the second expression is related to the branch executed last time, and the output of the second expression is used to indicate whether to execute the first expression in a loop.
- the initial input of the first expression includes a first value
- the first value is configured for encryption protection.
- the target code is configured to run in a trusted execution environment; based on the execution code of the AI model, obtaining the second calculation graph includes: the terminal device runs the target code in the trusted execution environment to Get the first expression in the second calculation graph.
- the target code is configured to be encrypted and protected using an encryption algorithm.
- the terminal device can decrypt the target code in the execution code to obtain the decrypted code; and the terminal device executes the decrypted code to obtain the first expression.
- the method also includes: based on the execution code of the AI model, obtaining a fourth calculation graph.
- the fourth calculation graph includes a second operator and a third expression, and the second operator is a function of the AI model. obtained by modifying the weight parameter of the first operator in , the input of the third expression includes the output of the second operator, and the output of the third expression is the same as the first operator when using the same input as the second operator.
- the output is the same; processing the input data based on the second calculation graph includes: processing the input data based on the second calculation graph and the fourth calculation graph.
- the weight parameter of the second operator is obtained by modifying the weight parameter of the first operator based on the second value
- the input of the third expression includes the second value
- the second value is Configured for encryption protection.
- model processing method and the model-based data processing method provided by the embodiments of the present application will be introduced below with reference to specific examples.
- Figure 11 is a schematic flowchart of a processing model and data processing based on the model provided by an embodiment of the present application.
- the calculation graph corresponding to the original model file is obtained by parsing the original model file. Then, the obtained calculation graph is subjected to control flow structure obfuscation, encrypted data structure obfuscation and/or model weight obfuscation based on encrypted data through the model processing method provided by the embodiment of the present application, to obtain a confused state model file.
- control flow structure obfuscation refers to adding obfuscation branches to fuzzy the execution order and dependencies of explicit operators in the calculation graph to achieve the effect of hiding the true calculation logic of the model.
- the method of adding confusion branches is as described in the corresponding embodiments of Figures 5A to 7B.
- the server generates a false subgraph corresponding to the calculation subgraph to be protected, and combines it with a user-defined opaque predicate expression (i.e., the above-mentioned third an expression), establish a switch operator structure.
- One branch of the switch operator structure is the calculation subgraph to be protected, and the other branch is a false subgraph or expression to blur the dependencies between operators.
- a certain number of false subgraphs and calculation expressions for judging branch selection are generated for the calculation subgraph to be protected, and the switch operator is used to insert the calculation subgraph to be protected and the false subgraph into the branch of each switch.
- the execution order of model operators is hidden by controlling the execution order of branches through calculation expressions and user-defined opaque predicates.
- Encrypted data structure obfuscation refers to obfuscation of the model structure based on encrypted data, as specifically described in the corresponding embodiment of Figure 8.
- the server generates corresponding false subgraphs and calculation expressions for the calculation subgraph to be protected.
- the random numbers are passed into the calculation expression as input conditions to determine the execution branch of the control flow structure. Only by passing in correct random numbers during inference can the obfuscated model output correct results, thereby preventing the model from being misappropriated.
- Model weight obfuscation based on encrypted data means that for each weight that needs to be protected, the weight is scrambled by referencing externally generated random noise, and different random noise can be used for each weight scrambling.
- a new subgraph i.e., the third expression described in the above embodiment
- the new subgraph can restore the unscrambled output of the protected operator, thereby satisfying the requirement that weight scrambling does not affect the accuracy of the model execution results.
- the random numbers can also be encrypted to generate metadata files.
- the obfuscated model file and the corresponding encrypted metadata file are deployed to the terminal device.
- the terminal device loads and parses the confused state model file to obtain the calculation graph of the AI model. Then, the terminal device decrypts the metadata file to obtain the random number set, and the decryption process can be executed in a trusted execution environment. After decrypting the set of random numbers, the terminal device traverses each computing unit in the execution task sequence based on the inference data input by the AI application and the decrypted random numbers, directly performs confusion state model inference, and obtains the inference results.
- FIG. 12 is a schematic structural diagram of a model processing device provided by an embodiment of the present application.
- the processing device of the model includes: an acquisition module 1201, which is used to acquire a first calculation graph.
- the first calculation graph is used to indicate the execution logic of the AI model.
- the first calculation graph includes at least one calculation graph.
- processing module 1202 configured to generate a second calculation graph based on the first calculation graph, the second calculation graph including at least one calculation branch, at least one confusion branch and a first expression, the first expression
- the output of is used to indicate execution of a branch in the at least one calculation branch or a branch in the at least one confusion branch, the at least one operator is included in the at least one calculation branch, the at least one calculation branch is consistent with the The at least one confusion branch has different calculation logic; the processing module 1202 is used to generate the execution code corresponding to the AI model according to the second calculation graph, and the target code related to the first expression in the execution code Configured for encryption protection.
- the second calculation graph includes only one calculation branch; the output of the first expression is used to indicate execution of the calculation branch and one of the at least one confusion branches.
- the second calculation graph includes a plurality of calculation branches, and the second calculation graph further includes a second expression; the output of the first expression is used to indicate execution of the multiple calculation branches. one of the calculation branches and the at least one confusion branch; the second expression is connected to the plurality of calculation branches and the at least one confusion branch, and the second expression is used to indicate the first The number of loop executions of the expression, and the input of the first expression is related to the last executed branch.
- the input of the second expression is related to the last executed branch, and the output of the second expression is used to indicate whether to execute the first expression in a loop.
- the initial input of the first expression includes a first value
- the first value is configured for encryption protection.
- the target code is configured to run in a trusted execution environment.
- the target code is configured to be encrypted and protected using an encryption algorithm.
- the acquisition module 1201 is also used to acquire a third calculation graph.
- the third calculation graph is used to indicate the execution logic of the AI model.
- the third calculation graph includes a first operator; the processing module 1202 is also used to: based on the third Calculation graph, generate a fourth calculation graph, the fourth calculation graph includes a second operator and a third expression, the second operator is obtained by modifying the weight parameter of the first operator, the The input of the third expression includes the output of the second operator, and the output of the third expression is the same as the output of the first operator using the same input as the second operator; according to The second calculation graph and the fourth calculation graph generate execution code corresponding to the AI model.
- the weight parameter of the second operator is obtained by modifying the weight parameter of the first operator based on the second value, and the input of the third expression includes the third Two values, and the second value is configured for encryption protection.
- FIG. 13 is a schematic structural diagram of a model-based data processing device provided by an embodiment of the present application.
- the model-based data processing device includes: an acquisition module 1301, which is used to acquire a second calculation graph based on the execution code of the AI model.
- the second calculation graph includes at least one calculation branch and at least one confusion branch.
- the output of which is used to indicate execution of a branch in the at least one calculation branch or a branch in the at least one obfuscation branch, the at least one calculation branch including at least one of the AI
- the operator of the model, the at least one calculation branch and the at least one confusion branch have different calculation logic, the target code related to the first expression in the execution code is configured for encryption protection; the acquisition module 1301 is also used to obtain the input data of the AI model; the processing module 1302 is also used to process the input data based on the second calculation graph to obtain the output data of the AI model.
- the second calculation graph includes only one calculation branch; the output of the first expression is used to indicate execution of the calculation branch and one of the at least one confusion branches.
- the second calculation graph includes a plurality of calculation branches, and the second calculation graph further includes a second expression; the output of the first expression is used to indicate execution of the multiple calculation branches. one of the calculation branches and the at least one confusion branch; the second expression is connected to the plurality of calculation branches and the at least one confusion branch, and the second expression is used to indicate the first The number of loop executions of the expression, and the input of the first expression is related to the last executed branch.
- the input of the second expression is related to the last executed branch, and the output of the second expression is used to indicate whether to execute the first expression in a loop.
- the initial input of the first expression includes a first value
- the first value is configured for encryption protection.
- the target code is configured to run in a trusted execution environment, and/or the target code is configured to perform code obfuscation.
- the target code is configured to be encrypted and protected using an encryption algorithm; the processing module 1302 is also used to decrypt the target code in the execution code to obtain the decrypted code ; Execute the decrypted code to obtain the first expression.
- the acquisition module 1301 is also used to acquire a fourth calculation graph based on the execution code of the AI model, where the fourth calculation graph includes a second operator and a third expression,
- the second operator is obtained by modifying the weight parameter of the first operator in the AI model
- the input of the third expression includes the output of the second operator
- the third expression The output of is the same as the output of the first operator when using the same input as the second operator
- the processing module 1302 is also configured to pair The input data is processed.
- the weight parameter of the second operator is obtained by modifying the weight parameter of the first operator based on the second value, and the input of the third expression includes the third Two values, and the second value is configured for encryption protection.
- FIG 14 is a schematic structural diagram of an execution device provided by an embodiment of the present application.
- the execution device 1400 can be embodied as a mobile phone, a tablet, a notebook computer, Smart wearable devices, servers, etc. are not limited here.
- the execution device 1400 includes: a receiver 1401, a transmitter 1402, a processor 1403 and a memory 1404 (the number of processors 1403 in the execution device 1400 can be one or more, one processor is taken as an example in Figure 14) , wherein the processor 1403 may include an application processor 14031 and a communication processor 14032.
- the receiver 1401, the transmitter 1402, the processor 1403, and the memory 1404 may be connected by a bus or other means.
- Memory 1404 may include read-only memory and random access memory and provides instructions and data to processor 1403 .
- Memory 1404 Part of the system may also include non-volatile random access memory (NVRAM).
- NVRAM non-volatile random access memory
- the memory 1404 stores processor and operating instructions, executable modules or data structures, or a subset thereof, or an extended set thereof, where the operating instructions may include various operating instructions for implementing various operations.
- the processor 1403 controls the execution of operations of the device.
- various components of the execution device are coupled together through a bus system.
- the bus system may also include a power bus, a control bus, a status signal bus, etc.
- various buses are called bus systems in the figure.
- the methods disclosed in the above embodiments of the present application can be applied to the processor 1403 or implemented by the processor 1403.
- the processor 1403 may be an integrated circuit chip with signal processing capabilities. During the implementation process, each step of the above method can be completed by instructions in the form of hardware integrated logic circuits or software in the processor 1403 .
- the above-mentioned processor 1403 can be a general-purpose processor, a digital signal processor (DSP), a microprocessor or a microcontroller, and can further include an application specific integrated circuit (ASIC), a field programmable Gate array (field-programmable gate array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
- DSP digital signal processor
- ASIC application specific integrated circuit
- FPGA field-programmable gate array
- the processor 1403 can implement or execute each method, step and logical block diagram disclosed in the embodiment of this application.
- a general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.
- the steps of the method disclosed in conjunction with the embodiments of the present application can be directly implemented by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor.
- the software module can be located in random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers and other mature storage media in this field.
- the storage medium is located in the memory 1404.
- the processor 1403 reads the information in the memory 1404 and completes the steps of the above method in combination with its hardware.
- the receiver 1401 may be configured to receive input numeric or character information and generate signal inputs related to performing relevant settings and functional controls of the device.
- the transmitter 1402 can be used to output numeric or character information through the first interface; the transmitter 1402 can also be used to send instructions to the disk group through the first interface to modify the data in the disk group; the transmitter 1402 can also include a display device such as a display screen .
- the processor 1403 is used to execute the method in the corresponding embodiment of Figure 4 or Figure 10.
- the electronic device provided in the embodiment of the present application may specifically be a chip, and the chip includes: a processing unit and a communication unit, wherein the processing unit may be, for example, a processor, and the communication unit may be, for example, an input/output interface, a pin or a circuit, etc.
- the processing unit may execute the computer execution instructions stored in the storage unit, so that the chip in the execution device executes the method for selecting the model hyperparameters described in the above embodiment, or so that the chip in the training device executes the method for selecting the model hyperparameters described in the above embodiment.
- the storage unit is a storage unit in the chip, such as a register, a cache, etc.
- the storage unit may also be a storage unit located outside the chip in the wireless access device, such as a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), etc.
- ROM read-only memory
- RAM random access memory
- Figure 15 is a schematic structural diagram of a chip provided by an embodiment of the present application.
- the chip can be represented as a neural network processor NPU 1500.
- the NPU 1500 serves as a co-processor and is mounted to the main CPU (Host). CPU), tasks are allocated by the Host CPU.
- the core part of the NPU is the arithmetic circuit 1503.
- the arithmetic circuit 1503 is controlled by the controller 1504 to extract the matrix data in the memory and perform multiplication operations.
- the computing circuit 1503 internally includes multiple processing units (Process Engine, PE).
- arithmetic circuit 1503 is a two-dimensional systolic array.
- the arithmetic circuit 1503 may also be a one-dimensional systolic array or other electronic circuit capable of performing mathematical operations such as multiplication and addition.
- arithmetic circuit 1503 is a general-purpose matrix processor.
- the arithmetic circuit obtains the corresponding data of matrix B from the weight memory 1502 and caches it on each PE in the arithmetic circuit.
- the operation circuit takes matrix A data and matrix B from the input memory 1501 to perform matrix operations, and the partial result or final result of the obtained matrix is stored in an accumulator (accumulator) 1508 .
- the unified memory 1506 is used to store input data and output data.
- the weight data directly passes through the storage unit access controller (Direct Memory Access Controller, DMAC) 1505, and the DMAC is transferred to the weight memory 1502.
- Input data is also transferred to unified memory 1506 via DMAC.
- DMAC Direct Memory Access Controller
- BIU is the Bus Interface Unit, that is, the bus interface unit 1515, which is used for the interaction between the AXI bus and the DMAC and the Instruction Fetch Buffer (IFB) 1509.
- IFB Instruction Fetch Buffer
- Bus Interface Unit 1515 (Bus Interface Unit, BIU for short), used to fetch memory 1509 to obtain instructions from external memory, It is also used for the storage unit access controller 1505 to obtain the original data of the input matrix A or the weight matrix B from the external memory.
- DMAC is mainly used to transfer the input data in the external memory DDR to the unified memory 1506 or the weight data to the weight memory 1502 or the input data to the input memory 1501 .
- the vector calculation unit 1507 includes multiple arithmetic processing units, and if necessary, further processes the output of the arithmetic circuit 1503, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc.
- vector calculation unit 1507 can store the processed output vectors to unified memory 1506 .
- the vector calculation unit 1507 can apply a linear function; or a nonlinear function to the output of the operation circuit 1503, such as linear interpolation on the feature plane extracted by the convolution layer, or a vector of accumulated values, to generate an activation value.
- vector calculation unit 1507 generates normalized values, pixel-wise summed values, or both.
- the processed output vector can be used as an activation input to the arithmetic circuit 1503, such as for use in a subsequent layer in a neural network.
- the instruction fetch buffer 1509 connected to the controller 1504 is used to store instructions used by the controller 1504;
- the unified memory 1506, the input memory 1501, the weight memory 1502 and the fetch memory 1509 are all On-Chip memories. External memory is private to the NPU hardware architecture.
- the processor mentioned in any of the above places can be a general central processing unit, a microprocessor, an ASIC, or one or more integrated circuits used to control the execution of the above programs.
- FIG. 16 is a schematic structural diagram of a computer-readable storage medium provided by an embodiment of the present application.
- the present application also provides a computer-readable storage medium.
- the method disclosed in Figure 4 or Figure 10 can be implemented as being encoded on a computer-readable storage medium in a machine-readable format or encoded in Computer program instructions on other non-transitory media or articles.
- 16 schematically illustrates a conceptual partial view of an example computer-readable storage medium including a computer program for executing a computer process on a computing device, arranged in accordance with at least some embodiments presented herein.
- computer-readable storage media 1600 is provided using signal bearing media 1601.
- Signal bearing medium 1601 may include one or more program instructions 1602 that, when executed by one or more processors, may provide the functionality or portions of the functionality described above with respect to FIG. 4 or FIG. 10 . Additionally, program instructions 1602 in Figure 16 also describe example instructions.
- signal bearing media 1601 may include computer readable media 1603 such as, but not limited to, a hard drive, compact disk (CD), digital video disc (DVD), digital tape, memory, ROM or RAM, and the like.
- computer readable media 1603 such as, but not limited to, a hard drive, compact disk (CD), digital video disc (DVD), digital tape, memory, ROM or RAM, and the like.
- signal bearing media 1601 may include computer recordable media 1604 such as, but not limited to, memory, read/write (R/W) CDs, R/W DVDs, and the like.
- signal bearing medium 1601 may include communication media 1605, such as, but not limited to, digital and/or analog communication media (eg, fiber optic cables, waveguides, wired communication links, wireless communication links, etc.).
- signal bearing medium 1601 may be conveyed by a wireless form of communication medium 1605 (e.g., a wireless communication medium that complies with the IEEE 802.16 standard or other transmission protocol).
- One or more program instructions 1602 may be, for example, computer-executable instructions or logic-implemented instructions.
- the computing device of the computing device may be configured to respond to program instructions 1602 communicated to the computing device via one or more of computer-readable media 1603 , computer-recordable media 1604 , and/or communication media 1605 , providing various operations, functions, or actions.
- the device embodiments described above are only illustrative.
- the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physically separate.
- the physical unit can be located in one place, or it can be distributed across multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
- the connection relationship between modules indicates that there are communication connections between them, which can be specifically implemented as one or more communication buses or signal lines.
- the computer software products are stored in readable storage media, such as computer floppy disks, U disks, mobile hard disks, ROM, RAM, magnetic disks, etc. disk or optical disk, etc., including a number of instructions to cause a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in various embodiments of the present application.
- readable storage media such as computer floppy disks, U disks, mobile hard disks, ROM, RAM, magnetic disks, etc. disk or optical disk, etc.
- the computer program product includes one or more computer instructions.
- the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device.
- the computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, the computer instructions may be transferred from a website, computer, training device, or data
- the center transmits to another website site, computer, training equipment or data center through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) means.
- wired such as coaxial cable, optical fiber, digital subscriber line (DSL)
- wireless such as infrared, wireless, microwave, etc.
- the computer-readable storage medium may be any available medium that a computer can store, or a data storage device such as a training device or a data center integrated with one or more available media.
- the available media may be magnetic media (eg, floppy disk, hard disk, magnetic tape), optical media (eg, DVD), or semiconductor media (eg, solid state disk (Solid State Disk, SSD)), etc.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Mathematical Physics (AREA)
- Computing Systems (AREA)
- Artificial Intelligence (AREA)
- Data Mining & Analysis (AREA)
- Evolutionary Computation (AREA)
- Health & Medical Sciences (AREA)
- Computational Linguistics (AREA)
- Life Sciences & Earth Sciences (AREA)
- Biomedical Technology (AREA)
- Biophysics (AREA)
- General Health & Medical Sciences (AREA)
- Molecular Biology (AREA)
- Computer Hardware Design (AREA)
- Computer Security & Cryptography (AREA)
- Multimedia (AREA)
- Technology Law (AREA)
- Medical Informatics (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Neurology (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Storage Device Security (AREA)
Abstract
Description
Claims (23)
- 一种模型的处理方法,其特征在于,包括:获取第一计算图,所述第一计算图用于指示人工智能AI模型的执行逻辑,所述第一计算图包括至少一个算子;基于所述第一计算图,生成第二计算图,所述第二计算图包括至少一个计算分支、至少一个混淆分支和第一表达式,所述第一表达式的输出用于指示执行所述至少一个计算分支中的分支或所述至少一个混淆分支中的分支,所述至少一个算子包含于所述至少一个计算分支中,所述至少一个计算分支与所述至少一个混淆分支具有不同的计算逻辑;根据所述第二计算图生成所述AI模型对应的执行代码,所述执行代码中的目标代码被配置为加密保护,所述目标代码是与所述第一表达式相关的代码。
- 根据权利要求1所述的方法,其特征在于,所述第二计算图仅包括一个计算分支;所述第一表达式的输出用于指示执行所述计算分支以及所述至少一个混淆分支中的一个分支。
- 根据权利要求1所述的方法,其特征在于,所述第二计算图包括多个计算分支,且所述第二计算图还包括第二表达式;所述第一表达式的输出用于指示执行所述多个计算分支和所述至少一个混淆分支中的一个分支;所述第二表达式与所述多个计算分支和所述至少一个混淆分支连接,所述第二表达式用于指示所述第一表达式的循环执行次数。
- 根据权利要求3所述的方法,其特征在于,所述第二表达式的输入与上一次执行的分支相关,所述第二表达式的输出用于确定是否循环执行所述第一表达式。
- 根据权利要求1-4任意一项所述的方法,其特征在于,所述第一表达式的初始输入包括第一数值,所述第一数值被配置为加密保护。
- 根据权利要求1-5任意一项所述的方法,其特征在于,所述目标代码被配置为运行于可信执行环境中,和/或所述目标代码被配置为进行代码混淆。
- 根据权利要求1-6任意一项所述的方法,其特征在于,所述目标代码被配置为采用加密算法加密保护。
- 根据权利要求1-7任意一项所述的方法,其特征在于,所述方法还包括:获取第三计算图,所述第三计算图用于指示所述AI模型的执行逻辑,所述第三计算图包括第一算子;基于所述第三计算图,生成第四计算图,所述第四计算图包括第二算子和第三表达式,所述第二算子是对所述第一算子的权重参数修改后得到的,所述第三表达式的输入包括所述第二算子的输出,且所述第三表达式的输出与所述第一算子在采用与所述第二算子相同的输入时的输出相同;所述根据所述第二计算图生成所述AI模型对应的执行代码,包括:根据所述第二计算图和所述第四计算图生成所述AI模型对应的执行代码。
- 根据权利要求8所述的方法,其特征在于,所述第二算子的权重参数是基于第二数值对所述第一算子的权重参数修改后得到的,所述第三表达式的输入包括所述第二数值,且所述第二数值被配置为加密保护。
- 一种基于模型的数据处理方法,其特征在于,包括:基于AI模型的执行代码,获取第二计算图,所述第二计算图包括至少一个计算分支、至少一个混淆分支和第一表达式,所述第一表达式的输出用于指示执行所述至少一个计算分支中的分支或所述至少一个混淆分支中的分支,所述至少一个计算分支包括至少一个所述AI模型的算子,所述至少一个计算分支与所述至少一个混淆分支具有不同的计算逻辑,所述执行代码中的目标代码被配置为加密保护,所述目标代码是与所述第一表达式相关的代码;获取所述AI模型的输入数据;基于所述第二计算图对所述输入数据进行处理,得到所述AI模型的输出数据。
- 根据权利要求10所述的方法,其特征在于,所述第二计算图仅包括一个计算分支;所述第一表达式的输出用于指示执行所述计算分支以及所述至少一个混淆分支中的一个分支。
- 根据权利要求10所述的方法,其特征在于,所述第二计算图包括多个计算分支,且所述第二计算图还包括第二表达式;所述第一表达式的输出用于指示执行所述多个计算分支和所述至少一个混淆分支中的一个分支;所述第二表达式与所述多个计算分支和所述至少一个混淆分支连接,所述第二表达式用于指示所述第一表达式的循环执行次数。
- 根据权利要求12所述的方法,其特征在于,所述第二表达式的输入与上一次执行的分支相关,所述第二表达式的输出用于确定是否循环执行所述第一表达式。
- 根据权利要求10-13任意一项所述的方法,其特征在于,所述第一表达式的初始输入包括第一数值,所述第一数值被配置为加密保护。
- 根据权利要求10-14任意一项所述的方法,其特征在于,所述目标代码被配置为运行于可信执行环境中,和/或所述目标代码被配置为进行代码混淆。
- 根据权利要求10-15任意一项所述的方法,其特征在于,所述目标代码被配置为采用加密算法加密保护;所述方法还包括:对所述执行代码中的所述目标代码进行解密,得到解密后的代码;执行所述解密后的代码,得到所述第一表达式。
- 根据权利要求10-16任意一项所述的方法,其特征在于,所述方法还包括:基于所述AI模型的执行代码,获取第四计算图,所述第四计算图包括第二算子和第三表达式,所述第二算子是对所述AI模型中第一算子的权重参数修改后得到的,所述第三表达式的输入包括所述第二算子的输出,且所述第三表达式的输出与所述第一算子在采用与所述第二算子相同的输入时的输出相同;所述基于所述第二计算图对所述输入数据进行处理,包括:基于所述第二计算图和所述第四计算图对所述输入数据进行处理。
- 根据权利要求17所述的方法,其特征在于,所述第二算子的权重参数是基于第二数值对所述第一算子的权重参数修改后得到的,所述第三表达式的输入包括所述第二数值,且所述第二数值被配置为加密保护。
- 一种模型的处理装置,其特征在于,包括存储器和处理器;所述存储器存储有代码,所述处理器被配置为执行所述代码,当所述代码被执行时,所述装置执行如权利要求1至9任一项所述的方法。
- 一种基于模型的数据处理装置,其特征在于,包括存储器和处理器;所述存储器存储有代码,所述处理器被配置为执行所述代码,当所述代码被执行时,所述装置执行如权利要求10至18任一项所述的方法。
- 一种AI系统,其特征在于,包括:如权利要求19所述的模型的处理装置以及如权利要求20所述的基于模型的数据处理装置。
- 一种计算机存储介质,其特征在于,所述计算机存储介质存储有指令,所述指令在由计算机执行时使得所述计算机实施权利要求1至18任意一项所述的方法。
- 一种计算机程序产品,其特征在于,所述计算机程序产品存储有指令,所述指令在由计算机执行时使得所述计算机实施权利要求1至18任意一项所述的方法。
Priority Applications (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| EP23867341.2A EP4582980A4 (en) | 2022-09-20 | 2023-09-12 | METHOD AND DEVICE FOR MODEL PROCESSING, AND METHOD AND DEVICE FOR MODEL-BASED DATA PROCESSING |
| US19/083,803 US20250245302A1 (en) | 2022-09-20 | 2025-03-19 | Model processing method, model-based data processing method, and related apparatus |
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202211145581.9 | 2022-09-20 | ||
| CN202211145581.9A CN115659169A (zh) | 2022-09-20 | 2022-09-20 | 模型的处理方法、基于模型的数据处理方法及相关装置 |
Related Child Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| US19/083,803 Continuation US20250245302A1 (en) | 2022-09-20 | 2025-03-19 | Model processing method, model-based data processing method, and related apparatus |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2024061052A1 true WO2024061052A1 (zh) | 2024-03-28 |
Family
ID=84984501
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2023/118186 Ceased WO2024061052A1 (zh) | 2022-09-20 | 2023-09-12 | 模型的处理方法、基于模型的数据处理方法及相关装置 |
Country Status (4)
| Country | Link |
|---|---|
| US (1) | US20250245302A1 (zh) |
| EP (1) | EP4582980A4 (zh) |
| CN (1) | CN115659169A (zh) |
| WO (1) | WO2024061052A1 (zh) |
Families Citing this family (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN115659169A (zh) * | 2022-09-20 | 2023-01-31 | 华为技术有限公司 | 模型的处理方法、基于模型的数据处理方法及相关装置 |
| US20250004727A1 (en) * | 2023-06-27 | 2025-01-02 | Mcafee, Llc | System and method for source code transformation |
| CN119720233A (zh) * | 2024-11-18 | 2025-03-28 | 中移互联网有限公司 | 基于控制流的机器学习模型加密方法和解密方法 |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20130036473A1 (en) * | 2011-08-01 | 2013-02-07 | Apple Inc. | System and method for branch function based obfuscation |
| CN111177663A (zh) * | 2019-12-20 | 2020-05-19 | 青岛海尔科技有限公司 | 编译器的代码混淆改进方法及装置、存储介质、电子装置 |
| CN114266336A (zh) * | 2020-09-15 | 2022-04-01 | 华为技术有限公司 | 一种处理人工智能模型的方法、数据处理的方法及装置 |
| CN114282181A (zh) * | 2021-12-01 | 2022-04-05 | 北京达佳互联信息技术有限公司 | 代码执行方法、装置、服务器及存储介质 |
| CN115659169A (zh) * | 2022-09-20 | 2023-01-31 | 华为技术有限公司 | 模型的处理方法、基于模型的数据处理方法及相关装置 |
Family Cites Families (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110135129B (zh) * | 2019-04-12 | 2023-04-07 | 平安科技(深圳)有限公司 | 代码段保护方法、装置、计算机设备和存储介质 |
| CN114830597B (zh) * | 2019-12-17 | 2025-09-19 | 微芯片技术股份有限公司 | 混淆用于椭圆曲线密码学的密码参数及相关系统和设备 |
| US12056219B2 (en) * | 2020-12-21 | 2024-08-06 | Cryptography Research, Inc. | Protection of neural networks by obfuscation of neural network architecture |
| CN113282892A (zh) * | 2021-04-16 | 2021-08-20 | 南方电网数字电网研究院有限公司 | 代码混淆方法、装置、计算机设备和存储介质 |
-
2022
- 2022-09-20 CN CN202211145581.9A patent/CN115659169A/zh active Pending
-
2023
- 2023-09-12 WO PCT/CN2023/118186 patent/WO2024061052A1/zh not_active Ceased
- 2023-09-12 EP EP23867341.2A patent/EP4582980A4/en active Pending
-
2025
- 2025-03-19 US US19/083,803 patent/US20250245302A1/en active Pending
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20130036473A1 (en) * | 2011-08-01 | 2013-02-07 | Apple Inc. | System and method for branch function based obfuscation |
| CN111177663A (zh) * | 2019-12-20 | 2020-05-19 | 青岛海尔科技有限公司 | 编译器的代码混淆改进方法及装置、存储介质、电子装置 |
| CN114266336A (zh) * | 2020-09-15 | 2022-04-01 | 华为技术有限公司 | 一种处理人工智能模型的方法、数据处理的方法及装置 |
| CN114282181A (zh) * | 2021-12-01 | 2022-04-05 | 北京达佳互联信息技术有限公司 | 代码执行方法、装置、服务器及存储介质 |
| CN115659169A (zh) * | 2022-09-20 | 2023-01-31 | 华为技术有限公司 | 模型的处理方法、基于模型的数据处理方法及相关装置 |
Non-Patent Citations (1)
| Title |
|---|
| See also references of EP4582980A4 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN115659169A (zh) | 2023-01-31 |
| EP4582980A1 (en) | 2025-07-09 |
| EP4582980A4 (en) | 2025-11-19 |
| US20250245302A1 (en) | 2025-07-31 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US12353608B2 (en) | Secure collaboration between processors and processing accelerators in enclaves | |
| WO2024061052A1 (zh) | 模型的处理方法、基于模型的数据处理方法及相关装置 | |
| EP2962193B1 (en) | Compiler based obfuscation | |
| CN107346401B (zh) | 用于安全地执行程序的信息保障系统 | |
| US7587616B2 (en) | System and method of iterative code obfuscation | |
| EP3757857B1 (en) | Device id for memory protection | |
| CN107408072B (zh) | 用于随机化指令的方法、介质和装置 | |
| JP5345726B2 (ja) | ストリーム・ペイロードを保護しながら復号メディア・ストリームにおいてナビゲーション・データへのソフトウェア・アクセスを可能にする方法及び装置 | |
| US20240154802A1 (en) | Model protection method and apparatus | |
| JP2023542574A (ja) | モデル保護方法、装置、機器、システム、記憶媒体及びプログラム | |
| CN111538962A (zh) | 程序控制流混淆方法、系统、存储介质、云服务器及应用 | |
| CN114266336B (zh) | 一种处理人工智能模型的方法、数据处理的方法及装置 | |
| CN107679409B (zh) | 一种数据加密的加速方法和系统 | |
| CN118643521A (zh) | 数据处理方法、装置、设备及存储介质 | |
| CN114936365A (zh) | 一种机密数据的保护系统、方法以及装置 | |
| WO2022133165A1 (en) | Privacy-enhanced computation via sequestered encryption | |
| US7970133B2 (en) | System and method for secure and flexible key schedule generation | |
| CN114756833B (zh) | 代码混淆方法、装置、设备、介质以及程序产品 | |
| CN108182358B (zh) | 文件保护方法、装置、计算设备及计算机存储介质 | |
| CN120675883A (zh) | 模型推理方法、模型加密方法、电子设备和存储介质 | |
| CN119004436A (zh) | 一种大模型训练系统、大模型训练方法及相关服务器 | |
| CN115242373B (zh) | 全同态算法的本地化服务方法、装置、计算机设备及介质 | |
| US12547682B2 (en) | Secure machine learning model processing | |
| CN108369613A (zh) | 计算设备和方法 | |
| CN119378023A (zh) | 一种数据处理方法、装置及设备 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 23867341 Country of ref document: EP Kind code of ref document: A1 |
|
| WWE | Wipo information: entry into national phase |
Ref document number: 2023867341 Country of ref document: EP |
|
| ENP | Entry into the national phase |
Ref document number: 2023867341 Country of ref document: EP Effective date: 20250403 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| WWP | Wipo information: published in national office |
Ref document number: 2023867341 Country of ref document: EP |