Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Unity][MSC][M2.4] Add quantizer for quantize model #16228

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions python/tvm/contrib/msc/core/runtime/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,14 @@ def apply_tool(self, tool_type: str, data_loader: Any = None) -> str:
self.run(inputs, ret_type="native")
break
plan = pruner.finalize()
elif tool_type == ToolType.QUANTIZER:
quantizer = self.get_tool(ToolType.QUANTIZER)
while not quantizer.calibrated:
assert data_loader, "data_loader should be given to plan prune"
for inputs in data_loader():
self.run(inputs, ret_type="native")
quantizer.calibrate()
plan = quantizer.finalize()
else:
plan = self.get_tool(tool_type).finalize()
assert plan, "Failed to create plan for {}".format(tool_type)
Expand Down
1 change: 1 addition & 0 deletions python/tvm/contrib/msc/core/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
from .tool import *
from .execute import *
from .prune import *
from .quantize import *
from .track import *
20 changes: 20 additions & 0 deletions python/tvm/contrib/msc/core/tools/quantize/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
"""tvm.contrib.msc.core.tools.quantize"""

from .quantizer import *
from .method import *
Loading
Loading