Improved Exception Handling in MXNet Examples Example 1

  • Slides: 24
Download presentation
Improved Exception Handling in MXNet

Improved Exception Handling in MXNet

Examples Example 1 (Operators) Example 2 (Iterators) import mxnet as mx data_path = ‘manual_2.

Examples Example 1 (Operators) Example 2 (Iterators) import mxnet as mx data_path = ‘manual_2. csv’ try: data_train = mx. io. CSVIter(data_csv=data_path, data_shape=(-4, 10), batch_size=1) except mx. base. MXNet. Error: print ‘Exception Handled’ try: mx. nd. random_normal(0, 1, (2, 3)) mx. nd. waitall() except mx. base. MXNet. Error: print ‘Exception Handled’

Result terminate called after throwing an instance of 'dmlc: : Error' what(): [02: 32:

Result terminate called after throwing an instance of 'dmlc: : Error' what(): [02: 32: 04]. . /src/engine/. /threaded_engine. h: 359: [02: 32: 04]. . /src/operator/random/. /sample_op. h: 301: Check failed: param. scale > 0 (-1 vs. 0) scale parameter in gaussian has to be positive Stack trace returned 10 entries: [bt] (0) /home/ubuntu/sparse_support/mxnet/python/mxnet/. . /build/libmxnet. so(_ZN 4 dmlc 10 S tack. Trace. B 5 cxx 11 Ev+0 x 54) [0 x 7 eff 0140 bf 5 b] [bt] (1) /home/ubuntu/sparse_support/mxnet/python/mxnet/. . /build/libmxnet. so(_ZN 4 dmlc 15 L og. Message. Fatal. D 1 Ev+0 x 2 a) [0 x 7 eff 0140 c 242] [bt] (2) /home/ubuntu/sparse_support/mxnet/python/mxnet/. . /build/libmxnet. so(_ZN 5 mxnet 2 o p 12 Sample. Master. IN 7 mshadow 3 cpu. ENS 0_13 Normal. Sampler. IS 3_EEE 2 op. ERKN 4 nnvm 9 Node. Attrs. ERKN S_9 Op. Context. ERKNS_9 Op. Req. Type. EPNS_5 TBlob. E+0 x 120) [0 x 7 eff 01 a 56 c 8 a]

Records in Record IO Format/ Custom Format Data Parser and Loader Queue of exception_ptrs

Records in Record IO Format/ Custom Format Data Parser and Loader Queue of exception_ptrs b 3 b 0 b 1 Exception caught and moved to parent thread Exception thrown Uses info from all exception_ptrs in queue to throw exception Image Conv-64 b 2 softmax Child Thread b 0 Main Thread

Exception Handling for Operators Dependency Engine – Decides if operator is ready to execute

Exception Handling for Operators Dependency Engine – Decides if operator is ready to execute Executors - Decides how to execute

Exception Handling for Operators Dependency Engine – Decides if operator is ready to execute

Exception Handling for Operators Dependency Engine – Decides if operator is ready to execute Executors - Decides how to execute Push an operator which is ready for execution

Exception Handling for Operators Dependency Engine – Decides if operator is ready to execute

Exception Handling for Operators Dependency Engine – Decides if operator is ready to execute Executors - Decides how to execute Execute. Opr. Block Execute. Opr On. Complete. Callback Push an operator which is ready for execution

Exception Handling for Operators Dependency Engine – Decides if operator is ready to execute

Exception Handling for Operators Dependency Engine – Decides if operator is ready to execute Executors - Decides how to execute Push an operator which is ready for execution Rethrow exception at the end of Wait. For. Var or Wait. For. All Execute. Opr. Block Onstart callback try { Execute. Opr } catch { Make exception_ptr member for opr point to the current exception } On. Complete callback

Exception Handling for Operators A=1 C=1 K=A+C E=K Wait. For. Var(E) Completed Operations Execute.

Exception Handling for Operators A=1 C=1 K=A+C E=K Wait. For. Var(E) Completed Operations Execute. Opr. Block Operations not executed

Exception Handling for Operators K=A+C E=K Wait. For. Var(E) Execute. Opr. Block A=1 Completed

Exception Handling for Operators K=A+C E=K Wait. For. Var(E) Execute. Opr. Block A=1 Completed Operations not executed

Exception Handling for Operators K=A+C E=K Wait. For. Var(E) Execute. Opr. Block A=1 Completed

Exception Handling for Operators K=A+C E=K Wait. For. Var(E) Execute. Opr. Block A=1 Completed Operations not executed/errored

Exception Handling for Operators E=K Wait. For. Var(E) Execute. Opr. Block K=A+C Completed Operations

Exception Handling for Operators E=K Wait. For. Var(E) Execute. Opr. Block K=A+C Completed Operations A=1 C=1 Operations not executed/errored

Exception Handling for Operators E=K Wait. For. Var(E) Execute. Opr. Block K = A

Exception Handling for Operators E=K Wait. For. Var(E) Execute. Opr. Block K = A + C ->Throws exception K=A+C K Completed Operations A=1 C=1 Operations not executed/errored

Exception Handling for Operators E=K Wait. For. Var(E) Execute. Opr. Block K = A

Exception Handling for Operators E=K Wait. For. Var(E) Execute. Opr. Block K = A + C ->Throws exception K=A+C K Completed Operations A=1 C=1 Operations not executed/errored

Exception Handling for Operators E=K Wait. For. Var(E) Execute. Opr. Block Completed Operations A=1

Exception Handling for Operators E=K Wait. For. Var(E) Execute. Opr. Block Completed Operations A=1 C=1 Operations not executed/errored K=A+C

Exception Handling for Operators Wait. For. Var(E) Execute. Opr. Block E=K Completed Operations A=1

Exception Handling for Operators Wait. For. Var(E) Execute. Opr. Block E=K Completed Operations A=1 C=1 Operations not executed/errored K=A+C

Exception Handling for Operators Wait. For. Var(E) Execute. Opr. Block E=K E Completed Operations

Exception Handling for Operators Wait. For. Var(E) Execute. Opr. Block E=K E Completed Operations A=1 C=1 Operations not executed/errored K=A+C

Exception Handling for Operators Wait. For. Var(E) Execute. Opr. Block Completed Operations A=1 C=1

Exception Handling for Operators Wait. For. Var(E) Execute. Opr. Block Completed Operations A=1 C=1 Operations not executed/errored K=A+C E=K

Exception Handling for Operators Execute. Opr. Block Wait. For. Var(E) Completed Operations A=1 C=1

Exception Handling for Operators Execute. Opr. Block Wait. For. Var(E) Completed Operations A=1 C=1 Operations not executed/errored K=A+C E=K

Exception Handling for Operators Notifies main thread at end of execution. Exception thrown from

Exception Handling for Operators Notifies main thread at end of execution. Exception thrown from main thread, caught and movable to frontend Execute. Opr. Block Wait. For. Var(E) – Since it is a wait it won’t be prevented from execution Completed Operations A=1 C=1 Operations not executed/errored K=A+C E=K

Exception Handling for Operators Notifies main thread at end of execution. Exception thrown from

Exception Handling for Operators Notifies main thread at end of execution. Exception thrown from main thread, caught and movable to frontend Execute. Opr. Block Wait. For. Var(E) – Since it is a wait it won’t be prevented from execution Completed Operations A=1 C=1 Operations not executed/errored K=A+C E=K

After the Exception Handling Change Example Result Import mxnet as mx Prints Exception Handled

After the Exception Handling Change Example Result Import mxnet as mx Prints Exception Handled try: mx. nd. random_normal(0, 1, (2, 3)) mx. nd. waitall() except mx. base. MXNet. Error: print ‘Exception Handled’

Links • Wiki: https: //cwiki. apache. org/confluence/display/MXNET/Improved+exce ption+handling+in+MXNet • Issues: https: //github. com/apache/incubator-mxnet/issues/7335

Links • Wiki: https: //cwiki. apache. org/confluence/display/MXNET/Improved+exce ption+handling+in+MXNet • Issues: https: //github. com/apache/incubator-mxnet/issues/7335

Thank you

Thank you