2021-12-07 10:57:55 +08:00
|
|
|
// Copyright (c) OpenMMLab. All rights reserved.
|
|
|
|
|
|
|
|
#include "archive/value_archive.h"
|
|
|
|
#include "core/operator.h"
|
2022-06-01 14:10:43 +08:00
|
|
|
#include "pipeline.h"
|
2021-12-07 10:57:55 +08:00
|
|
|
|
|
|
|
namespace mmdeploy::graph {
|
|
|
|
|
2022-06-01 14:10:43 +08:00
|
|
|
class UnflattenNode : public Node {
|
|
|
|
public:
|
|
|
|
Sender<Value> Process(Sender<Value> input) override {
|
|
|
|
return Then(std::move(input), [](Value args) {
|
|
|
|
Value rets = Value::kArray;
|
|
|
|
auto idxs = from_value<std::vector<int>>(args.back());
|
|
|
|
for (int i = 0; i < rets.size() - 1; ++i) {
|
|
|
|
auto ret = Unflatten(std::move(args[i]), idxs).value();
|
|
|
|
rets.push_back(std::move(ret));
|
|
|
|
}
|
|
|
|
return rets;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
2021-12-07 10:57:55 +08:00
|
|
|
|
|
|
|
class UnflattenCreator : public Creator<Node> {
|
|
|
|
public:
|
|
|
|
const char* GetName() const override { return "Unflatten"; }
|
|
|
|
int GetVersion() const override { return 0; }
|
2022-06-01 14:10:43 +08:00
|
|
|
std::unique_ptr<Node> Create(const Value& config) override {
|
|
|
|
auto inst = std::make_unique<UnflattenNode>();
|
|
|
|
NodeParser::Parse(config, *inst).value();
|
|
|
|
return inst;
|
2021-12-07 10:57:55 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
REGISTER_MODULE(Node, UnflattenCreator);
|
|
|
|
|
|
|
|
} // namespace mmdeploy::graph
|