-
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.
Selective load ONNX schema by specific opset_version (onnx#3266)
* fix debug build Signed-off-by: Chun-Wei Chen <[email protected]> * prototype: add operator_versions to handle dynamically schema register Signed-off-by: Chun-Wei Chen <[email protected]> * typo Signed-off-by: Chun-Wei Chen <[email protected]> * find the latest opset and handle missing Signed-off-by: Chun-Wei Chen <[email protected]> * fix mac error about unordered_map Signed-off-by: Chun-Wei Chen <[email protected]> * complete all opset versions Signed-off-by: Chun-Wei Chen <[email protected]> * while adding the newer opset, remove the old one Signed-off-by: Chun-Wei Chen <[email protected]> * use ONNX_TRY Signed-off-by: Chun-Wei Chen <[email protected]> * reverse the order for loading Signed-off-by: Chun-Wei Chen <[email protected]> * fix bug Signed-off-by: Chun-Wei Chen <[email protected]> * skip debug check if partially load schema Signed-off-by: Chun-Wei Chen <[email protected]> * check repeated register before register Signed-off-by: Chun-Wei Chen <[email protected]> * correct; not use map() Signed-off-by: Chun-Wei Chen <[email protected]> * remove unnecessary const Signed-off-by: Chun-Wei Chen <[email protected]> * simplified with the original function Signed-off-by: Chun-Wei Chen <[email protected]> * use integer instead of bool Signed-off-by: Chun-Wei Chen <[email protected]> * don't insert version > max_version Signed-off-by: Chun-Wei Chen <[email protected]> * fix debug mode condition; change ver name; update comments Signed-off-by: Chun-Wei Chen <[email protected]> * try enable ONNX_DISABLE_STATIC_REGISTRATION Signed-off-by: Chun-Wei Chen <[email protected]> * fix useless name_space Signed-off-by: Chun-Wei Chen <[email protected]> * set -DONNX_DISABLE_STATIC_REGISTRATION=ON in the right place Signed-off-by: Chun-Wei Chen <[email protected]> * move def Signed-off-by: Chun-Wei Chen <[email protected]> * include the missing lib Signed-off-by: Chun-Wei Chen <[email protected]> * fix Signed-off-by: Chun-Wei Chen <[email protected]> * update cmake Signed-off-by: Chun-Wei Chen <[email protected]> * recover NOEBUG Signed-off-by: Chun-Wei Chen <[email protected]> * still use __ONNX_DISABLE_STATIC_REGISTRATION Signed-off-by: Chun-Wei Chen <[email protected]> * skip for ONNX_DISABLE_STATIC_REGISTRATION Signed-off-by: Chun-Wei Chen <[email protected]> * correct the right def Signed-off-by: Chun-Wei Chen <[email protected]> * register RegisterOnnxOperatorSetSchema if needed Signed-off-by: Chun-Wei Chen <[email protected]> * fix def Signed-off-by: Chun-Wei Chen <[email protected]> * add missing library Signed-off-by: Chun-Wei Chen <[email protected]> * decouple tests Signed-off-by: Chun-Wei Chen <[email protected]> * cd back Signed-off-by: Chun-Wei Chen <[email protected]> * refactor cd path Signed-off-by: Chun-Wei Chen <[email protected]> * correct path Signed-off-by: Chun-Wei Chen <[email protected]> * use $ instead Signed-off-by: Chun-Wei Chen <[email protected]> * try simple test Signed-off-by: Chun-Wei Chen <[email protected]> * correct CI Signed-off-by: Chun-Wei Chen <[email protected]> * fix typo Signed-off-by: Chun-Wei Chen <[email protected]> * add more tests Signed-off-by: Chun-Wei Chen <[email protected]> * update comments Signed-off-by: Chun-Wei Chen <[email protected]> * switch testing places Signed-off-by: Chun-Wei Chen <[email protected]> * correct gtest_filter Signed-off-by: Chun-Wei Chen <[email protected]> * update by comments Signed-off-by: Chun-Wei Chen <[email protected]> * typo Signed-off-by: Chun-Wei Chen <[email protected]> * remove Signed-off-by: Chun-Wei Chen <[email protected]> * move GetRegisteredSchemaCount to private Signed-off-by: Chun-Wei Chen <[email protected]> * remove in .h as well Signed-off-by: Chun-Wei Chen <[email protected]> * remove space Signed-off-by: Chun-Wei Chen <[email protected]> Co-authored-by: Michał Karzyński <[email protected]>
- Loading branch information
1 parent
3c8160e
commit 2fe362c
Showing
7 changed files
with
126 additions
and
16 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
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
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,43 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <iostream> | ||
#include "gtest/gtest.h" | ||
#include "onnx/defs/operator_sets.h" | ||
#include "onnx/defs/schema.h" | ||
|
||
using namespace ONNX_NAMESPACE; | ||
|
||
namespace ONNX_NAMESPACE { | ||
namespace Test { | ||
|
||
// By default ONNX registers all opset versions and selective schema loading cannot be tested | ||
// So this test is run only when static registration is disabled | ||
TEST(SchemaRegistrationTest, RegisterSpecifiedOpsetSchemaVersion) { | ||
#ifdef __ONNX_DISABLE_STATIC_REGISTRATION | ||
EXPECT_TRUE(OpSchemaRegistry::Instance()->GetLoadedSchemaVersion() == -1); | ||
RegisterOnnxOperatorSetSchema(13); | ||
EXPECT_TRUE(OpSchemaRegistry::Instance()->GetLoadedSchemaVersion() == 13); | ||
|
||
auto opSchema = OpSchemaRegistry::Schema("Add"); | ||
EXPECT_NE(nullptr, opSchema); | ||
EXPECT_EQ(opSchema->SinceVersion(), 13); | ||
|
||
// Should not find opset 12 | ||
opSchema = OpSchemaRegistry::Schema("Add", 12); | ||
EXPECT_EQ(nullptr, opSchema); | ||
|
||
// Should not find opset 14 | ||
opSchema = OpSchemaRegistry::Schema("Trilu"); | ||
EXPECT_EQ(nullptr, opSchema); | ||
|
||
// Acos-7 is the latest Acos before specified 13 | ||
opSchema = OpSchemaRegistry::Schema("Acos"); | ||
EXPECT_NE(nullptr, opSchema); | ||
EXPECT_EQ(opSchema->SinceVersion(), 7); | ||
#endif | ||
} | ||
|
||
} // namespace Test | ||
} // namespace ONNX_NAMESPACE |