From: Alexander Sidorov Date: Fri, 22 Mar 2019 18:49:04 +0000 (-0700) Subject: Caffe2: crash op (#18207) X-Git-Tag: accepted/tizen/6.5/unified/20211028.231830~681 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d4c52158c7e6e2c8397196f0ec31f9a47f7b5ca1;p=platform%2Fupstream%2Fpytorch.git 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 --- 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