areusch commented on a change in pull request #8072: URL: https://github.com/apache/tvm/pull/8072#discussion_r660197575
########## File path: src/printer/model_library_format_printer.cc ########## @@ -0,0 +1,75 @@ +/* + * 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. + */ + +#include <tvm/runtime/module.h> +#include <tvm/runtime/registry.h> +#include <tvm/tir/var.h> + +#include "text_printer.h" + +namespace tvm { +namespace printer { + +class ModelLibraryFormatPrinter : public ::tvm::runtime::ModuleNode { + public: + ModelLibraryFormatPrinter(bool show_meta_data, + const runtime::TypedPackedFunc<std::string(ObjectRef)>& annotate, + bool show_warning) + : text_printer_{show_meta_data, annotate, show_warning} {} + + const char* type_key() const override { return "model_library_format_printer"; } + + std::string Print(const ObjectRef& node) { + Doc doc; + doc << text_printer_.PrintFinal(node); + return doc.str(); + } + + PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>& sptr_to_self) override { Review comment: i agree with that--however, we do need the lambda function to capture `sptr_to_self` (this mimics the Python descriptor `get()` implementation). i moved the body into a separate function to align this class for a future world where we implemented the auto-generated interface. cc @jroesch who has a prototype of the auto-generator -- 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]
