Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-03 08:57:55

0001 // Copyright (c) ONNX Project Contributors
0002 
0003 /*
0004  * SPDX-License-Identifier: Apache-2.0
0005  */
0006 
0007 // Adapter for Upsample in default domain from version 9 to 10
0008 
0009 #pragma once
0010 
0011 #include <memory>
0012 #include <string>
0013 namespace ONNX_NAMESPACE {
0014 namespace version_conversion {
0015 
0016 class Upsample_9_10 final : public Adapter {
0017  public:
0018   explicit Upsample_9_10() : Adapter("Upsample", OpSetID(9), OpSetID(10)) {}
0019 
0020   Node* adapt_upsample_9_10(std::shared_ptr<Graph> graph, Node* node) const {
0021     std::string mode = node->hasAttribute(kmode) ? node->s(kmode) : "nearest";
0022 
0023     // Replace the node with an equivalent Resize node
0024     Node* resize = graph->create(kResize);
0025     resize->s_(kmode, mode);
0026     resize->addInput(node->inputs()[0]);
0027     resize->addInput(node->inputs()[1]);
0028     node->replaceAllUsesWith(resize);
0029 
0030     resize->insertBefore(node);
0031     node->destroy();
0032 
0033     return resize;
0034   }
0035 
0036   Node* adapt(std::shared_ptr<Graph> graph, Node* node) const override {
0037     return adapt_upsample_9_10(graph, node);
0038   }
0039 };
0040 
0041 } // namespace version_conversion
0042 } // namespace ONNX_NAMESPACE