Skip to content

Commit 7f0997e

Browse files
committed
rename subgraph executor into pipeline executor
1 parent f553674 commit 7f0997e

File tree

10 files changed

+88
-91
lines changed

10 files changed

+88
-91
lines changed

CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,11 @@ if(USE_PROFILER)
351351
list(APPEND RUNTIME_SRCS ${RUNTIME_VM_PROFILER_SRCS})
352352
endif(USE_PROFILER)
353353

354-
if(USE_SUBGRAPH_EXECUTOR)
355-
message(STATUS "Build with Subgraph Executor support...")
356-
file(GLOB RUNTIME_SUBGRAPH_SRCS src/runtime/subgraph/*.cc)
357-
list(APPEND RUNTIME_SRCS ${RUNTIME_SUBGRAPH_SRCS})
358-
endif(USE_SUBGRAPH_EXECUTOR)
354+
if(USE_PIPELINE_EXECUTOR)
355+
message(STATUS "Build with Pipeline Executor support...")
356+
file(GLOB RUNTIME_PIPELINE_SRCS src/runtime/pipeline/*.cc)
357+
list(APPEND RUNTIME_SRCS ${RUNTIME_PIPELINE_SRCS})
358+
endif(USE_PIPELINE_EXECUTOR)
359359

360360
# Module rules
361361
include(cmake/modules/VTA.cmake)

cmake/config.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ set(USE_STACKVM_RUNTIME OFF)
9999
# Whether enable tiny embedded graph executor.
100100
set(USE_GRAPH_EXECUTOR ON)
101101
# Whether enable subgraph runtime.
102-
set(USE_SUBGRAPH_EXECUTOR ON)
102+
set(USE_PIPELINE_EXECUTOR ON)
103103

104104
# Whether enable tiny graph executor with CUDA Graph
105105
set(USE_GRAPH_EXECUTOR_CUDA_GRAPH OFF)

python/tvm/contrib/subgraph_executor.py renamed to python/tvm/contrib/pipeline_executor.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
"""Minimum subgraph executor that executes subgraph containing TVM PackedFunc."""
17+
"""Minimum pipeline executor that executes pipeline containing TVM PackedFunc."""
1818
import tvm._ffi
1919
from tvm.contrib import graph_executor
2020

2121

2222
def create(sub_mods):
23-
"""Create a subgraph runtime executor.
23+
"""Create a pipeline runtime executor.
2424
2525
Parameters
2626
----------
@@ -30,19 +30,19 @@ def create(sub_mods):
3030
3131
Returns
3232
-------
33-
submodule : SubGraphModule
34-
Runtime subgraph module.
33+
submodule : PipelineModule
34+
Runtime pipeline module.
3535
"""
3636
mods = []
3737
for sub_mod in sub_mods:
3838
mod = graph_executor.GraphModule(sub_mod["default"](sub_mods[sub_mod]["dev"]))
3939
mods.append(mod)
4040

41-
submodule = SubGraphModule(mods)
41+
submodule = PipelineModule(mods)
4242
return submodule
4343

4444

45-
class SubGraphModule(object):
45+
class PipelineModule(object):
4646
"""Wrapper runtime module.
4747
4848
This is a thin wrapper of the underlying TVM module.
@@ -66,8 +66,8 @@ def __init__(self, graph_modules):
6666
for module in graph_modules:
6767
mods.append(module.module)
6868

69-
subgraphcreate = tvm._ffi.get_global_func("tvm.subgraph_executor.create")
70-
module = subgraphcreate(mods)
69+
pipelinecreate = tvm._ffi.get_global_func("tvm.pipeline_executor.create")
70+
module = pipelinecreate(mods)
7171

7272
self.graph_modules_ = graph_modules
7373

@@ -115,7 +115,7 @@ def run(self, **input_dict):
115115
self._run()
116116

117117
def stop(self):
118-
"""Stop subgraph run"""
118+
"""Stop pipeline run"""
119119
self._stop()
120120

121121
def get_num_outputs(self):

src/runtime/subgraph/subgraph_data.h renamed to src/runtime/pipeline/pipeline_data.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
#ifndef TVM_RUNTIME_SUBGRAPH_SUBGRAPH_DATA_H_
20-
#define TVM_RUNTIME_SUBGRAPH_SUBGRAPH_DATA_H_
19+
#ifndef TVM_RUNTIME_PIPELINE_PIPELINE_DATA_H_
20+
#define TVM_RUNTIME_PIPELINE_PIPELINE_DATA_H_
2121
#define EXPORT __attribute__((visibility("default")))
2222
#define IMPORT
2323
#include <condition_variable>
2424
#include <cstddef>
2525
#include <mutex>
2626
#include <thread>
2727

28-
#include "subgraph_struct.h"
28+
#include "pipeline_struct.h"
2929
#ifdef __cplusplus
3030

3131
#define read_barrier() std::atomic_thread_fence(std::memory_order_acquire)
@@ -71,4 +71,4 @@ bool q_poll(squeue<SLOT_TYPE>* q, VARIABLE_TYPE* s) {
7171
// extern "C"
7272
#endif
7373

74-
#endif // TVM_RUNTIME_SUBGRAPH_SUBGRAPH_DATA_H_
74+
#endif // TVM_RUNTIME_PIPELINE_PIPELINE_DATA_H_

src/runtime/subgraph/subgraph_executor.cc renamed to src/runtime/pipeline/pipeline_executor.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,26 @@
1818
*/
1919

2020
/*!
21-
* \file subgraph_runtime.cc
21+
* \file pipeline_runtime.cc
2222
*/
23-
#include "subgraph_executor.h"
23+
#include "pipeline_executor.h"
2424

2525
#include <tvm/runtime/registry.h>
2626

2727
namespace tvm {
2828
namespace runtime {
2929

3030
/*!
31-
*\bief Stop subgraph run.
31+
*\bief Stop pipeline run.
3232
*/
33-
void SubGraphRuntime::Stop() { subgraph_stop(runtimes); }
33+
void SubGraphRuntime::Stop() { pipeline_stop(runtimes); }
3434
/*!
3535
* \brief Run all the operations one by one.
3636
*/
37-
void SubGraphRuntime::Run() { subgraph_run(runtimes); }
37+
void SubGraphRuntime::Run() { pipeline_run(runtimes); }
3838

3939
void SubGraphRuntime::Init(const Array<tvm::runtime::Module>& modules) {
40-
subgraph_init(modules, &runtimes);
40+
pipeline_init(modules, &runtimes);
4141
SetupStorage();
4242
return;
4343
}
@@ -77,14 +77,14 @@ void SubGraphRuntime::SetInput(const std::string& name, DLTensor* data_in) {
7777
/*!
7878
* \brief Get the number of outputs
7979
*
80-
* \return The number of outputs from last subgraph.
80+
* \return The number of outputs from last pipeline.
8181
*/
8282
int SubGraphRuntime::NumOutputs() const { return runtimes.back()->runtimePtr->NumOutputs(); }
8383

8484
/*!
8585
* \brief Get the number of inputs
8686
*
87-
* \return The number of inputs to the first subgraph.
87+
* \return The number of inputs to the first pipeline.
8888
*/
8989
int SubGraphRuntime::NumInputs() const { return runtimes.front()->runtimePtr->NumInputs(); }
9090

@@ -111,7 +111,7 @@ NDArray SubGraphRuntime::GetInput(const std::string& name, int mIndx) const {
111111
*/
112112
Array<NDArray> SubGraphRuntime::GetOutput(bool syncPoll) {
113113
Array<NDArray> nd;
114-
if (subgraph_poll(&output_entry_, runtimes, syncPoll)) {
114+
if (pipeline_poll(&output_entry_, runtimes, syncPoll)) {
115115
for (auto output : output_entry_) {
116116
nd.push_back(output);
117117
}
@@ -169,14 +169,14 @@ PackedFunc SubGraphRuntime::GetFunction(const std::string& name,
169169
}
170170
}
171171

172-
Module SubGraphRuntimeCreate(const Array<tvm::runtime::Module>& m) {
172+
Module PipelineRuntimeCreate(const Array<tvm::runtime::Module>& m) {
173173
auto exec = make_object<SubGraphRuntime>();
174174
exec->Init(m);
175175
return Module(exec);
176176
}
177177

178-
TVM_REGISTER_GLOBAL("tvm.subgraph_executor.create").set_body([](TVMArgs args, TVMRetValue* rv) {
179-
*rv = SubGraphRuntimeCreate(args[0]);
178+
TVM_REGISTER_GLOBAL("tvm.pipeline_executor.create").set_body([](TVMArgs args, TVMRetValue* rv) {
179+
*rv = PipelineRuntimeCreate(args[0]);
180180
});
181181
} // namespace runtime
182182
} // namespace tvm

src/runtime/subgraph/subgraph_executor.h renamed to src/runtime/pipeline/pipeline_executor.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@
2222
* containing only tvm PackedFunc.
2323
* \file graph_runtime.h
2424
*/
25-
#ifndef TVM_RUNTIME_SUBGRAPH_SUBGRAPH_EXECUTOR_H_
26-
#define TVM_RUNTIME_SUBGRAPH_SUBGRAPH_EXECUTOR_H_
25+
#ifndef TVM_RUNTIME_PIPELINE_PIPELINE_EXECUTOR_H_
26+
#define TVM_RUNTIME_PIPELINE_PIPELINE_EXECUTOR_H_
2727
#include <memory>
2828
#include <string>
2929
#include <vector>
3030

31-
#include "subgraph_function.h"
31+
#include "pipeline_function.h"
3232

3333
namespace tvm {
3434
namespace runtime {
3535

3636
/*!
37-
* \brief subgraph runtime.
37+
* \brief pipeline runtime.
3838
*
3939
* This runtime can be acccesibly in various language via
4040
* TVM runtime PackedFunc API.
@@ -106,4 +106,4 @@ class TVM_DLL SubGraphRuntime : public ModuleNode {
106106
} // namespace runtime
107107
} // namespace tvm
108108

109-
#endif // TVM_RUNTIME_SUBGRAPH_SUBGRAPH_EXECUTOR_H_
109+
#endif // TVM_RUNTIME_PIPELINE_PIPELINE_EXECUTOR_H_

src/runtime/subgraph/subgraph_function.cc renamed to src/runtime/pipeline/pipeline_function.cc

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
#include "subgraph_function.h"
19+
#include "pipeline_function.h"
2020

2121
#include <utility>
2222
using namespace tvm::runtime;
2323

24-
void subgraph_pipeline_run(const int& num, const shared_ptr<RuntimeItem>& curRunItem) {
24+
void pipeline_pipeline_run(const int& num, const shared_ptr<RuntimeItem>& curRunItem) {
2525
QUEUE* curQueue = curRunItem->queue;
2626
QUEUE* nextQueue = curRunItem->next->queue;
2727

@@ -31,28 +31,28 @@ void subgraph_pipeline_run(const int& num, const shared_ptr<RuntimeItem>& curRun
3131
*/
3232
bool suc = false;
3333
while (curRunItem->waitPipeLineData(suc)) {
34-
suc = subgraph_queue_poll(curQueue, &curRunItem->rData);
34+
suc = pipeline_queue_poll(curQueue, &curRunItem->rData);
3535
if (!suc) {
3636
continue;
3737
}
3838

3939
curRunItem->Run();
4040

4141
auto output = curRunItem->GetOutput();
42-
subgraph_queue_push(nextQueue, output);
42+
pipeline_queue_push(nextQueue, output);
4343
curRunItem->notifyDataReadyToNext();
4444
}
4545
curRunItem->notifyNextExit();
4646
}
4747

48-
thread* subgraph_pipeline_init(SHARED_RUNTIME_VEC* runtimes) {
48+
thread* pipeline_pipeline_init(SHARED_RUNTIME_VEC* runtimes) {
4949
for (size_t i = 1; i < runtimes->size(); i++) {
50-
(*runtimes)[i]->t = thread(subgraph_pipeline_run, i, (*runtimes)[i]);
50+
(*runtimes)[i]->t = thread(pipeline_pipeline_run, i, (*runtimes)[i]);
5151
}
5252
return NULL;
5353
}
5454

55-
void subgraph_init(Array<Module> graphRuntimes, SHARED_RUNTIME_VEC* runtimes) {
55+
void pipeline_init(Array<Module> graphRuntimes, SHARED_RUNTIME_VEC* runtimes) {
5656
int len = graphRuntimes.size();
5757
for (int i = 0; i < len; i++) {
5858
QUEUE* sub_queue = createQueue<SLOT>(NULL, SUB_Q_SIZE);
@@ -69,43 +69,43 @@ void subgraph_init(Array<Module> graphRuntimes, SHARED_RUNTIME_VEC* runtimes) {
6969
(*runtimes)[i]->next = (*runtimes)[0];
7070
}
7171
}
72-
subgraph_pipeline_init(runtimes);
72+
pipeline_pipeline_init(runtimes);
7373
return;
7474
}
7575

76-
inline void subgraph_queue_push(QUEUE* queue, Array<NDArray> arrays) {
76+
inline void pipeline_queue_push(QUEUE* queue, Array<NDArray> arrays) {
7777
q_push<SLOT, Array<NDArray>>(queue, arrays);
7878
return;
7979
}
8080

81-
bool subgraph_queue_poll(QUEUE* queue, RuntimeData* runtimeData) {
81+
bool pipeline_queue_poll(QUEUE* queue, RuntimeData* runtimeData) {
8282
return q_poll<SLOT, RuntimeData>(queue, runtimeData);
8383
}
8484

85-
void subgraph_run(const SHARED_RUNTIME_VEC& runtimes) {
85+
void pipeline_run(const SHARED_RUNTIME_VEC& runtimes) {
8686
shared_ptr<RuntimeItem> runtime = runtimes.front();
8787
runtime->Run();
88-
subgraph_queue_push(runtime->next->queue, runtime->GetOutput());
88+
pipeline_queue_push(runtime->next->queue, runtime->GetOutput());
8989
runtime->notifyDataReadyToNext();
9090
return;
9191
}
9292

93-
bool subgraph_poll(vector<NDArray>* output, const SHARED_RUNTIME_VEC& runtimes, const bool bSynch) {
93+
bool pipeline_poll(vector<NDArray>* output, const SHARED_RUNTIME_VEC& runtimes, const bool bSynch) {
9494
shared_ptr<RuntimeItem> firstRuntime = runtimes.front();
9595
QUEUE* queue = firstRuntime->queue;
9696
bool suc = false;
97-
subgraphOutputData<> outputData(output);
98-
suc = q_poll<SLOT, subgraphOutputData<>>(queue, &outputData);
97+
pipelineOutputData<> outputData(output);
98+
suc = q_poll<SLOT, pipelineOutputData<>>(queue, &outputData);
9999
while (!suc && bSynch) {
100100
/*
101101
* If get exit notify then break.
102102
*/
103103
if (!firstRuntime->waitPipeLineData(!bSynch)) {
104104
break;
105105
}
106-
suc = q_poll<SLOT, subgraphOutputData<>>(queue, &outputData);
106+
suc = q_poll<SLOT, pipelineOutputData<>>(queue, &outputData);
107107
}
108108
return suc;
109109
}
110110

111-
void subgraph_stop(const SHARED_RUNTIME_VEC& runtimes) { runtimes.front()->notifyNextExit(); }
111+
void pipeline_stop(const SHARED_RUNTIME_VEC& runtimes) { runtimes.front()->notifyNextExit(); }

src/runtime/subgraph/subgraph_function.h renamed to src/runtime/pipeline/pipeline_function.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
#ifndef TVM_RUNTIME_SUBGRAPH_SUBGRAPH_FUNCTION_H_
20-
#define TVM_RUNTIME_SUBGRAPH_SUBGRAPH_FUNCTION_H_
19+
#ifndef TVM_RUNTIME_PIPELINE_PIPELINE_FUNCTION_H_
20+
#define TVM_RUNTIME_PIPELINE_PIPELINE_FUNCTION_H_
2121
#include <memory>
2222
#include <vector>
2323

24-
#include "subgraph_data.h"
24+
#include "pipeline_data.h"
2525

2626
using namespace std;
2727
using namespace tvm::runtime;
2828
typedef vector<shared_ptr<RuntimeItem>> SHARED_RUNTIME_VEC;
2929

30-
void subgraph_init(Array<Module> graphRuntimes, SHARED_RUNTIME_VEC* runtimes);
31-
void subgraph_run(const SHARED_RUNTIME_VEC& runtimes);
32-
inline void subgraph_queue_push(QUEUE* queue, Array<NDArray> arrays);
33-
bool subgraph_queue_poll(QUEUE* queue, RuntimeData* runtimeData);
34-
bool subgraph_poll(vector<NDArray>* output, const SHARED_RUNTIME_VEC& runtimes,
30+
void pipeline_init(Array<Module> graphRuntimes, SHARED_RUNTIME_VEC* runtimes);
31+
void pipeline_run(const SHARED_RUNTIME_VEC& runtimes);
32+
inline void pipeline_queue_push(QUEUE* queue, Array<NDArray> arrays);
33+
bool pipeline_queue_poll(QUEUE* queue, RuntimeData* runtimeData);
34+
bool pipeline_poll(vector<NDArray>* output, const SHARED_RUNTIME_VEC& runtimes,
3535
const bool bSync = false);
36-
void subgraph_stop(const SHARED_RUNTIME_VEC& runtimes);
36+
void pipeline_stop(const SHARED_RUNTIME_VEC& runtimes);
3737

38-
#endif // TVM_RUNTIME_SUBGRAPH_SUBGRAPH_FUNCTION_H_
38+
#endif // TVM_RUNTIME_PIPELINE_PIPELINE_FUNCTION_H_

0 commit comments

Comments
 (0)