CN116185371B - Hardware device registration method, device, equipment and storage medium - Google Patents

Hardware device registration method, device, equipment and storage medium Download PDF

Info

Publication number
CN116185371B
CN116185371B CN202310448879.5A CN202310448879A CN116185371B CN 116185371 B CN116185371 B CN 116185371B CN 202310448879 A CN202310448879 A CN 202310448879A CN 116185371 B CN116185371 B CN 116185371B
Authority
CN
China
Prior art keywords
equipment
hardware
registered
target
function
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202310448879.5A
Other languages
Chinese (zh)
Other versions
CN116185371A (en
Inventor
曾炜
陈建平
袁孝宇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Peking University
Original Assignee
Peking University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Peking University filed Critical Peking University
Priority to CN202310448879.5A priority Critical patent/CN116185371B/en
Publication of CN116185371A publication Critical patent/CN116185371A/en
Application granted granted Critical
Publication of CN116185371B publication Critical patent/CN116185371B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Stored Programmes (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application relates to a hardware device registration method, a device, equipment and a storage medium. By adopting the scheme of the application, the access code supporting the algorithm frame does not need to be written and the frame code is recompiled, so that the efficiency of accessing the hardware equipment into the algorithm frame is improved.

Description

Hardware device registration method, device, equipment and storage medium
Technical Field
The present application relates to the field of computers, and in particular, to a method, an apparatus, a device, and a storage medium for registering a hardware device.
Background
Heterogeneous hardware devices are the core basic resources of artificial intelligence algorithms, and any artificial intelligence algorithm finally needs to be calculated in the hardware devices. The artificial intelligence algorithm is currently dependent on the deep learning computing framework, so to use the hardware device in the artificial intelligence algorithm, the hardware device needs to be accessed into the deep learning computing framework, so that the deep learning computing framework can identify the hardware device.
Currently, deep learning computing frameworks provide more or less ways of accessing hardware devices, such as TensorFlow provides some abstract device access interfaces, and Pytorch also provides a tightly coupled deep integration way. However, mainstream frameworks like TensorFlow and Pytorch mainly only support CUDA and CPU hardware at present, and have no good access mode for some newly-emerging hardware devices.
Thus, a hardware device, if it wants to access a deep learning framework, needs to either have a hardware vendor to provide an existing dynamic library that is built in to support the deep learning framework, or needs to write the access code that supports the deep learning framework itself and recompile the framework code. The development workload related to any method is very large, and the access efficiency of the hardware equipment to the deep learning framework is affected.
Disclosure of Invention
The application provides a hardware device registration method, a device, equipment and a storage medium, which are used for solving the problems of large development workload and low access efficiency when hardware devices are accessed into a deep learning framework.
In a first aspect, a hardware device registration method is provided, including:
acquiring basic information of equipment of hardware equipment to be registered, equipment base class matched with the hardware equipment to be registered in an algorithm framework and target functions required to be registered by the hardware equipment to be registered;
and registering the target function of the hardware device to be registered with the algorithm framework by using the device basic information and the device base class.
Optionally, acquiring device basic information of the hardware device to be registered includes:
acquiring declaration definition of the hardware equipment to be registered; acquiring the basic information of the equipment from the declaration definition;
or alternatively, the first and second heat exchangers may be,
and acquiring a protocol buffer file corresponding to the hardware equipment to be registered, and compiling the protocol buffer file to obtain the basic information of the equipment.
Optionally, obtaining a device base class matched with the hardware device to be registered in the algorithm framework includes:
acquiring the device type corresponding to each device base class in the algorithm frame and the current device type of the hardware device to be registered;
determining a target equipment type matched with the current equipment type from the equipment types;
and determining the equipment base class corresponding to the target equipment type as the equipment base class matched with the hardware equipment to be registered.
Optionally, obtaining the target function to be registered of the hardware device to be registered includes:
acquiring the current equipment type of the hardware equipment to be registered and the equipment type corresponding to the equipment base class;
inquiring a preset mapping relation by adopting the current equipment type and the equipment type to obtain the target function; the preset mapping relation is a corresponding relation between the equipment type of the hardware equipment and the function of the hardware equipment.
Optionally, registering the target function of the hardware device to be registered with the algorithm framework using the device basic information and the device base class, including:
generating a first target mapping relation, wherein the target mapping relation is a corresponding relation between the basic information of the equipment and a function handle corresponding to the target function;
and adding the first target relation in the mapping relation set corresponding to the equipment base class.
Optionally, after registering the target function of the hardware device to be registered with the algorithm framework by using the device basic information and the device base class, the method further includes:
acquiring a device handle of a hardware device to which the called function belongs;
acquiring a target device identifier of the hardware device based on the device handle;
determining a target equipment base class corresponding to the target equipment identifier;
acquiring a second target mapping relation corresponding to the target equipment identifier in the target equipment base class;
querying the second target mapping relation by adopting the identification of the called function to obtain a function handle corresponding to the called function;
and calling the called function by using the function handle.
Optionally, before determining the target device base class corresponding to the target device identifier, the method further includes:
and determining that the called function does not belong to a default function of the device base class integration in the algorithm framework based on the target device identification.
In a second aspect, there is provided a hardware device registration apparatus including:
the acquisition module acquires equipment basic information of the hardware equipment to be registered, equipment basic classes matched with the hardware equipment to be registered in an algorithm framework and target functions required to be registered by the hardware equipment to be registered;
and the registration module is used for registering the target function of the hardware device to be registered to the algorithm framework by utilizing the device basic information and the device basic class.
In a third aspect, there is provided an electronic device comprising: the device comprises a processor, a memory and a communication bus, wherein the processor and the memory are communicated with each other through the communication bus;
the memory is used for storing a computer program;
the processor is configured to execute the program stored in the memory, and implement the hardware device registration method described in the first aspect.
In a fourth aspect, a computer readable storage medium is provided, storing a computer program, which when executed by a processor implements the hardware device registration method of the first aspect.
Compared with the prior art, the technical scheme provided by the embodiment of the application has the following advantages: according to the method provided by the embodiment of the application, the target function of the hardware equipment to be registered is registered in the algorithm framework by determining the equipment type matched with the hardware equipment to be registered. By adopting the scheme of the application, the access code supporting the algorithm frame does not need to be written and the frame code is recompiled, so that the efficiency of accessing the hardware equipment into the algorithm frame is improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description, serve to explain the principles of the application.
In order to more clearly illustrate the embodiments of the application or the technical solutions of the prior art, the drawings which are used in the description of the embodiments or the prior art will be briefly described, and it will be obvious to a person skilled in the art that other drawings can be obtained from these drawings without inventive effort.
FIG. 1 is a schematic flow chart of a hardware device registration method in an embodiment of the application;
FIG. 2 is a flowchart of a hardware device registration method according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a hardware device registration apparatus according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments of the present application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present application and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the application described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
The embodiment of the application provides a hardware device registration method, which can be applied to electronic devices, wherein the electronic devices can comprise terminal devices or servers. The terminal device may be a mobile terminal such as a mobile phone, tablet computer, notebook computer, palm computer, PAD (Personal Digital Assistant ), etc., a fixed terminal such as a digital TV, desktop computer, etc.
As shown in fig. 1, the method may include the steps of:
step 101, obtaining basic information of a device of the hardware device to be registered, a device base class matched with the hardware device to be registered in an algorithm framework and a target function of the hardware device to be registered.
In this embodiment, the device basic information of the hardware device to be registered includes information such as an identification of the hardware device to be registered, a device type, a device name (name), and/or a model number (model). Wherein the device type indicates the type to which the hardware device to be registered belongs, for example, the device type may be a CPU, a GPU (graphics processor, graphics processing unit), an NPU (Neural-Network Processing Unit, neural network processor), or the like. The device model is used for distinguishing the same type of device, and the device model in the application can be represented by a manufacturer of the device or other information.
In this embodiment, the target function to be registered of the hardware device to be registered characterizes a function specific to the hardware device of the device type corresponding to the device base class of the hardware device to be registered.
In this embodiment, the device basic information of the hardware device to be registered, the device basic class matched with the hardware device to be registered in the algorithm framework, and the target function to be registered of the hardware device to be registered may be directly indicated by the user.
In this embodiment, the target function may be any function supported by the hardware device to be registered. In practical applications, in order to reduce resource overhead, the target function may also be a function specific to the hardware device corresponding to the hardware device to be registered by default with respect to the device base class.
In this embodiment, the algorithm frame may have a plurality of device base classes, where a device base class that matches with a device to be registered refers to a device base class that has a higher degree of matching with a hardware device to be registered than other device base classes in the plurality of device base classes that the algorithm frame has, that is, the degree of matching between the device base class and the hardware device to be registered is greater than a degree threshold.
In the application, the matching degree of the device base class and the hardware device to be registered can be represented by the similarity degree between the function of the hardware device corresponding to the device base class and the function of the hardware device to be registered, namely, when the similarity degree between the function of the hardware device corresponding to the device base class and the function of the hardware device to be registered is high, the matching degree between the device base class and the hardware device to be registered is also high; on the contrary, when the degree of similarity between the functions of the hardware devices corresponding to the device base class and the functions of the hardware devices to be registered is low, the degree of matching between the device base class and the hardware devices to be registered is also low.
In application, hardware devices of different device types often have some identical functions, so that the degree of similarity between hardware devices of different device types can be measured by the duty ratio of the identical functions. In short, for hardware devices belonging to two different device types, the more the two hardware devices have the same function, the higher the degree of similarity between the two hardware devices is represented.
In this embodiment, when the user indicates the device basic information of the hardware device to be registered, the device basic information may be implemented in a declarative definition manner or implemented by a protocol buffer (protocol buffer) file. Correspondingly, when the basic information of the hardware equipment to be registered is acquired, acquiring the declaration definition of the hardware equipment to be registered; acquiring basic information of the equipment from the declaration definition; or acquiring a protobuf file corresponding to the hardware equipment to be registered, and compiling the protobuf file to obtain the basic information of the equipment.
In application, in general, the device base class of the hardware device with some common device types in the algorithm frame, such as GPUDevice (GPU base class) corresponding to the GPU device, and HostDevice corresponding to the CPU device, when some new device types of hardware devices need to be registered in the algorithm frame, the embodiment selects one device base class from the existing device base classes in the algorithm frame to register the hardware devices, so that the problem of large development workload caused by the need to implement the device base class of the hardware device in the algorithm frame when the new device types of hardware devices occur each time can be avoided.
In this embodiment, the device base class that matches the hardware device to be registered in the algorithm framework may be determined based on the device type of the hardware device to be registered.
In a specific implementation, in an optional embodiment, obtaining a device type corresponding to each device base class in an algorithm frame and a current device type of a hardware device to be registered; determining a target device type matched with the current device type from the device types; and determining the device base class corresponding to the target device type as the device base class matched with the hardware device to be registered.
It should be understood that the current device type of the hardware device to be registered may be obtained from the device basic information of the hardware device to be registered.
In this embodiment, the target device type matched with the current device type may be indicated by the user, or may be determined based on a preset mapping relationship. When determining based on the preset mapping relationship, the preset mapping relationship characterizes the corresponding relationship between hardware devices of different device types.
In this embodiment, the algorithm framework further has a preset mapping relationship indicating a correspondence between a device type of the hardware device and a function of the hardware device, and by querying the preset mapping relationship, functions of hardware devices of different device types can be clarified, so that a target function of the hardware device to be registered is determined based on the queried functions of the hardware devices.
In a specific implementation, in an optional embodiment, a current device type of a hardware device to be registered and a device type corresponding to a device base class are obtained; inquiring a preset mapping relation by adopting the current equipment type and the equipment type to obtain a target function; the preset mapping relation is a corresponding relation between the equipment type of the hardware equipment and the function of the hardware equipment.
It should be understood that, a first type of function supported by the hardware device to be registered can be obtained by querying the preset mapping relation by using the current device type, a second type of function supported by the hardware device corresponding to the device type can be obtained by querying the preset mapping relation by using the device type, then the two types of functions are compared, and a target function which only belongs to the first type of function and not belongs to the second type of function is found from the first type of function.
In this embodiment, when comparing the first type of function and the second type of function, the identifiers of the function functions corresponding to the functions in the first type of function and the identifiers of the function functions corresponding to the functions in the second type of function are obtained, and the target function is found based on the identifiers of the function functions. In one example, the identities of the function functions corresponding to the functions in the first class of functions are a, b, c, and the identities of the function functions corresponding to the functions in the second class of functions are b, c, and d, and then the function corresponding to the identity a may be determined to be the target function.
And 102, registering the target function of the hardware device to be registered with the algorithm framework by using the device basic information and the device base class.
In this embodiment, the registration of the target function of the hardware device to be registered in the algorithm framework is achieved by establishing a correspondence between the hardware device to be registered and the target function in the device base class matched with the hardware device to be registered.
In a specific implementation, in an optional embodiment, a first target mapping relationship is generated, where the target mapping relationship is a corresponding relationship between basic information of the device and a function handle corresponding to a target function; and adding a first target shooting relation in the mapping relation set corresponding to the equipment base class.
Wherein a function handle is a data type that provides an interface implementation that can indirectly invoke a function associated with the function handle at any location.
It should be understood that, in the algorithm framework, the mapping relationship in the mapping relationship set integrated under one device base class originally characterizes the functions of each hardware device under the device type corresponding to the device base class, for example, for GPUDevice, the mapping relationship in the mapping relationship set may be the corresponding relationship between GPU1 and the function handle of function 1, the function handle of function 2 and the function handle of function 3, the corresponding relationship between GPU2 and the function handle of function 2, the function handle of function 3 and the function handle of function 4, where function 1, function 2 and function 3 are functions of GPU1, and function 2, function 3 and function 4 are functions of GPU 2.
After the registration of the target function of the hardware device is completed, when the computing framework needs to use the hardware device, the implementation can be realized based on the mapping relation generated in the registration process.
In a specific implementation, in an optional embodiment, after registering a target function of a hardware device to be registered with an algorithm framework by using device basic information and a device base class, a device handle of the hardware device to which the called function belongs is obtained; acquiring a target device identifier of the hardware device based on the device handle; determining a target equipment base class corresponding to the target equipment identifier; acquiring a second target mapping relation corresponding to the target equipment identifier in the target equipment base class; querying a second target mapping relation by adopting the identification of the called function to obtain a function handle corresponding to the called function; the called function is called using the function handle.
In this embodiment, when the algorithm framework needs to call the called function, the algorithm framework provides the device handle of the hardware device to which the called function belongs, where the device handle uniquely corresponds to the target device identifier of the hardware device, so that the target device identifier of the hardware device to which the called function belongs can be obtained based on the device handle.
It should be understood that when registering the called function in the algorithm frame, the corresponding relationship between the device base class in the algorithm frame matched with the hardware device to which the called function belongs and the hardware device is synchronously recorded, so that when determining the target device base class corresponding to the target device identifier, the corresponding relationship between the device base class and the hardware device recorded in the registration process is realized.
It should be understood that, when the algorithm framework invokes the function of the hardware device originally integrated in the device base class, the flow of invoking the invoked function in this embodiment may also be adopted, and, of course, in order to save the flow and improve efficiency, the function of the hardware device originally integrated in the device base class may also be invoked according to the original flow. In this case, before the called function proposed in the present embodiment is adopted, it may also be determined whether the called function belongs to a default function originally integrated by the device base class in the computing framework, and when it is determined that the called function does not belong to the default function originally integrated by the device base class in the computing framework, the called function is called according to the procedure proposed in the present embodiment.
In particular, in an alternative embodiment, before determining the target device base class corresponding to the target device identifier, the called function is determined not to belong to a default function integrated by the device base class in the algorithm framework based on the target device identifier.
It should be understood that the default functionality herein refers to the functionality of the hardware device into which the device base class is originally integrated. Taking GPUDevice as an example, GPUDevice integrates functions of a GPU as default functions, and does not include functions of hardware devices of other device types.
According to the technical scheme provided by the embodiment of the application, the target function of the hardware equipment to be registered is registered in the algorithm framework by determining the equipment type matched with the hardware equipment to be registered. By adopting the scheme of the application, the access code supporting the algorithm frame does not need to be written and the frame code is recompiled, so that the efficiency of accessing the hardware equipment into the algorithm frame is improved.
The scheme of the application is described below by taking an algorithm framework as a deep learning framework as an example. As shown in fig. 2, the hardware device registration method may include the steps of:
in the scenario of the deep learning framework as an example, the method mainly comprises the following three parts:
step 201, definition statement of hardware device:
the definition of hardware equipment mainly comprises the following parts:
the basic information of the hardware device may specifically include an ID, a name, a device type, and a model of the hardware device, where the type specifies whether the GPU or the CPU, and the model is a device distinction of the same type, such as a manufacturer or other distinguishing information.
Two initialization modes for the hardware device are realized according to declaration definition, and further support to be directly compiled and generated from a protobuf file.
Step 202, registering functions of the hardware equipment:
firstly, defining a function mapping rule, wherein the function mapping rule indicates the corresponding relation between the hardware equipment and the function of the hardware equipment, and the corresponding relation can be realized by the equipment basic information of the hardware equipment and the function handle of the function.
Next, the above-described function mapping rule is implemented in a function management module (devicefuncfactor) in the deep learning framework. The device to be accessed can register the related functions into the devicefuncfactor through a function registration method.
In this way, the new hardware device is accessed into the deep learning framework, the new device base class is not required to be defined, only the existing device base class of the framework is required to be integrated, and then the specific function of the newly accessed hardware device is registered into the deviceFuncFactory through the function registration mechanism, so that the registration of the hardware device to the deep learning framework can be realized.
Step 203, performing function acquisition of the hardware device:
when the hardware device added into the deep learning framework needs to use the specific function, if the function of the specific function does not exist in the default function definition of the deep learning framework, a corresponding function handle can be acquired from the deviceFuncFactory through the acquired device identifier, and then the function is called.
From the above description, it can be seen that by performing extended definition on the hardware device access deep learning framework, the need for redefining a new hardware device and recompiling the framework code for accessing the new hardware device to the deep learning framework is simplified. The access of various subsequent new hardware devices can be seamlessly connected through the existing device definition and the expanded function management module of the deep learning framework, and the code development and realization of the access of the new hardware devices to the framework are facilitated.
The scheme of the application expands the equipment management of the existing deep learning framework, adds a function management module, and supports different hardware accesses to register in the deep learning framework; the work of defining a new device base class when the new hardware device is accessed is eliminated, and the workload of a developer for accessing the hardware into the deep learning framework is reduced; the device interface compatible with the existing framework can use the device registration interface of the existing framework, and a new registration mode does not need to be developed.
Based on the same concept, the embodiment of the present application provides a hardware device registration apparatus, and the specific implementation of the apparatus may refer to the description of the embodiment part of the method, and the repetition is omitted, as shown in fig. 3, where the apparatus mainly includes:
the acquiring module 301 acquires device basic information of the hardware device to be registered, a device basic class matched with the hardware device to be registered in the algorithm frame, and a target function to be registered of the hardware device to be registered;
a registration module 302, configured to register, with the algorithm framework, a target function of the hardware device to be registered, using the device basic information and the device base class.
The acquisition module 301 is configured to:
acquiring declaration definition of hardware equipment to be registered; acquiring basic information of the equipment from the declaration definition;
or alternatively, the first and second heat exchangers may be,
and acquiring a protocol buffer file corresponding to the hardware equipment to be registered, and compiling the protocol buffer file to obtain the basic information of the equipment.
The acquisition module 301 is configured to:
acquiring the device type corresponding to each device base class in the algorithm frame and the current device type of the hardware device to be registered;
determining a target device type matched with the current device type from the device types;
and determining the device base class corresponding to the target device type as the device base class matched with the hardware device to be registered.
The acquisition module 301 is configured to:
acquiring the current equipment type of the hardware equipment to be registered and the equipment type corresponding to the equipment base class;
inquiring a preset mapping relation by adopting the current equipment type and the equipment type to obtain a target function; the preset mapping relation is a corresponding relation between the equipment type of the hardware equipment and the function of the hardware equipment.
The registration module 302 is configured to:
generating a first target mapping relation, wherein the target mapping relation is a corresponding relation between basic information of equipment and function handles corresponding to target functions;
and adding a first target shooting relation in the mapping relation set corresponding to the equipment base class.
The device is also used for:
the method comprises the steps of utilizing device basic information and device basic classes to register target functions of hardware devices to be registered to an algorithm framework, and then obtaining device handles of the hardware devices to which the called functions belong;
acquiring a target device identifier of the hardware device based on the device handle;
determining a target equipment base class corresponding to the target equipment identifier;
acquiring a second target mapping relation corresponding to the target equipment identifier in the target equipment base class;
querying a second target mapping relation by adopting the identification of the called function to obtain a function handle corresponding to the called function;
the called function is called using the function handle.
The device is also used for:
before determining a target device base class corresponding to the target device identifier, determining that the called function does not belong to a default function of device base class integration in the algorithm framework based on the target device identifier.
Based on the same conception, the embodiment of the application also provides an electronic device, as shown in fig. 4, which mainly comprises: a processor 401, a memory 402 and a communication bus 403, wherein the processor 401 and the memory 402 perform communication with each other through the communication bus 403. The memory 402 stores a program executable by the processor 401, and the processor 401 executes the program stored in the memory 402 to implement the following steps:
acquiring basic information of equipment of the hardware equipment to be registered, equipment base class matched with the hardware equipment to be registered in an algorithm framework and a target function to be registered of the hardware equipment to be registered;
and registering the target function of the hardware device to be registered with the algorithm framework by using the device basic information and the device basic class.
The communication bus 403 mentioned in the above-mentioned electronic device may be a peripheral component interconnect standard (Peripheral Component Interconnect, abbreviated to PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, abbreviated to EISA) bus, or the like. The communication bus 403 may be classified into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in fig. 4, but not only one bus or one type of bus.
The memory 402 may include random access memory (Random Access Memory, simply RAM) or may include non-volatile memory (non-volatile memory), such as at least one disk memory. Alternatively, the memory may be at least one memory device located remotely from the aforementioned processor 401.
The processor 301 may be a general-purpose processor including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), a digital signal processor (Digital Signal Processing, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a Field programmable gate array (Field-Programmable Gate Array, FPGA), or other programmable logic device, discrete gate or transistor logic device, or discrete hardware components.
In yet another embodiment of the present application, there is also provided a computer-readable storage medium having stored therein a computer program which, when run on a computer, causes the computer to perform the hardware device registration method described in the above embodiment.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, the processes or functions described in accordance with embodiments of the present application are produced in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, by a wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)), or wireless (e.g., infrared, microwave, etc.) means from one website, computer, server, or data center to another. The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape, etc.), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk), etc.
It should be noted that in this document, relational terms such as "first" and "second" and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The foregoing is only a specific embodiment of the application to enable those skilled in the art to understand or practice the application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (9)

