From ead8811f22102f174747c088bf5b2603cba94d48 Mon Sep 17 00:00:00 2001 From: panhaolin Date: Wed, 29 May 2024 15:42:19 +0000 Subject: [PATCH] add string_of_items to fix inst2vec_preprocess.py --- .../third_party/inst2vec/inst2vec_preprocess.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/compiler_gym/third_party/inst2vec/inst2vec_preprocess.py b/compiler_gym/third_party/inst2vec/inst2vec_preprocess.py index 3a07f0fca..5535ba3b3 100644 --- a/compiler_gym/third_party/inst2vec/inst2vec_preprocess.py +++ b/compiler_gym/third_party/inst2vec/inst2vec_preprocess.py @@ -33,6 +33,21 @@ from compiler_gym.third_party.inst2vec import rgx_utils as rgx +######################################################################################################################## +# Helper functions: list and stmt handling +######################################################################################################################## +def string_of_items(dic): + """ + Return a string containing all keys of a dictionary, separated by a comma + (Helper function for structure inlining) + :param dic: dictionary [key=string: value=string] + :return: string constructed of the dictionaries' keys + """ + s = '' + for k, v in dic.items(): + s += k + ': ' + v + '\n' + return s + ######################################################################################################################## # LLVM IR preprocessing ########################################################################################################################