#include "passes/interpreter/InterpreterPass.h"
#include "passes/soft_backend/CPPGenerator.h"
+#include "passes/dot_dumper/DumperPass.h"
#include "passes/acl_soft_backend/AclCppGenerator.h"
#include "support/CommandLine.h"
#include "Definitions.h"
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NNCC_DUMPERPASS_H
+#define NNCC_DUMPERPASS_H
+
+#include "pass/Pass.h"
+#include "pass/PassData.h"
+#include "core/modelIR/IrDotDumper.h"
+
+namespace nnc {
+
+/**
+ * @brief Dumps the graph to a dot file named %number%.dot
+ * where %number% is how many times the graph was dumped.
+ */
+class DumperPass : public Pass {
+public:
+
+ PassData run(PassData data) override;
+
+private:
+ static int _counter;
+};
+
+} // namespace nnc
+#endif //NNCC_DUMPERPASS_H
#
set(DEF_CONV ${NNC_ROOT_SRC_DIR}/utils/def2src.cpp)
add_executable(def2src ${DEF_CONV})
+add_subdirectory(dot_dumper)
#
# FRONTENDs
--- /dev/null
+file(GLOB_RECURSE DUMPER_SRC ./*.cpp ./*.h)
+nnc_add_library(nnc_dumper SHARED ${DUMPER_SRC})
+target_link_libraries(nnc_dumper PRIVATE nnc_core nnc_support)
+
+# install dumper library
+nnc_install_library(nnc_dumper)
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "passes/dot_dumper/DumperPass.h"
+#include "core/modelIR/Graph.h"
+#include "pass/PassException.h"
+
+#include <fstream>
+#include <fstream>
+
+namespace nnc {
+
+using namespace mir;
+int DumperPass::_counter = 0;
+
+PassData DumperPass::run(PassData data) {
+ auto g = static_cast<Graph*>(data);
+ assert(g);
+ IrDotDumper dotDumper;
+ g->accept(&dotDumper);
+ std::ofstream f_out;
+ f_out.open(std::to_string(_counter) + ".dot");
+ dotDumper.writeDot(f_out);
+ f_out.close();
+
+ _counter++;
+ return g;
+}
+
+} // namespace nnc