Skip to content

Commit

Permalink
refactor(//core/runtime): Renaming execution -> runtime
Browse files Browse the repository at this point in the history
Signed-off-by: Naren Dasan <naren@narendasan.com>
Signed-off-by: Naren Dasan <narens@nvidia.com>
  • Loading branch information
narendasan committed Oct 21, 2020
1 parent b8fa228 commit b24c0d8
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 30 deletions.
2 changes: 1 addition & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pkg_tar(
"//core/conversion/tensorcontainer:include",
"//core/conversion/evaluators:include",
"//core/conversion/converters/impl/plugins:include",
"//core/execution:include",
"//core/runtime:include",
"//core/lowering:include",
"//core/lowering/passes:include",
"//core/util:include",
Expand Down
15 changes: 12 additions & 3 deletions core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ config_setting(
}
)

config_setting(
name = "python_core",
values = {
"define": "target_lang=python"
}
)

cc_library(
name = "core",
hdrs = [
Expand All @@ -17,7 +24,7 @@ cc_library(
],
deps = [
"//core/conversion",
"//core/execution",
"//core/runtime",
"//core/lowering",
"//core/util/logging",
"@tensorrt//:nvinfer"
Expand All @@ -28,11 +35,13 @@ cc_library(
alwayslink=True,
)


load("@rules_pkg//:pkg.bzl", "pkg_tar")

pkg_tar(
name = "include",
package_dir = "core/",
srcs = ["compiler.h"],
srcs = [
"backend.h",
"compiler.h",
],
)
8 changes: 4 additions & 4 deletions core/execution/BUILD → core/runtime/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ config_setting(
)

cc_library(
name = "execution",
name = "runtime",
hdrs = [
"execution.h",
"runtime.h",
],
srcs = [
"TRTEngine.cpp",
Expand All @@ -30,6 +30,6 @@ load("@rules_pkg//:pkg.bzl", "pkg_tar")

pkg_tar(
name = "include",
package_dir = "core/execution/",
srcs = ["execution.h"],
package_dir = "core/runtime/",
srcs = ["runtime.h"],
)
9 changes: 5 additions & 4 deletions core/execution/TRTEngine.cpp → core/runtime/TRTEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#include "torch/csrc/jit/frontend/function_schema_parser.h"

#include "core/util/prelude.h"
#include "core/execution/execution.h"
#include "core/runtime/runtime.h"

namespace trtorch {
namespace core {
namespace execution {
namespace runtime {

std::string slugify(std::string s) {
std::replace(s.begin(), s.end(), '.', '_');
Expand Down Expand Up @@ -81,6 +81,7 @@ TRTEngine::~TRTEngine() {
// return c10::List<at::Tensor>(output_vec);
// }

namespace {
static auto TRTORCH_UNUSED TRTEngineTSRegistrtion = torch::class_<TRTEngine>("tensorrt", "Engine")
.def(torch::init<std::string>())
// TODO: .def("__call__", &TRTEngine::Run)
Expand All @@ -94,7 +95,7 @@ static auto TRTORCH_UNUSED TRTEngineTSRegistrtion = torch::class_<TRTEngine>("te
return c10::make_intrusive<TRTEngine>(std::move(seralized_engine));
}
);

} // namespace execution
} // namespace
} // namespace runtime
} // namespace core
} // namespace trtorch
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#include "torch/csrc/jit/runtime/custom_operator.h"

#include "core/util/prelude.h"
#include "core/execution/execution.h"
#include "core/runtime/runtime.h"

namespace trtorch {
namespace core {
namespace execution {
namespace runtime {

std::vector<at::Tensor> execute_engine(std::vector<at::Tensor> inputs, c10::intrusive_ptr<TRTEngine> compiled_engine) {
LOG_DEBUG("Attempting to run engine (ID: " << compiled_engine->name << ")");
Expand Down
4 changes: 2 additions & 2 deletions core/execution/execution.h → core/runtime/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace trtorch {
namespace core {
namespace execution {
namespace runtime {

using EngineID = int64_t;

Expand All @@ -35,6 +35,6 @@ struct TRTEngine : torch::CustomClassHolder {

std::vector<at::Tensor> execute_engine(std::vector<at::Tensor> inputs, c10::intrusive_ptr<TRTEngine> compiled_engine);

} // namespace execution
} // namespace runtime
} // namespace core
} // namespace trtorch
9 changes: 4 additions & 5 deletions docsrc/contributors/phases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ The conversion phase is made up of three main components, a context to manage co
a evaluator library which will execute operations that can be resolved at compile time and a converter
library which maps an op from JIT to TensorRT.

Execution
^^^^^^^^^^^
Compilation and Runtime
^^^^^^^^^^^^^^^^^^^^^^^^
:ref:`execution`

The execution phase constructs a TorchScript program to run the converted TensorRT engine. It
The final compilation phase constructs a TorchScript program to run the converted TensorRT engine. It
takes a serialized engine and instantiates it within a engine manager, then the compiler will
build out a JIT graph that references this engine and wraps it in a module to return to the user.
When the user executes the module, the JIT program will look up the engine and pass the inputs
to it, then return the results.
When the user executes the module, the JIT program run in the JIT runtime extended by TRTorch with the data providied from the user.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.. _execution:

Execution Phase
Runtime Phase
================

The execution phase is responsible for constructing self standing TorchScript graphs with embedded TensorRT engines and serving as the runtime
The Runtime phase is responsible for constructing self standing TorchScript graphs with embedded TensorRT engines and serving as the runtime
when these engines are called. The main interface accepts a serialized TensorRT engine. The execution phase
will deserialize and wrap this engine in a class which maintains a execution context for each engine
and some metadata about its inputs and outputs and is compatable with the TorchScript interpreter so that
Expand Down
4 changes: 0 additions & 4 deletions docsrc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ Getting Started
tutorials/trtorchc
_notebooks/lenet

Notebooks
------------
* :ref:`lenet`

.. toctree::
:caption: Notebooks
:maxdepth: 1
Expand Down
6 changes: 3 additions & 3 deletions tests/util/run_graph_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "torch/csrc/jit/ir/irparser.h"
#include "torch/custom_class.h"
#include "core/conversion/conversion.h"
#include "core/execution/execution.h"
#include "core/runtime/runtime.h"
#include "cuda_runtime_api.h"

#include <vector>
Expand Down Expand Up @@ -43,8 +43,8 @@ std::vector<core::conversion::InputRange> toInputRangesDynamic(std::vector<at::T

std::vector<at::Tensor> RunEngine(std::string& eng, std::vector<at::Tensor> inputs) {
LOG_DEBUG("Running TRT version");
auto engine_ptr = c10::make_intrusive<trtorch::core::execution::TRTEngine>("test_engine", eng);
auto outputs = trtorch::core::execution::execute_engine(inputs, engine_ptr);
auto engine_ptr = c10::make_intrusive<trtorch::core::runtime::TRTEngine>("test_engine", eng);
auto outputs = trtorch::core::runtime::execute_engine(inputs, engine_ptr);
return outputs;
}

Expand Down

0 comments on commit b24c0d8

Please sign in to comment.