Game processing method and device, equipment and storage medium
By converting the resource data of game AI rivals into tensor data and inputting the inference model in ONNX format, localized real-time inference is realized, and the problems of AI interaction delay and network dependence in game development are solved, AI response speed and intelligence are improved, cost is reduced, and game compatibility and privacy security are enhanced.
Patent Information
- Application Number
- CN202510787839.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-11
- Publication Date
- 2025-08-29
AI Technical Summary
In the development of existing games, AI interaction delay is large, and relying on external services leads to high network connection dependence, latency problems, privacy and security risks, high operating costs, difficult platform adaptation and poor experience.
Convert the resource data of AI opponents in the game into tensor data, input the inference model in ONNX format trained based on historical data, realize localized real-time inference and output decision tensors to control the AI behavior of opponents, and reduce the cost of dependence on the network through cross-platform adaptation and data localization processing.
Improve AI response speed and behavioral intelligence, reduce game interaction latency, enhance game compatibility and privacy security, reduce network dependence and operation costs, and provide a rich gaming experience.
Smart Images

Figure CN120562514A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of game development technology, and in particular to a game processing method, apparatus, device, and storage medium. Background Art
[0002] At present, with the rapid development of artificial intelligence technology, neural network models have been widely used in many fields such as image recognition, natural language processing, speech synthesis, etc., especially in the field of game development.
[0003] In the existing technology, game developers usually need to rely on external services or application programming interfaces (APIs) to implement artificial intelligence (AI) functions. In this way, there is a technical problem of large game interaction delays. Summary of the Invention
[0004] In view of the above problems, embodiments of the present invention provide a game processing method, apparatus, device, and storage medium for solving the technical problem of high game interaction delay existing in the prior art.
[0005] According to one aspect of an embodiment of the present invention, a game processing method is provided, the method comprising:
[0006] Obtaining first tensor data indicated by first resource data corresponding to the AI opponent to be controlled in the game;
[0007] Inputting the first tensor data into a preset inference model to obtain second tensor data corresponding to target decision data corresponding to the AI opponent to be controlled, wherein the inference model is a model in an open neural network exchange format trained based on resource data of at least one AI opponent in the game and optimal decision data corresponding to the resource data of the at least one AI opponent;
[0008] The AI opponent to be controlled is controlled according to the second tensor data.
[0009] According to another aspect of an embodiment of the present invention, there is provided a game processing device, characterized in that the device comprises:
[0010] An acquisition module, configured to acquire first tensor data indicated by first resource data corresponding to an AI opponent to be controlled in the game;
[0011] a processing module, configured to input the first tensor data into a preset inference model to obtain second tensor data corresponding to target decision data corresponding to the AI opponent to be controlled, wherein the inference model is a model in an open neural network exchange format trained based on resource data of at least one AI opponent in the game and optimal decision data corresponding to the resource data of the at least one AI opponent;
[0012] A control module is used to control the AI opponent to be controlled according to the second tensor data.
[0013] According to another aspect of an embodiment of the present invention, there is provided an electronic device, including:
[0014] A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus;
[0015] The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute the operation of the above-mentioned game processing method.
[0016] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, wherein the storage medium stores at least one executable instruction, and the executable instruction enables an electronic device / game processing device to perform operations such as the above-mentioned game processing method.
[0017] According to another aspect of an embodiment of the present invention, a computer program product is provided, characterized in that it includes a computer program, and when the computer program is executed by a processor, the game processing device / electronic device executes the above-mentioned game processing method.
[0018] The embodiment of the present invention converts the resource data of the AI opponent in the game into a first tensor data input into an ONNX format inference model trained based on historical data, realizes localized real-time inference and outputs a decision tensor to control the opponent's AI behavior, which can improve the AI response speed and behavioral intelligence, reduce the operating cost of network dependence, and reduce the game interaction delay. At the same time, it enhances game compatibility and privacy security through cross-platform adaptation and data localization processing.
[0019] The above description is only an overview of the technical solutions of the embodiments of the present invention. In order to more clearly understand the technical means of the embodiments of the present invention, they can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the embodiments of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are specifically listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The accompanying drawings are only used to illustrate the embodiments and are not to be considered as limiting the present invention. In addition, the same reference symbols are used to represent the same components throughout the drawings. In the drawings:
[0021] Figure 1 A schematic diagram showing the structure of the game processing system provided by the present invention is shown;
[0022] Figure 2 A flowchart showing a first embodiment of a game processing method provided by the present invention is shown;
[0023] Figure 3 A flowchart showing a second embodiment of the game processing method provided by the present invention is shown;
[0024] Figure 4 A flowchart showing a third embodiment of the game processing method provided by the present invention is shown;
[0025] Figure 5 A schematic structural diagram of an embodiment of a game processing device provided by the present invention is shown;
[0026] Figure 6 A schematic structural diagram of an embodiment of an electronic device provided by the present invention is shown. DETAILED DESCRIPTION
[0027] The exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be limited to the embodiments set forth herein.
[0028] With the rapid development of artificial intelligence (AI), neural network models have been widely used in a variety of fields, including image recognition, natural language processing, and speech synthesis. However, in the field of game development, integrating and running neural network models, especially in 3D games, still faces many technical challenges.
[0029] In existing technologies, game developers usually need to rely on external services or APIs to implement AI functions. This approach has the following major drawbacks:
[0030] 1. Dependence on network connection: Relying on cloud services means that the game requires a stable network connection, which may cause features to be unavailable in certain scenarios (such as mobile devices or areas with unstable networks);
[0031] 2. Latency issue: Network requests take time to complete, which cannot meet the low latency requirements of real-time interactive games.
[0032] 3. Privacy and security risks: Sending user data to external servers may cause privacy issues;
[0033] 4. High operating costs: Continuous API calls will incur considerable costs, especially in large-scale user scenarios;
[0034] 5. Difficulty in platform adaptation: Different platforms (personal computers (PCs), mobile devices, game consoles, etc.) have different ways of integrating AI models, and developers need to adapt specifically for each platform.
[0035] 6. Poor user experience: Existing game engines typically use traditional decision tree or state machine methods for AI implementation, lacking effective support for modern neural network technology. This results in AI characters in the game having a single behavior pattern and insufficiently intelligent environmental responses, failing to provide players with an immersive gaming experience.
[0036] Based on the above technical problems, the technical concept of the present invention is as follows: the inventors realized that the root cause of the slow game timeliness is the delay in the decision-making process of the AI opponent, and the existing methods failed to efficiently process the relationship between resource data and decision-making. In view of the advantages of the open neural network exchange format model in data processing and model deployment, combined with past research experience on the relationship between the resource data and optimal decision data of AI opponents in the game, by converting the resource data of the AI opponent into tensor data and inputting it into a trained inference model, the decision data can be quickly output. Therefore, this solution was conceived to optimize the decision-making process of the AI opponent and improve the timeliness of the game.
[0037] The technical solution of the present invention is described in detail below through specific embodiments. The implementation subject of the present invention is a vehicle, specifically, an electronic device such as a controller in the vehicle.
[0038] It should be noted that the following specific embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0039] Figure 1 FIG. 4 shows a schematic diagram of the structure of the game processing system provided by the present invention. Figure 1 As shown, the schematic diagram includes: model loader (English: Model Loader), tensor processing system (English: Tensor System), execution engine (English: Execution Engine), and engine inheritance layer (English: Engine Integration Layer).
[0040] The model loader is responsible for importing and parsing pre-trained neural network models, supporting the import of Open Neural Network Exchange (ONNX) models. It generates an executable runtime model by parsing files, mapping operators, and optimizing models. The tensor processing system processes the input and output data of the neural network, namely, it processes multidimensional array data of the neural network, supporting data type conversion, shape operations, element-level operations, and conversion between game resources (such as textures and audio) and tensors. The execution engine schedules and executes neural network operations on different hardware backends, namely, it supports the CPU backend (CPU backend), GPU compute shader backend (GPU compute shader backend), GPU pixel shader backend (GPU pixel shader backend), and hardware accelerated backend (Hardware Accelerated Backend). It selects the optimal execution path based on the device hardware characteristics and uses asynchronous execution to avoid blocking the main game thread. The engine integration layer connects the system with the 3D engine's rendering loop and resource management system, namely, it connects to the 3D engine's main loop and resource management system to implement model loading, worker creation, and inference task updates.
[0041] Based on the above game processing system, the contents in the embodiment of the present invention are described in detail.
[0042] Figure 2 FIG. 1 is a flow chart showing a first embodiment of the game processing method provided by the present invention. Figure 2 As shown, the method includes the following steps:
[0043] Step 21: Obtain first tensor data indicated by first resource data corresponding to the AI opponent to be controlled in the game;
[0044] In this step, in the control scenario of the game AI, first resource data of the AI opponent to be controlled is obtained, and the first resource data is mapped into first tensor data to meet the input of the following reasoning model.
[0045] Among them, the first resource data can be in-game status data, such as the attributes of the AI opponent (such as health points, attack power), environmental information (such as map coordinates, enemy unit positions), action history (such as the types of the last three attacks), etc.; it can also be sensor data (if the AI opponent is based on visual / auditory input (such as game screen pixels, sound effect spectrum)), etc.
[0046] Correspondingly, the acquisition method can be: taking the in-game status data as an example, it is generally stored in a structured manner, and the component properties are obtained through the game engine API (such as Unity's GameObject.GetComponent(), Unreal's GetActorComponent()); taking sensor data as an example, it is generally stored in an unstructured manner, and the image is captured using a rendering texture (such as Unity's RenderTexture), or spectrum data is obtained through the audio system (such as the FMOD audio interface).
[0047] Optionally, the mapping to the first tensor data may be implemented by using a deep learning framework tool for conversion.
[0048] Among them, tensor data types support: including float, int, bool and other data types.
[0049] Step 22: Input the first tensor data into a preset inference model to obtain second tensor data corresponding to the target decision data corresponding to the AI opponent to be controlled;
[0050] The inference model is a model in an open neural network exchange format obtained by training based on resource data of at least one AI opponent in the game and optimal decision data corresponding to the resource data of at least one AI opponent;
[0051] In this step, after the first resource data of the AI opponent to be controlled is converted into the first tensor data, it is used as the input of the inference model, and then the inference model is executed using a game engine such as ONNX Runtime to obtain second tensor data. The second tensor data can be the second tensor data corresponding to the target decision data for controlling the AI to be controlled.
[0052] Step 23: Control the AI opponent to be controlled according to the second tensor data.
[0053] Optionally, step 23 may include the following steps:
[0054] Step 1: Parse the second tensor data into target decision data for the AI opponent to be controlled;
[0055] In this implementation, the second tensor data is the original numerical result output by the inference model, which can be in the following two forms: one is classification output: representing the probability distribution of various possible actions (e.g., [0.1, 0.05, 0.7, 0.05, 0.01, 0.01, 0.01, 0.02], corresponding to actions: [move forward, move backward, attack, defend, skill 1, skill 2, jump, standby], then the maximum probability is 0.7 corresponding to the attack); the other is regression output: directly representing continuous parameters (e.g., [0.8, 0.2] represents the moving direction vector (x=0.8, y=0.2)).
[0056] Then, the probability distribution is converted into specific actions (such as attacking), the normalized values corresponding to the regression output are restored to game-usable parameters (such as restoring continuous parameters based on the game map size), and game-specific logic is added (such as skill cooldown and resource consumption), thus generating target decision data for the AI opponent to be controlled.
[0057] Step 2: Control the AI opponent to be controlled and apply the target decision data.
[0058] In this implementation, the target decision data is a parsed structured instruction, which usually includes: discrete action types: such as attack, movement, and skill release; continuous parameters: such as movement direction vector and skill release intensity; auxiliary information: such as action priority, confidence, and target object; then, according to the decision type, the corresponding actuator is called, thereby calling system APIs such as physics, animation, and special effects to achieve control of the AI opponent to be controlled.
[0059] The game processing method provided by the embodiment of the present invention obtains the first tensor data indicated by the first resource data corresponding to the AI opponent to be controlled in the game; inputs the first tensor data into a preset inference model to obtain the second tensor data corresponding to the target decision data corresponding to the AI opponent to be controlled, and the inference model is a model in an open neural network exchange format trained based on the resource data of at least one AI opponent in the game and the optimal decision data corresponding to the resource data of at least one AI opponent; and controls the AI opponent to be controlled according to the second tensor data. In this technical solution, by converting the resource data of the AI opponent in the game into the first tensor data and inputting it into the inference model in ONNX format trained based on historical data, localized real-time inference is achieved and the decision tensor is output to control the opponent's AI behavior. This can improve the AI response speed and behavioral intelligence, reduce the operating cost of network dependence, reduce the game interaction delay, and enhance the game compatibility and privacy security through cross-platform adaptation and data localization processing.
[0060] Based on the above embodiments, Figure 3 FIG. 4 shows a flow chart of a second embodiment of the game processing method provided by the present invention. Figure 3As shown, before step 22, the method further includes the following steps:
[0061] Step 31: Obtain resource data of at least one AI opponent in the game and optimal decision data corresponding to the resource data of at least one AI opponent;
[0062] In this step, during the historical game process, the resource data of the AI opponent and the corresponding optimal decision data can be recorded simultaneously while the game is running.
[0063] Among them, the optimal decision data corresponding to the resource data of the AI opponent can be the theoretically best behavior under a specific state in the game.
[0064] Step 32: Training a preset neural network model based on input tensor data corresponding to resource data of at least one AI opponent and output tensor data corresponding to at least one optimal decision data to obtain an inference model;
[0065] In this step, the resource data of at least one AI opponent (such as health, position, enemy distance, etc.) is converted into a numerical tensor acceptable to the neural network model, recorded as input tensor data; and at least one optimal decision data (such as attack, dodge, etc.) is converted into a numerical tensor that can be output by the neural network model, recorded as output tensor data.
[0066] Then, the input tensor data is input, the neural network model predicts the action probability distribution; the predicted action is compared with the output tensor data; and the model parameters are updated by gradient descent to minimize the prediction error.
[0067] Optionally, graph optimization techniques, such as operator fusion and constant folding, can be used to optimize the model.
[0068] Step 33: Convert the inference model into the open neural network exchange format and load it into the model loader of the game engine.
[0069] In this step, after the above training is completed, the inference model is converted to ONNX format and loaded into the model loader of the game engine so that it can be deployed and used in the game engine.
[0070] Optionally, the implementation of "loading into the model loader of the game engine" in step 33 may be:
[0071] Step 1: Parse multiple nodes (English: Node) and multiple Open Neural Network Interchange Format operators (English: Operator) of the graph in the inference model of the Open Neural Network Interchange Format;
[0072] In this implementation, multiple nodes and operators in the graph of the inference model in the Open Neural Network Exchange format are parsed. That is, the computational graph structure of the model can be read through the ONNX API or tool, and each node in the graph can be traversed and the ONNX operator information contained therein can be parsed.
[0073] Each node represents a basic operation in the model calculation (such as convolution, full connection, activation function, etc.), and contains information such as ONNX operator type (such as Conv, Gemm, Relu), input and output tensor names, attribute parameters (such as convolution kernel size, step size), etc.
[0074] By parsing these nodes and ONNX operators, model structure visualization, operator compatibility checking (such as whether the game engine supports the operator), computational graph optimization (such as fusing adjacent nodes and removing redundant operations), and cross-framework deployment (such as converting PyTorch models into computational logic recognizable by game engines) can be achieved.
[0075] Step 2: Establish a mapping relationship between the internal operators supported by the game engine and the open neural network interchange format operators of multiple nodes, and load them into the model loader of the game engine.
[0076] In this implementation, in order to solve the compatibility issue between the Open Neural Network Exchange Format (ONNX) model and the game engine, an operator mapping bridge can be built and the parsing execution of the model in the engine can be realized.
[0077] Specifically, you can pre-define a one-to-one correspondence between the internal operators supported by the underlying game engine (such as VectorAdd, MatrixMultiply) and the node operators in the ONNX model (such as Add, Gemm) to form a mapping relationship (for example: mapping ONNX's Relu operator to the engine's ReLUActivation function).
[0078] After the mapping relationship is established, the nodes in the model calculation graph are read through the game engine's model loader (such as a custom ONNX loading plug-in), and each ONNX operator is converted into an internal operator recognizable by the engine according to the mapping relationship, while passing the node's attribute parameters (such as convolution kernel size, activation function threshold).
[0079] The above process ensures that the computational logic of the inference model can be correctly parsed and executed by the engine. For example, when loading an ONNX model in Unity or Unreal, the model loader traverses the nodes and applies mapping relationships to convert abstract ONNX operations into specific instructions executable by the engine's physics system, rendering pipeline, or scripting system, ultimately enabling the deployment and operation of the AI inference model in the gaming environment.
[0080] The game processing method provided by the embodiment of the present invention obtains the resource data of at least one AI opponent in the game and the optimal decision data corresponding to the resource data of at least one AI opponent, and trains the preset neural network model according to the input tensor data corresponding to the resource data of at least one AI opponent and the output tensor data corresponding to the at least one optimal decision data to obtain an inference model; the inference model is converted into an open neural network exchange format and loaded into the model loader of the game engine. In this technical solution, the resource data and the corresponding optimal decision data of the AI opponent are obtained, and the data are converted into input and output tensor data to train the preset neural network model, so that the inference model can learn the ability to make optimal decisions based on the resource data, thereby improving the decision-making accuracy and intelligence of the model in the game scene; the inference model is converted into an open neural network exchange format and loaded into the model loader of the game engine, thereby achieving effective compatibility between the model and the game engine, facilitating the rapid call of the inference model during the game operation, and providing real-time support for AI decision-making in the game, thereby enhancing the intelligent performance of the AI opponent in the game, and improving the player's gaming experience and playability.
[0081] Based on the above embodiments, Figure 4 FIG. 4 shows a flow chart of a third embodiment of the game processing method provided by the present invention. Figure 4 As shown, step 22 includes the following steps:
[0082] Step 41: Get the processor information of the current device;
[0083] The processor information includes: performance data of the target CPU, performance data of the target GPU, or identification of the target acceleration module;
[0084] In this step, processor-related information of the current device is obtained through the system interface or hardware detection library. The purpose is to provide hardware performance data to the game engine or AI inference module to optimize the model execution strategy.
[0085] In one possible implementation, the performance data of the target CPU (such as the number of cores, main frequency, cache size, and instruction set support) is obtained by calling the operating system API or cross-platform library, the performance data of the target GPU is obtained through the graphics API or GPU detection tool, and the target acceleration module is identified at the same time.
[0086] Step 42: Determine the target execution strategy corresponding to the target running backend using the preset allocation strategy based on the processor information;
[0087] The allocation strategy is based on the CPU performance data, the GPU performance data, the running backend determined by the acceleration module, or at least one execution strategy for running the inference model determined by the running backend;
[0088] In this step, the optimal model execution strategy can be dynamically selected based on the processor information of the current device to improve inference efficiency.
[0089] In one possible implementation, hardware detection can be used to obtain information such as the number of CPU cores, GPU computing power, and acceleration module type, and then a target running backend (such as CPU, GPU, NPU, or a hybrid backend) can be selected for the inference model based on a preset allocation strategy.
[0090] Furthermore, after determining the target running backend, the execution strategy is further adjusted according to the hardware characteristics of the target running backend.
[0091] Optionally, the allocation strategy includes at least one of the following execution strategies:
[0092] 1) If the CPU performance data indicates that the performance is greater than a first threshold and the number of CPU cores is greater than a second threshold, then the running backend is determined to be the CPU Backend, and the execution strategy is to split the calculation task of the inference model into multiple independent jobs and execute them using multi-threaded parallel computing;
[0093] In this implementation, hardware performance indicators can be used to determine whether to enable CPU multi-threaded parallel computing to optimize inference efficiency. First, the CPU's performance data (such as main frequency, cache, etc.) and number of cores are tested. If the performance value exceeds the preset first threshold (such as 2.5GHz main frequency) and the number of cores is greater than the second threshold (such as 4 cores), the current CPU is determined to have strong computing power and multitasking potential, and the CPU Backend is selected as the running backend.
[0094] In terms of execution strategy, the computational graph of the inference model is broken down into multiple independent jobs (e.g., by neural network layer or data batch), and these jobs are executed in parallel using the multi-threaded nature of the CPU, reducing overall inference time through concurrent computing. For example, convolutional layer computations can be distributed to different cores for parallel processing, or forward propagation can be performed simultaneously on different batches of input data. This fully utilizes the computing resources of multi-core CPUs and improves model inference speed. This is suitable for environments with strong CPU performance but limited GPU resources.
[0095] 2) If the GPU performance data indicates that the shader is supported, the running backend is determined to be the GPU Compute backend, and the execution strategy is to submit the calculation tasks of the inference model to the shader in batches to configure the thread group for execution;
[0096] In this implementation, the inference model execution optimization strategy based on GPU characteristics is centered on leveraging the GPU's parallel computing capabilities to accelerate model inference. First, the GPU's performance data is checked. If it supports shaders, the GPU is determined to have general-purpose computing (GPGPU) capabilities, and the GPU Compute backend is selected as the execution backend.
[0097] In terms of execution strategy, the computational tasks of the inference model (such as matrix multiplication and activation function operations) are converted into parallel computational tasks that can be executed by shaders and then submitted in batches to the GPU thread groups for execution. For example, the weight matrix of a fully connected layer of a neural network is divided into multiple sub-matrices, with each thread group responsible for calculating a portion of the output neurons. This leverages the GPU's thousands of threads for parallel processing, significantly improving computational efficiency. Shader configuration must match the GPU architecture, maximizing memory bandwidth and compute unit utilization by properly setting thread block size and grid layout.
[0098] 3) If the performance data of the GPU indicates that the shader is not supported, determining that the running backend is the GPU pixel backend, and the execution strategy is to encode the tensor data to be processed into a texture and execute it using a pixel shader;
[0099] In this implementation, when the GPU does not support general-purpose compute shaders, an alternative strategy is to indirectly implement AI reasoning through the graphics rendering pipeline. For example, when it is detected that the GPU only supports traditional graphics APIs, the GPU Pixel backend is selected as the execution backend.
[0100] In terms of execution strategy, the tensor data of the inference model is encoded as a texture image, and the GPU's pixel shader is used to perform the computation. For example, matrix multiplication is converted into texture sampling and color blending operations: input values are obtained through texture sampling, element-level operations (such as dot products) are implemented in the pixel shader, and the results are written to the output texture.
[0101] 4) If an acceleration module exists, the running backend is determined to be a hardware acceleration backend, and the execution strategy is to execute the inference model calculation through the hardware acceleration API.
[0102] In this implementation, the native computing power of dedicated hardware acceleration modules (such as NPU, TPU, DSP, or FPGA) is used to optimize inference efficiency. First, the device is checked to see if it has an acceleration module. If so, the hardware acceleration backend is selected.
[0103] In terms of execution strategy, the hardware acceleration API of this acceleration module offloads the computational tasks of the inference model directly to the hardware acceleration unit. For example, the quantized neural network layer is mapped to the dedicated computing core of the NPU, and its built-in matrix operation unit or tensor accelerator is used to achieve low-power, high-throughput computing.
[0104] Step 43: Based on the first tensor data, use the target execution strategy in the target execution backend to run the inference model to obtain the second tensor data.
[0105] In this step, the first resource data of the AI opponent to be controlled collected in the game is preprocessed into first tensor data, and the backend, i.e., the hardware carrier for performing inference, is run according to the above-determined target.
[0106] Then, based on the target execution strategy corresponding to the backend running the target, the inference model is run to obtain the second tensor data.
[0107] Optionally, step 43 may include the following implementation:
[0108] Step 1: Run the backend according to the target and determine the target internal operators supported by the game engine in the mapping relationship;
[0109] In this implementation, the standard operators in the ONNX inference model are converted into internal operators supported by the game engine by querying the pre-established mapping relationship.
[0110] That is, the game loader traverses each node of the inference model graph and selects the most suitable mapping rule based on the target running backend: for example, on the GPU backend, matrix multiplication is mapped to ComputeBuffer operation; on the NPU backend, it is mapped to a dedicated operator of the hardware acceleration API.
[0111] The mapping process needs to handle parameter conversion (such as converting the ONNX strides attribute to the step value understood by the engine) and compatibility checks (such as whether the engine supports floating-point operations of a specific precision) to ensure that the calculation logic of each node can be correctly migrated to the target environment.
[0112] Step 2: In the target running backend, according to the target execution strategy, schedule the execution of the computational graph corresponding to the inference model composed of the target internal operators;
[0113] In this implementation, the parsed internal operators are organized into executable computation sequences according to the target execution strategy.
[0114] On the CPU backend, the scheduler breaks down the computational graph into independent tasks (such as splitting by layer) and distributes them to multi-core processors for parallel execution through the thread pool. On the GPU backend, the operators are converted into shader programs, and the thread block / grid parameters are configured to optimize the video memory access mode. On the NPU backend, the operator sequence is compiled into an accelerator instruction stream through the hardware driver.
[0115] In addition, the scheduling process needs to consider dependencies (such as the output of the convolution layer must precede the input of the pooling layer) and resource allocation (such as avoiding GPU memory overflow), and reduce computing waiting time through asynchronous execution and pipelining technology.
[0116] Step 3: According to the execution process of the calculation graph corresponding to the inference model, the first tensor data is calculated layer by layer in the target running backend to obtain the second tensor data.
[0117] In this implementation, the first input tensor data is processed layer by layer according to the scheduled calculation order, that is, each internal operator acts as a calculation unit, receives the input tensor, performs a specific operation and outputs the result tensor: for example, the convolution operator applies the convolution kernel to the input feature map, and the activation function operator applies the nonlinear transformation element by element.
[0118] For example, on the GPU backend, data is passed between shaders in the form of textures; on the NPU backend, quantized tensors are transmitted through a dedicated memory bus.
[0119] Optimization strategies can be applied during the calculation process (such as layer fusion to reduce memory access and batch processing to improve throughput), and finally the second tensor data (such as action probability distribution or state prediction value) is output to complete the conversion from game state to AI decision.
[0120] Optionally, you can also pre-plan memory usage to avoid performance loss and stability issues caused by dynamic memory allocation during the above inference process.
[0121] In Example 1, assuming the current device has 4GB of RAM, dynamic allocation can easily lead to insufficient memory. In this case, you can: quantize model weights (e.g., from FP32 to INT8) to reduce memory usage; pre-allocate a fixed-size memory pool for multiple AI opponents to share and reuse, eliminating the need to allocate memory individually for each character;
[0122] Example 2: Multiple AI opponents are reasoning simultaneously. To avoid memory allocation contention, each character can be allocated an independent memory slice (divided from a pre-allocated large memory block). A lock-free queue (full name: Lock-Free Queue) can be used to manage memory reuse and improve multi-threaded concurrency efficiency.
[0123] The game processing method provided by an embodiment of the present invention obtains processor information of the current device, the processor information including: target CPU performance data, target GPU performance data, or target acceleration module identification; based on the processor information, a preset allocation strategy is used to determine the target execution strategy corresponding to the target running backend, the allocation strategy is based on the CPU performance data, GPU performance data, or the running backend determined by the acceleration module, and the execution strategy of the running backend running the inference model; based on the first tensor data, the target execution strategy is used in the target running backend to run the inference model to obtain second tensor data. This solution first obtains processor information of the current device including target CPU, target GPU performance data and target acceleration module identification, and determines the running backend and corresponding execution strategy based on the preset allocation strategy in combination with different hardware performance and acceleration modules to ensure that the inference model can adapt to the device hardware characteristics; then, based on the first tensor data, the target execution strategy is used to run the inference model in the selected running backend to obtain second tensor data. This enables the inference model to fully utilize the advantages of the device hardware, improve inference efficiency and running speed, reduce resource waste, and ensure that inference tasks can be completed efficiently and stably in different hardware environments, providing good performance support for applications that rely on inference models.
[0124] In the implementation of the above method, compared with the existing technology, there are the following technical effects:
[0125] Technical effect 1. No network dependency: The model runs locally on the device without the need for a network connection, which improves the usability and stability of the application.
[0126] Technical Effect 2. Low-latency response: Through an optimized multi-backend execution strategy, millisecond-level inference response time is achieved to meet real-time interaction requirements;
[0127] Technical Effect 3. Cross-platform compatibility: The same set of APIs can run on multiple platforms such as PC, mobile devices, and game consoles, significantly reducing development costs;
[0128] Technical Effect 4. High Performance: Automatically select the optimal execution path based on the device hardware characteristics, maximizing performance while ensuring functionality;
[0129] Technical Effect 5. Privacy Protection: Data processing is completed locally, and there is no need to send user information to external servers;
[0130] Technical Effect 6. Cost-effectiveness: No need to pay API call fees, reducing game operation costs;
[0131] Technical Effect 7. Rich gaming experience: Supports advanced AI features such as real-time object recognition, intelligent NPC behavior, dynamic content generation, etc., significantly improving the gaming experience.
[0132] Figure 5 FIG. 1 shows a schematic diagram of the structure of an embodiment of the game processing device provided by the present invention. Figure 5 As shown, the device includes:
[0133] An acquisition module 51 is configured to acquire first tensor data indicated by first resource data corresponding to an AI opponent to be controlled in the game;
[0134] a processing module 52 configured to input the first tensor data into a preset inference model to obtain second tensor data corresponding to target decision data corresponding to the AI opponent to be controlled, wherein the inference model is a model in an open neural network exchange format trained based on resource data of at least one AI opponent in the game and optimal decision data corresponding to the resource data of the at least one AI opponent;
[0135] The control module 53 is configured to control the AI opponent to be controlled according to the second tensor data.
[0136] In one or more embodiments, before inputting the first tensor data into a preset inference model to obtain the second tensor data corresponding to the target decision data of the AI opponent to be controlled, the processing module 52 is further configured to:
[0137] Obtaining resource data of at least one AI opponent in the game and optimal decision data corresponding to the resource data of the at least one AI opponent;
[0138] Training a preset neural network model based on the input tensor data corresponding to the resource data of the at least one AI opponent and the output tensor data corresponding to the at least one optimal decision data to obtain the inference model;
[0139] The inference model is converted into the open neural network exchange format and loaded into the model loader of the game engine.
[0140] In one or more embodiments, the control module 53 controls the AI opponent to be controlled according to the second tensor data, specifically for:
[0141] Parsing the second tensor data into target decision data of the AI opponent to be controlled;
[0142] Controlling the AI opponent to be controlled to apply the target decision data.
[0143] In one or more embodiments, the processing module 52 is loaded into the model loader of the game engine and is specifically used to:
[0144] Parsing a plurality of nodes of a graph in the inference model of the open neural network interchange format and open neural network interchange format operators of the plurality of nodes;
[0145] A mapping relationship between internal operators supported by the game engine and open neural network interchange format operators of the plurality of nodes is established and loaded into a model loader of the game engine.
[0146] In one or more embodiments, the processing module 52 inputs the first tensor data into a preset inference model to obtain second tensor data corresponding to the target decision data of the AI opponent to be controlled, specifically for:
[0147] Obtain processor information of the current device, the processor information including: performance data of the target CPU, performance data of the target GPU, or identification of the target acceleration module;
[0148] Determine, based on the processor information, a target execution strategy corresponding to the target execution backend using a preset allocation strategy, where the allocation strategy is based on at least one execution strategy of the execution backend determined by the CPU performance data, the GPU performance data, the acceleration module, or the execution inference model determined by the execution backend;
[0149] According to the execution process of the calculation graph corresponding to the inference model, the first tensor data is calculated layer by layer in the target operation backend to obtain the second tensor data.
[0150] In one or more embodiments, the processing module 52 runs the inference model using the target execution strategy in the target execution backend based on the first tensor data to obtain the second tensor data, specifically for:
[0151] According to the target running backend, determining the target internal operators supported by the game engine in the mapping relationship;
[0152] In the target execution backend, according to the target execution strategy, the computation graph corresponding to the inference model and composed of the target internal operators is scheduled for execution;
[0153] According to the execution flow of the calculation graph corresponding to the inference model, the first tensor data is calculated layer by layer to obtain the second tensor data.
[0154] In one or more embodiments, the allocation strategy includes at least one of the following execution strategies:
[0155] If the CPU performance data indicates that the performance is greater than a first threshold and the number of cores of the CPU is greater than a second threshold, determining that the running backend is a CPU backend, and the execution strategy is to split the computing task of the inference model into multiple independent jobs and execute them using multi-threaded parallel computing;
[0156] If the performance data of the GPU indicates that the shader is supported, determining that the running backend is the GPU Compute backend, and the execution strategy is to submit the computing tasks of the inference model to the shader in batches to configure the thread group for execution;
[0157] If the performance data of the GPU indicates that shaders are not supported, determining that the running backend is the GPU Pixel backend, and the execution strategy is to encode the tensor data to be processed into a texture and execute it using a pixel shader;
[0158] If an acceleration module exists, it is determined that the running backend is a hardware acceleration backend, and the execution strategy is to execute the inference model calculation through a hardware acceleration API.
[0159] It should be noted that it should be understood that the division of the various modules of the above device is merely a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. Moreover, these modules can all be implemented in the form of software called by a processing element. They can also all be implemented in the form of hardware. Some modules can also be implemented in the form of software called by a processing element, and some modules can be implemented in the form of hardware. In addition, these modules can all or partly be integrated together or implemented independently. The processing element here can be an integrated circuit with signal processing capabilities. During implementation, each step of the above method or each of the above modules can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.
[0160] From the above, it can be seen that the game processing device provided by the embodiment of the present invention converts the resource data of the AI opponent in the game into a first tensor data input into an inference model in ONNX format trained based on historical data, realizes localized real-time inference and outputs a decision tensor to control the opponent's AI behavior, which can improve the AI response speed and behavioral intelligence, reduce the operating cost of network dependence, and reduce the game interaction delay. At the same time, it enhances game compatibility and privacy security through cross-platform adaptation and data localization processing.
[0161] Figure 6 FIG. 1 shows a schematic structural diagram of an embodiment of an electronic device provided by the present invention, as shown in FIG. Figure 6As shown, the electronic device may include: a processor 62 , a communications interface 64 , a memory 66 , and a communication bus 68 .
[0162] Processor 62, communication interface 64, and memory 66 communicate with each other via communication bus 68. Communication interface 64 is used to communicate with other devices, such as client devices or other server network elements. Processor 62 is used to execute program 60, specifically, the steps described in the aforementioned embodiment of the game processing method.
[0163] Specifically, the program 60 may include program code including computer-executable instructions.
[0164] Processor 62 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention. The one or more processors included in the electronic device may be processors of the same type, such as one or more CPUs. Alternatively, they may be processors of different types, such as one or more CPUs and one or more ASICs.
[0165] The memory 66 is used to store the program 60. The memory 66 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0166] The program 60 can be specifically called by the processor 62 to enable the electronic device to perform the following operations:
[0167] Obtaining first tensor data indicated by first resource data corresponding to the AI opponent to be controlled in the game;
[0168] Inputting the first tensor data into a preset inference model to obtain second tensor data corresponding to target decision data corresponding to the AI opponent to be controlled, the inference model being a model in an open neural network exchange format trained based on resource data of at least one AI opponent in the game and optimal decision data corresponding to the resource data of at least one AI opponent;
[0169] Control the AI opponent to be controlled according to the second tensor data.
[0170] In one or more embodiments, before inputting the first tensor data into a preset inference model to obtain the second tensor data corresponding to the target decision data of the AI opponent to be controlled, the following steps are further performed:
[0171] Obtaining resource data of at least one AI opponent in the game and optimal decision data corresponding to the resource data of at least one AI opponent;
[0172] Training a preset neural network model based on input tensor data corresponding to resource data of at least one AI opponent and output tensor data corresponding to at least one optimal decision data to obtain an inference model;
[0173] Convert the inference model to the Open Neural Network Interchange format and load it into the game engine's model loader.
[0174] In one or more embodiments, controlling the AI opponent to be controlled according to the second tensor data includes:
[0175] Parse the second tensor data into target decision data of the AI opponent to be controlled;
[0176] Control the AI opponent to be controlled and apply target decision data.
[0177] In one or more embodiments, loading into a model loader of a game engine includes:
[0178] Parsing multiple nodes of a graph in an ONIx inference model and ONIx operators of multiple nodes;
[0179] Establish a mapping relationship between the internal operators supported by the game engine and the open neural network interchange format operators of multiple nodes, and load them into the model loader of the game engine.
[0180] In one or more embodiments, inputting the first tensor data into a preset inference model to obtain second tensor data corresponding to the target decision data of the AI opponent to be controlled includes:
[0181] Get the processor information of the current device, including the target CPU performance data, target GPU performance data, or the target acceleration module identifier;
[0182] Determine, based on the processor information, a target execution strategy corresponding to the target execution backend using a preset allocation strategy, where the allocation strategy is based on at least one execution strategy of the execution backend determined by the CPU performance data, the GPU performance data, the acceleration module, or the execution inference model determined by the execution backend;
[0183] According to the execution process of the calculation graph corresponding to the inference model, the first tensor data is calculated layer by layer in the target operation backend to obtain the second tensor data.
[0184] In one or more embodiments, executing an inference model using a target execution strategy in a target execution backend based on the first tensor data to obtain second tensor data includes:
[0185] Based on the target running backend, determine the target internal operators supported by the game engine in the mapping relationship;
[0186] In the target running backend, according to the target execution strategy, the computation graph corresponding to the inference model composed of the target internal operators is scheduled for execution;
[0187] According to the execution flow of the calculation graph corresponding to the inference model, the first tensor data is calculated layer by layer to obtain the second tensor data.
[0188] In one or more embodiments, the allocation strategy includes at least one of the following execution strategies:
[0189] If the CPU performance data indicates that the performance is greater than a first threshold and the number of CPU cores is greater than a second threshold, the running backend is determined to be the CPU backend, and the execution strategy is to split the calculation task of the inference model into multiple independent jobs and execute them using multi-threaded parallel computing;
[0190] If the GPU performance data indicates that shaders are supported, the GPU compute backend is determined to be the running backend, and the execution strategy is to batch submit the computational tasks of the inference model to the shader to configure the thread group for execution;
[0191] If the performance data of the GPU indicates that the shader is not supported, determining that the running backend is the GPU pixel backend, and the execution strategy is to encode the tensor data to be processed into a texture and execute it using a pixel shader;
[0192] If an acceleration module exists, the running backend is determined to be a hardware acceleration backend, and the execution strategy is to execute the inference model calculation through the hardware acceleration API.
[0193] From the above, it can be seen that the electronic device provided by the embodiment of the present invention, by converting the resource data of the AI opponent in the game into a first tensor data input into an inference model in ONNX format trained based on historical data, realizes localized real-time inference and outputs a decision tensor to control the opponent's AI behavior, which can improve the AI response speed and behavioral intelligence, reduce the operating cost of dependence on the network, and reduce the game interaction delay. At the same time, it enhances game compatibility and privacy security through cross-platform adaptation and data localization processing.
[0194] An embodiment of the present invention provides a computer-readable storage medium storing at least one executable instruction. When the executable instruction runs on a game processing device / electronic device, the game processing device / electronic device executes the game processing method of any of the above method embodiments.
[0195] The executable instructions can be specifically used to cause the game processing device / electronic device to perform the following operations:
[0196] Obtaining first tensor data indicated by first resource data corresponding to the AI opponent to be controlled in the game;
[0197] Inputting the first tensor data into a preset inference model to obtain second tensor data corresponding to target decision data corresponding to the AI opponent to be controlled, the inference model being a model in an open neural network exchange format trained based on resource data of at least one AI opponent in the game and optimal decision data corresponding to the resource data of at least one AI opponent;
[0198] Control the AI opponent to be controlled according to the second tensor data.
[0199] In one or more embodiments, before inputting the first tensor data into a preset inference model to obtain the second tensor data corresponding to the target decision data of the AI opponent to be controlled, the following steps are further performed:
[0200] Obtaining resource data of at least one AI opponent in the game and optimal decision data corresponding to the resource data of at least one AI opponent;
[0201] Training a preset neural network model based on input tensor data corresponding to resource data of at least one AI opponent and output tensor data corresponding to at least one optimal decision data to obtain an inference model;
[0202] Convert the inference model to the Open Neural Network Interchange format and load it into the game engine's model loader.
[0203] In one or more embodiments, controlling the AI opponent to be controlled according to the second tensor data includes:
[0204] Parse the second tensor data into target decision data of the AI opponent to be controlled;
[0205] Control the AI opponent to be controlled and apply target decision data.
[0206] In one or more embodiments, loading into a model loader of a game engine includes:
[0207] Parsing multiple nodes of a graph in an ONIx inference model and ONIx operators of multiple nodes;
[0208] Establish a mapping relationship between the internal operators supported by the game engine and the open neural network interchange format operators of multiple nodes, and load them into the model loader of the game engine.
[0209] In one or more embodiments, inputting the first tensor data into a preset inference model to obtain second tensor data corresponding to the target decision data of the AI opponent to be controlled includes:
[0210] Get the processor information of the current device, including the performance data of the target CPU, the performance data of the target GPU, or the identification of the target acceleration module;
[0211] Based on the processor information, a preset allocation strategy is used to determine the target execution strategy corresponding to the target running backend. The allocation strategy is based on the CPU performance data, GPU performance data, or the running backend determined by the acceleration module, and the execution strategy of the running backend running the inference model;
[0212] Based on the first tensor data, the target execution strategy is used in the target execution backend to run the inference model to obtain the second tensor data.
[0213] In one or more embodiments, executing an inference model using a target execution strategy in a target execution backend based on the first tensor data to obtain second tensor data includes:
[0214] Based on the target running backend, determine the target internal operators supported by the game engine in the mapping relationship;
[0215] In the target running backend, according to the target execution strategy, the computation graph corresponding to the inference model composed of the target internal operators is scheduled for execution;
[0216] According to the execution flow of the calculation graph corresponding to the inference model, the first tensor data is calculated layer by layer to obtain the second tensor data.
[0217] In one or more embodiments, the allocation strategy includes at least one of the following:
[0218] If the CPU performance data indicates that the performance is greater than a first threshold and the number of CPU cores is greater than a second threshold, the running backend is determined to be the CPU backend, and the execution strategy is to split the calculation task of the inference model into multiple independent jobs and execute them using multi-threaded parallel computing;
[0219] If the GPU performance data indicates that shaders are supported, the GPU compute backend is determined to be the running backend, and the execution strategy is to batch submit the computational tasks of the inference model to the shader to configure the thread group for execution;
[0220] If the performance data of the GPU indicates that the shader is not supported, determining that the running backend is the GPU pixel backend, and the execution strategy is to encode the tensor data to be processed into a texture and execute it using a pixel shader;
[0221] If an acceleration module exists, the running backend is determined to be a hardware acceleration backend, and the execution strategy is to execute the inference model calculation through the hardware acceleration API.
[0222] From the above, it can be seen that the execution instructions in the computer-readable storage medium provided by the embodiment of the present invention, by converting the resource data of the AI opponent in the game into a first tensor data input based on the inference model in ONNX format trained with historical data, realize localized real-time reasoning and output decision tensors to control the opponent's AI behavior, which can improve the AI response speed and behavioral intelligence, reduce the operating cost of network dependence, reduce the game interaction delay, and enhance the game compatibility and privacy security through cross-platform adaptation and data localization processing.
[0223] An embodiment of the present invention provides a computer program product, including a computer program, which implements the operations of the above-mentioned game processing method when executed by a processor.
[0224] Its implementation principle and technical effects are shown in the above disclosure.
[0225] The above description of the various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced with each other and will not be repeated herein for the sake of brevity.
[0226] The methods disclosed in the various method embodiments provided by the present invention can be arbitrarily combined without conflict to obtain new method embodiments.
[0227] The features disclosed in the various product embodiments provided by the present invention can be arbitrarily combined without conflict to obtain new product embodiments.
[0228] The features disclosed in the various method or device embodiments provided by the present invention can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0229] It should be noted that the computer-readable storage medium may be a ROM, a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface mount storage device, an optical disk, or a compact disc read-only memory (CD-ROM). Various vehicles may also include any one or any combination of the above-mentioned memories.
[0230] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.
[0231] The serial numbers of the above embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments.
[0232] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus necessary general hardware nodes, or of course by hardware, but in many cases the former is a better embodiment. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, air conditioner, vehicle terminal or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0233] It should be noted that the above embodiments illustrate rather than limit the invention, and that alternative embodiments may be devised by a person skilled in the art without departing from the scope of the appended claims. In the claims, any reference signs placed between brackets should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising several different elements and by means of appropriately programmed computers. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third etc. does not indicate any order. These words may be interpreted as names. The steps in the above embodiments should not be understood as limiting the order of execution unless otherwise specified.
Claims
1. A game processing method, characterized in that: The method comprises: Obtaining first tensor data indicated by first resource data corresponding to the AI opponent to be controlled in the game; Inputting the first tensor data into a preset inference model to obtain second tensor data corresponding to target decision data corresponding to the AI opponent to be controlled, wherein the inference model is a model in an open neural network exchange format trained based on resource data of at least one AI opponent in the game and optimal decision data corresponding to the resource data of the at least one AI opponent; The AI opponent to be controlled is controlled according to the second tensor data.
2. The method according to claim 1, characterized in that Before inputting the first tensor data into a preset inference model to obtain second tensor data corresponding to the target decision data of the AI opponent to be controlled, the method further includes: Obtaining resource data of at least one AI opponent in the game and optimal decision data corresponding to the resource data of the at least one AI opponent; Training a preset neural network model based on the input tensor data corresponding to the resource data of the at least one AI opponent and the output tensor data corresponding to the at least one optimal decision data to obtain the inference model; The inference model is converted into the open neural network exchange format and loaded into the model loader of the game engine.
3. The method according to claim 2, characterized in that The step of controlling the AI opponent to be controlled according to the second tensor data includes: Parsing the second tensor data into target decision data of the AI opponent to be controlled; Controlling the AI opponent to be controlled to apply the target decision data.
4. The method according to claim 2, characterized in that The model loader loaded into the game engine includes: Parsing a plurality of nodes of a graph in the inference model of the open neural network interchange format and open neural network interchange format operators of the plurality of nodes; A mapping relationship between internal operators supported by the game engine and open neural network interchange format operators of the plurality of nodes is established and loaded into a model loader of the game engine.
5. The method according to claim 4, characterized in that Inputting the first tensor data into a preset inference model to obtain second tensor data corresponding to the target decision data of the AI opponent to be controlled includes: Obtain processor information of the current device, the processor information including: performance data of the target CPU, performance data of the target GPU, or identification of the target acceleration module; Determine, based on the processor information, a target execution strategy corresponding to a target running backend using a preset allocation strategy, wherein the allocation strategy is based on CPU performance data, GPU performance data, a running backend determined by an acceleration module, or at least one execution strategy for running the inference model determined by the running backend; According to the first tensor data, the target execution strategy is used in the target execution backend to run the inference model to obtain the second tensor data.
6. The method according to claim 5, characterized in that The step of executing the inference model using the target execution strategy in the target execution backend according to the first tensor data to obtain the second tensor data includes: According to the target running backend, determining the target internal operators supported by the game engine in the mapping relationship; In the target execution backend, according to the target execution strategy, the computation graph corresponding to the inference model and composed of the target internal operators is scheduled for execution; According to the execution process of the calculation graph corresponding to the inference model, the first tensor data is calculated layer by layer in the target operation backend to obtain the second tensor data.
7. The method according to claim 5 or 6, characterized in that The allocation strategy includes at least one of the following execution strategies: If the CPU performance data indicates that the performance is greater than a first threshold and the number of cores of the CPU is greater than a second threshold, determining that the running backend is a CPU backend, and the execution strategy is to split the computing task of the inference model into multiple independent jobs and execute them using multi-threaded parallel computing; If the performance data of the GPU indicates that the shader is supported, determining that the running backend is the GPU Compute backend, and the execution strategy is to submit the computing tasks of the inference model to the shader in batches to configure the thread group for execution; If the performance data of the GPU indicates that shaders are not supported, determining that the running backend is the GPU Pixel backend, and the execution strategy is to encode the tensor data to be processed into a texture and execute it using a pixel shader; If an acceleration module exists, it is determined that the running backend is a hardware acceleration backend, and the execution strategy is to execute the inference model calculation through a hardware acceleration API.
8. A game processing device, characterized in that: The device comprises: An acquisition module, configured to acquire first tensor data indicated by first resource data corresponding to an AI opponent to be controlled in the game; a processing module, configured to input the first tensor data into a preset inference model to obtain second tensor data corresponding to target decision data corresponding to the AI opponent to be controlled, wherein the inference model is a model in an open neural network exchange format trained based on resource data of at least one AI opponent in the game and optimal decision data corresponding to the resource data of the at least one AI opponent; A control module is used to control the AI opponent to be controlled according to the second tensor data.
9. An electronic device, characterized in that: include: A processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute the operation of the game processing method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The storage medium stores at least one executable instruction. When the executable instruction is executed on the game processing device / electronic device, the game processing device / electronic device executes the operation of the game processing method according to any one of claims 1 to 7.