|
25 | 25 | # Everytime the contents of compileOption is changed in input.yaml
|
26 | 26 | # this script should be run to create new fi.exe and prof.exe
|
27 | 27 |
|
28 |
| -import sys, os, shutil |
| 28 | +import sys, os, shutil, math |
29 | 29 | import yaml
|
30 | 30 | import subprocess
|
31 | 31 |
|
@@ -319,13 +319,25 @@ def readCompileOption():
|
319 | 319 | if (str(cOpt["tracingPropagationOption"]["generateCDFG"]).lower() == "true"):
|
320 | 320 | options["genDotGraph"] = True
|
321 | 321 |
|
322 |
| - if 'fakeQuant' in cOpt and (cOpt['fakeQuant']['targetLayer'] == 'conv' or cOpt['fakeQuant']['targetLayer'] == 'matmul'): |
| 322 | + if 'fakeQuant' in cOpt: |
| 323 | + targetLayer = cOpt['fakeQuant']['targetLayer'] |
323 | 324 | minPercentileOutlierThreshold = cOpt['fakeQuant'].get('minPercentileOutlierThreshold', 0)
|
324 | 325 | maxPercentileOutlierThreshold = cOpt['fakeQuant'].get('maxPercentileOutlierThreshold', 100)
|
325 |
| - bitWidth = cOpt['fakeQuant'].get('bitWidth') |
| 326 | + bitWidth = cOpt['fakeQuant'].get('bitWidth', 8) |
| 327 | + |
| 328 | + assert isinstance(targetLayer, str), "TargetLayer must be of type string" |
| 329 | + assert targetLayer == "conv" or targetLayer == "matmul" , "TargetLayer can only be 'conv' and 'matmul'" |
| 330 | + assert isinstance(minPercentileOutlierThreshold, int), "Minimum Percentile Value should be of type int" |
| 331 | + assert isinstance(maxPercentileOutlierThreshold, int), "Maximum Percentile Value should be of type int" |
| 332 | + assert isinstance(bitWidth, int), "BitWidth should be of type int" |
| 333 | + assert 0 < bitWidth, "BitWidth must be a integer greater than 0" |
| 334 | + assert math.log2(bitWidth).is_integer(), "BitWidth must be a exponent of power 2" |
| 335 | + assert 0 <= minPercentileOutlierThreshold and minPercentileOutlierThreshold <= 100, "Minimum Percentile Value for Percentile should be greater than or equal to 0" |
| 336 | + assert 0 <= maxPercentileOutlierThreshold and maxPercentileOutlierThreshold <= 100, "Maximum Percentile Value for Percentile should be greater than or equal to 0 and lesser than or equal to 100" |
| 337 | + assert minPercentileOutlierThreshold <= maxPercentileOutlierThreshold, "Minimum Percentile Value should be lesser than Maximum Percentile Value" |
326 | 338 |
|
327 | 339 | global fakeQuant
|
328 |
| - fakeQuant = [cOpt['fakeQuant']['targetLayer'], minPercentileOutlierThreshold, maxPercentileOutlierThreshold, bitWidth] |
| 340 | + fakeQuant = [targetLayer, minPercentileOutlierThreshold, maxPercentileOutlierThreshold, bitWidth] |
329 | 341 |
|
330 | 342 | ################################################################################
|
331 | 343 | def _suffixOfIR():
|
|
0 commit comments