junrushao1994 commented on a change in pull request #9061: URL: https://github.com/apache/tvm/pull/9061#discussion_r715198488
########## File path: include/tvm/meta_schedule/workload_registry.h ########## @@ -0,0 +1,136 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +#ifndef TVM_META_SCHEDULE_WORKLOAD_REGISTRY_H_ +#define TVM_META_SCHEDULE_WORKLOAD_REGISTRY_H_ + +#include <tvm/ir/module.h> + +#include <unordered_map> +#include <vector> + +namespace tvm { +namespace meta_schedule { + +/*! \brief The class of workload tokens. */ +class WorkloadTokenNode : public runtime::Object { + public: + /*! \brief The workload's IRModule. */ + IRModule mod; + /*! \brief The workload's structural hash. */ + String shash; + /*! \brief The workload's token id. */ + int64_t token_id_; + + void VisitAttrs(tvm::AttrVisitor* v) { + v->Visit("mod", &mod); + v->Visit("shash", &shash); + // `token_id_` is not visited + } + + /*! + * \brief Export the workload token to a JSON string. + * \return An array containing the structural hash and the base64 json string. + */ + ObjectRef AsJSON() const; + + static constexpr const char* _type_key = "meta_schedule.WorkloadToken"; + TVM_DECLARE_FINAL_OBJECT_INFO(WorkloadTokenNode, runtime::Object); +}; + +/*! + * \brief Managed reference to WorkloadTokenNode. + * \sa WorkloadTokenNode + */ +class WorkloadToken : public runtime::ObjectRef { + public: + /*! + * \brief Constructor of WorkloadToken. + * \param mod The workload's IRModule. + * \param shash The workload's structural hash. + * \param token_id The workload's token id. + */ + TVM_DLL explicit WorkloadToken(IRModule mod, String shash, int64_t token_id); + + /*! + * \brief Create a workload token from a json object. + * \param json_obj The json object. + * \param token_id The workload's token id. + * \return The created workload token. + */ + TVM_DLL static WorkloadToken FromJSON(const ObjectRef& json_obj, int64_t token_id); + + TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(WorkloadToken, runtime::ObjectRef, WorkloadTokenNode); +}; + +/*! \brief The class for workload registry. */ +class WorkloadRegistryNode : public runtime::Object { Review comment: No it's not a right name -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
