Autotune result usage


I had done autotuning for a resnet 50 model a few days back and the result was stored in a kernel.log file. I wanted to use this for my current inference of resnet50 via tvm as

tunefile = "kernel.log"
history_best_context = tvm.autotvm.apply_history_best(tunefile)
            with history_best_context:
               with tvm.transform.PassContext(opt_level=2):
                  self.lib =
                     self.mod, target=self.common_interface.device, params=self.params)

But as soon as I run the infrence i get the error -

File "", line 24, in <module>
    tvm_results = itvm.inference()
  File "/home/nvidia/", line 144, in inference
    history_best_context = tvm.autotvm.apply_history_best(tunefile)
  File "/home/nvidia/sdcard/tvm/python/tvm/autotvm/task/", line 257, in __init__
  File "/home/nvidia/sdcard/tvm/python/tvm/autotvm/task/", line 286, in load
    joint_records += rec
  File "/home/nvidia/sdcard/tvm/python/tvm/autotvm/", line 213, in load_from_file
    ret = decode(row)
  File "/home/nvidia/sdcard/tvm/python/tvm/autotvm/", line 145, in decode
    row = json.loads(row)
  File "/usr/lib/python3.8/json/", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 289 (char 288)

The kernel.log (tunefile) has the first line as -

{"input": ["cuda -keys=cuda,gpu -arch=sm_72 -max_num_threads=1024 -model=unknown -thread_warp_size=32", "dense_small_batch.gpu", [["TENSOR", [1, 2048], "float32"], ["TENSOR", [1000, 2048], "float32"], null, "float32"], {}], "config": {"index": 5, "code_hash": null, "entity": [["tile_k", "sp", [-1, 32]]]}, "result": [[0.00013503773753462605], 0, 3.5121700763702393, 1656911006.6791778], "version": 0.2, "tvm_version": "0.9.dev0"}

and the error seems to be that the double quotes between [“tile_k”, “sp”, …] is causing some issue and needs to be escaped. But I cannot keep doing this for around 15000 similar lines which are part of the kernel.log file! Is there any way to avoid this error?

The error specifying line 1 column 289 put me off…the actual error was in the last line of the log which was filled partially, not sure why. Just removing this partial line fixed the issue