Skip to content

Refactor backends #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion include/glow/ExecutionEngine/ExecutionEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ class Variable;
class Tensor;
class Value;

enum class ExecutorKind {
Interpreter, // Execute the network with the built-in interpreter.
None,
};

/// This is the ExecutionEngine. It owns the Graph, the IR, and the backends.
/// The Graph, Module, etc in this class are defined as pointers, in order to
/// erase the type and prevent the internal types from leaking out to the
Expand All @@ -34,7 +39,7 @@ class ExecutionEngine final {
Trainer trainer_{};

public:
ExecutionEngine();
ExecutionEngine(ExecutorKind execKind = ExecutorKind::Interpreter);

~ExecutionEngine();

Expand Down
3 changes: 3 additions & 0 deletions src/glow/Backends/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

add_subdirectory(Interpreter)

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2017 Facebook Inc. All Rights Reserved.

#include "glow/Interpreter/Interpreter.h"
#include "glow/Backends/Interpreter/Interpreter.h"
#include "glow/Graph/Graph.h"
#include "glow/Graph/Nodes.h"
#include "glow/IR/Instrs.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2017 Facebook Inc. All Rights Reserved.

#include "glow/Backends/Interpreter/Interpreter.h"
#include "glow/IR/Instrs.h"
#include "glow/Interpreter/Interpreter.h"

#include "llvm/Support/Casting.h"

Expand Down
2 changes: 1 addition & 1 deletion src/glow/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

add_subdirectory(Backends)
add_subdirectory(Base)
add_subdirectory(ExecutionEngine)
add_subdirectory(Graph)
add_subdirectory(IR)
add_subdirectory(Importer)
add_subdirectory(Interpreter)
add_subdirectory(Optimizer)
add_subdirectory(Support)

16 changes: 13 additions & 3 deletions src/glow/ExecutionEngine/ExecutionEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,29 @@

#include "glow/ExecutionEngine/ExecutionEngine.h"

#include "glow/Backends/Interpreter/Interpreter.h"
#include "glow/Graph/Graph.h"
#include "glow/IR/IR.h"
#include "glow/IR/IRBuilder.h"
#include "glow/IR/Instrs.h"
#include "glow/Interpreter/Interpreter.h"
#include "glow/Optimizer/Optimizer.h"

using namespace glow;

ExecutionEngine::ExecutionEngine() {
ExecutionEngine::ExecutionEngine(ExecutorKind execKind) {
G_ = std::unique_ptr<Graph>(new Graph());
M_ = std::unique_ptr<Module>(new Module(&*G_));
IP_ = std::unique_ptr<Interpreter>(new Interpreter(&*M_));

switch (execKind) {
case ExecutorKind::Interpreter:
IP_ = std::unique_ptr<Interpreter>(new Interpreter(&*M_));
break;

default:
// Unknown execution backend.
glow_unreachable();
break;
}
}

ExecutionEngine::~ExecutionEngine() = default;
Expand Down