-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Target Platform Capabilities Design (#1276)
* Refactor Target Platform Capabilities Design - Create a new `schema` package to house all target platform modeling classes - Introduce a new versioning system with minor and patch versions Additional Changes: - Created mct_current_schema.py for one place to update the schema version, and replaced all the imports in mct to work with this location. - Update existing target platform models to adhere to the new versioning convention - Add necessary metadata - Correct all import statements - Update and enhance tests to reflect the design changes - Remove unused files --------- Co-authored-by: liord <lior.dikstein@altair-semi.com>
- Loading branch information
1 parent
0c6d0b0
commit 28b461b
Showing
75 changed files
with
1,672 additions
and
1,392 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
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
14 changes: 14 additions & 0 deletions
14
model_compression_toolkit/target_platform_capabilities/schema/__init__.py
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,14 @@ | ||
# Copyright 2024 Sony Semiconductor Israel, Inc. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ============================================================================== |
11 changes: 11 additions & 0 deletions
11
model_compression_toolkit/target_platform_capabilities/schema/mct_current_schema.py
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,11 @@ | ||
import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema | ||
|
||
Signedness = schema.Signedness | ||
AttributeQuantizationConfig = schema.AttributeQuantizationConfig | ||
OpQuantizationConfig = schema.OpQuantizationConfig | ||
QuantizationConfigOptions = schema.QuantizationConfigOptions | ||
OperatorsSetBase = schema.OperatorsSetBase | ||
OperatorsSet = schema.OperatorsSet | ||
OperatorSetConcat= schema.OperatorSetConcat | ||
Fusing = schema.Fusing | ||
TargetPlatformModel = schema.TargetPlatformModel |
37 changes: 37 additions & 0 deletions
37
model_compression_toolkit/target_platform_capabilities/schema/schema_functions.py
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,37 @@ | ||
# Copyright 2024 Sony Semiconductor Israel, Inc. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ============================================================================== | ||
import copy | ||
from typing import Any, Dict | ||
|
||
|
||
def clone_and_edit_object_params(obj: Any, **kwargs: Dict) -> Any: | ||
""" | ||
Clones the given object and edit some of its parameters. | ||
Args: | ||
obj: An object to clone. | ||
**kwargs: Keyword arguments to edit in the cloned object. | ||
Returns: | ||
Edited copy of the given object. | ||
""" | ||
|
||
obj_copy = copy.deepcopy(obj) | ||
for k, v in kwargs.items(): | ||
assert hasattr(obj_copy, | ||
k), f'Edit parameter is possible only for existing parameters in the given object, ' \ | ||
f'but {k} is not a parameter of {obj_copy}.' | ||
setattr(obj_copy, k, v) | ||
return obj_copy |
Oops, something went wrong.