WO2023040390A1 - 一种模型保护方法及装置 - Google Patents

一种模型保护方法及装置 Download PDF

Info

Publication number
WO2023040390A1
WO2023040390A1 PCT/CN2022/099851 CN2022099851W WO2023040390A1 WO 2023040390 A1 WO2023040390 A1 WO 2023040390A1 CN 2022099851 W CN2022099851 W CN 2022099851W WO 2023040390 A1 WO2023040390 A1 WO 2023040390A1
Authority
WO
WIPO (PCT)
Prior art keywords
model
operator
data
execution
processing logic
Prior art date
Application number
PCT/CN2022/099851
Other languages
English (en)
French (fr)
Inventor
何剑
Original Assignee
华为技术有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP22868767.9A priority Critical patent/EP4339819A1/en
Publication of WO2023040390A1 publication Critical patent/WO2023040390A1/zh
Priority to US18/415,995 priority patent/US20240154802A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/088Usage controlling of secret information, e.g. techniques for restricting cryptographic keys to pre-authorized uses, different access levels, validity of crypto-period, different key- or password length, or different strong and weak cryptographic algorithms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6209Protecting access to data via a platform, e.g. using keys or access control rules to a single file or object, e.g. in a secure envelope, encrypted and accessed using a key, or with access control rules appended to the object itself
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N5/00Computing arrangements using knowledge-based models
    • G06N5/04Inference or reasoning models

