Model operation method, electronic equipment and readable storage medium
By integrating an encryption and decryption module with a key register in the neural network processor, the method addresses NPU limitations in isolated environments, ensuring secure and efficient model operation with unrestricted NPU usage and data protection.
Patent Information
- Application Number
- CN202411318012.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-20
- Publication Date
- 2025-01-03
AI Technical Summary
Large models running in isolated execution environments, such as TEE or virtualization, face limitations in using neural network processors (NPUs) due to conflicts or inability to accelerate model operations, leading to potential data leakage and tampering risks.
Implement an encryption and decryption module within the neural network processor, coupled with a key register, to securely manage ciphertext and plaintext data, allowing unrestricted NPU usage by encrypting and decrypting data as needed during model operation.
Ensures secure model operation by protecting data integrity while enabling full NPU utilization, without the need for separate secure memory, maintaining performance and scalability, and simplifying software development.
Smart Images

Figure CN119249448A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of data processing technology, and specifically relates to a model operation method, an electronic device and a readable storage medium. Background Art
[0002] One of the protection targets for the protection of large models on the end is model operation. Usually, large models on the end are run in at least one of the Android system and the kernel system. Once the system is rooted, the model files will be leaked, so there is a risk of user data leakage or tampering.
[0003] In order to solve this problem, the measure taken is to put the model into an isolated execution environment of a non-Android system and a non-kernel system to run, so as to ensure that user data will not be leaked or tampered with during the operation of the model. For example, the mainstream isolated execution environment is a trusted execution environment (TEE) or virtualization. Among them, when the model runs in TEE, the software in the TEE cannot call the neural network processor (NPU), making it impossible to use the NPU to accelerate the operation of the model file; when the model runs in virtualization, concurrent access to the secure NPU and the non-secure NPU will conflict, resulting in the inability to use the NPU in parallel.
[0004] It can be seen that in the prior art, when the model runs in an isolated execution environment, there is a problem of limited use of the NPU. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a model running method that can solve the problem in the prior art that when the model runs in an isolated execution environment, the use of the NPU is limited.
[0006] In a first aspect, an embodiment of the present application provides a model operation method, which is applied to an electronic device, wherein the electronic device includes: a memory and a neural network processor for data transmission, the neural network processor includes an encryption and decryption module and a key register, and data is transmitted between the encryption and decryption module and the key register; the method includes: when a target model is deployed on the electronic device, loading the file of the target model into the memory; when the neural network processor reads ciphertext data in the file of the target model, the encryption and decryption module reads the decryption key in the key register; the encryption and decryption module decrypts the ciphertext data according to the decryption key; when the neural network processor is about to write plaintext data to the file of the target model, the encryption and decryption module reads the encryption key in the key register; the encryption and decryption module encrypts the plaintext data according to the encryption key.
[0007] In a second aspect, an embodiment of the present application provides an electronic device, comprising: a memory and a neural network processor for data transmission, the neural network processor comprising an encryption and decryption module and a key register, data is transmitted between the encryption and decryption module and the key register; a loading module, for loading a file of a target model to the memory when a target model is deployed on the electronic device; the encryption and decryption module, for reading a decryption key in the key register when the neural network processor reads ciphertext data in the file of the target model; decrypting the ciphertext data according to the decryption key; and reading an encryption key in the key register when the neural network processor is about to write plaintext data to the file of the target model; and encrypting the plaintext data according to the encryption key.
[0008] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps described in the first aspect are implemented.
[0009] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
[0010] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.
[0011] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the first aspect.
[0012] In an embodiment of the present application, the target model is deployed to an electronic device, and the file of the target model is loaded into a memory. When the neural network processor reads the ciphertext data in the file of the target model from the memory, the encryption and decryption module in the neural network processor reads the decryption key from the key register to decrypt the ciphertext data into plaintext data, so that the target model can be run on the neural network processor; if during operation, the target model generates data, and the data generated here is plaintext data, then the encryption and decryption module in the neural network processor reads the encryption key from the key register, encrypts the plaintext data into ciphertext data, and then stores it in the memory. It can be seen that the model operation method provided by the embodiment of the present application, on the one hand, the data in the model file in the memory is encrypted and protected, and on the other hand, the data in the model file read by the neural network processor is the plaintext data obtained after decryption, thereby ensuring the safe operation of the model on the basis of ensuring that the use of the neural network processor is unrestricted, and effectively preventing user data from being leaked and tampered with. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 is a flow chart of a model operation method of some embodiments of the present application;
[0014] Figure 2 is a schematic diagram of the structure of a neural network processor in some embodiments of the present application;
[0015] Figure 3 is a block diagram of an electronic device of some embodiments of the present application;
[0016] Figure 4 Schematic diagram of the hardware structure of the electronic device of some embodiments of the present application;
[0017] Figure 5 It is a schematic diagram of the hardware structure of an electronic device of some embodiments of the present application. DETAILED DESCRIPTION
[0018] The following will be combined with the drawings of the embodiments of the present application to clearly describe the technical solutions of the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present application belong to the scope of protection of this application.
[0019] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally a class, and the number of objects is not limited. For example, the target object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated before and after are in an "or" relationship.
[0020] The model operation method provided in the embodiment of the present application is described in detail below through specific embodiments and their application scenarios in conjunction with the accompanying drawings.
[0021] like Figure 1 As shown, a flow chart of a model operation method according to an embodiment of the present application is shown, and the method is applied to an electronic device as an example, and the electronic device includes:
[0022] Memory and neural network processor for data transfer. Figure 2 As shown, the neural network processor 201 includes an encryption and decryption module 202 and a key slot register 203, and data is transmitted between the encryption and decryption module 202 and the key slot register 203.
[0023] Optionally, the memory is a double data rate synchronous dynamic random access memory (DDR SDRAM); optionally, the memory is a static random access memory (SRAM).
[0024] Optionally, the encryption and decryption module is an inline crypto engine (ICE); the key register is used to store an encryption key required by the ICE for encrypting data and a decryption key required by the ICE for decrypting data.
[0025] like Figure 2As shown, the working process of the neural network processor 201 is as follows: the NPU modules 204 in the neural network processor 201 are the modules where the core of the NPU is located. During the working process, if the NPU modules 204 need to read and write data, the memory control module 205 uses the bus protocol (Advanced eXtensible interface, AXI) interface 206 to read and write data from the external memory, so that the data will be cached in the cache module 207.
[0026] Based on this, the method includes:
[0027] Step 110: When the target model is deployed on the electronic device, the file of the target model is loaded into the memory.
[0028] In this step, the target model is deployed on the electronic device, and the file of the target model is loaded into the memory.
[0029] Step 120: When the neural network processor reads the ciphertext data in the file of the target model, the encryption and decryption module reads the decryption key in the key register.
[0030] When the target model is deployed to an electronic device, the file of the target model is loaded into a memory. Since the target model is an encrypted model, the data in the file of the target model loaded into the memory is ciphertext data. Therefore, the data in the file of the target model read by the neural network processor is ciphertext data.
[0031] It should be noted that when the server generates the target model, based on the pre-set operation protection requirements for the target model, the server directly generates an encrypted file of the target model, and the data in the encrypted file is encrypted data.
[0032] Optionally, the electronic device in this embodiment is a user end, and the user end can identify the need to perform operation protection on the target model based on the compilation configuration of the target model, that is, identify that the target model is an encrypted model.
[0033] In this step, refer to Figure 2 When the neural network processor 201 reads data in the target model file from the external memory through the memory controller module 205, the read data is ciphertext data, so the encryption and decryption module 202 reads the decryption key from the key register 203.
[0034] Step 130: The encryption and decryption module decrypts the ciphertext data according to the decryption key.
[0035] In this step, the encryption and decryption module decrypts the ciphertext data based on the decryption key to obtain the plaintext data.
[0036] Step 140: When the neural network processor is about to write plaintext data to the target model file, the encryption and decryption module reads the encryption key in the key register.
[0037] In this step, the target model runs on the neural network processor. If data is generated, the neural network processor needs to write the generated data into the model file in the memory. The generated data is ordinary data, that is, plaintext data. Therefore, the encryption and decryption module reads the encryption key from the key register.
[0038] For example, when the target model runs on a neural network processor, the user will input some instructions, such as language instructions and text instructions, by operating on the electronic device. The model will generate text results to reply to the user based on the instructions entered by the user. These text results are the generated data.
[0039] Step 150: The encryption and decryption module encrypts the plaintext data according to the encryption key.
[0040] In this step, the encryption and decryption module encrypts the plaintext data to be written into the memory based on the encryption key to obtain ciphertext data, and then writes the ciphertext data into the external memory.
[0041] like Figure 2 As shown, when the neural network processor 201 reads and writes data from the external memory, the external memory is accessed through the memory controller module 205 from the AXI interface 206; at the same time, the encryption and decryption module 202 performs corresponding decryption operations or encryption operations on the read or written data. Based on this, the ciphertext data in the model file in the memory is decrypted into plaintext data, so that the target model can run normally on the neural network processor; further, the plaintext data generated during the operation of the target model is encrypted into ciphertext data and stored in the memory. The key required for the encryption and decryption operation is stored in the key register.
[0042] In an embodiment of the present application, the target model is deployed to an electronic device, and the file of the target model is loaded into a memory. When the neural network processor reads the ciphertext data in the file of the target model from the memory, the encryption and decryption module in the neural network processor reads the decryption key from the key register to decrypt the ciphertext data into plaintext data, so that the target model can be run on the neural network processor; if during operation, the target model generates data, and the data generated here is plaintext data, then the encryption and decryption module in the neural network processor reads the encryption key from the key register, encrypts the plaintext data into ciphertext data, and then stores it in the memory. It can be seen that the model operation method provided by the embodiment of the present application, on the one hand, the data in the model file in the memory is encrypted and protected, and on the other hand, the data in the model file read by the neural network processor is the plaintext data obtained after decryption, thereby ensuring the safe operation of the model on the basis of ensuring that the use of the neural network processor is unrestricted, and effectively preventing user data from being leaked and tampered with.
[0043] In the process of the model running method of another embodiment of the present application, the electronic device also includes a central processor; when the target model is deployed on the electronic device, the method also includes:
[0044] Step A1: The CPU obtains the encryption key and the decryption key according to the compilation information of the target model.
[0045] Optionally, when the server generates an encrypted file of the target model, the encryption key used and the decryption key corresponding to the encryption key can be deployed on the electronic device together with the model file as part of the compilation information.
[0046] Optionally, the corresponding encryption key and decryption key are generated by a preset method; optionally, the corresponding encryption key and decryption key are generated by a public key infrastructure (PKI) system.
[0047] Step A2: The CPU stores the encryption key and the decryption key into the key register.
[0048] In this step, combine Figure 2 The encryption key and decryption key are configured in the key register 203 by an external central processing unit (CPU) through an advanced high-performance bus (AHB) interface 208 in the neural network processor 201.
[0049] In this embodiment, based on the encryption key and decryption key in the compilation information of the target model deployed on the electronic device, the central processing unit completes the relevant configuration in the key register to ensure that the neural network processor performs encryption and decryption operations on the file data of the target model.
[0050] In the model running method of another embodiment of the present application, the encryption key and the decryption key are the same.
[0051] In this embodiment, based on a symmetric cryptographic system, the same encryption key and decryption key are used to perform encryption and decryption operations.
[0052] In the model running method of another embodiment of the present application, the encryption key and the decryption key are different, and there is a corresponding relationship between the encryption key and the decryption key.
[0053] In this embodiment, based on an asymmetric cryptographic system, encryption and decryption operations are performed using different encryption keys and decryption keys that have a specific corresponding relationship.
[0054] In a model operation method of another embodiment of the present application, there are multiple target models, one target model corresponds to one key group, and one key group includes one encryption key and one decryption key.
[0055] In this embodiment, when multiple target models are deployed on an electronic device, the neural network processor uses different encryption and decryption keys for different target models to perform encryption and decryption operations on the file data of each target model, thereby ensuring that the operations of different target models are isolated from each other and further improving the security of model operation.
[0056] In summary, the present application adds an encryption and decryption module and a corresponding key register to the neural network processor, so that the neural network processor can directly process the ciphertext data read from the memory and the plaintext data to be written into the memory. Based on this, there is no need to store the ciphertext data files and the plaintext data files separately, and there is no need to consider the limitations of the isolated operating environment. Even if the ciphertext data files are obtained by malicious programs, they cannot obtain useful data because they cannot be decrypted. It can be seen that, first, the present application does not need to reserve independent secure memory, and only uses ordinary memory, so that the memory can be reused and has good scalability; second, the neural network processor with higher security of the present application is compared with the ordinary neural network processor, only during the model operation, the encryption and decryption operations of the model file data are added, and the other modules are consistent, and the performance loss is small; third, there is no need to consider developing software in an isolated environment, making the use of software more convenient.
[0057] The model operation method provided in the embodiment of the present application can be executed by an electronic device. In the embodiment of the present application, the electronic device provided in the embodiment of the present application is described by taking the execution of the model operation method by an electronic device as an example.
[0058] Figure 3 A block diagram of an electronic device according to an embodiment of the present application is shown, and the electronic device includes:
[0059] A memory 10 and a neural network processor 20 for data transmission, wherein the neural network processor 20 includes an encryption and decryption module 30 and a key register 40, and data is transmitted between the encryption and decryption module 30 and the key register 40;
[0060] A loading module 50, used to load the target model file to the memory 10 when the target model is deployed on the electronic device;
[0061] The encryption and decryption module 30 is used to read the decryption key in the key register 40 when the neural network processor 20 reads the ciphertext data in the file of the target model; decrypt the ciphertext data according to the decryption key; and read the encryption key in the key register 40 when the neural network processor 20 is about to write plaintext data to the file of the target model; and encrypt the plaintext data according to the encryption key.
[0062] In an embodiment of the present application, the target model is deployed to an electronic device, and the file of the target model is loaded into a memory. When the neural network processor reads the ciphertext data in the file of the target model from the memory, the encryption and decryption module in the neural network processor reads the decryption key from the key register to decrypt the ciphertext data into plaintext data, so that the target model can be run on the neural network processor; if during operation, the target model generates data, and the data generated here is plaintext data, then the encryption and decryption module in the neural network processor reads the encryption key from the key register, encrypts the plaintext data into ciphertext data, and then stores it in the memory. It can be seen that the model operation method provided by the embodiment of the present application, on the one hand, the data in the model file in the memory is encrypted and protected, and on the other hand, the data in the model file read by the neural network processor is the plaintext data obtained after decryption, thereby ensuring the safe operation of the model on the basis of ensuring that the use of the neural network processor is unrestricted, and effectively preventing user data from being leaked and tampered with.
[0063] Optionally, the electronic device further includes:
[0064] The central processing unit is used to obtain the encryption key and the decryption key according to the compilation information of the target model; and store the encryption key and the decryption key in the key register 40.
[0065] Optionally, the encryption key and decryption key are the same.
[0066] Optionally, the encryption key and the decryption key are different, and there is a corresponding relationship between the encryption key and the decryption key.
[0067] Optionally, there are multiple target models, one target model corresponds to one key group, and one key group includes one encryption key and one decryption key.
[0068] The electronic device in the embodiment of the present application may also be a component in the electronic device, such as an integrated circuit or a chip. The electronic device may be a terminal, or may be other devices other than a terminal. Exemplarily, the electronic device may be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and may also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0069] The electronic device of the embodiment of the present application may be an electronic device having an action system. The action system may be an Android action system, an iOS action system, or other possible action systems, which are not specifically limited in the embodiment of the present application.
[0070] The electronic device provided in the embodiment of the present application can implement each process implemented in the above method embodiment and achieve the same technical effect. To avoid repetition, it will not be described here.
[0071] Alternatively, if Figure 4 As shown, an embodiment of the present application also provides an electronic device 100, including a processor 101, a memory 102, and a program or instruction stored in the memory 102 and executable on the processor 101. When the program or instruction is executed by the processor 101, each step of any of the above-mentioned model operation method embodiments is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0072] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.
[0073] Figure 5 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.
[0074] The electronic device 1000 includes but is not limited to: a radio frequency unit 1001, a network module 1002, an audio output unit 1003, an input unit 1004, a sensor 1005, a display unit 1006, a user input unit 1007, an interface unit 1008, a memory 1009, a processor 1010, a camera 1011 and other components.
[0075] Those skilled in the art will appreciate that the electronic device 1000 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 1010 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Figure 5 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.
[0076] Among them, processor 1010 includes a neural network processor and a central processing unit, the neural network processor includes an encryption and decryption module and a key register, and data is transmitted between the encryption and decryption module and the key register; the central processing unit is used to load the file of the target model to the memory when the target model is deployed on the electronic device; the neural network processor is used to read the decryption key in the key register when the encryption and decryption module reads the ciphertext data in the file of the target model; the encryption and decryption module decrypts the ciphertext data according to the decryption key; when plaintext data is about to be written to the file of the target model, the encryption and decryption module reads the encryption key in the key register; the encryption and decryption module encrypts the plaintext data according to the encryption key.
[0077] In an embodiment of the present application, the target model is deployed to an electronic device, and the file of the target model is loaded into a memory. When the neural network processor reads the ciphertext data in the file of the target model from the memory, the encryption and decryption module in the neural network processor reads the decryption key from the key register to decrypt the ciphertext data into plaintext data, so that the target model can be run on the neural network processor; if during operation, the target model generates data, and the data generated here is plaintext data, then the encryption and decryption module in the neural network processor reads the encryption key from the key register, encrypts the plaintext data into ciphertext data, and then stores it in the memory. It can be seen that the model operation method provided by the embodiment of the present application, on the one hand, the data in the model file in the memory is encrypted and protected, and on the other hand, the data in the model file read by the neural network processor is the plaintext data obtained after decryption, thereby ensuring the safe operation of the model on the basis of ensuring that the use of the neural network processor is unrestricted, and effectively preventing user data from being leaked and tampered with.
[0078] The central processing unit is used to obtain an encryption key and a decryption key according to the compilation information of the target model; and store the encryption key and the decryption key in the key register.
[0079] Optionally, the encryption key and the decryption key are the same.
[0080] Optionally, the encryption key and the decryption key are different, and there is a corresponding relationship between the encryption key and the decryption key.
[0081] Optionally, there are multiple target models, one target model corresponds to one key group, and one key group includes one encryption key and one decryption key.
[0082] In summary, the present application adds an encryption and decryption module and a corresponding key register to the neural network processor, so that the neural network processor can directly process the ciphertext data read from the memory and the plaintext data to be written into the memory. Based on this, there is no need to store the ciphertext data files and the plaintext data files separately, and there is no need to consider the limitations of the isolated operating environment. Even if the ciphertext data files are obtained by malicious programs, they cannot obtain useful data because they cannot be decrypted. It can be seen that, first, the present application does not need to reserve independent secure memory, and only uses ordinary memory, so that the memory can be reused and has good scalability; second, the neural network processor with higher security of the present application is compared with the ordinary neural network processor, only during the model operation, the encryption and decryption operations of the model file data are added, and the other modules are consistent, and the performance loss is small; third, there is no need to consider developing software in an isolated environment, making the use of software more convenient.
[0083] It should be understood that in the embodiment of the present application, the input unit 1004 may include a graphics processor (Graphics Processing Unit, GPU) 10041 and a microphone 10042, and the graphics processor 10041 processes the image data of the static picture or video image obtained by the image capture device (such as a camera) in the video image capture mode or the image capture mode. The display unit 1006 may include a display panel 10061, and the display panel 10061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 1007 includes a touch panel 10071 and at least one of other input devices 10072. The touch panel 10071 is also called a touch screen. The touch panel 10071 may include two parts: a touch detection device and a touch controller. Other input devices 10072 may include, but are not limited to, a physical keyboard, a function key (such as a volume control button, a switch button, etc.), a trackball, a mouse, and an action rod, which will not be repeated here. The memory 1009 can be used to store software programs and various data, including but not limited to applications and action systems. The processor 1010 may integrate an application processor and a modem processor, wherein the application processor mainly processes the action system, user pages and application programs, etc., and the modem processor mainly processes wireless communications. It is understandable that the modem processor may not be integrated into the processor 1010.
[0084] The memory 1009 can be used to store software programs and various data. The memory 1009 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 1009 may include a volatile memory or a non-volatile memory, or the memory 1009 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 1009 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
[0085] The processor 1010 may include one or more processing units; optionally, the processor 1010 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 1010.
[0086] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned model operation method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0087] The processor is the processor in the electronic device in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0088] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned model operation method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0089] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0090] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned model operation method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0091] It should be noted that, in this article, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or electronic device. In the absence of further restrictions, an element defined by the sentence "comprises one..." does not exclude the presence of other identical elements in the process, method, article or electronic device including the element. In addition, it should be pointed out that the scope of the method and electronic device in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0092] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods of each embodiment of the present application.
[0093] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A model operation method, characterized in that: Applicable to electronic equipment, the electronic equipment comprising: A memory and a neural network processor for data transmission, wherein the neural network processor includes an encryption and decryption module and a key register, and data is transmitted between the encryption and decryption module and the key register; The method comprises: In case of deploying the target model on the electronic device, loading the file of the target model into the memory; In the case where the neural network processor reads the ciphertext data in the file of the target model, the encryption and decryption module reads the decryption key in the key register; The encryption and decryption module decrypts the ciphertext data according to the decryption key; In the case where the neural network processor is about to write plaintext data to the file of the target model, the encryption and decryption module reads the encryption key in the key register; The encryption and decryption module encrypts the plaintext data according to the encryption key.
2. The method according to claim 1, characterized in that: The electronic device further includes a central processor; in the case where the target model is deployed on the electronic device, the method further includes: The central processing unit obtains an encryption key and a decryption key according to the compilation information of the target model; The central processing unit stores the encryption key and the decryption key in the key register.
3. The method according to claim 1, characterized in that: The encryption key and the decryption key are the same.
4. The method according to claim 1, characterized in that The encryption key and the decryption key are different, and there is a corresponding relationship between the encryption key and the decryption key.
5. The method according to claim 1, characterized in that: There are multiple target models, one target model corresponds to one key group, and one key group includes one encryption key and one decryption key.
6. An electronic device, characterized in that: The electronic device comprises: A memory and a neural network processor for data transmission, wherein the neural network processor includes an encryption and decryption module and a key register, and data is transmitted between the encryption and decryption module and the key register; A loading module, used for loading a file of the target model into the memory when the target model is deployed on the electronic device; The encryption and decryption module is used to read the decryption key in the key register when the neural network processor reads the ciphertext data in the file of the target model; decrypt the ciphertext data according to the decryption key; and read the encryption key in the key register when the neural network processor is about to write plaintext data to the file of the target model; and encrypt the plaintext data according to the encryption key.
7. The device according to claim 6, characterized in that The electronic device further comprises: The central processing unit is used to obtain an encryption key and a decryption key according to the compilation information of the target model; and store the encryption key and the decryption key in the key register.
8. The device according to claim 6, characterized in that The encryption key and the decryption key are the same.
9. The device according to claim 6, characterized in that The encryption key and the decryption key are different, and there is a corresponding relationship between the encryption key and the decryption key.
10. The device according to claim 6, characterized in that There are multiple target models, one target model corresponds to one key group, and one key group includes one encryption key and one decryption key.
11. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the model running method according to any one of claims 1 to 5 are implemented.
12. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the model operation method according to any one of claims 1 to 5 are implemented.