Skip to content

March 1 Update. Backend API changes

Roman L edited this page Mar 1, 2019 · 2 revisions

API changes Week of 2/25

CPU Backend:

We have re-factored the CPU backend and moved the re-usable parts of it into a dedicated library called LLVMIRCodeGen (#2461). This library defines types LLVMBackend, LLVMCompiledFunction and LLVMIRGen that can be used to quickly create new LLVM IR based backends. Such backends just need to derived from those new classes and define how to handle custom backend-specific instructions. All the common functionality can be delegated to the LLVMIRCodeGen library. The CPU backend is re-factored to use this new library. The APIs of the CPU backend have not changed, but its implementation was significantly changed. If your backend is based on the CPU backend you may want to check if this re-factoring has broken any functionality on your side.

Backends:

We have updated the Backend::isOpSupported() API, so that it now takes a single NodeInfo as a parameter. NodeInfo is a helper class that represents information about a Node (NodeKind as well as the input and output types). This change allows backends to provide better answers about what they do and do not support; for example, the backend can now specify that it supports a ConvolutionNodeKind with Int32QTy Bias, but not Int8QTy Bias.

As the compilation process has become more configurable we have changed the compile() interface to take a new CompilationOptions struct (#2451, #2459). This allows us to eliminate the interface methods compileWithoutConstants and instrumentAndCompile and replace them with flags in the CompilationOptions. The existing compile method that takes a CompilationMode enumeration is maintained for backwards compatibility.

DeviceManager:

A change to the ExecutionEngine this week (#2431) means a DeviceManager is now required for running unit tests and many examples. If a backend does not have a DeviceManager implementation it will default to the new DummyDeviceManager wrapper, but we recommend implementing a DeviceManager specific for your backend to ease integration in to the Runtime components. The DeviceManager interface itself has changed as well (#2437) adding return codes to init and stop, and a callback to evictNetwork.