Definitions

  • the present application relates to the field of artificial intelligence, in particular to a model protection method and device.
  • AI artificial intelligence
  • DNN Deep Neural Network
  • Machine learning service providers provide training platforms and query interfaces for using models, and users can query some instances through these interfaces.
  • FIG. 1 shows a schematic diagram of a model protection method in the related art.
  • the model owner provides the AI application to the user, it will also provide a hardware dongle.
  • the AI application first obtains the encrypted AI model (which can be stored in the form of a file), and reads the key and authorization information from the hardware dongle. After the authentication of authorization information is passed, the AI application can use the key to decrypt the encrypted AI model to obtain the decrypted AI model and store it in the memory.
  • the AI accelerator card loads the decrypted AI model from the memory for inference or model incremental training.
  • the hardware dongle is deployed on the host, which increases the cost and complexity of deployment. How to achieve model protection and reduce system cost without adding additional components has become an urgent problem to be solved.
  • the embodiment of the present application provides a model protection method, the method includes: obtaining a plurality of execution operators from the first model, the plurality of execution operators include the first operator, the second An operator is used to indicate the decryption processing logic; executing the multiple execution operators in sequence according to the hierarchical relationship of the multiple execution operators includes: when the first operator is executed, based on the decryption processing logic Decrypting the first data under the first operator to obtain second data, and executing one or more execution operators arranged behind the first operator based on the second data.
  • data decryption is implemented in a pure software manner. That is, the protection of the model is achieved without adding additional components. It not only reduces the hardware cost, but also reduces the requirements for the scale of the operating environment and the algorithm.
  • the second data is: at least one weight; or, at least one execution operator; or, at least one weight and at least one execution operator son.
  • the parameters of the model to be protected can be flexibly selected, which improves flexibility and user-friendliness.
  • the decryption of the first data based on the decryption processing logic to obtain the second The second data includes: in response to the key returned based on the key acquisition request, using the key to decrypt the first data to obtain the second data.
  • the key is acquired in an interactive manner to realize model protection.
  • the first operator is used to indicate the location of the storage space where the first data is located. Address, when executing to the first operator, said decrypting the first data under the first operator based on the decryption processing logic to obtain the second data, including: when executing to the address , based on the decryption processing logic, decrypt the data stored in the address to obtain the second data.
  • the stored data is directly decrypted, which improves efficiency.
  • the method further includes: after executing the multiple execution operators , deleting the first model, the plurality of execution operators, and the second data.
  • the first model is Train the model or infer the model.
  • the method further includes: returning an inference result if the first model is an inference model; If the first model is a training model, return the trained model.
  • the decryption processing logic is symmetric decryption processing logic or asymmetric decryption processing logic.
  • the user can choose the appropriate decryption processing logic according to the actual needs, which improves the flexibility and user-friendliness, realizes personalized customization, and further improves the security of the model.
  • the embodiment of the present application provides a model protection method, including: encrypting the first area in the second model; adding the first area to the calculation graph of the second model according to the first area An operator is used to obtain a first model, and the first operator is used to indicate a decryption processing logic; and the first model is sent.
  • the data in the first area is: at least one weight; or, at least one execution operator; or, at least one weight and at least An execution operator.
  • the method further includes: in response to the key acquisition request from the device processor, Authenticate the device processor; and return a key to the device processor if the authentication is passed.
  • the key acquisition request includes the identifier of the first model
  • the authenticating the device processor includes: authenticating the device processor based on the identification of the first model and the identification of the device processor.
  • the encrypting the first area in the second model includes: adopting the first The second operator encrypts the first area, and the second operator is used to indicate an encryption processing logic.
  • the embodiment of the present application provides a model protection device, including: an acquisition module, configured to obtain a plurality of execution operators from the first model, and the plurality of execution operators include the first operator, so The first operator is used to indicate the decryption processing logic; the execution module is used to execute the multiple execution operators acquired by the acquisition module according to the hierarchical relationship of the multiple execution operators; the execution module is specifically used to : When the first operator is executed, the first data under the first operator is decrypted based on the decryption processing logic to obtain the second data, and the second data is executed based on the second data.
  • One or more execution operators following an operator is performed.
  • the second data is:
  • At least one weight and at least one execution operator are provided.
  • the executing module is also used for:
  • the key In response to the key returned based on the key acquisition request, the key is used to decrypt the first data to obtain the second data.
  • the first operator is used to indicate the address of the storage space where the first data is located, and when the first operator is executed, the execution module is further used to:
  • the data stored in the address is decrypted based on the decryption processing logic to obtain the second data.
  • the device further includes:
  • a deletion module configured to delete the first model, the multiple execution operators, and the second data when the execution of the plurality of execution operators is completed.
  • the first model is a training model or an inference model.
  • the device further includes:
  • a returning module configured to return an inference result if the first model is an inference model; and return a trained model if the first model is a training model.
  • the decryption processing logic is symmetric decryption processing logic or asymmetric decryption processing logic.
  • the embodiment of the present application provides a model protection device, including:
  • An encryption module configured to encrypt the first area in the second model
  • An adding module configured to add a first operator to the calculation graph of the second model according to the first area encrypted by the encryption module to obtain a first model, and the first operator is used to indicate the decryption processing logic
  • a sending module configured to send the first model obtained after the adding module adds the first operator.
  • the data in the first area is:
  • At least one weight and at least one execution operator are provided.
  • the device further includes:
  • an authentication module configured to authenticate the device processor in response to a key acquisition request from the device processor
  • the key is returned to the device processor.
  • the key acquisition request includes the identifier of the first model and the identifier of the device processor, and the authentication module is further configured to:
  • the device processor is authenticated based on the identification of the first model and the identification of the device processor.
  • the encryption module is also used for:
  • the first area is encrypted by using a second operator, and the second operator is used to indicate an encryption processing logic.
  • the embodiments of the present application provide an electronic device.
  • the terminal device can execute one or more of the model protection methods of the above-mentioned first aspect or multiple possible implementations of the first aspect, or execute The model protection method of the second aspect or one or more of the multiple possible implementations of the second aspect.
  • the embodiments of the present application provide a processor, which can execute one or more of the model protection methods of the first aspect or multiple possible implementations of the first aspect, or execute The model protection method of the second aspect or one or more of the multiple possible implementations of the second aspect.
  • the embodiments of the present application provide a chip, which can implement the model protection method of the above-mentioned first aspect or one or more of the various possible implementations of the first aspect, or execute the above-mentioned first aspect The model protection method of the second aspect or one or more of the multiple possible implementations of the second aspect.
  • the embodiment of the present application provides a model protection system, the system includes a host processor, a storage unit, and a device processor, wherein the host processor is configured to perform Encryption; add a first operator to the calculation graph of the second model according to the first area to obtain a first model, and the first operator is used to indicate the decryption processing logic; send the first model; store A unit, configured to store the first model; a device processor, configured to obtain a plurality of execution operators from the first model, the plurality of execution operators include a first operator, and the first operator It is used to indicate the decryption processing logic; execute the multiple execution operators in sequence according to the hierarchical relationship of the multiple execution operators, including: when the first operator is executed, based on the decryption processing logic, the The first data under the first operator is decrypted to obtain the second data, and one or more execution operators arranged behind the first operator are executed based on the second data.
  • the embodiments of the present application provide a readable storage medium, on which computer program instructions are stored, and when the computer program instructions are executed by a processor, the above first aspect or multiple possible possibilities of the first aspect can be realized.
  • the embodiments of the present application provide a computer program product, including computer readable codes, or a non-volatile computer readable storage medium bearing computer readable codes, when the computer readable codes are stored in an electronic
  • the processor in the electronic device executes the model protection method of the above-mentioned first aspect or one or more of the multiple possible implementations of the first aspect, or executes the above-mentioned second aspect or the second A model protection method for one or more of the various possible implementations of the aspect.
  • FIG. 1 shows a schematic diagram of a model protection method in the related art
  • Figure 2 shows a schematic diagram of the architecture of the model protection system provided by the embodiment of the present application
  • Figure 3 shows an exemplary schematic diagram of a calculation graph
  • Fig. 4 shows a flow chart of the model protection method provided by the embodiment of the present application
  • Fig. 5 shows a flow chart of the model protection method provided by the embodiment of the present application.
  • Fig. 6 shows an interactive schematic diagram of the model protection method provided by the embodiment of the present application.
  • Fig. 7 shows a schematic structural diagram of a model protection device provided by the embodiment of the present application.
  • Fig. 8 shows a schematic structural diagram of a model protection device provided by an embodiment of the present application.
  • the embodiment of the present application provides a model protection method, which realizes the protection of the model through pure software, does not add additional components, and has low requirements on the scale of the operating environment and algorithms, thereby reducing the system cost.
  • the model protection method provided by the embodiment of the present application can be applied to the model calculation process in the end, edge, and cloud scenarios.
  • the end refers to the client or device end, such as a mobile phone or computer
  • the edge refers to an edge device, such as a router, switch, etc.
  • the cloud refers to the cloud, such as a server cluster.
  • the model protection method provided by the embodiment of the present application can be used in model inference scenarios and model incremental training scenarios. The embodiment of this application does not limit the application scenario.
  • FIG. 2 shows a schematic diagram of the architecture of the model protection system provided by the embodiment of the present application.
  • the model protection system includes a host processor 21 , a storage unit 22 and a device processor 23 .
  • the host processor 21 is the control center of the host (host), and is used to run AI applications.
  • the storage unit 22 may be used to save data such as AI models involved in AI applications.
  • the device processor 23 is the control center of the device, and is used to process the AI model involved in the AI application, for example, use the AI model involved in the AI application to perform inference, or perform incremental training on the AI model involved in the AI application.
  • the AI model can be used for target detection, image processing, signal control, etc., and the embodiments of the present application do not limit the function of the AI model.
  • the AI model can be a convolutional neural network model (Convolutional Neural Networks, CNN), a cyclic neural network model (Recurrent Neural Network, RNN) and a deep neural network (Deep Neural Network, DNN) model, etc. Categories are not limited.
  • the management module of the host processor 21 can realize the loading and execution of the AI model by calling the interface provided by the graph executor (Graphy Engine, GE), and by calling the operation management module
  • the interface provided by the Runtime realizes the management of the storage unit 22 and the device processor 23, etc., so as to use the computing power of the AI model provided by the device processor 23 to complete the business.
  • the host processor 21 may be a processor, or may be a general term for multiple processing elements.
  • the host processor 21 can be a central processing unit (Central Processing Unit, CPU), or a specific integrated circuit (Application Specific Integrated Circuit, ASIC), field programmable gate array (Field Programmable Gate Array, FPGA), image A processor (Graphics Processing Unit, GPU) or one or more integrated circuits configured in the disclosed embodiments, for example: one or more digital signal processors (Digital Signal Processor, DSP), or, one or more on-site Programmable Gate Array (Field Programmable Gate Array, FPGA).
  • the device processor 23 may refer to the host processor 21, which will not be repeated here. It should be noted that the device processor 23 has strong model computing capabilities.
  • the storage unit 22 may include a volatile memory or a nonvolatile memory, or may include both volatile and nonvolatile memories.
  • the non-volatile memory can be read-only memory (read-only memory, ROM), programmable read-only memory (programmable ROM, PROM), erasable programmable read-only memory (erasable PROM, EPROM), electrically programmable Erases programmable read-only memory (electrically EPROM, EEPROM) or flash memory.
  • the volatile memory can be random access memory (RAM), which acts as external cache memory.
  • RAM random access memory
  • SRAM static random access memory
  • DRAM dynamic random access memory
  • SDRAM synchronous dynamic random access memory
  • Double data rate synchronous dynamic random access memory double data date SDRAM, DDR SDRAM
  • enhanced SDRAM enhanced synchronous dynamic random access memory
  • SLDRAM synchronous connection dynamic random access memory
  • direct rambus RAM direct rambus RAM
  • the host processor 21 and the device processor 23 may be located in different devices.
  • the host processor 21 may be located in a host device such as an X86 server, an ARM server, or a Windows PC
  • the device processor 23 may be installed in a hardware device that can be connected to the host device.
  • the host processor 21 and the storage unit 22 are located in a host device, and the device processor 23 is located in a hardware device.
  • the host processor 21 and the storage unit 22 can be connected by a bus, wherein the bus can be an industry standard architecture (Industry Standard Architecture, ISA) bus, a peripheral component interconnect (Peripheral Component Interconnect, PCI) bus or an extended industry standard brick system Structure (Extended Industry Standard Architecture, EISA) bus, etc.
  • the bus can be divided into address bus, data bus, control bus and so on.
  • a high-speed serial computer expansion bus standard (Peripheral Component Interconnect express, PCIe) interface can be set on the host device, and the hardware device can be connected to the host device through the PCIe interface.
  • PCIe serial computer expansion bus standard
  • the foregoing host device and the foregoing hardware device may be co-located, and are collectively referred to as a host device.
  • Fig. 2 shows only an exemplary architecture diagram of the model protection system provided by the embodiment of the present application, and does not constitute a limitation on the model protection system.
  • the model protection system may include more or less components, or combinations of certain components, or different arrangements of components.
  • AI model refers to the structure fixed by a neural network according to a certain algorithm.
  • the AI model includes calculation graphs and weights. Among them, the calculation graph is used to represent the operation process of the algorithm, which is a method to formalize the algorithm.
  • the weight is used to represent the data that the operator needs to use during execution.
  • the calculation graph includes multiple nodes, which are connected by directed edges, and each node represents an execution operator.
  • the input edge entering a node represents the input data of the node corresponding to the execution operator, and the output edge leaving the node represents the output data of the node corresponding to the execution operator.
  • the calculation process represented by the calculation graph can be a model reasoning process or a model training process.
  • FIG. 3 shows an exemplary schematic diagram of a computation graph.
  • a and B are input data
  • C and D are execution operators
  • E is weight.
  • C means multiplication
  • D means addition
  • E means constant.
  • This calculation graph shows the operation process of outputting A*B+E.
  • the calculation graph can be serialized into a model file readable by the device processor (for example, the device processor 23 shown in FIG. 2 ) for saving, so that the device processor can run the model file to realize the calculation .
  • the model files readable by the device processor include but are not limited to MindIR format files, AIR (Ascend Intermediate Presentation) format files, ONNX (Open Neural Network Exchange) format files, etc. That is to say, Tensorflow, Pytorch or other AI frameworks on the host processor can save the calculation graph and weights of the AI model according to a certain data structure, so as to facilitate subsequent model reasoning or model increment on the device processor train.
  • FIG. 4 shows a flowchart of a model protection method provided by an embodiment of the present application. This method can be applied to the device processor 23 shown in FIG. 2 . As shown in Figure 4, the method may include:
  • step S401 a plurality of execution operators are obtained from a first model, and the plurality of execution operators include a first operator, and the first operator is used to indicate a decryption processing logic.
  • the first model may represent an encrypted AI model.
  • the first model may be a training model or an inference model.
  • the first model can be used for image classification, speech recognition, object detection or object tracking, and the like.
  • the embodiment of the present application does not limit the type and function of the first model.
  • the first model includes a computation graph and weights, and the computation graph of the first model includes multiple execution operators.
  • the application processor may decompress the first model layer by layer to obtain multiple execution operators.
  • the first operator may represent an execution operator for instructing decryption processing logic.
  • the multiple execution operators of the first model may include one or more first operators.
  • the embodiment of the present application does not limit the number of first operators.
  • the application processor may decrypt the input data based on the decryption processing logic indicated by the first operator, and then output the decrypted input.
  • the data that needs to be input to the first operator is called the first data under the first operator, and the output data after being operated by the first operator is called the second data. It can be understood that the first data is data that needs to be decrypted, and the second data is decrypted data.
  • the second data may be at least one weight; or, at least one execution operator; or at least one weight and at least one execution operator. That is to say, the first data may be at least one encrypted weight, or at least one encrypted execution operator, or at least one encrypted weight and at least one encrypted execution operator.
  • the weight M1 is input into the first operator for decryption to obtain the weight M2; the execution operator N1 is input into the first operator for decryption to obtain the execution operator N2; the weight M1 and the execution operator N1 are input into the first After the operator decrypts, the weight M2 and the execution operator N2 are obtained.
  • the decryption processing logic may be symmetric decryption processing logic or asymmetric decryption processing logic.
  • symmetric decryption processing logic includes but not limited to DES TripleDES algorithm, BlowFish algorithm and RC algorithm, etc.
  • asymmetric decryption processing logic includes but not limited to RSA, Elgamal, knapsack algorithm, Rabin algorithm and ECC algorithm, etc.
  • the embodiment of the present application does not limit the decryption processing logic. Users can flexibly choose encryption and decryption algorithms to encrypt and decrypt data.
  • the first model may be provided by the host processor.
  • the host processor 21 can generate the first model and save the first model in the storage unit 22 while the host processor 21 is running the AI application, and the device processor 23 can retrieve the first model from the storage unit 22. Load the first model.
  • the transmission of the first model may be implemented by means of memory copy.
  • the host processor 21 and the device processor 23 may apply for storage space in the storage unit 22 respectively.
  • the host processor 21 stores the first model in its corresponding storage space, realizing the storage of the first model.
  • the device processor 23 copies the data in the storage space where the first model is located to the corresponding storage space of the device processor 23 to implement loading of the first model.
  • Step S402 execute the multiple execution operators in sequence according to the hierarchical relationship of the multiple execution operators.
  • the device processor may execute these execution operators in sequence according to the hierarchical relationship of the multiple execution operators. Since the multiple execution operators of the first model include one or more first operators, when any first operator is executed, the device processor may perform step S403.
  • Step S403 when the first operator is executed, decrypt the first data under the first operator based on the decryption processing logic to obtain second data, and execute the ranking in the second data based on the second data
  • the first data (including the encrypted execution operator and/or the encrypted weight value) can be used as the input of the first operator.
  • the device processor can use the decryption processing logic indicated by the first operator to decrypt the data input to the first operator, so as to obtain the second data (including the decrypted execution operator and /or decrypted weights).
  • the weight E shown in FIG. 3 is an encrypted weight. If the device processor directly adopts the weight E or decrypts the weight E incorrectly, the output result will be wrong.
  • the weight E is the input of the first operator, and the first operator is arranged before the execution operator D, and the application processor needs to execute the first operator first, and then execute the execution operator D.
  • the application processor executes the first operator, it will input the weight E into the first operator, and output the decryption result of the weight E, and then execute the execution operator D, that is, the result of A*B and the weight E The decrypted results are added.
  • the execution operator C shown in FIG. 3 is an encrypted execution operator. If the device processor directly uses the execution operator C or the decryption processing of the execution operator C is incorrect, the output result is wrong.
  • the execution operator C is the input of the first operator, and the first operator is arranged before the execution operator D, and the application processor needs to execute the first operator before executing the execution operator D.
  • the application processor executes the first operator, it will input the execution operator C into the first operator to obtain the decryption result execution operator "*".
  • the application processor multiplies the input data A and the input data B to obtain The result of A*B; then, execute the execution operator D, that is, add the result of A*B and the decryption result of the weight E.
  • the weight E shown in FIG. 3 is an encrypted weight
  • the execution operator C is an encrypted execution operator.
  • the first operator 1 is arranged before the first operator 2
  • the first operator 2 is arranged before the execution operator D.
  • the application processor executes the first operator 1, it inputs the execution operator C into the first operator to obtain the decryption result execution operator "*", and the application processor multiplies the input data A by the input data B to obtain A*B results.
  • the application processor executes the first operator 2, at this time, inputs the weight E into the first operator 2, and outputs the decryption result of the weight E.
  • the application processor executes the execution operator D, that is, adds the result of A*B to the decryption result of the weight E.
  • the first operator can be ranked first among all execution operators of the first model. At this time, the protection of the entire calculation graph and all values can be realized; the first operator ranks in other locations.
  • the user can flexibly set the position of the first operator and the number of the first operator, and can also continuously set the first operator (to realize multiple encryption), Thereby improving data security.
  • the first operator may also be used to indicate the address of the storage space where the first data is located.
  • decrypting the first data under the first operator based on the decryption processing logic to obtain the second data may include: When the address is the address, the data stored in the address is decrypted based on the decryption processing logic to obtain the second data.
  • the calculation graph and weights obtained after decompression of the first model are stored in the storage space (for example, the storage unit 22 shown in FIG. 2 ) in the form of a data sequence.
  • the application processor reads data in the storage space, and executes the first operator when the data corresponding to the first operator is read. Since the first operator indicates the address of the first data. Therefore, when the application processor executes the first operator, it first reads the first data from the address indicated by the first operator, and then decrypts the first data based on the decryption processing logic to obtain the second data.
  • decrypting the first data based on the decryption processing logic to obtain the second data may include: responding to the key returned based on the key acquisition request, using the key to perform the decryption on the first data Decrypt to obtain the second data.
  • the device processor may send a key acquisition request to the host processor, so as to acquire the key to decrypt the first data.
  • the host processor may authenticate the device processor, and return the key to the device processor if the authentication is passed.
  • the key acquisition request is used to acquire the key.
  • the key acquisition request may include an identifier of the first model and an identifier of the device processor.
  • the host processor may obtain the identifier of the first model and the identifier of the device processor from the key acquisition request, and then authenticate the device processor based on the identifier of the first model and the identifier of the device processor.
  • a permission table may be maintained in the host processor, and the permission table may be used to store the identifier of the model, the identifier of the processor, and the association relationship of permissions.
  • the model identification can be the name of the model, the number of the model or the category of the model, etc.
  • the identification of the processor can be the name of the processor, the number of the processor, the model of the processor, etc.
  • the permission can be decryption permission or no Decryption permission.
  • the host processor finds in the authority table that the authority associated with the identifier of the first model and the identifier of the device processor has decryption authority, then it is determined that the authentication is passed and the key is returned; if the host processor is not in the authority table If the identification of the first model or the identification of the device processor is found, or the authority associated with the identification of the first model and the identification of the device processor is found to be no decryption authority, then it is determined that the authentication has not passed and the key is not returned .
  • authentication may also be performed in other ways, for example, according to the process number, according to the interface number, etc., and the embodiment of the present application does not limit the authentication method.
  • the key exchange between the device processor and the host processor may be implemented through an asynchronous API or a proprietary interface, which is not limited in this embodiment of the present application.
  • the decryption processing logic decrypts the first data under the first operator, it continues to execute one or more execution operators ranked behind the first operator, so as to realize the operation of the first model.
  • data decryption is realized in a pure software manner. That is, the protection of the model is achieved without adding additional components. It not only reduces the hardware cost, but also reduces the requirements on the scale of the operating environment and the algorithm.
  • users can choose the appropriate decryption processing logic according to actual needs, which improves flexibility, user-friendliness, and realizes personalized customization, thereby further improving the security of the model.
  • the model protection method may further include: after executing the multiple execution operators, deleting the first model, the multiple execution operators, and the second data .
  • the device processor deletes the second data after executing multiple execution operators of the first model, which can further Guarantee the security of the model.
  • the application processor may return an inference result.
  • AI applications in the host processor can use the inference results during runtime.
  • the application processor may return the trained model.
  • the AI application in the host processor can use the trained model during operation. It can be understood that the trained model returned by the application processor includes a calculation graph and weights of the trained model.
  • FIG. 5 shows a flow chart of the model protection method provided by the embodiment of the present application. This method can be applied to the host processor 21 shown in FIG. 2 . As shown in Figure 5, the method may include:
  • Step S501 encrypting the first area in the second model.
  • the second model represents a model that needs to be protected by encryption.
  • the first area may represent an area in the second model that needs to be encrypted.
  • the data in the first area is: at least one weight; or, at least one execution operator; or, at least one weight and at least one execution operator.
  • the user can flexibly select the area to be encrypted, which improves flexibility and user-friendliness. For example, users can choose to encrypt key data and sensitive data, users can choose to encrypt key operators, or users can encrypt the entire calculation graph.
  • the first area is not limited.
  • step S501 may include: encrypting the first area by using a second operator, where the second operator is used to indicate an encryption processing logic.
  • the host processor may choose to encrypt the first region using the second operator. It can be understood that, in the embodiment of the present application, the encryption processing logic indicated by the second operator corresponds to the decryption processing logic indicated by the first operator, and the encryption algorithm and decryption algorithm used are matched. Of course, the host processor may also choose other methods, such as manual editing, to encrypt the first area, which is not limited in this embodiment of the present application.
  • Step S502 adding a first operator to the calculation graph of the second model according to the first region to obtain a first model, where the first operator is used to indicate decryption processing logic.
  • Step S503 sending the first model.
  • the host processor may directly send the first model to the device processor for processing.
  • the host processor may send the first model to the storage unit for storage, and then the device processor may load the first model from the storage unit for processing.
  • the first operator can be inserted in any layer of the calculation graph of the second model to obtain the first model, and the user can also flexibly use the first operator to insert a certain
  • the weights of one or more layers are randomly encrypted to avoid leakage of core data.
  • Fig. 6 shows a schematic diagram of the interaction of the model protection method provided by the embodiment of the present application. This approach can be applied to the system shown in Figure 2. As shown in Figure 6, the method may include:
  • Step S601 the host processor encrypts the first area in the second model.
  • step S602 the host processor adds the first operator used to indicate the decryption processing logic to the calculation graph of the second model according to the first region to obtain the first model.
  • Step S603 the host processor stores the first model in the storage unit.
  • Step S604 the device processor loads the first model from the storage unit.
  • Step S605 the device processor obtains multiple execution operators from the first model.
  • Step S606 the device processor executes the multiple execution operators in sequence according to the hierarchical relationship of the multiple execution operators.
  • Step S6061 when the device processor executes the first operator, it sends a key acquisition request to the host processor.
  • step S6062 the host processor authenticates the device processor in response to the key acquisition request from the device processor.
  • the key acquisition request includes an identifier of the first model and an identifier of the device processor.
  • Step S608 may include: the host processor authenticating the device processor based on the identifier of the first model and the identifier of the device processor.
  • Step S6063 if the authentication is passed, the host processor returns the key to the device processor.
  • Step S6064 the device processor responds to the key returned based on the key acquisition request, uses the key to decrypt the first data to obtain the second data, and executes one or Multiple execution operators.
  • Step S607 the device processor returns the inference result or the trained model.
  • step S608 the device processor deletes the first model, the multiple execution operators and the second data after executing the plurality of execution operators.
  • the decryption processing logic decrypts the first data under the first operator, it continues to execute one or more execution operators ranked behind the first operator, so as to realize the operation of the first model.
  • data decryption is realized in a pure software manner. That is, the protection of the model is achieved without adding additional components. It not only reduces the hardware cost, but also reduces the requirements on the scale of the operating environment and the algorithm.
  • users can choose the appropriate decryption processing logic according to actual needs, which improves flexibility, user-friendliness, and realizes personalized customization, thereby further improving the security of the model.
  • the decryption of data is performed by the device processor, and it is difficult for an attacker to enter the device side to attack, which improves the security. Since all the implementation logic of the first operator development method is controlled by the user, the user can choose the encryption and decryption algorithm and the key exchange method more flexibly. For example, the user can use the symmetric encryption method to encrypt the data content, and the asymmetric method Based on the public key that transmits the key in the public network environment, the embodiment of the present application does not limit the encryption and decryption algorithm.
  • the key protection area of the model needs to be temporarily stored in the storage unit (such as memory) without performing analysis operations, and supports dynamic analysis of the second data after decryption is completed.
  • Fig. 7 shows a schematic structural diagram of a model protection device provided by an embodiment of the present application. This means can be applied to the device processor 23 shown in FIG. 2 . As shown in Figure 7, the device 70 may include:
  • An obtaining module 71 configured to obtain a plurality of execution operators from the first model, the plurality of execution operators include a first operator, and the first operator is used to indicate the decryption processing logic;
  • Executing module 72 is used for executing the plurality of execution operators that described acquisition module 71 obtains according to the hierarchical relationship order of described multiple execution operators;
  • the execution module 72 is specifically used for:
  • the first operator When the first operator is executed, based on the decryption processing logic, the first data under the first operator is decrypted to obtain the second data, and based on the second data, the first One or more execution operators following the operator.
  • the second data is:
  • At least one weight and at least one execution operator are provided.
  • the executing module is also used for:
  • the key In response to the key returned based on the key acquisition request, the key is used to decrypt the first data to obtain the second data.
  • the first operator is used to indicate the address of the storage space where the first data is located, and when the first operator is executed, the execution module is further used to:
  • the data stored in the address is decrypted based on the decryption processing logic to obtain the second data.
  • the device further includes:
  • a deletion module configured to delete the first model, the multiple execution operators, and the second data when the execution of the plurality of execution operators is completed.
  • the first model is a training model or an inference model.
  • the device further includes:
  • a returning module configured to return an inference result if the first model is an inference model; and return a trained model if the first model is a training model.
  • the decryption processing logic is symmetric decryption processing logic or asymmetric decryption processing logic.
  • the decryption processing logic decrypts the first data under the first operator, it continues to execute one or more execution operators ranked behind the first operator, so as to realize the operation of the first model.
  • data decryption is realized in a pure software manner. That is, the protection of the model is achieved without adding additional components. It not only reduces the hardware cost, but also reduces the requirements on the scale of the operating environment and the algorithm.
  • users can choose the appropriate decryption processing logic according to actual needs, which improves flexibility, user-friendliness, and realizes personalized customization, thereby further improving the security of the model.
  • Fig. 8 shows a schematic structural diagram of a model protection device provided by an embodiment of the present application. This device can be applied to the host processor 21 shown in FIG. 2 . As shown in Figure 8, the device 80 may include:
  • An encryption module 81 configured to encrypt the first area in the second model
  • the adding module 82 is configured to add a first operator to the calculation graph of the second model according to the first area encrypted by the encryption module 81 to obtain a first model, and the first operator is used to indicate the decryption processing logic ;
  • the sending module 83 is configured to send the first model obtained after the adding module 82 adds the first operator.
  • the data in the first area is:
  • At least one weight and at least one execution operator are provided.
  • the device further includes:
  • an authentication module configured to authenticate the device processor in response to a key acquisition request from the device processor
  • the key is returned to the device processor.
  • the key acquisition request includes the identifier of the first model and the identifier of the device processor, and the authentication module is further configured to:
  • the device processor is authenticated based on the identification of the first model and the identification of the device processor.
  • the encryption module is also used for:
  • the first area is encrypted by using a second operator, and the second operator is used to indicate an encryption processing logic.
  • An embodiment of the present application provides an electronic device, including: a processor and a memory for storing instructions executable by the processor; wherein the processor is configured to implement the above method when executing the instructions.
  • An embodiment of the present application provides a processor, and the booster is configured to execute the above method.
  • Embodiments of the present application provide a chip that can execute the above method.
  • the embodiment of the present application provides a model protection system, the architecture of the system is shown in Figure 2, the system includes a host processor, a storage unit and a device processor, wherein the host processor is used to Encrypt the first area of the first area; add a first operator to the calculation graph of the second model according to the first area to obtain the first model, and the first operator is used to indicate the decryption processing logic; send the A first model; a storage unit, configured to store the first model; a device processor, configured to obtain a plurality of execution operators from the first model, and the plurality of execution operators include a first operator, so The first operator is used to indicate the decryption processing logic; executing the multiple execution operators in sequence according to the hierarchical relationship of the multiple execution operators includes: when the first operator is executed, based on the decryption The processing logic decrypts the first data under the first operator to obtain second data, and executes one or more execution operators arranged behind the first operator based on the second data.
  • An embodiment of the present application provides a non-volatile computer-readable storage medium, on which computer program instructions are stored, and when the computer program instructions are executed by a processor, the foregoing method is realized.
  • An embodiment of the present application provides a computer program product, including computer-readable codes, or a non-volatile computer-readable storage medium bearing computer-readable codes, when the computer-readable codes are stored in a processor of an electronic device When running in the electronic device, the processor in the electronic device executes the above method.
  • a computer readable storage medium may be a tangible device that can retain and store instructions for use by an instruction execution device.
  • a computer readable storage medium may be, for example, but is not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing.
  • Non-exhaustive list of computer-readable storage media include: portable computer disk, hard disk, random access memory (Random Access Memory, RAM), read only memory (Read Only Memory, ROM), erasable Electrically Programmable Read-Only-Memory (EPROM or flash memory), Static Random-Access Memory (Static Random-Access Memory, SRAM), Portable Compression Disk Read-Only Memory (Compact Disc Read-Only Memory, CD -ROM), Digital Video Disc (DVD), memory sticks, floppy disks, mechanically encoded devices such as punched cards or raised structures in grooves with instructions stored thereon, and any suitable combination of the foregoing .
  • RAM Random Access Memory
  • ROM read only memory
  • EPROM or flash memory erasable Electrically Programmable Read-Only-Memory
  • Static Random-Access Memory SRAM
  • Portable Compression Disk Read-Only Memory Compact Disc Read-Only Memory
  • CD -ROM Compact Disc Read-Only Memory
  • DVD Digital Video Disc
  • the computer-readable program instructions or codes described herein may be downloaded from a computer-readable storage medium to a respective computing/processing device, or downloaded to an external computer or external storage device over a network, such as the Internet, a local area network, a wide area network, and/or a wireless network.
  • the network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and/or edge servers.
  • a network adapter card or a network interface in each computing/processing device receives computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in a computer-readable storage medium in each computing/processing device .
  • Computer program instructions for performing the operations of the present application may be assembly instructions, instruction set architecture (Instruction Set Architecture, ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or in one or more source or object code written in any combination of programming languages, including object-oriented programming languages—such as Smalltalk, C++, etc., and conventional procedural programming languages—such as the “C” language or similar programming languages.
  • Computer readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server implement.
  • the remote computer can be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or it can be connected to an external computer such as use an Internet service provider to connect via the Internet).
  • electronic circuits such as programmable logic circuits, field-programmable gate arrays (Field-Programmable Gate Array, FPGA) or programmable logic arrays (Programmable Logic Array, PLA), the electronic circuit can execute computer-readable program instructions, thereby realizing various aspects of the present application.
  • These computer-readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine such that when executed by the processor of the computer or other programmable data processing apparatus , producing an apparatus for realizing the functions/actions specified in one or more blocks in the flowchart and/or block diagram.
  • These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause computers, programmable data processing devices and/or other devices to work in a specific way, so that the computer-readable medium storing instructions includes An article of manufacture comprising instructions for implementing various aspects of the functions/acts specified in one or more blocks in flowcharts and/or block diagrams.
  • each block in a flowchart or block diagram may represent a module, a portion of a program segment, or an instruction that includes one or more Executable instructions.
  • the functions noted in the block may occur out of the order noted in the figures. For example, two blocks in succession may, in fact, be executed substantially concurrently, or they may sometimes be executed in the reverse order, depending upon the functionality involved.
  • each block in the block diagrams and/or flowcharts, and combinations of blocks in the block diagrams and/or flowcharts can be implemented with hardware (such as circuits or ASIC (Application Specific Integrated Circuit, application-specific integrated circuit)), or can be implemented with a combination of hardware and software, such as firmware.
  • hardware such as circuits or ASIC (Application Specific Integrated Circuit, application-specific integrated circuit)
  • firmware such as firmware

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Artificial Intelligence (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Bioethics (AREA)
  • General Health & Medical Sciences (AREA)
  • Storage Device Security (AREA)

Abstract

本申请涉及一种模型保护方法及装置,所述方法包括从第一模型获得多个执行算子,所述多个执行算子中包括第一算子,所述第一算子用于指示解密处理逻辑;按照所述多个执行算子的层级关系顺序执行所述多个执行算子,包括:在执行到所述第一算子时,基于所述解密处理逻辑对所述第一算子下的第一数据进行解密获得第二数据,并基于所述第二数据执行排在所述第一算子后面的一个或多个执行算子。本申请实施例提供的模型保护方法及装置能够在不增加额外组件的情况下,实现模型保护。

Description

一种模型保护方法及装置
本申请要求于2021年09月16日提交中国专利局、申请号为202111086393.9、申请名称为“一种模型保护方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及人工智能领域,尤其涉及一种模型保护方法及装置。
背景技术
人工智能(Artificial Intelligence,AI)技术正在加速崛起,主要依托于三个关键因素:一是深度神经网络(Deep Neural Network,DNN)在多个经典机器学习任务中取得了突破性进展;二是大数据处理技术的成熟以及海量数据的积累;三是硬件计算能力的显著提高。在这三个因素的推动下,AI技术已经成功应用于自动驾驶、图像识别和语音识别等场景,加速了传统行业的智能化变革。
目前大多数现实世界的机器学习任务是资源密集型的,需要依靠大量的计算资源和存储资源来完成模型的训练或预测。机器学习服务商提供训练平台和使用模型的查询接口,而使用者可以通过这些接口来对一些实例进行查询。
然而,AI技术在高速发展的同时面临着严峻的数据泄露风险。AI模型的参数需要得到保护,否则将对模型拥有者带来巨大的经济损失。图1示出相关技术中的模型保护方法的示意图。如图1所示,模型拥有者在向使用者提供AI应用时,会同时提供一个硬件加密狗。使用者在主机上运行AI应用时,AI应用首先获取加密后的AI模型(可以以文件的形式存储),并从硬件加密狗读取密钥以及授权信息。在授权信息认证通过后,AI应用可以采用密钥对加密后的AI模型进行解密得到解密后的AI模型,并存储在内存中。之后,AI加速卡从内存中加载解密后的AI模型进行推理或者模型增量训练。在上述方法中,在主机上部署硬件加密狗,增加了成本和部署复杂性。如何在不增加额外组件的情况下,实现模型保护,降低系统成本成为亟需解决的问题。
发明内容
有鉴于此,提出了一种模型保护方法及装置,能够在不增加额外组件的情况下,实现模型保护。
第一方面,本申请的实施例提供了一种模型保护方法,所述方法包括:从第一模型获得多个执行算子,所述多个执行算子中包括第一算子,所述第一算子用于指示解密处理逻辑;按照所述多个执行算子的层级关系顺序执行所述多个执行算子,包括:在执行到所述第一算子时,基于所述解密处理逻辑对所述第一算子下的第一数据进行解密获得第二数据,并基于所述第二数据执行排在所述第一算子后面的一个或多个执行算子。
在本申请实施例中,以纯软件的方式实现了数据的解密。也就是说,在不增加额外组件的情况下,实现了对模型的保护。既降低了硬件成本,又降低了对运行环境的规模以及算法 的要求。
根据第一方面,在所述方法的第一种可能的实现方式中,所述第二数据为:至少一个权值;或者,至少一个执行算子;或者,至少一个权值以及至少一个执行算子。
在本申请实施例中,可以灵活选择需要保护的模型的参数,提高了灵活性和用户友好度。
根据第一方面,或者第一方面的第一种可能的实现方式,在所述方法的第二种可能的实现方式中,所述基于所述解密处理逻辑对所述第一数据进行解密获得第二数据,包括:响应于基于密钥获取请求返回的密钥,采用所述密钥对所述第一数据进行解密获得所述第二数据。
在本申请实施例中,以交互的方式获取密钥,实现了模型保护。
根据第一方面,或者第一方面的第一种可能的实现方式,在所述方法的第三种可能的实现方式中,所述第一算子用于指示所述第一数据所在存储空间的地址,所述在执行到所述第一算子时,所述基于所述解密处理逻辑对所述第一算子下的第一数据进行解密获得第二数据,包括:在执行到所述地址时,基于所述解密处理逻辑对所述地址中存储的数据进行解密获得所述第二数据。
在本申请实施例中,直接对存储的数据进行解密,提高了效率。
根据第一方面,或者以上第一方面的任意一种可能的实现方式,在所述方法的第四种可能的实现方式中,所述方法还包括:在执行完所述多个执行算子时,删除所述第一模型、所述多个执行算子以及所述第二数据。
这样,可以节省存储空间,同时提高模型的安全性。
根据第一方面,或者第一方面的第一种可能的实现方式至三种种可能的实现方式中的任意一种,在所述方法的第五种可能的实现方式中,所述第一模型为训练模型或者推理模型。
根据第一方面的第五种可能的实现方式,在所述方法的第六种可能的实现方式中,所述方法还包括:在所述第一模型为推理模型的情况下,返回推理结果;在所述第一模型为训练模型的情况下,返回训练后的模型。
根据第一方面,或者以上第一方面的任意一种可能的实现方式,在所述方法的第七种可能的实现方式中,所述解密处理逻辑为对称式解密处理逻辑或者非对称式解密处理逻辑。
这样,用户可以根据实际需求的选择合适的解密处理逻辑,提高了灵活性、用户友好度,实现了个性化定制,从而进一步提高了模型的安全性。
第二方面,本申请的实施例提供了一种模型保护方法,包括:对第二模型中的第一区域进行加密;按照所述第一区域向所述第二模型的计算图中添加第一算子,得到第一模型,所述第一算子用于指示解密处理逻辑;发送所述第一模型。
在本申请实施例中,通过按照加密后的第一区域添加用于指示解密处理逻辑的第一算子,在不增加额外组件的情况下,既可以实现模型的保护,又可以保障模型的正常运算功能。
根据第二方面,在所述方法的第一种可能的实现方式中,所述第一区域中的数据为:至少一个权值;或者,至少一个执行算子;或者,至少一个权值以及至少一个执行算子。
根据第二方面,或者第二方面的第一种可能的实现方式,在所述方法的第二种可能的实现方式中,所述方法还包括:响应于来自设备处理器的密钥获取请求,对所述设备处理器进行鉴权;在鉴权通过的情况下,向所述设备处理器返回密钥。
根据第二方面的第二种可能的实现方式,在所述方法的第三种可能的实现方式中,所述密钥获取请求中包括所述第一模型的标识,以及所述设备处理器的标识,所述对所述设备处 理器进行鉴权包括:基于所述第一模型的标识,以及所述设备处理器的标识对所述设备处理器进行鉴权。
根据第二方面,或者以上第二方面的任意一种可能的实现方式,在所述方法的第四种可能的实现方式中,所述对第二模型中的第一区域进行加密包括:采用第二算子对所述第一区域进行加密,所述第二算子用于指示加密处理逻辑。
第三方面,本申请的实施例提供了一种模型保护装置,包括:获取模块,用于从第一模型获得多个执行算子,所述多个执行算子中包括第一算子,所述第一算子用于指示解密处理逻辑;执行模块,用于按照所述多个执行算子的层级关系顺序执行所述获取模块获取的多个执行算子;所述执行模块,具体用于:在执行到所述第一算子时,基于所述解密处理逻辑对所述第一算子下的第一数据进行解密获得第二数据,并基于所述第二数据执行排在所述第一算子后面的一个或多个执行算子。
在一种可能的实现方式中,所述第二数据为:
至少一个权值;或者,
至少一个执行算子;或者,
至少一个权值以及至少一个执行算子。
在一种可能的实现方式中,所述执行模块还用于:
响应于基于密钥获取请求返回的密钥,采用所述密钥对所述第一数据进行解密获得所述第二数据。
在一种可能的实现方式中,所述第一算子用于指示所述第一数据所在存储空间的地址,所述在执行到所述第一算子时,所述执行模块还用于:
在执行到所述地址时,基于所述解密处理逻辑对所述地址中存储的数据进行解密获得所述第二数据。
在一种可能的实现方式中,所述装置还包括:
删除模块,用于在执行完所述多个执行算子时,删除所述第一模型、所述多个执行算子以及所述第二数据。
在一种可能的实现方式中,所述第一模型为训练模型或者推理模型。
在一种可能的实现方式中,所述装置还包括:
返回模块,用于在所述第一模型为推理模型的情况下,返回推理结果;以及在所述第一模型为训练模型的情况下,返回训练后的模型。
在一种可能的实现方式中,所述解密处理逻辑为对称式解密处理逻辑或者非对称式解密处理逻辑。
第四方面,本申请的实施例提供了一种模型保护装置,包括:
加密模块,用于对第二模型中的第一区域进行加密;
添加模块,用于按照所述加密模块加密的第一区域向所述第二模型的计算图中添加第一算子,得到第一模型,所述第一算子用于指示解密处理逻辑;
发送模块,用于发送所述添加模块添加了所述第一算子后得到的第一模型。
在一种可能的实现方式中,所述第一区域中的数据为:
至少一个权值;或者,
至少一个执行算子;或者,
至少一个权值以及至少一个执行算子。
在一种可能的实现方式中,所述装置还包括:
鉴权模块,用于响应于来自设备处理器的密钥获取请求,对所述设备处理器进行鉴权;
在鉴权通过的情况下,向所述设备处理器返回密钥。
在一种可能的实现方式中,所述密钥获取请求中包括所述第一模型的标识,以及所述设备处理器的标识,所述鉴权模块还用于:
基于所述第一模型的标识,以及所述设备处理器的标识对所述设备处理器进行鉴权。
在一种可能的实现方式中,所述加密模块还用于:
采用第二算子对所述第一区域进行加密,所述第二算子用于指示加密处理逻辑。
第五方面,本申请的实施例提供了一种电子设备,该终端设备可以执行上述第一方面或者第一方面的多种可能的实现方式中的一种或几种的模型保护方法,或者执行上述第二方面或者第二方面的多种可能的实现方式中的一种或几种的模型保护方法。
第六方面,本申请的实施例提供了一种处理器,该处理器可以执行上述第一方面或者第一方面的多种可能的实现方式中的一种或几种的模型保护方法,或者执行上述第二方面或者第二方面的多种可能的实现方式中的一种或几种的模型保护方法。
第七方面,本申请的实施例提供了一种芯片,该芯片可以执行上述第一方面或者第一方面的多种可能的实现方式中的一种或几种的模型保护方法,或者执行上述第二方面或者第二方面的多种可能的实现方式中的一种或几种的模型保护方法。
第八方面,本申请的实施例提供了一种模型保护系统,所述系统包括主机处理器、存储单元和设备处理器,其中,主机处理器,用于对第二模型中的第一区域进行加密;按照所述第一区域向所述第二模型的计算图中添加第一算子,得到第一模型,所述第一算子用于指示解密处理逻辑;发送所述第一模型;存储单元,用于存储所述第一模型;设备处理器,用于从所述第一模型获得多个执行算子,所述多个执行算子中包括第一算子,所述第一算子用于指示解密处理逻辑;按照所述多个执行算子的层级关系顺序执行所述多个执行算子,包括:在执行到所述第一算子时,基于所述解密处理逻辑对所述第一算子下的第一数据进行解密获得第二数据,并基于所述第二数据执行排在所述第一算子后面的一个或多个执行算子。
第九方面,本申请的实施例提供了一种可读存储介质,其上存储有计算机程序指令,所述计算机程序指令被处理器执行时实现上述第一方面或者第一方面的多种可能的实现方式中的一种或几种的模型保护方法,或者实现上述第二方面或者第二方面的多种可能的实现方式中的一种或几种的模型保护方法。
第十方面,本申请的实施例提供了一种计算机程序产品,包括计算机可读代码,或者承载有计算机可读代码的非易失性计算机可读存储介质,当所述计算机可读代码在电子设备中运行时,所述电子设备中的处理器执行上述第一方面或者第一方面的多种可能的实现方式中的一种或几种的模型保护方法,或者执行上述第二方面或者第二方面的多种可能的实现方式中的一种或几种的模型保护方法。
本申请的这些和其他方面在以下(多个)实施例的描述中会更加简明易懂。
附图说明
包含在说明书中并且构成说明书的一部分的附图与说明书一起示出了本申请的示例性实 施例、特征和方面,并且用于解释本申请的原理。
图1示出相关技术中的模型保护方法的示意图;
图2示出本申请实施例提供的模型保护系统的架构示意图;
图3示出计算图的一个示例性示意图;
图4示出本申请实施例提供的模型保护方法的流程图;
图5示出本申请实施例提供的模型保护方法的流程图;
图6示出本申请实施例提供的模型保护方法的交互示意图;
图7示出本申请实施例提供的一种模型保护装置的结构示意图;
图8示出本申请实施例提供的一种模型保护装置的结构示意图。
具体实施方式
以下将参考附图详细说明本申请的各种示例性实施例、特征和方面。附图中相同的附图标记表示功能相同或相似的元件。尽管在附图中示出了实施例的各种方面,但是除非特别指出,不必按比例绘制附图。
在这里专用的词“示例性”意为“用作例子、实施例或说明性”。这里作为“示例性”所说明的任何实施例不必解释为优于或好于其它实施例。
另外,为了更好的说明本申请,在下文的具体实施方式中给出了众多的具体细节。本领域技术人员应当理解,没有某些具体细节,本申请同样可以实施。在一些实例中,对于本领域技术人员熟知的方法、手段、元件和电路未作详细描述,以便于凸显本申请的主旨。
本申请实施例提供了一种模型保护方法,通过纯软件方式实现了对模型的保护,未增加额外组件、对运行环境的规模以及算法的要求也较低,从而降低了系统成本。从应用设备角度来讲,本申请实施例提供的模型保护方法可以应用于端、边以及云场景下的模型运算过程。其中,端指客户端或者设备端,例如手机或者电脑等;边指边缘设备,例如路由器、交换机等;云指云端,例如服务器集群等。从功能角度来讲,本申请实施例提供的模型保护方法可以用于模型推理场景以及模型增量训练场景。本申请实施例对应用场景不做限制。
图2示出本申请实施例提供的模型保护系统的架构示意图。如图2所示,该模型保护系统包括主机处理器21、存储单元22以及设备处理器23。其中,主机处理器21是主机(host)的控制中心,用于运行AI应用。存储单元22可以用于保存AI应用涉及的AI模型等数据。设备处理器23是设备(device)的控制中心,用于处理AI应用涉及的AI模型,例如,采用AI应用涉及的AI模型进行推理,或者,对AI应用涉及的AI模型进行增量训练。其中,AI模型可以用于目标检测、图像处理以及信号控制等,本申请实施例对AI模型的作用不做限制。AI模型可以为卷积神经网络模型(Convolutional Neural Networks,CNN)、循环神经网络模型(Recurrent Neural Network,RNN)以及深度神经网络(Deep Neural Network,DNN)模型等,本申请实施例对AI模型的类别不做限制。
在一种可能的实现方式中,在运行AI应用时,主机处理器21的管理模块可以通过调用图执行器(Graphy Engine,GE)提供的接口实现AI模型的加载与执行,以及通过调用运行管理器(Runtime)提供的接口实现存储单元22以及设备处理器23等的管理,从而利用设备处理器23提供的AI模型的运算能力,完成业务。
在一种可能的实现方式中,主机处理器21可以是一个处理器,也可以是多个处理元件的统称。例如,主机处理器21可以是一个中央处理器(Central Processing Unit,CPU),也可以是特定集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field Programmable Gate Srray,FPGA)、图像处理器(Graphics Processing Unit,GPU)或者是被配置成本公开实施例的一个或多个集成电路,例如:一个或多个数字信号处理器(Digital Signal Processor,DSP),或,一个或者多个现场可编程门列阵(Field Programmable Gate Array,FPGA)。设备处理器23可以参照主机处理器21,这里不再赘述。需要说明的是,设备处理器23具有较强的模型运算能力。
在一种可能的实现方式中,存储单元22可以包括易失性存储器或非易失性存储器,或可包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(read-only memory,ROM)、可编程只读存储器(programmable ROM,PROM)、可擦除可编程只读存储器(erasable PROM,EPROM)、电可擦除可编程只读存储器(electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(random access memory,RAM),其用作外部高速缓存。通过示例性但不是限制性说明,许多形式的RAM可用,例如静态随机存取存储器(static RAM,SRAM)、动态随机存取存储器(DRAM)、同步动态随机存取存储器(synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(double data date SDRAM,DDR SDRAM)、增强型同步动态随机存取存储器(enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(synchlink DRAM,SLDRAM)和直接内存总线随机存取存储器(direct rambus RAM,DR RAM)。
在本申请实施例中,主机处理器21和设备处理器23可以位于在不同的设备中。例如,主机处理器21可以位于X86服务器、ARM服务器或者WindowsPC等主机设备中,设备处理器23可以安装在能够与上述主机设备相连接的硬件设备中。在一个示例中,主机处理器21和存储单元22位于主机设备中,设备处理器23位于硬件设备中。其中,主机处理器21和存储单元22可以通过总线连接,其中,总线可以是工业标准体系结构(Industry Standard Architecture,ISA)总线、外部设备互联(Peripheral Component Interconnect,PCI)总线或扩展工业标砖体系结构(Extended Industry Standard Architecture,EISA)总线等。该总线可以分为地址总线、数据总线、控制总线等。主机设备上可以设置高速串行计算机扩展总线标准(Peripheral Component Interconnect express,PCIe)接口,硬件设备可以通过该PCIe接口连接主机设备。在一种可能的实现方式中,上述主机设备与上述硬件设备可以合设,统称为主机设备。
需要说明的是,图2示出的仅为本申请实施例提供的模型保护系统的示例性架构示意图,并不构成对模型保护系统的限定,模型保护系统可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
为了便于理解,下面对本申请实施例中涉及的AI模型、计算图、权值以及执行算子进行说明。
AI模型是指一个神经网络按照一定算法固定下来的结构。AI模型里面包括计算图以及权值。其中,计算图用于表示算法的运算过程,是一种将算法形式化的方法。权值用于表示执行算子在执行过程中需要使用的数据。
计算图包括多个节点,这些节点之间通过有向边连接,每个节点代表一个执行算子。进入节点的输入边表示该节点对应执行算子的输入数据,离开节点的输出边表示该节点对应执 行算子的输出数据。计算图所表示的运算过程可以是模型推理过程也可以是模型训练过程。
图3示出计算图的一个示例性示意图。如图3所示,A和B为输入数据,C和D为执行算子,E为权值。其中,C表示乘法,D表示加法,E表示常量,这个计算图表示的就是输出A*B+E的运算过程。在保存成模型的时候,可以按照计算图中有向边的连接方式将各执行算子保存下来,以及各执行算子涉及的权值保存下来,从而实现AI模型的保存。
在保存AI模型时,可以将计算图序列化为设备处理器(例如,图2所示的设备处理器23)可读的模型文件进行保存,从而使得设备处理器可以运行该模型文件以实现运算。在一个示例中,设备处理器可读的模型文件包括但不限于MindIR格式文件、AIR(Ascend Intermediate Pepresentation)格式文件和ONNX(Open Neural Network Exchange)格式文件等。也就是说,主机处理器上的Tensorflow、Pytorch或者其他AI框架,可以将AI模型的计算图和权值按照一定的数据结构进行保存,以便于后续在设备处理器上进行模型推理或者模型增量训练。
图4示出本申请实施例提供的模型保护方法的流程图。该方法可以应用于图2所示的设备处理器23。如图4所示,该方法可以包括:
步骤S401,从第一模型获得多个执行算子,所述多个执行算子中包括第一算子,所述第一算子用于指示解密处理逻辑。
其中,第一模型可以表示加密后的AI模型。第一模型可以为训练模型或者推理模型。第一模型可以用于图像分类、语音识别、目标检测或者目标跟踪等。本申请实施例对第一模型的类型和作用不做限制。第一模型包括计算图和权值,第一模型的计算图包括多个执行算子。在本申请实施例中,应用处理器在加载第一模型后,可以对第一模型进行逐层解压,获得多个执行算子。
第一算子可以表示用于指示解密处理逻辑的执行算子。第一模型的多个执行算子中可以包括一个或多个第一算子。本申请实施例对第一算子的数量不做限制。数据输入第一算子后,应用处理器可以基于第一算子指示的解密处理逻辑对输入的数据进行解密,然后输出解密后的输入。在本申请实施例中,需要输入第一算子进行的数据称为第一算子下的第一数据,经第一算子运算后输出的数据称为第二数据。可以理解的是,第一数据是需要进行解密的数据,第二数据是解密后的数据。
在本申请实施例中,第二数据可以为至少一个权值;或者,至少一个执行算子;或者至少一个权值以及至少一个执行算子。也就是说,第一数据可能为至少一个加密后的权值,或者至少一个加密后的执行算子,或者是至少一个加密后的权值以及至少一个加密后的执行算子。在一个示例中,权值M1输入第一算子进行解密后得到权值M2;执行算子N1输入第一算子进行解密后得到执行算子N2;权值M1以及执行算子N1输入第一算子进行解密后得到权值M2以及执行算子N2。
在一种可能的实现方式中,解密处理逻辑可以为对称式解密处理逻辑或者非对称式解密处理逻辑。举例来说,对称式解密处理逻辑包括但不限于DES TripleDES算法、BlowFish算法和RC算法等,非对称式解密处理逻辑包括但不限于RSA、Elgamal、背包算法、Rabin算法和ECC算法等。本申请实施例对解密处理逻辑不做限制。用户可以灵活选择加解密算法来对数据进行加密以及解密。
在本申请实施例中,第一模型可以由主机处理器提供。在一个示例中,如图2所示,在 主机处理器21在运行AI应用的过程中可以生成第一模型,并将第一模型保存在存储单元22中,设备处理器23可以从存储单元22加载第一模型。在一种可能的实现方式中,第一模型的传输可以通过内存复制的方式实现。具体的,主机处理器21和设备处理器23可以分别存储单元22中申请存储空间。主机处理器21将第一模型存储在其对应的存储空间中,实现第一模型的存储。设备处理器23将第一模型所在存储空间的数据复制到设备处理器23对应的存储空间中,实现第一模型的加载。
步骤S402,按照所述多个执行算子的层级关系顺序执行所述多个执行算子。
设备处理器在获得多个执行算子之后,可以按照多个执行算子的层级关系顺序执行这些执行算子。由于第一模型的多个执行算子中包括一个或多个第一算子,在执行到任意一个第一算子时,设备处理器可以执行步骤S403。
步骤S403,在执行到所述第一算子时,基于所述解密处理逻辑对所述第一算子下的第一数据进行解密获得第二数据,并基于所述第二数据执行排在所述第一算子后面的一个或多个执行算子。
在第一模型中,第一数据(包括加密后的执行算子和/或加密后的权值)可以作为第一算子的输入。这样,在执行到第一算子时,设备处理器可以采用第一算子指示的解密处理逻辑对输入第一算子的数据进行解密,从而得到第二数据(包括解密后的执行算子和/或解密后的权值)。
在一个示例中,图3所示的权值E为被加密后的权值。若设备处理器直接采用权值E或者对权值E的解密处理不正确则输出的结果是错误的。在本示例中,权值E是第一算子的输入,第一算子排在执行算子D之前,应用处理器需要先执行第一算子,再执行执行算子D。应用处理器在执行到第一算子时,会将权值E输入第一算子,并输出权值E的解密结果,然后执行执行算子D,即将A*B的结果与权值E的解密结果相加。
在又一示例中,图3所示的执行算子C为被加密后的执行算子。若设备处理器直接采用执行算子C或者对执行算子C的解密处理不正确则输出的结果是错误的。在本示例中,执行算子C是第一算子的输入,第一算子排在执行算子D之前,应用处理器需要先执行第一算子,再执行执行算子D。应用处理器在执行到第一算子时,会将执行算子C输入第一算子中,得到解密结果执行算子“*”,应用处理器将输入数据A和输入数据B相乘,得到A*B的结果;然后,执行执行算子D,即将A*B的结果与权值E的解密结果相加。
在另一示例中,图3所示的权值E为被加密后的权值,执行算子C为被加密后的执行算子。假设以执行算子C为输入的第一算子记为第一算子1,以权值E为输入的第一算子记为第一算子2。在本示例中,第一算子1排在第一算子2之前,第一算子2排在执行算子D之前。应用处理器在执行到第一算子1时,将执行算子C输入第一算子中,得到解密结果执行算子“*”,应用处理器将输入数据A和输入数据B相乘,得到A*B的结果。然后,应用处理器执行第一算子2,此时,将权值E输入第一算子2,并输出权值E的解密结果。之后,应用处理器执行执行算子D,即将A*B的结果与权值E的解密结果相加。
可以理解的是,在本申请实施例中,第一算子可以排在第一模型的所有执行算子的首位,此时,可以实现对整个计算图和所有权值的保护;第一算子排在其他位置。在本申请实施例中,用户在生成第一模型的过程中,可以灵活的设置第一算子的位置,以及第一算子的数量,还可以连续设置第一算子(实现多重加密),从而提高数据安全性。
在一种可能的实现方式中,第一算子还可以用于指示第一数据所在存储空间的地址。步骤S403中在执行到所述第一算子时,基于所述解密处理逻辑对所述第一算子下的第一数据进行解密获得第二数据可以包括:在执行到第一数据所在存储空间的地址时,基于解密处理逻辑对该地址中存储的数据进行解密获得第二数据。
第一模型解压后得到的计算图以及权值以数据序列的形式存储在存储空间(例如,图2所示的存储单元22)中。应用处理器读取存储空间中的数据,在读取到第一算子对应的数据时,执行第一算子。由于第一算子指示了第一数据的地址。因此,应用处理器在执行第一算子时,首先去第一算子指示的地址读取第一数据,然后基于解密处理逻辑对第一数据进行解密,得到第二数据。
在一种可能的实现方式中,基于解密处理逻辑对第一数据进行解密获得第二数据可以包括:响应于基于密钥获取请求返回的密钥,采用所述密钥对所述第一数据进行解密获得所述第二数据。
在执行到第一算子时,设备处理器可以向主机处理器发送密钥获取请求,以获取密钥对第一数据进行解密。主机处理器响应于来自设备处理器的密钥获取请求,可以对设备处理器进行鉴权,并在鉴权通过的情况下,向设备处理器返回密钥。
其中,密钥获取请求用于获取密钥。在一个示例中,密钥获取请求中可以包括第一模型的标识,以及设备处理器的标识。主机处理器可以从密钥获取请求中获取第一模型的标识以及设备处理器的标识,然后基于第一模型的标识以及设备处理器的标识对设备处理器进行鉴权。例如,主机处理器中可以维护一个权限表,该权限表可以用于存储模型的标识、处理器的标识以及权限的关联关系。其中,模型的标识可以为模型的名称、模型的编号或者模型的类别等,处理器的标识可以为处理器的名称、处理器的编号、处理器的型号等,权限可以为有解密权限或者无解密权限。若主机处理器在权限表中查找到与第一模型的标识以及设备处理器的标识相关联的权限为有解密权限,则确定鉴权通过,返回密钥;若主机处理器在权限表中未查找到第一模型的标识或者设备处理器的标识,或者查找到的与第一模型的标识以及设备处理器的标识相关联的权限为无解密权限,则确定鉴权未通过,不返回密钥。在本申请实施例中,还可以通过其他方式进行鉴权,例如根据进程号、根据接口号等,本申请实施例对鉴权方式不做限制。
在一个示例中,设备处理器与主机处理器进行密钥交换,可以通过异步API或者专有接口进行实现,本申请实施例不做限制。
在本申请实施例中,按照第一模型的多个执行算子的层级关系顺序执行各执行算子的过程中,在执行到第一模型的第一算子时,采用第一算子指示的解密处理逻辑对第一算子下的第一数据进行解密后,再继续执行排在第一算子后面的一个或多个执行算子,从而实现第一模型的运行。在上述执行第一模型各执行算子的过程中,以纯软件的方式实现了数据的解密。也就是说,在不增加额外组件的情况下,实现了对模型的保护。既降低了硬件成本,又降低了对运行环境的规模以及算法的要求。同时,用户可以根据实际需求的选择合适的解密处理逻辑,提高了灵活性、用户友好度,实现了个性化定制,从而进一步提高了模型的安全性。
在一种可能的实现方式中,所述模型保护方法还可以包括:在执行完所述多个执行算子时,删除所述第一模型、所述多个执行算子以及所述第二数据。
在本申请实施例中,在执行完第一模型的多个执行算子后,表示已经完成了第一模型的 运算,例如已经完成了基于第一模型的推理或者已经完成了对第一模型的增量训练等,此时,删除第一模型,以及在运算第一模型过程中产生的执行算子和第二数据,可以节省存储空间。另外,考虑到第二数据为解密后的数据,第二数据泄露会造成模型参数的泄露,因此,设备处理器在执行完第一模型的多个执行算子之后,删除第二数据,可以进一步保障模型的安全性。
在一个示例中,在第一模型为推理模型的情况下,应用处理器可以返回推理结果。主机处理器中的AI应用在运行过程中可以使用该推理结果。
在一个示例中,在第一模型为训练模型的情况下,应用处理器可以返回训练后的模型。主机处理器中的AI应用在运行过程中可以使用该训练后的模型。可以理解的是,应用处理器返回的训练后的模型包括训练后的模型的计算图和权值。
图5示出本申请实施例提供的模型保护方法的流程图。该方法可以应用于图2所示的主机处理器21。如图5所示,该方法可以包括:
步骤S501,对第二模型中的第一区域进行加密。
其中,第二模型表示需要进行加密保护的模型。第一区域可以表示第二模型中需要进行加密的区域。在一种可能的实现方式中,所述第一区域中的数据为:至少一个权值;或者,至少一个执行算子;或者,至少一个权值以及至少一个执行算子。在本申请实施例中,用户可以灵活的选择需要加密的区域,提高灵活性和用户友好度。例如,用户可以选择将关键数据、敏感数据进行加密,用户可以选择将关键算子进行加密,或者,用户可以将整个计算图进行加密。本申请实施例,对第一区域不做限制。
在一种可能的实现方式中,步骤S501可以包括:采用第二算子对第一区域进行加密,第二算子用于指示加密处理逻辑。主机处理器可以选择采用第二算子对第一区域进行加密。可以理解的是,在本申请实施例中,第二算子指示的加密处理逻辑与第一算子指示的解密处理逻辑是相对应的,采用的加密算法和解密算法是配套的。当然,主机处理器还可以选择其他方式,例如人工编辑的方式对第一区域进行加密,对此本申请实施例不做限制。
步骤S502,按照所述第一区域向所述第二模型的计算图中添加第一算子,得到第一模型,所述第一算子用于指示解密处理逻辑。
在第一区域之前添加第一算子,这样,设备处理器在需要使用第一区域的数据之前,会先执行第一算子对第一区域中的数据进行解密,既保护了第一数据中的数据的安全,又保证了模型的正常运算功能。
步骤S503,发送所述第一模型。
在一种可能的实现方式中,主机处理器可以将第一模型直接发送给设备处理器进行处理。在另一种可能的实现方式中,主机处理器可以将第一模型发送至存储单元进行存储,之后设备处理器可以从存储单元加载第一模型进行处理。
在本申请实施例中,通过按照加密后的第一区域添加用于指示解密处理逻辑的第一算子,在不增加额外组件的情况下,既可以实现模型的保护,又可以保障模型的正常运算功能。
在本申请实施例中,第一算子可以插在第二模型的计算图的任意一层,得到第一模型,用户还可以灵活的通过第一算子将第二模型的计算图中某一层或多层的权值进行随机加密,避免核心数据的泄露。
图6示出本申请实施例提供的模型保护方法的交互示意图。该方法可以应用于图2所示 的系统。如图6所示,该方法可以包括:
步骤S601,主机处理器对第二模型中的第一区域进行加密。
步骤S602,主机处理器按照第一区域向第二模型的计算图中添加用于指示解密处理逻辑的第一算子,得到第一模型。
步骤S603,主机处理器在存储单元中存储第一模型。
步骤S604,设备处理器从存储单元中加载第一模型。
步骤S605,设备处理器从第一模型获得多个执行算子。
步骤S606,设备处理器按照所述多个执行算子的层级关系顺序执行所述多个执行算子。
步骤S6061,设备处理器在执行到第一算子时,向主机处理器发送密钥获取请求。
步骤S6062,主机处理器响应于来自设备处理器的密钥获取请求,对设备处理器进行鉴权。
在一种可能的实现方式中,所述密钥获取请求中包括所述第一模型的标识,以及所述设备处理器的标识。步骤S608可以包括:主机处理器基于第一模型的标识以及设备处理器的标识对设备处理器进行鉴权。
步骤S6063,在鉴权通过的情况下,主机处理器向设备处理器返回密钥。
步骤S6064,设备处理器响应于基于密钥获取请求返回的密钥,采用所述密钥对第一数据进行解密获得第二数据,并基于第二数据执行排在第一算子后面的一个或多个执行算子。
步骤S607,设备处理器返回推理结果或者训练后的模型。
步骤S608,设备处理器在执行完所述多个执行算子时,删除第一模型、多个执行算子以及第二数据。
在本申请实施例中,按照第一模型的多个执行算子的层级关系顺序执行各执行算子的过程中,在执行到第一模型的第一算子时,采用第一算子指示的解密处理逻辑对第一算子下的第一数据进行解密后,再继续执行排在第一算子后面的一个或多个执行算子,从而实现第一模型的运行。在上述执行第一模型各执行算子的过程中,以纯软件的方式实现了数据的解密。也就是说,在不增加额外组件的情况下,实现了对模型的保护。既降低了硬件成本,又降低了对运行环境的规模以及算法的要求。同时,用户可以根据实际需求的选择合适的解密处理逻辑,提高了灵活性、用户友好度,实现了个性化定制,从而进一步提高了模型的安全性。
在本申请实施例中,数据的解密均由设备处理器执行,攻击者本身也较难进入到设备侧进行攻击,提高了安全性。由于第一算子的开发方式其全部实现逻辑由用户控制,用户可以较灵活的选择加解密算法以及密钥交换方式,如用户可以采用对称加密方式来进行数据内容的加密,采用非对称的方式基于公网环境传递密钥的公钥,本申请实施例对加解密算法不做限制。
在本申请实施例中,第一算子未执行解密前,模型的关键保护区域需要暂时保存在存储单元(例如内存)中不执行解析操作,解密完成后支持对第二数据进行动态的解析。
图7示出本申请实施例提供的一种模型保护装置的结构示意图。该装置可以应用于图2所示的设备处理器23。如图7所示,装置70可以包括:
获取模块71,用于从第一模型获得多个执行算子,所述多个执行算子中包括第一算子,所述第一算子用于指示解密处理逻辑;
执行模块72,用于按照所述多个执行算子的层级关系顺序执行所述获取模块71获取的 多个执行算子;
所述执行模块72,具体用于:
在执行到所述第一算子时,基于所述解密处理逻辑对所述第一算子下的第一数据进行解密获得第二数据,并基于所述第二数据执行排在所述第一算子后面的一个或多个执行算子。
在一种可能的实现方式中,所述第二数据为:
至少一个权值;或者,
至少一个执行算子;或者,
至少一个权值以及至少一个执行算子。
在一种可能的实现方式中,所述执行模块还用于:
响应于基于密钥获取请求返回的密钥,采用所述密钥对所述第一数据进行解密获得所述第二数据。
在一种可能的实现方式中,所述第一算子用于指示所述第一数据所在存储空间的地址,所述在执行到所述第一算子时,所述执行模块还用于:
在执行到所述地址时,基于所述解密处理逻辑对所述地址中存储的数据进行解密获得所述第二数据。
在一种可能的实现方式中,所述装置还包括:
删除模块,用于在执行完所述多个执行算子时,删除所述第一模型、所述多个执行算子以及所述第二数据。
在一种可能的实现方式中,所述第一模型为训练模型或者推理模型。
在一种可能的实现方式中,所述装置还包括:
返回模块,用于在所述第一模型为推理模型的情况下,返回推理结果;以及在所述第一模型为训练模型的情况下,返回训练后的模型。
在一种可能的实现方式中,所述解密处理逻辑为对称式解密处理逻辑或者非对称式解密处理逻辑。
在本申请实施例中,按照第一模型的多个执行算子的层级关系顺序执行各执行算子的过程中,在执行到第一模型的第一算子时,采用第一算子指示的解密处理逻辑对第一算子下的第一数据进行解密后,再继续执行排在第一算子后面的一个或多个执行算子,从而实现第一模型的运行。在上述执行第一模型各执行算子的过程中,以纯软件的方式实现了数据的解密。也就是说,在不增加额外组件的情况下,实现了对模型的保护。既降低了硬件成本,又降低了对运行环境的规模以及算法的要求。同时,用户可以根据实际需求的选择合适的解密处理逻辑,提高了灵活性、用户友好度,实现了个性化定制,从而进一步提高了模型的安全性。
图8示出本申请实施例提供的一种模型保护装置的结构示意图。该装置可以应用于图2所示的主机处理器21。如图8所示,装置80可以包括:
加密模块81,用于对第二模型中的第一区域进行加密;
添加模块82,用于按照所述加密模块81加密的第一区域向所述第二模型的计算图中添加第一算子,得到第一模型,所述第一算子用于指示解密处理逻辑;
发送模块83,用于发送所述添加模块82添加了所述第一算子后得到的第一模型。
在一种可能的实现方式中,所述第一区域中的数据为:
至少一个权值;或者,
至少一个执行算子;或者,
至少一个权值以及至少一个执行算子。
在一种可能的实现方式中,所述装置还包括:
鉴权模块,用于响应于来自设备处理器的密钥获取请求,对所述设备处理器进行鉴权;
在鉴权通过的情况下,向所述设备处理器返回密钥。
在一种可能的实现方式中,所述密钥获取请求中包括所述第一模型的标识,以及所述设备处理器的标识,所述鉴权模块还用于:
基于所述第一模型的标识,以及所述设备处理器的标识对所述设备处理器进行鉴权。
在一种可能的实现方式中,所述加密模块还用于:
采用第二算子对所述第一区域进行加密,所述第二算子用于指示加密处理逻辑。
本申请的实施例提供了一种电子设备,包括:处理器以及用于存储处理器可执行指令的存储器;其中,所述处理器被配置为执行所述指令时实现上述方法。
本申请的实施例提供了一种处理器,该助力器被配置为执行上述方法。
本申请的实施例提供了一种芯片,该芯片可以执行上述方法。
本申请的实施例提供了一种模型保护系统,该系统的架构如图2所示,该系统包括主机处理器、存储单元和设备处理器,其中,主机处理器,用于对第二模型中的第一区域进行加密;按照所述第一区域向所述第二模型的计算图中添加第一算子,得到第一模型,所述第一算子用于指示解密处理逻辑;发送所述第一模型;存储单元,用于存储所述第一模型;设备处理器,用于从所述第一模型获得多个执行算子,所述多个执行算子中包括第一算子,所述第一算子用于指示解密处理逻辑;按照所述多个执行算子的层级关系顺序执行所述多个执行算子,包括:在执行到所述第一算子时,基于所述解密处理逻辑对所述第一算子下的第一数据进行解密获得第二数据,并基于所述第二数据执行排在所述第一算子后面的一个或多个执行算子。
本申请的实施例提供了一种非易失性计算机可读存储介质,其上存储有计算机程序指令,所述计算机程序指令被处理器执行时实现上述方法。
本申请的实施例提供了一种计算机程序产品,包括计算机可读代码,或者承载有计算机可读代码的非易失性计算机可读存储介质,当所述计算机可读代码在电子设备的处理器中运行时,所述电子设备中的处理器执行上述方法。
计算机可读存储介质可以是可以保持和存储由指令执行设备使用的指令的有形设备。计算机可读存储介质例如可以是――但不限于――电存储设备、磁存储设备、光存储设备、电磁存储设备、半导体存储设备或者上述的任意合适的组合。计算机可读存储介质的更具体的例子(非穷举的列表)包括:便携式计算机盘、硬盘、随机存取存储器(Random Access Memory,RAM)、只读存储器(Read Only Memory,ROM)、可擦式可编程只读存储器(Electrically Programmable Read-Only-Memory,EPROM或闪存)、静态随机存取存储器(Static Random-Access Memory,SRAM)、便携式压缩盘只读存储器(Compact Disc Read-Only Memory,CD-ROM)、数字多功能盘(Digital Video Disc,DVD)、记忆棒、软盘、机械编码设备、例如其上存储有指令的打孔卡或凹槽内凸起结构、以及上述的任意合适的组合。
这里所描述的计算机可读程序指令或代码可以从计算机可读存储介质下载到各个计算/处理设备,或者通过网络、例如因特网、局域网、广域网和/或无线网下载到外部计算机或外 部存储设备。网络可以包括铜传输电缆、光纤传输、无线传输、路由器、防火墙、交换机、网关计算机和/或边缘服务器。每个计算/处理设备中的网络适配卡或者网络接口从网络接收计算机可读程序指令,并转发该计算机可读程序指令,以供存储在各个计算/处理设备中的计算机可读存储介质中。
用于执行本申请操作的计算机程序指令可以是汇编指令、指令集架构(Instruction Set Architecture,ISA)指令、机器指令、机器相关指令、微代码、固件指令、状态设置数据、或者以一种或多种编程语言的任意组合编写的源代码或目标代码,所述编程语言包括面向对象的编程语言—诸如Smalltalk、C++等,以及常规的过程式编程语言—诸如“C”语言或类似的编程语言。计算机可读程序指令可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络—包括局域网(Local Area Network,LAN)或广域网(Wide Area Network,WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。在一些实施例中,通过利用计算机可读程序指令的状态信息来个性化定制电子电路,例如可编程逻辑电路、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或可编程逻辑阵列(Programmable Logic Array,PLA),该电子电路可以执行计算机可读程序指令,从而实现本申请的各个方面。
这里参照根据本申请实施例的方法、装置(系统)和计算机程序产品的流程图和/或框图描述了本申请的各个方面。应当理解,流程图和/或框图的每个方框以及流程图和/或框图中各方框的组合,都可以由计算机可读程序指令实现。
这些计算机可读程序指令可以提供给通用计算机、专用计算机或其它可编程数据处理装置的处理器,从而生产出一种机器,使得这些指令在通过计算机或其它可编程数据处理装置的处理器执行时,产生了实现流程图和/或框图中的一个或多个方框中规定的功能/动作的装置。也可以把这些计算机可读程序指令存储在计算机可读存储介质中,这些指令使得计算机、可编程数据处理装置和/或其他设备以特定方式工作,从而,存储有指令的计算机可读介质则包括一个制造品,其包括实现流程图和/或框图中的一个或多个方框中规定的功能/动作的各个方面的指令。
也可以把计算机可读程序指令加载到计算机、其它可编程数据处理装置、或其它设备上,使得在计算机、其它可编程数据处理装置或其它设备上执行一系列操作步骤,以产生计算机实现的过程,从而使得在计算机、其它可编程数据处理装置、或其它设备上执行的指令实现流程图和/或框图中的一个或多个方框中规定的功能/动作。
附图中的流程图和框图显示了根据本申请的多个实施例的装置、系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或指令的一部分,所述模块、程序段或指令的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个连续的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。
也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行相应的功能或动作的硬件(例如电路或ASIC(Application Specific Integrated  Circuit,专用集成电路))来实现,或者可以用硬件和软件的组合,如固件等来实现。
尽管在此结合各实施例对本发明进行了描述,然而,在实施所要求保护的本发明过程中,本领域技术人员通过查看所述附图、公开内容、以及所附权利要求书,可理解并实现所述公开实施例的其它变化。在权利要求中,“包括”(comprising)一词不排除其他组成部分或步骤,“一”或“一个”不排除多个的情况。单个处理器或其它单元可以实现权利要求中列举的若干项功能。相互不同的从属权利要求中记载了某些措施,但这并不表示这些措施不能组合起来产生良好的效果。
以上已经描述了本申请的各实施例,上述说明是示例性的,并非穷尽性的,并且也不限于所披露的各实施例。在不偏离所说明的各实施例的范围和精神的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。本文中所用术语的选择,旨在最好地解释各实施例的原理、实际应用或对市场中的技术的改进,或者使本技术领域的其它普通技术人员能理解本文披露的各实施例。

Claims (30)

  1. 一种模型保护方法,其特征在于,所述方法包括:
    从第一模型获得多个执行算子,所述多个执行算子中包括第一算子,所述第一算子用于指示解密处理逻辑;
    按照所述多个执行算子的层级关系顺序执行所述多个执行算子,包括:
    在执行到所述第一算子时,基于所述解密处理逻辑对所述第一算子下的第一数据进行解密获得第二数据,并基于所述第二数据执行排在所述第一算子后面的一个或多个执行算子。
  2. 根据权利要求1所述的方法,其特征在于,所述第二数据为:
    至少一个权值;或者,
    至少一个执行算子;或者,
    至少一个权值以及至少一个执行算子。
  3. 根据权利要求1或2所述的方法,其特征在于,所述基于所述解密处理逻辑对所述第一数据进行解密获得第二数据,包括:
    响应于基于密钥获取请求返回的密钥,采用所述密钥对所述第一数据进行解密获得所述第二数据。
  4. 根据权利要求1或2所述的方法,其特征在于,所述第一算子用于指示所述第一数据所在存储空间的地址,所述在执行到所述第一算子时,所述基于所述解密处理逻辑对所述第一算子下的第一数据进行解密获得第二数据,包括:
    在执行到所述地址时,基于所述解密处理逻辑对所述地址中存储的数据进行解密获得所述第二数据。
  5. 根据权利要求1至4中任意一项所述的方法,其特征在于,所述方法还包括:
    在执行完所述多个执行算子时,删除所述第一模型、所述多个执行算子以及所述第二数据。
  6. 根据权利要求1至4中任意一项所述的方法,其特征在于,所述第一模型为训练模型或者推理模型。
  7. 根据权利要求6所述的方法,其特征在于,所述方法还包括:
    在所述第一模型为推理模型的情况下,返回推理结果;
    在所述第一模型为训练模型的情况下,返回训练后的模型。
  8. 根据权利要求1至7中任意一项所述的方法,其特征在于,所述解密处理逻辑为对称式解密处理逻辑或者非对称式解密处理逻辑。
  9. 一种模型保护方法,其特征在于,所述方法包括:
    对第二模型中的第一区域进行加密;
    按照所述第一区域向所述第二模型的计算图中添加第一算子,得到第一模型,所述第一算子用于指示解密处理逻辑;
    发送所述第一模型。
  10. 根据权利要求9所述的方法,其特征在于,所述第一区域中的数据为:
    至少一个权值;或者,
    至少一个执行算子;或者,
    至少一个权值以及至少一个执行算子。
  11. 根据权利要求9或10所述的方法,其特征在于,所述方法还包括:
    响应于来自设备处理器的密钥获取请求,对所述设备处理器进行鉴权;
    在鉴权通过的情况下,向所述设备处理器返回密钥。
  12. 根据权利要求11所述的方法,其特征在于,所述密钥获取请求中包括所述第一模型的标识,以及所述设备处理器的标识,所述对所述设备处理器进行鉴权包括:
    基于所述第一模型的标识,以及所述设备处理器的标识对所述设备处理器进行鉴权。
  13. 根据权利要求9至12中任意一项所述的方法,其特征在于,所述对第二模型中的第一区域进行加密包括:
    采用第二算子对所述第一区域进行加密,所述第二算子用于指示加密处理逻辑。
  14. 一种模型保护装置,其特征在于,所述装置包括:
    获取模块,用于从第一模型获得多个执行算子,所述多个执行算子中包括第一算子,所述第一算子用于指示解密处理逻辑;
    执行模块,用于按照所述多个执行算子的层级关系顺序执行所述获取模块获取的多个执行算子;
    所述执行模块,具体用于:
    在执行到所述第一算子时,基于所述解密处理逻辑对所述第一算子下的第一数据进行解密获得第二数据,并基于所述第二数据执行排在所述第一算子后面的一个或多个执行算子。
  15. 根据权利要求14所述的装置,其特征在于,所述第二数据为:
    至少一个权值;或者,
    至少一个执行算子;或者,
    至少一个权值以及至少一个执行算子。
  16. 根据权利要求14或15所述的装置,其特征在于,所述执行模块还用于:
    响应于基于密钥获取请求返回的密钥,采用所述密钥对所述第一数据进行解密获得所述第二数据。
  17. 根据权利要求14或15所述的装置,其特征在于,所述第一算子用于指示所述第一数据所在存储空间的地址,所述在执行到所述第一算子时,所述执行模块还用于:
    在执行到所述地址时,基于所述解密处理逻辑对所述地址中存储的数据进行解密获得所述第二数据。
  18. 根据权利要求14至17中任意一项所述的装置,其特征在于,所述装置还包括:
    删除模块,用于在执行完所述多个执行算子时,删除所述第一模型、所述多个执行算子以及所述第二数据。
  19. 根据权利要求14至17中任意一项所述的装置,其特征在于,所述第一模型为训练模型或者推理模型。
  20. 根据权利要求19所述的装置,其特征在于,所述装置还包括:
    返回模块,用于在所述第一模型为推理模型的情况下,返回推理结果;以及在所述第一模型为训练模型的情况下,返回训练后的模型。
  21. 根据权利要求14至20中任意一项所述的装置,其特征在于,所述解密处理逻辑为对称式解密处理逻辑或者非对称式解密处理逻辑。
  22. 一种模型保护装置,其特征在于,所述装置包括:
    加密模块,用于对第二模型中的第一区域进行加密;
    添加模块,用于按照所述加密模块加密的第一区域向所述第二模型的计算图中添加第一 算子,得到第一模型,所述第一算子用于指示解密处理逻辑;
    发送模块,用于发送所述添加模块添加了所述第一算子后得到的所述第一模型。
  23. 根据权利要求22所述的装置,其特征在于,所述第一区域中的数据为:
    至少一个权值;或者,
    至少一个执行算子;或者,
    至少一个权值以及至少一个执行算子。
  24. 根据权利要求22或23所述的装置,其特征在于,所述装置还包括:
    鉴权模块,用于响应于来自设备处理器的密钥获取请求,对所述设备处理器进行鉴权;
    在鉴权通过的情况下,向所述设备处理器返回密钥。
  25. 根据权利要求24所述的装置,其特征在于,所述密钥获取请求中包括所述第一模型的标识,以及所述设备处理器的标识,所述鉴权模块还用于:
    基于所述第一模型的标识,以及所述设备处理器的标识对所述设备处理器进行鉴权。
  26. 根据权利要求22至25中任意一项所述的装置,其特征在于,所述加密模块还用于:
    采用第二算子对所述第一区域进行加密,所述第二算子用于指示加密处理逻辑。
  27. 一种电子设备,其特征在于,包括:
    处理器;
    用于存储处理器可执行指令的存储器;
    其中,所述处理器被配置为执行所述指令时实现权利要求1至8中任意一项所述的方法,或者实现权利要求9至13中任意一项所述的方法。
  28. 一种模型保护系统,其特征在于,所述系统包括主机处理器、存储单元和设备处理器,其中,
    主机处理器,用于对第二模型中的第一区域进行加密;按照所述第一区域向所述第二模型的计算图中添加第一算子,得到第一模型,所述第一算子用于指示解密处理逻辑;发送所述第一模型;
    存储单元,用于存储所述第一模型;
    设备处理器,用于从所述第一模型获得多个执行算子,所述多个执行算子中包括第一算子,所述第一算子用于指示解密处理逻辑;按照所述多个执行算子的层级关系顺序执行所述 多个执行算子,包括:在执行到所述第一算子时,基于所述解密处理逻辑对所述第一算子下的第一数据进行解密获得第二数据,并基于所述第二数据执行排在所述第一算子后面的一个或多个执行算子。
  29. 一种计算机可读存储介质,其上存储有计算机程序指令,其特征在于,所述计算机程序指令被处理器执行时实现权利要求1至8中任意一项所述的方法,或者实现权利要求9至13中任意一项所述的方法。
  30. 一种计算机程序产品,包括计算机可读代码,或者承载有计算机可读代码的计算机可读存储介质,当所述计算机可读代码被处理器执行时实现权利要求1至8中任意一项所述的方法,或者实现权利要求9至13中任意一项所述的方法。
PCT/CN2022/099851 2021-09-16 2022-06-20 一种模型保护方法及装置 WO2023040390A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP22868767.9A EP4339819A1 (en) 2021-09-16 2022-06-20 Model protection method and apparatus
US18/415,995 US20240154802A1 (en) 2021-09-16 2024-01-18 Model protection method and apparatus

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111086393.9A CN115828271A (zh) 2021-09-16 2021-09-16 一种模型保护方法及装置
CN202111086393.9 2021-09-16

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US18/415,995 Continuation US20240154802A1 (en) 2021-09-16 2024-01-18 Model protection method and apparatus

Publications (1)

Publication Number Publication Date
WO2023040390A1 true WO2023040390A1 (zh) 2023-03-23

Family

ID=85515039

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/099851 WO2023040390A1 (zh) 2021-09-16 2022-06-20 一种模型保护方法及装置

Country Status (4)

Country Link
US (1) US20240154802A1 (zh)
EP (1) EP4339819A1 (zh)
CN (1) CN115828271A (zh)
WO (1) WO2023040390A1 (zh)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109687952A (zh) * 2018-11-16 2019-04-26 创新奇智(重庆)科技有限公司 数据处理方法及其装置、电子装置及存储介质
US20190334716A1 (en) * 2018-04-27 2019-10-31 The University Of Akron Blockchain-empowered crowdsourced computing system
CN111428887A (zh) * 2020-03-19 2020-07-17 腾讯云计算(北京)有限责任公司 一种基于多个计算节点的模型训练控制方法、装置及系统
CN112749780A (zh) * 2019-10-31 2021-05-04 阿里巴巴集团控股有限公司 数据的处理方法、装置及设备
CN112804184A (zh) * 2019-11-13 2021-05-14 阿里巴巴集团控股有限公司 数据混淆方法、装置及设备

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190334716A1 (en) * 2018-04-27 2019-10-31 The University Of Akron Blockchain-empowered crowdsourced computing system
CN109687952A (zh) * 2018-11-16 2019-04-26 创新奇智(重庆)科技有限公司 数据处理方法及其装置、电子装置及存储介质
CN112749780A (zh) * 2019-10-31 2021-05-04 阿里巴巴集团控股有限公司 数据的处理方法、装置及设备
CN112804184A (zh) * 2019-11-13 2021-05-14 阿里巴巴集团控股有限公司 数据混淆方法、装置及设备
CN111428887A (zh) * 2020-03-19 2020-07-17 腾讯云计算(北京)有限责任公司 一种基于多个计算节点的模型训练控制方法、装置及系统

Also Published As

Publication number Publication date
EP4339819A1 (en) 2024-03-20
CN115828271A (zh) 2023-03-21
US20240154802A1 (en) 2024-05-09

Similar Documents

Publication Publication Date Title
US11196541B2 (en) Secure machine learning analytics using homomorphic encryption
EP3916604B1 (en) Method and apparatus for processing privacy data of block chain, device, storage medium and computer program product
US9020149B1 (en) Protected storage for cryptographic materials
US11546348B2 (en) Data service system
CN107612683B (zh) 一种加解密方法、装置、系统、设备和存储介质
JP2014126865A (ja) 暗号処理装置および方法
US11676011B2 (en) Private transfer learning
EP2778953A1 (en) Encoded-search database device, method for adding and deleting data for encoded search, and addition/deletion program
US20170103083A1 (en) System and method for searching distributed files across a plurality of clients
US9755832B2 (en) Password-authenticated public key encryption and decryption
KR20220092811A (ko) 암호화 데이터를 저장하는 방법 및 장치
Sharma ENHANCE DATA SECURITY IN CLOUD COMPUTING USING MACHINE LEARNING AND HYBRID CRYPTOGRAPHY TECHNIQUES.
US20220271914A1 (en) System and Method for Providing a Secure, Collaborative, and Distributed Computing Environment as well as a Repository for Secure Data Storage and Sharing
WO2023040390A1 (zh) 一种模型保护方法及装置
US10693628B2 (en) Enabling distance-based operations on data encrypted using a homomorphic encryption scheme with inefficient decryption
US20230344634A1 (en) Gesture-based authentication tokens for information security within a metaverse
CN115766173A (zh) 数据的处理方法、系统及装置
CN107111635B (zh) 内容传递方法
US11455404B2 (en) Deduplication in a trusted execution environment
Zhang et al. Secure deduplication based on Rabin fingerprinting over wireless sensing data in cloud computing
CN115843359A (zh) 计算秘密的管理
US20220351074A1 (en) Encrypting data in a machine learning model
Dwivedi et al. Cloud Security Enhancement Using Modified Enhanced Homomorphic Cryptosystem
CN115333811B (zh) 一种多关键词搜索功能的安全无信道公钥认证可搜索加密方法及相关装置
Baligodugula et al. A Comparative Study of Secure and Efficient Data Duplication Mechanisms for Cloud-Based IoT Applications

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: 22868767

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 22868767.9

Country of ref document: EP

Ref document number: 2022868767

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 2022868767

Country of ref document: EP

Effective date: 20231214

NENP Non-entry into the national phase

Ref country code: DE