MXNet currently has support for handling dmlc::Error exceptions in the backend and propagating them to frontend for both the operators and the iterators case.

There is still some work needed w.r.t Exception Handling. This document lists out all the further improvements that can be done for the exception handling feature.

Improved Exception Types for the Backend

Currently, there are only three exceptions available for MXNet C++ backend: dmlc::Error, InferTypeError (inherits from dmlc::Error) and InferShapeError(inherits from dmlc::Error).

There are more scenarios where exceptions are thrown. Here are some examples: MemoryAllocationError, ConfigurationError(GPU_ENABLED), KVStoreError.

Add support for these exceptions in C++ backend. Exceptions that can be shared with dmlc-core should go in dmlc-core. 

Here is the implementation of dmlc::Error:

Here are a few examples for the other exceptions inheriting from dmlc::Error:


Improved Exception Types for the Frontend Language Bindings - (Python, Scala, Perl..)

Will require a mapping of error codes and corresponding frontend exceptions.

The setting of error code for the frontend exception currently happens here:

Frontend exception checking for Python example:

Support for handling exception thrown from consumed libraries

Currently we are handling only dmlc::Error and terminating the process for other exceptions. Once we have finished the above two tasks,

It should be easy to add exception mapping in the frontend corresponding to std::exception in backend. This will ensure that all exceptions inheriting from dmlc::Error 

and std::exception are handled and propagated to frontend.



  • No labels