# Copyright 2021 Yan Yan # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. STR = """ BWG 0.0008761882781982422 BWG 0.0008311271667480469 BWG 0.002079486846923828 BWG 0.002329587936401367 BWG 0.0025458335876464844 BWG 0.0026700496673583984 BWG 0.002583742141723633 BWG 0.0025262832641601562 BWG 0.003481149673461914 BWG 0.003238201141357422 BWG 0.005095958709716797 BWG 0.0037899017333984375 BWG 0.003931283950805664 BWG 0.003300189971923828 """ """ 0.003921985626220703 0.0049707889556884766 0.0052530765533447266 0.0060312747955322266 0.0036766529083251953 0.00421142578125 0.002129793167114258 0.0023038387298583984 0.0013151168823242188 0.0015285015106201172 0.0008392333984375 0.0008127689361572266 0.0002486705780029297 0.00030994415283203125 """ STR1 = """ SUBM 0.00036716461181640625 G 0.0010955333709716797 G 0.0010745525360107422 REGU 0.0006923675537109375 M 0.0005242824554443359 SUBM 0.0003108978271484375 G 0.0010905265808105469 G 0.0011067390441894531 REGU 0.00058746337890625 M 0.0005304813385009766 SUBM 0.0002682209014892578 G 0.0010945796966552734 G 0.0011165142059326172 REGU 0.0005419254302978516 M 0.0005164146423339844 SUBM 0.00021505355834960938 G 0.0010805130004882812 G 0.0010516643524169922 REGU 0.00052642822265625 M 0.0004677772521972656 SUBM 0.0002262592315673828 G 0.0010986328125 G 0.0010256767272949219 REGU 0.0005693435668945312 M 0.00048661231994628906 SUBM 0.0002319812774658203 G 0.0011110305786132812 G 0.0011196136474609375 REGU 0.0005295276641845703 M 0.0005729198455810547 SUBM 0.00023889541625976562 G 0.0005326271057128906 G 0.0005140304565429688 """ STR2 = """ SUBM 0.0003352165222167969 G 0.001149892807006836 G 0.0017066001892089844 REGU 0.0006349086761474609 M 0.00048804283142089844 SUBM 0.00029850006103515625 G 0.001767873764038086 G 0.0020656585693359375 REGU 0.0005462169647216797 M 0.0005753040313720703 SUBM 0.0002789497375488281 G 0.0012230873107910156 G 0.0014438629150390625 REGU 0.0005102157592773438 M 0.0005676746368408203 SUBM 0.00020241737365722656 G 0.00102996826171875 G 0.0011174678802490234 REGU 0.0005424022674560547 M 0.0005102157592773438 SUBM 0.0001976490020751953 G 0.0010385513305664062 G 0.0010204315185546875 REGU 0.0005321502685546875 M 0.00047278404235839844 SUBM 0.00021529197692871094 G 0.0010280609130859375 G 0.0010151863098144531 REGU 0.0004942417144775391 M 0.0004811286926269531 SUBM 0.00020694732666015625 G 0.0005142688751220703 G 0.0005171298980712891 """ def _handle_lines(s: str): arr = s.split(" ") return (arr[0], float(arr[-1])) from cumm.gemm.codeops import group_by def print_str(s: str): nums = list(map(_handle_lines, s.strip().split("\n"))) num_dict = group_by(lambda x: x[0], nums) num_dict_ = {k: sum([vv[1] for vv in v]) for k, v in num_dict.items()} print(num_dict_) print_str(STR1) print_str(STR2)