Skip to content

Commit bbd17bd

Browse files
authored
[onert] Add BulkPipelineLayer implementation for trix backend (#16343)
It adds new BulkPipelineLayer class to handle bulk pipeline operations in the trix backend. ONE-DCO-1.0-Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
1 parent d3587cc commit bbd17bd

File tree

2 files changed

+126
-0
lines changed

2 files changed

+126
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright (c) 2026 Samsung Electronics Co., Ltd. All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include "BulkPipelineLayer.h"
18+
19+
#include <iostream>
20+
#include <memory>
21+
22+
namespace onert::backend::trix::ops
23+
{
24+
25+
BulkPipelineLayer::BulkPipelineLayer() : _inputs(), _outputs()
26+
{
27+
// DO NOTHING
28+
}
29+
30+
BulkPipelineLayer::~BulkPipelineLayer()
31+
{
32+
// DO NOTHING - _pipeline_manager will be automatically cleaned up by unique_ptr
33+
}
34+
35+
void BulkPipelineLayer::configure(const std::vector<const IPortableTensor *> &inputs,
36+
std::vector<IPortableTensor *> &outputs,
37+
const std::vector<std::string> &binary_path)
38+
{
39+
_inputs = inputs;
40+
_outputs = outputs;
41+
42+
// Configure BulkPipeLineManager
43+
BulkPipelineManager::PipelineConfig config;
44+
config.model_paths = binary_path;
45+
config.device_id = 0; // default device id = 0
46+
47+
_pipeline_manager = std::make_unique<BulkPipelineManager>(config);
48+
49+
if (!_pipeline_manager->initialize())
50+
{
51+
throw std::runtime_error("Failed to initialize BulkPipelineManager");
52+
}
53+
}
54+
55+
void BulkPipelineLayer::run()
56+
{
57+
try
58+
{
59+
_pipeline_manager->execute(_inputs, _outputs);
60+
}
61+
catch (const std::exception &e)
62+
{
63+
std::cerr << "BulkPipelineLayer execution failed: " << e.what() << std::endl;
64+
throw;
65+
}
66+
}
67+
68+
void BulkPipelineLayer::prepare()
69+
{
70+
// DO NOTHING
71+
}
72+
73+
} // namespace onert::backend::trix::ops
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (c) 2026 Samsung Electronics Co., Ltd. All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef __ONERT_BACKEND_TRIX_OPS_BULK_PIPELINE_LAYER_H__
18+
#define __ONERT_BACKEND_TRIX_OPS_BULK_PIPELINE_LAYER_H__
19+
20+
#include <backend/IPortableTensor.h>
21+
#include "../DevContext.h"
22+
#include <exec/IFunction.h>
23+
#include "BulkPipelineManager.h"
24+
25+
namespace onert::backend::trix::ops
26+
{
27+
28+
class BulkPipelineLayer : public ::onert::exec::IFunction
29+
{
30+
public:
31+
BulkPipelineLayer();
32+
~BulkPipelineLayer() override;
33+
34+
public:
35+
void configure(const std::vector<const IPortableTensor *> &inputs,
36+
std::vector<IPortableTensor *> &outputs,
37+
const std::vector<std::string> &binary_path);
38+
39+
void run() override;
40+
41+
void prepare() override;
42+
43+
private:
44+
std::vector<const IPortableTensor *> _inputs;
45+
std::vector<IPortableTensor *> _outputs;
46+
47+
// Pipeline manager
48+
std::unique_ptr<BulkPipelineManager> _pipeline_manager;
49+
};
50+
51+
} // namespace onert::backend::trix::ops
52+
53+
#endif // __ONERT_BACKEND_TRIX_OPS_BULK_PIPELINE_LAYER_H__

0 commit comments

Comments
 (0)