1. A hardware device registration method, comprising:
acquiring basic information of equipment of hardware equipment to be registered, equipment base class matched with the hardware equipment to be registered in an algorithm framework and target functions required to be registered by the hardware equipment to be registered; registering the target function of the hardware device to be registered with the algorithm framework by using the device basic information and the device base class;
obtaining a device base class matched with the hardware device to be registered in an algorithm framework, wherein the device base class comprises:
acquiring the device type corresponding to each device base class in the algorithm frame and the current device type of the hardware device to be registered;
determining a target equipment type matched with the current equipment type from the equipment types;
and determining the equipment base class corresponding to the target equipment type as the equipment base class matched with the hardware equipment to be registered.
2. The method of claim 1, wherein obtaining device basic information of a hardware device to be registered comprises:
acquiring declaration definition of the hardware equipment to be registered; acquiring the basic information of the equipment from the declaration definition;
or alternatively, the first and second heat exchangers may be,
and acquiring a protocol buffer file corresponding to the hardware equipment to be registered, and compiling the protocol buffer file to obtain the basic information of the equipment.
3. The method according to claim 1, wherein obtaining the target function that the hardware device to be registered needs to register comprises:
acquiring the current equipment type of the hardware equipment to be registered and the equipment type corresponding to the equipment base class;
inquiring a preset mapping relation by adopting the current equipment type and the equipment type to obtain the target function; the preset mapping relation is a corresponding relation between the equipment type of the hardware equipment and the function of the hardware equipment.
4. The method of claim 1, wherein registering the target function of the hardware device to be registered with the algorithm framework using the device base information and the device base class comprises:
generating a first target mapping relation, wherein the target mapping relation is a corresponding relation between the basic information of the equipment and a function handle corresponding to the target function;
and adding the first target relation in the mapping relation set corresponding to the equipment base class.
5. The method according to any one of claims 1-4, further comprising, after registering the target function of the hardware device to be registered with the algorithm framework using the device basic information and the device basic class:
acquiring a device handle of a hardware device to which the called function belongs;
acquiring a target device identifier of the hardware device based on the device handle;
determining a target equipment base class corresponding to the target equipment identifier;
acquiring a second target mapping relation corresponding to the target equipment identifier in the target equipment base class;
querying the second target mapping relation by adopting the identification of the called function to obtain a function handle corresponding to the called function;
and calling the called function by using the function handle.
6. The method of claim 5, further comprising, prior to determining the target device base class corresponding to the target device identification:
and determining that the called function does not belong to a default function of the device base class integration in the algorithm framework based on the target device identification.
7. A hardware device registration apparatus, comprising:
the acquisition module acquires equipment basic information of the hardware equipment to be registered, equipment basic classes matched with the hardware equipment to be registered in an algorithm framework and target functions required to be registered by the hardware equipment to be registered;
the registration module is used for registering the target function of the hardware device to be registered to the algorithm framework by utilizing the device basic information and the device basic class;
the acquisition module is used for:
acquiring the device type corresponding to each device base class in the algorithm frame and the current device type of the hardware device to be registered;
determining a target equipment type matched with the current equipment type from the equipment types;
and determining the equipment base class corresponding to the target equipment type as the equipment base class matched with the hardware equipment to be registered.
8. An electronic device, comprising: the device comprises a processor, a memory and a communication bus, wherein the processor and the memory are communicated with each other through the communication bus;
the memory is used for storing a computer program;
the processor is configured to execute a program stored in the memory, and implement the hardware device registration method of any one of claims 1 to 6.
9. A computer readable storage medium storing a computer program, wherein the computer program when executed by a processor implements the hardware device registration method of any one of claims 1-6.
CN202310448879.5A 2023-04-24 2023-04-24 Hardware device registration method, device, equipment and storage medium Active CN116185371B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310448879.5A CN116185371B (en) 2023-04-24 2023-04-24 Hardware device registration method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310448879.5A CN116185371B (en) 2023-04-24 2023-04-24 Hardware device registration method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN116185371A CN116185371A (en) 2023-05-30
CN116185371B true CN116185371B (en) 2023-09-19

