Skip to content

Commit 6774d7b

Browse files
authored
Merge pull request #92 from CortexFoundation/zh
8.16
2 parents d2f5922 + 10fff0e commit 6774d7b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+153
-17
lines changed

docs/deep_dive/mrt.rst

Lines changed: 63 additions & 0 deletions

docs/index.rst

Lines changed: 1 addition & 0 deletions

docs/mrt/model.md

Lines changed: 75 additions & 8 deletions

python/mrt/V3/evaluate.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from yacs.config import CfgNode as CN
99
import logging
10+
import time
1011

1112
import mxnet as mx
1213
from mxnet import gluon, ndarray as nd
@@ -132,8 +133,10 @@ def get_evaluation_info(cm_cfg, pass_cfg, logger=None):
132133
def evalfunc(data, label):
133134
# outs = forward(graph, data, ctx=ctx)
134135
outs = forward(graph, data, ctx, baxis, olen)
136+
start = time.time()
135137
acc = dataset.validate(metric, outs, label)
136-
return acc
138+
end = time.time()
139+
return acc, int((end-start)*1e3)
137140

138141
# forward function for the quantized model
139142
if conf_map.get("split_keys", "") != "":
@@ -161,8 +164,10 @@ def quantize(data, label):
161164
outs = forward(qgraph, data, ctx, baxis, olen)
162165
outs = outs / oscales[0] if olen == 1 \
163166
else [(t / oscales[i]) for i, t in enumerate(outs)]
167+
start = time.time()
164168
acc = dataset.validate(qmetric, outs, label)
165-
return acc
169+
end = time.time()
170+
return acc, int((end-start)*1e3)
166171

167172
return evalfunc, data_iter_func, quantize
168173

python/mrt/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,17 +188,17 @@ def multi_validate(base_func, data_iter, *comp_funcs,
188188
log_str = "Iteration: {:3d} | " + base_func.__name__ + ": {} | "
189189
for func in comp_funcs:
190190
log_str += func.__name__ + ": {} | "
191-
log_str += "Total Sample: {:5d}"
191+
log_str += "time: {}ms {}ms | Total Sample: {:5d}"
192192

193193
total = 0
194194
for i in range(iter_num):
195195
data, label = data_iter()
196-
base_acc = base_func(data, label)
196+
base_acc, base_time = base_func(data, label)
197197
comp_acc = [func(data, label) for func in comp_funcs]
198198
total += batch_size
199-
200-
msg = log_str.format(i, base_acc, *comp_acc, total)
199+
msg = log_str.format(i, base_acc, comp_acc[0][0], base_time, comp_acc[0][1], total)
201200
logger.info(msg)
201+
202202

203203
def multi_eval_accuracy(base_func, data_iter_func, *comp_funcs,
204204
iter_num=10, logger=logging):
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy