From d4c52158c7e6e2c8397196f0ec31f9a47f7b5ca1 Mon Sep 17 00:00:00 2001 From: Alexander Sidorov Date: Fri, 22 Mar 2019 11:49:04 -0700 Subject: [PATCH] Caffe2: crash op (#18207) Summary: this is handy when testing various core dump related things. If in the future we want to unit test our future gdb debugger extensions, we can use this op to generate a core dump for us within a unit test. Pull Request resolved: https://github.com/pytorch/pytorch/pull/18207 Differential Revision: D14482186 Pulled By: salexspb fbshipit-source-id: 39a9fffbdd4bd083597f544d1c783a82cf023a89 --- caffe2/operators/crash_op.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 caffe2/operators/crash_op.cc diff --git a/caffe2/operators/crash_op.cc b/caffe2/operators/crash_op.cc new file mode 100644 index 0000000..a7bb9b1 --- /dev/null +++ b/caffe2/operators/crash_op.cc @@ -0,0 +1,25 @@ +#if defined(__linux__) + +#include "caffe2/core/context.h" +#include "caffe2/core/operator.h" + +namespace caffe2 { + +class CrashOp final : public Operator { + public: + CrashOp(const OperatorDef& operator_def, Workspace* ws) + : Operator(operator_def, ws) {} + + bool RunOnDevice() override { + raise(SIGABRT); + return true; + } +}; + +OPERATOR_SCHEMA(Crash).NumInputs(0).NumOutputs(0).SetDoc( + R"DOC(Crashes the program. Use for testing)DOC"); + +REGISTER_CPU_OPERATOR(Crash, CrashOp); + +} // namespace caffe2 +#endif -- 2.7.4