Family

ID=86452479

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310448879.5A Active CN116185371B (en) 2023-04-24 2023-04-24 Hardware device registration method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116185371B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113835695A (en) * 2021-11-25 2021-12-24 之江实验室 Deep learning framework and hardware equipment adaptation method based on unified back-end engine
CN113918351A (en) * 2021-12-08 2022-01-11 之江实验室 Method and device for adapting to distributed training in deep learning framework and AI acceleration card
CN113918507A (en) * 2021-12-09 2022-01-11 之江实验室 Method and device for adapting deep learning framework to AI acceleration chip

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11164079B2 (en) * 2017-12-15 2021-11-02 International Business Machines Corporation Multi-GPU deep learning using CPUs

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113835695A (en) * 2021-11-25 2021-12-24 之江实验室 Deep learning framework and hardware equipment adaptation method based on unified back-end engine
CN113918351A (en) * 2021-12-08 2022-01-11 之江实验室 Method and device for adapting to distributed training in deep learning framework and AI acceleration card
CN113918507A (en) * 2021-12-09 2022-01-11 之江实验室 Method and device for adapting deep learning framework to AI acceleration chip

Also Published As

Publication number Publication date
CN116185371A (en) 2023-05-30

Similar Documents

Publication Publication Date Title
CN108696381B (en) Protocol configuration method and device
CN110365724B (en) Task processing method and device and electronic equipment
CN114580344A (en) Test excitation generation method, verification system and related equipment
CN112434278B (en) Bare metal authentication method, device, equipment and medium
CN114090623A (en) Method and device for creating cache resources, electronic equipment and storage medium
EP4350507A1 (en) Data processing system, method and apparatus
CN112286594B (en) Object serialization and deserialization method and device, electronic device and medium
CN110619204A (en) Invitation code generation method and device, terminal equipment and storage medium
CN116185371B (en) Hardware device registration method, device, equipment and storage medium
CN107133169B (en) Application test packet generation method and generation device
CN116107669A (en) Operator registration method, device and equipment of deep learning framework and storage medium
CN107341038B (en) Compatibility processing method and device and electronic equipment
CN112256252A (en) Interface generation method and device, storage medium and electronic equipment
US8997044B2 (en) Overriding system attributes and function returns in a software subsystem
WO2018121652A1 (en) Method and device for connecting wireless access point through application in user equipment
CN110471708B (en) Method and device for acquiring configuration items based on reusable components
CN114546410A (en) Code optimization method based on design mode and related equipment
CN113742156A (en) Joint debugging method and device, electronic equipment and storage medium
WO2021102616A1 (en) Smart contract development method and device, electronic apparatus, and storage medium
CN115150316A (en) Gateway control method, device, medium and gateway equipment based on dynamic routing
CN110168521B (en) Data processing apparatus and data processing method
CN118747248A (en) Multimode space-time resource processing method, device, equipment and readable storage medium
CN117827191B (en) Execution method, device, equipment and storage medium based on visual modeling
CN112596929B (en) Micro-service registration and calling method based on command event conversion and related device
US20240291890A1 (en) System and method for managing end point presenting devices

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant