-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Add checkpoint to quantize #28612
Add checkpoint to quantize #28612
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Copyright (c) 2020 PaddlePaddle Authors. 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 unittest | ||
import numpy as np | ||
from inference_pass_test import InferencePassTest | ||
import paddle.fluid as fluid | ||
from paddle.fluid.core import PassVersionChecker | ||
|
||
|
||
class TestMKLDNNCpuBfloat16Pass(InferencePassTest): | ||
def setUp(self): | ||
self.init_data() | ||
with fluid.program_guard(self.main_program, self.startup_program): | ||
x = fluid.data( | ||
name='x', shape=[-1] + self.shape_x, dtype=self.d_type) | ||
y = fluid.data( | ||
name='y', shape=[-1] + self.shape_y, dtype=self.d_type) | ||
out = fluid.layers.matmul(x, y) | ||
out = fluid.layers.transpose(out, perm=[0, 1, 2, 3]) | ||
out = fluid.layers.reshape(out, [0, 0, 0, 0]) | ||
out = fluid.layers.fc(out, size=1) | ||
|
||
self.feeds = { | ||
"x": | ||
np.random.random([self.bs] + self.shape_x).astype(self.d_type), | ||
"y": | ||
np.random.random([self.bs] + self.shape_y).astype(self.d_type) | ||
} | ||
self.fetch_list = [out] | ||
|
||
def init_data(self): | ||
self.bs = 8 | ||
self.d_type = np.float32 | ||
self.shape_x = [12, 1, 1] | ||
self.shape_y = [12, 1, 64] | ||
self.enable_mkldnn = True | ||
|
||
def test_check_output(self): | ||
self.enable_mkldnn = True | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are two The test shows that if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I agree that just adding |
||
use_gpu = False | ||
self.check_output_with_option(use_gpu, flatten=True, bfloat16=True) | ||
self.assertTrue(PassVersionChecker.IsCompatible('cpu_bfloat16_pass')) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some time ago, baidu require test dimension to be over 100? Maybe
self.shape_x = [12, 1, 10]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I changed.