@@ -870,29 +870,37 @@ def tune_kernel_T1(
870
870
simulation_mode = False ,
871
871
output_T4 = True ,
872
872
iterations = 7 ,
873
- strategy_options = None ,
874
- ):
875
- """Call the tune function with a T1 input file."""
873
+ device = None ,
874
+ strategy : str = None ,
875
+ strategy_options : dict = {},
876
+ ) -> tuple :
877
+ """
878
+ Call the tune function with a T1 input file.
879
+
880
+ The device, strategy and strategy_options can be overridden by passing a strategy name and options, otherwise the input file specification is used.
881
+ """
876
882
inputs = get_input_file (input_filepath )
877
883
kernelspec : dict = inputs ["KernelSpecification" ]
878
884
kernel_name : str = kernelspec ["KernelName" ]
879
885
kernel_filepath = Path (kernelspec ["KernelFile" ])
880
886
kernel_source = (
881
- kernel_filepath if kernel_filepath .exists () else Path (input_filepath ).parent .parent / kernel_filepath
887
+ kernel_filepath if kernel_filepath .exists () else Path (input_filepath ).parent / kernel_filepath
888
+ )
889
+ kernel_source = (
890
+ kernel_source if kernel_source .exists () else Path (input_filepath ).parent .parent / kernel_filepath
882
891
)
883
892
assert kernel_source .exists (), f"KernelFile '{ kernel_source } ' does not exist at { kernel_source .resolve ()} "
884
893
language : str = kernelspec ["Language" ]
885
894
problem_size = kernelspec ["ProblemSize" ]
886
- device = kernelspec ["Device" ]["Name" ]
887
- strategy = inputs ["Search" ]["Name" ]
888
- if "Attributes" in inputs ["Search" ]:
889
- strategy_options = {}
890
- for attribute in inputs ["Search" ]["Attributes" ]:
891
- strategy_options [attribute ["Name" ]] = attribute ["Value" ]
895
+ if device is None :
896
+ device = kernelspec ["Device" ]["Name" ]
897
+ if strategy is None :
898
+ strategy = inputs ["Search" ]["Name" ]
899
+ if "Attributes" in inputs ["Search" ]:
900
+ for attribute in inputs ["Search" ]["Attributes" ]:
901
+ strategy_options [attribute ["Name" ]] = attribute ["Value" ]
892
902
if "Budget" in inputs :
893
903
budget = inputs ["Budget" ][0 ]
894
- if strategy_options is None :
895
- strategy_options = {}
896
904
if budget ["Type" ] == "ConfigurationCount" :
897
905
strategy_options ["max_fevals" ] = budget ["BudgetValue" ]
898
906
elif budget ["Type" ] == "TuningDuration" :
0 commit comments