diff --git a/hpvm/projects/keras/keras_frontend/approxhpvm_translator.py b/hpvm/projects/keras/keras_frontend/approxhpvm_translator.py index 8f39d77987fe0a4b595f48276480b80187047ea2..812c276798a6cfd54bfeb3bd05b7fa01ad404758 100644 --- a/hpvm/projects/keras/keras_frontend/approxhpvm_translator.py +++ b/hpvm/projects/keras/keras_frontend/approxhpvm_translator.py @@ -950,16 +950,11 @@ class TensorRtTranslator: op_cost_str = " \"op_cost\" : { \n" op_cost_str += self.json_str[:-3] - #f.write(self.json_str) op_cost_str += "\n }, \n\n" f.write(op_cost_str) - - knobs_speedup_str = "\n \"knob_speedup\" : { \n" - for key in knobs_speedups: - knobs_speedup_str += "\"" + str(key) + "\" : " + str(knobs_speedups[key]) + ", \n" - - f.write(knobs_speedup_str[:-3] + "\n}, \n\n") - + + f.write(knobs_speedup_str + " \n") + f.write(knobs_devices_str + " \n") layer_knobs_str = " \"op_knobs\" : { \n" layer_knobs_str += self.knobs_str[:-3] diff --git a/hpvm/projects/keras/keras_frontend/knobs.py b/hpvm/projects/keras/keras_frontend/knobs.py index 942df9021cacdffd21950db9ce98bce80957571a..388cbd28f804f9b92a8141b9273b226495bc9acc 100644 --- a/hpvm/projects/keras/keras_frontend/knobs.py +++ b/hpvm/projects/keras/keras_frontend/knobs.py @@ -1,37 +1,321 @@ -knobs_speedups = {} -knobs_speedups[11] = 1 -knobs_speedups[12] = 1.5 -knobs_speedups[151] = 3 -knobs_speedups[152] = 3 -knobs_speedups[153] = 3 -knobs_speedups[154] = 3 -knobs_speedups[155] = 2.25 -knobs_speedups[156] = 2.25 -knobs_speedups[157] = 2.25 -knobs_speedups[158] = 2.25 -knobs_speedups[159] = 2.25 -knobs_speedups[160] = 2.25 -knobs_speedups[161] = 2 -knobs_speedups[162] = 2 -knobs_speedups[163] = 2 -knobs_speedups[164] = 2 -knobs_speedups[165] = 2 -knobs_speedups[166] = 2 -knobs_speedups[167] = 2 -knobs_speedups[168] = 2 -knobs_speedups[261] = 3 -knobs_speedups[262] = 3 -knobs_speedups[263] = 2.25 -knobs_speedups[264] = 2.25 -knobs_speedups[265] = 2.25 -knobs_speedups[266] = 2 -knobs_speedups[267] = 2 -knobs_speedups[268] = 2 -knobs_speedups[269] = 2 - - -conv_knobs = "\"12\", \"151\", \"152\", \"153\", \"154\", \"155\", \"156\", \"157\", \"158\", \"159\", \"160\", \"161\", \"162\", \"163\", \"164\", \"165\", \"166\", \"167\", \"168\", \"261\", \"262\", \"263\", \"264\", \"265\", \"266\", \"267\", \"268\", \"269\"" + +knobs_devices_str = """ + +"knob_devices": { + + "11": null, + + "12": [ + "gpu" + ], + + "121": [ + "cpu" + ], + + "122": [ + "cpu" + ], + + "123": [ + "cpu" + ], + + "124": [ + "cpu" + ], + + "125": [ + "cpu" + ], + + "126": [ + "cpu" + ], + + "127": [ + "cpu" + ], + + "128": [ + "cpu" + ], + + "129": [ + "cpu" + ], + + "130": [ + "cpu" + ], + + "131": [ + "cpu" + ], + + "132": [ + "cpu" + ], + + "133": [ + "cpu" + ], + + "134": [ + "cpu" + ], + + "135": [ + "cpu" + ], + + "136": [ + "cpu" + ], + + "137": [ + "cpu" + ], + + "138": [ + "cpu" + ], + + "231": [ + "cpu" + ], + + "232": [ + "cpu" + ], + + "233": [ + "cpu" + ], + + "234": [ + "cpu" + ], + + "235": [ + "cpu" + ], + + "236": [ + "cpu" + ], + + "237": [ + "cpu" + ], + + "238": [ + "cpu" + ], + + "239": [ + "cpu" + ], + + "151": [ + "gpu" + ], + + "152": [ + "gpu" + ], + + "153": [ + "gpu" + ], + + "154": [ + "gpu" + ], + + "155": [ + "gpu" + ], + + "156": [ + "gpu" + ], + + "157": [ + "gpu" + ], + + "158": [ + "gpu" + ], + + "159": [ + "gpu" + ], + + "160": [ + "gpu" + ], + + "161": [ + "gpu" + ], + + "162": [ + "gpu" + ], + + "163": [ + "gpu" + ], + + "164": [ + "gpu" + ], + + "165": [ + "gpu" + ], + + "166": [ + "gpu" + ], + + "167": [ + "gpu" + ], + + "168": [ + "gpu" + ], + + "261": [ + "gpu" + ], + + "262": [ + "gpu" + ], + + "263": [ + "gpu" + ], + + "264": [ + "gpu" + ], + + "265": [ + "gpu" + ], + + "266": [ + "gpu" + ], + + "267": [ + "gpu" + ], + + "268": [ + "gpu" + ], + + "269": [ + "gpu" + ] + + }, + +""" + + + +knobs_speedup_str = """ + +"knob_speedup": { + "11": 1.0, + "12": 1.5, + "121": 2, + "122": 2, + "123": 2, + "124": 2, + "125": 1.5, + "126": 1.5, + "127": 1.5, + "128": 1.5, + "129": 1.5, + "130": 1.5, + "131": 1.33, + "132": 1.33, + "133": 1.33, + "134": 1.33, + "135": 1.33, + "136": 1.33, + "137": 1.33, + "138": 1.33, + "231": 2, + "232": 2, + "233": 1.5, + "234": 1.5, + "235": 1.5, + "236": 1.33, + "237": 1.33, + "238": 1.33, + "239": 1.33, + "151": 3.0, + "152": 3.0, + "153": 3.0, + "154": 3.0, + "155": 2.25, + "156": 2.25, + "157": 2.25, + "158": 2.25, + "159": 2.25, + "160": 2.25, + "161": 2.0, + "162": 2.0, + "163": 2.0, + "164": 2.0, + "165": 2.0, + "166": 2.0, + "167": 2.0, + "168": 2.0, + "261": 3.0, + "262": 3.0, + "263": 2.25, + "264": 2.25, + "265": 2.25, + "266": 2.0, + "267": 2.0, + "268": 2.0, + "269": 2.0 + }, +""" + + + + +conv_knobs = "\"11\", \"12\"," + +for i in range(121, 139): + conv_knobs += "\"" + str(i) + "\"" + conv_knobs += ", " + +for i in range(151, 169): + conv_knobs += "\"" + str(i) + "\"" + conv_knobs += ", " + +for i in range(231, 240): + conv_knobs += "\"" + str(i) + "\"" + conv_knobs += ", " + +for i in range(261, 270): + conv_knobs += "\"" + str(i) + "\"" + if i != 269: + conv_knobs += ", " + baseline_knobs = "\"12\""