@@ -98,6 +98,9 @@ struct WorkloadEqual {
9898 }
9999};
100100
101+ /* ! \brief The class of measure candidates. */
102+ class MeasureCandidate ;
103+
101104/* ! \brief The class of tuning records. */
102105class TuningRecordNode : public runtime ::Object {
103106 public:
@@ -123,6 +126,9 @@ class TuningRecordNode : public runtime::Object {
123126 static constexpr const char * _type_key = " meta_schedule.TuningRecord" ;
124127 TVM_DECLARE_FINAL_OBJECT_INFO (TuningRecordNode, runtime::Object);
125128
129+ /* ! \brief Construct the measure candidate given the initial IR module and trace
130+ * stored in the tuning record. */
131+ MeasureCandidate AsMeasureCandidate () const ;
126132 /* !
127133 * \brief Export the tuning record to a JSON string.
128134 * \return An array containing the trace, running secs, serialized target, and
@@ -187,6 +193,11 @@ class DatabaseNode : public runtime::Object {
187193 * \return An array of top K tuning records for the given workload.
188194 */
189195 virtual Array<TuningRecord> GetTopK (const Workload& workload, int top_k) = 0;
196+ /* !
197+ * \brief Get all tuning records from the database.
198+ * \return An Array of all the tuning records in the database.
199+ */
200+ virtual Array<TuningRecord> GetAllTuningRecords () = 0;
190201 /* !
191202 * \brief Get the size of the database.
192203 * \return The size of the database.
@@ -224,6 +235,11 @@ class PyDatabaseNode : public DatabaseNode {
224235 * \return An array of top K tuning records for the given workload.
225236 */
226237 using FGetTopK = runtime::TypedPackedFunc<Array<TuningRecord>(const Workload&, int )>;
238+ /* !
239+ * \brief The function type of `GetAllTuningRecords` method.
240+ * \return An Array of all the tuning records in the database.
241+ */
242+ using FGetAllTuningRecords = runtime::TypedPackedFunc<Array<TuningRecord>()>;
227243 /* !
228244 * \brief The function type of `Size` method.
229245 * \return The size of the database.
@@ -238,6 +254,8 @@ class PyDatabaseNode : public DatabaseNode {
238254 FCommitTuningRecord f_commit_tuning_record;
239255 /* ! \brief The packed function to the `GetTopK` function. */
240256 FGetTopK f_get_top_k;
257+ /* ! \brief The packed function to the `GetAllTuningRecords` function. */
258+ FGetAllTuningRecords f_get_all_tuning_records;
241259 /* ! \brief The packed function to the `Size` function. */
242260 FSize f_size;
243261
@@ -249,6 +267,7 @@ class PyDatabaseNode : public DatabaseNode {
249267 // `f_commit_workload` is not visited
250268 // `f_commit_tuning_record` is not visited
251269 // `f_get_top_k` is not visited
270+ // `f_get_all_tuning_records` is not visited
252271 // `f_size` is not visited
253272 }
254273
@@ -273,6 +292,12 @@ class PyDatabaseNode : public DatabaseNode {
273292 return f_get_top_k (workload, top_k);
274293 }
275294
295+ Array<TuningRecord> GetAllTuningRecords () final {
296+ ICHECK (f_get_all_tuning_records != nullptr )
297+ << " PyDatabase's GetAllTuningRecords method not implemented!" ;
298+ return f_get_all_tuning_records ();
299+ }
300+
276301 int64_t Size () final {
277302 ICHECK (f_size != nullptr ) << " PyDatabase's Size method not implemented!" ;
278303 return f_size ();
@@ -302,13 +327,15 @@ class Database : public runtime::ObjectRef {
302327 * \param f_commit_workload The packed function of `CommitWorkload`.
303328 * \param f_commit_tuning_record The packed function of `CommitTuningRecord`.
304329 * \param f_get_top_k The packed function of `GetTopK`.
330+ * \param f_get_all_tuning_records The packed function of `GetAllTuningRecords`.
305331 * \param f_size The packed function of `Size`.
306332 * \return The created database.
307333 */
308334 TVM_DLL static Database PyDatabase (PyDatabaseNode::FHasWorkload f_has_workload,
309335 PyDatabaseNode::FCommitWorkload f_commit_workload,
310336 PyDatabaseNode::FCommitTuningRecord f_commit_tuning_record,
311337 PyDatabaseNode::FGetTopK f_get_top_k,
338+ PyDatabaseNode::FGetAllTuningRecords f_get_all_tuning_records,
312339 PyDatabaseNode::FSize f_size);
313340 TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS (Database, runtime::ObjectRef, DatabaseNode);
314341};
0 commit comments