123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2020 Nomadic Labs. <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)typegroup=Standalone|Groupofstring|Generictype'configparameters={bench_number:int;config:'config}typepurpose=Other_purposeofstring|Generate_codeofstringletpp_purposeppft=matchtwith|Other_purposes->Format.fprintfppf"Other purpose: %s"s|Generate_codes->Format.fprintfppf"Generate code: %s"smoduletypeBenchmark_base=sigvalname:Namespace.tvalinfo:stringvalmodule_filename:stringvalpurpose:purposevaltags:stringlisttypeconfigvaldefault_config:configvalconfig_encoding:configData_encoding.ttypeworkloadvalworkload_encoding:workloadData_encoding.tvalworkload_to_vector:workload->Sparse_vec.String.tendmoduletypeS=sigincludeBenchmark_basevalmodels:(string*workloadModel.t)listincludeGenerator.Swithtypeconfig:=configandtypeworkload:=workloadendmoduletypeSimple=sigincludeBenchmark_basevalgroup:groupvalmodel:workloadModel.tvalcreate_benchmark:rng_state:Random.State.t->config->workloadGenerator.benchmarkendmoduletypeSimple_with_num=sigincludeBenchmark_basevalgroup:groupvalmodel:workloadModel.tincludeGenerator.Swithtypeworkload:=workloadandtypeconfig:=configendtypet=(moduleS)typesimple=(moduleSimple)typesimple_with_num=(moduleSimple_with_num)letppppf(moduleBench:S)=letopenBenchinletopenFormatinletffmt=fprintfppffmtinletpp_configfmtconfig=Data_encoding.Json.ppfmt@@Data_encoding.Json.constructconfig_encodingconfiginf"@[<v>";f"name: %a@;"Namespace.ppname;f"info: %s@;"info;f"module_filename: %s@;"module_filename;f"purpose: %a@;"pp_purposepurpose;f"tags: [%a]@;"(pp_print_list~pp_sep:(funppf()->fprintfppf"; ")pp_print_string)tags;f"@[<v2>default_config:@ @[%a@]@]@;"pp_configdefault_config;f"@[<v2>local models for inference:@ @[<v>%a@]@]@;"(pp_print_list(funppf(local_model_name,model)->fprintfppf"@[<v2>%s:@ @[%a@]@]"local_model_nameModel.ppmodel))models;f"@]"type('cfg,'workload)poly=(moduleSwithtypeconfig='cfgandtypeworkload='workload)typepacked=Ex:('cfg,'workload)poly->packedletname((moduleB):t)=B.nameletinfo((moduleB):t)=B.infolettags((moduleB):t)=B.tagsletex_unpack:t->packed=fun(moduleBench)->Ex((moduleBench):_poly)letget_free_variable_set(moduleBench:S)=List.fold_left(funacc(_,model)->Free_variable.Set.unionacc@@Model.get_free_variable_set_of_tmodel)Free_variable.Set.emptyBench.models