|
| 1 | +# Copyright (c) 2022 Intel Corporation |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +transformation: |
| 16 | + location: |
| 17 | + - insert_above_inference_line |
| 18 | + - insert_below_inference_line |
| 19 | + - indent_inference_line |
| 20 | + content: |
| 21 | + - |- |
| 22 | + [+] if not ACCURACY_MODE: |
| 23 | + [+] import time |
| 24 | + [+] count_iter_ = 0 |
| 25 | + [+] total_time_ = 0 |
| 26 | + [+] num_iter_ = NUM_BENCHMARK_ITERATION |
| 27 | + [+] num_warmup_iter_ = 3 |
| 28 | + [+] list_batch_time_ = [] |
| 29 | + [+] for i_ in range(num_iter_): |
| 30 | + [+] count_iter_ = count_iter_ + 1 |
| 31 | + [+] if count_iter_ > num_warmup_iter_: |
| 32 | + [+] t1_ = time.time() |
| 33 | + [+] with torch.no_grad(): |
| 34 | + - |- |
| 35 | + [+] if count_iter_ > num_warmup_iter_: |
| 36 | + [+] t2_ = time.time() |
| 37 | + [+] batch_time_ = t2_ - t1_ |
| 38 | + [+] list_batch_time_.append(batch_time_) |
| 39 | + [+] total_time_ = total_time_ + batch_time_ |
| 40 | + [+] print("Neural_Coder_Bench_IPS: ", round((num_iter_ - num_warmup_iter_) / total_time_, 3)) |
| 41 | + [+] print("Neural_Coder_Bench_MSPI: ", round(total_time_ / (num_iter_ - num_warmup_iter_) * 1000, 3)) |
| 42 | + [+] list_batch_time_.sort() |
| 43 | + [+] p50_latency_ = list_batch_time_[int(len(list_batch_time_) * 0.50) - 1] * 1000 |
| 44 | + [+] p90_latency_ = list_batch_time_[int(len(list_batch_time_) * 0.90) - 1] * 1000 |
| 45 | + [+] p99_latency_ = list_batch_time_[int(len(list_batch_time_) * 0.99) - 1] * 1000 |
| 46 | + [+] print("Neural_Coder_Bench_P50: ", round(p50_latency_, 3)) |
| 47 | + [+] print("Neural_Coder_Bench_P90: ", round(p90_latency_, 3)) |
| 48 | + [+] print("Neural_Coder_Bench_P99: ", round(p99_latency_, 3)) |
| 49 | + [+] quit() |
| 50 | + [+] else: |
| 51 | + [+] INFERENCE_LINE |
| 52 | + - 3 |
| 53 | + order: |
| 54 | + - below: |
| 55 | + above: |
| 56 | + - below: |
| 57 | + above: |
| 58 | + - below: |
| 59 | + above: |
0 commit comments