1 | /* |
2 | * Licensed to the Apache Software Foundation (ASF) under one |
3 | * or more contributor license agreements. See the NOTICE file |
4 | * distributed with this work for additional information |
5 | * regarding copyright ownership. The ASF licenses this file |
6 | * to you under the Apache License, Version 2.0 (the |
7 | * "License"); you may not use this file except in compliance |
8 | * with the License. You may obtain a copy of the License at |
9 | * |
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
11 | * |
12 | * Unless required by applicable law or agreed to in writing, |
13 | * software distributed under the License is distributed on an |
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
15 | * KIND, either express or implied. See the License for the |
16 | * specific language governing permissions and limitations |
17 | * under the License. |
18 | */ |
19 | |
20 | /*! |
21 | * \file auto_scheduler/search_policy/empty_policy.h |
22 | * \brief A simple example of the search policy which always returns the initial naive schedule |
23 | * (state). |
24 | */ |
25 | |
26 | #ifndef TVM_AUTO_SCHEDULER_SEARCH_POLICY_EMPTY_POLICY_H_ |
27 | #define TVM_AUTO_SCHEDULER_SEARCH_POLICY_EMPTY_POLICY_H_ |
28 | |
29 | #include <tvm/auto_scheduler/loop_state.h> |
30 | #include <tvm/auto_scheduler/measure.h> |
31 | #include <tvm/auto_scheduler/search_policy.h> |
32 | |
33 | #include <utility> |
34 | |
35 | namespace tvm { |
36 | namespace auto_scheduler { |
37 | |
38 | /*! |
39 | * \brief A simple example of the search policy which always returns the initial naive schedule |
40 | * (state). |
41 | * The key implementation for this structure is `Search()`, check `empty_policy.cc` for more |
42 | * details. |
43 | */ |
44 | class EmptyPolicyNode : public SearchPolicyNode { |
45 | public: |
46 | State Search(int num_measure_trials, int early_stopping, int num_measures_per_round, |
47 | ProgramMeasurer measurer) final; |
48 | |
49 | std::pair<Array<MeasureInput>, Array<MeasureResult>> ContinueSearchOneRound( |
50 | int num_measure, ProgramMeasurer measurer) final; |
51 | |
52 | static constexpr const char* _type_key = "auto_scheduler.EmptyPolicy" ; |
53 | TVM_DECLARE_FINAL_OBJECT_INFO(EmptyPolicyNode, SearchPolicyNode); |
54 | |
55 | private: |
56 | /*! |
57 | * \brief Use a sub function to generate several candidate states in each search round. |
58 | * \returns The generated states |
59 | */ |
60 | Array<State> SearchOneRound(); |
61 | }; |
62 | |
63 | /*! |
64 | * \brief Managed reference to EmptyPolicyNode. |
65 | * \sa EmptyPolicyNode |
66 | */ |
67 | class EmptyPolicy : public SearchPolicy { |
68 | public: |
69 | explicit EmptyPolicy(SearchTask task, Optional<Array<SearchCallback>> init_search_callbacks); |
70 | |
71 | TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS(EmptyPolicy, SearchPolicy, EmptyPolicyNode); |
72 | }; |
73 | |
74 | } // namespace auto_scheduler |
75 | } // namespace tvm |
76 | |
77 | #endif // TVM_AUTO_SCHEDULER_SEARCH_POLICY_EMPTY_POLICY_H_ |
78 | |