forked from onnx/onnx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upsample_9_10.h
38 lines (28 loc) · 990 Bytes
/
upsample_9_10.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* SPDX-License-Identifier: Apache-2.0
*/
// Adapter for Upsample in default domain from version 9 to 10
#pragma once
namespace ONNX_NAMESPACE {
namespace version_conversion {
class Upsample_9_10 final : public Adapter {
public:
explicit Upsample_9_10() : Adapter("Upsample", OpSetID(9), OpSetID(10)) {}
Node* adapt_upsample_9_10(std::shared_ptr<Graph> graph, Node* node) const {
std::string mode = node->hasAttribute(kmode) ? node->s(kmode) : "nearest";
// Replace the node with an equivalent Resize node
Node* resize = graph->create(kResize);
resize->s_(kmode, mode);
resize->addInput(node->inputs()[0]);
resize->addInput(node->inputs()[1]);
node->replaceAllUsesWith(resize);
resize->insertBefore(node);
node->destroy();
return resize;
}
Node* adapt(std::shared_ptr<Graph> graph, Node* node) const override {
return adapt_upsample_9_10(graph, node);
}
};
} // namespace version_conversion
} // namespace ONNX_NAMESPACE