-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Batchnorm Version Conversion Adapters (onnx#1288)
* Squashing into 1 commit * New BatchNormalization_7_6 adapter
- Loading branch information
Showing
6 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Adapter for BatchNormalization in default domain from version 6 to 5 | ||
|
||
#pragma once | ||
|
||
#include "onnx/version_converter/adapters/adapter.h" | ||
|
||
namespace ONNX_NAMESPACE { namespace version_conversion { | ||
|
||
class BatchNormalization_6_5 final : public Adapter { | ||
public: | ||
explicit BatchNormalization_6_5() | ||
: Adapter("BatchNormalization", OpSetID(6), OpSetID(5)) { | ||
} | ||
|
||
void adapt_batch_normalization_6_5(std::shared_ptr<Graph> graph, Node* node) const { | ||
node->is_(kconsumed_inputs, {0, 0}); | ||
} | ||
|
||
void adapt(std::shared_ptr<Graph> graph, Node* node) const override { | ||
adapt_batch_normalization_6_5(graph, node); | ||
} | ||
}; | ||
|
||
}} // namespace ONNX_NAMESPACE::version_conversion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Adapter for BatchNormalization in default domain from version 6 to 7 | ||
|
||
#pragma once | ||
|
||
#include "onnx/version_converter/adapters/adapter.h" | ||
|
||
namespace ONNX_NAMESPACE { namespace version_conversion { | ||
|
||
struct BatchNormalization_6_7 final : public Adapter { | ||
explicit BatchNormalization_6_7() | ||
: Adapter("BatchNormalization", OpSetID(6), OpSetID(7)) { | ||
} | ||
|
||
void adapt_batch_normalization_6_7(std::shared_ptr<Graph> graph, Node* node) const { | ||
if (node->hasAttribute(kis_test)) { | ||
ONNX_ASSERTM(node->i(kis_test) != 0, | ||
"ONNX currently only supports inference, not training."); | ||
node->removeAttribute(kis_test); | ||
} | ||
} | ||
|
||
void adapt(std::shared_ptr<Graph> graph, Node* node) const override { | ||
adapt_batch_normalization_6_7(graph, node); | ||
} | ||
}; | ||
|
||
}} // namespace ONNX_NAMESPACE::version_conversion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Adapter for BatchNormalization in default domain from version 7 to 6 | ||
|
||
#pragma once | ||
|
||
#include "onnx/version_converter/adapters/adapter.h" | ||
|
||
namespace ONNX_NAMESPACE { namespace version_conversion { | ||
|
||
struct BatchNormalization_7_6 final : public Adapter { | ||
explicit BatchNormalization_7_6() | ||
: Adapter("BatchNormalization", OpSetID(7), OpSetID(6)) { | ||
} | ||
|
||
void adapt_batch_normalization_7_6(std::shared_ptr<Graph> graph, Node* node) const { | ||
node->i_(kis_test, 1); | ||
} | ||
|
||
void adapt(std::shared_ptr<Graph> graph, Node* node) const override { | ||
adapt_batch_normalization_7_6(graph, node); | ||
} | ||
}; | ||
|
||
}} // namespace ONNX_NAMESPACE::version_conversion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters