areusch commented on a change in pull request #10311: URL: https://github.com/apache/tvm/pull/10311#discussion_r815232003
########## File path: include/tvm/runtime/metadata.h ########## @@ -0,0 +1,127 @@ +/* + * 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. + */ + +/*! + * \file tvm/runtime/metadata.h + * \brief Defines types which can be used in Metadata. + */ +#ifndef TVM_RUNTIME_METADATA_H_ +#define TVM_RUNTIME_METADATA_H_ + +#include <inttypes.h> +#include <tvm/runtime/c_runtime_api.h> +#include <tvm/runtime/metadata_base.h> +#include <tvm/support/span.h> + +#define TVM_METADATA_VERSION 1 +static const constexpr int64_t kMetadataVersion = TVM_METADATA_VERSION; +#ifdef __cplusplus Review comment: in #10283, I moved the `#ifdef` to exclude any c++ syntax and test_cpp_aot now proves that this file compiles under C. it is my intent that this file can be compiled without the need for C++. ########## File path: include/tvm/runtime/metadata.h ########## @@ -0,0 +1,127 @@ +/* + * 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. + */ + +/*! + * \file tvm/runtime/metadata.h + * \brief Defines types which can be used in Metadata. + */ +#ifndef TVM_RUNTIME_METADATA_H_ +#define TVM_RUNTIME_METADATA_H_ + +#include <inttypes.h> +#include <tvm/runtime/c_runtime_api.h> +#include <tvm/runtime/metadata_base.h> +#include <tvm/support/span.h> + +#define TVM_METADATA_VERSION 1 +static const constexpr int64_t kMetadataVersion = TVM_METADATA_VERSION; +#ifdef __cplusplus +extern "C" { +#endif + +struct TVMMetadata { + int64_t version; + const struct TVMTensorInfo* inputs; + int64_t num_inputs; + const struct TVMTensorInfo* outputs; + int64_t num_outputs; + const char** devices; + int64_t num_devices; + const char* executor; + const char* mod_name; + const char* interface_api; + bool use_unpacked_api; +}; + +struct TVMTensorInfo { + const char* name; + const int64_t* shape; + int64_t num_shape; + DLDataType dtype; +}; +#ifdef __cplusplus Review comment: let's discuss above ########## File path: include/tvm/runtime/metadata.h ########## @@ -0,0 +1,127 @@ +/* + * 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. + */ + +/*! + * \file tvm/runtime/metadata.h + * \brief Defines types which can be used in Metadata. + */ +#ifndef TVM_RUNTIME_METADATA_H_ +#define TVM_RUNTIME_METADATA_H_ + +#include <inttypes.h> +#include <tvm/runtime/c_runtime_api.h> +#include <tvm/runtime/metadata_base.h> +#include <tvm/support/span.h> + +#define TVM_METADATA_VERSION 1 +static const constexpr int64_t kMetadataVersion = TVM_METADATA_VERSION; +#ifdef __cplusplus +extern "C" { +#endif + +struct TVMMetadata { + int64_t version; + const struct TVMTensorInfo* inputs; + int64_t num_inputs; + const struct TVMTensorInfo* outputs; + int64_t num_outputs; + const char** devices; + int64_t num_devices; + const char* executor; + const char* mod_name; + const char* interface_api; + bool use_unpacked_api; +}; + +struct TVMTensorInfo { + const char* name; + const int64_t* shape; + int64_t num_shape; + DLDataType dtype; +}; +#ifdef __cplusplus +} // extern "C" +#include <tvm/runtime/object.h> +namespace tvm { +namespace runtime { +namespace metadata { + +class Metadata; +class TensorInfo; + +class MetadataNode : public MetadataBaseNode { + public: + MetadataNode(const struct ::TVMMetadata* data) : data_{data} {} + static constexpr const char* _type_key = "metadata.MetadataNode"; + std::string get_name() override; + inline int64_t version() const { return int64_t(data_->version); } + inline int64_t num_inputs() const { return data_->num_inputs; } + ArrayAccessor<struct TVMTensorInfo, TensorInfo> inputs(); + inline int64_t num_outputs() const { return data_->num_outputs; } + ArrayAccessor<struct TVMTensorInfo, TensorInfo> outputs(); + inline int64_t num_devices() const { return data_->num_devices; } + ArrayAccessor<const char*, ::tvm::runtime::String> devices(); + inline ::tvm::runtime::String executor() const { return ::tvm::runtime::String(data_->executor); } Review comment: i'll address this in #10283 ########## File path: include/tvm/runtime/metadata_base.h ########## @@ -0,0 +1,190 @@ +/* + * 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. + */ + +/*! + * \file tvm/runtime/metadata_base.h + * \brief Defines types which can be used in Metadata. + */ +#ifndef TVM_RUNTIME_METADATA_BASE_H_ +#define TVM_RUNTIME_METADATA_BASE_H_ + +#include <string> +#include <tvm/ir/expr.h> +#include <tvm/runtime/object.h> + +namespace tvm { +namespace runtime { +namespace metadata { + +class MetadataBaseNode : public ::tvm::runtime::Object { + public: + virtual std::string get_name() = 0; + + static constexpr const char* _type_key = "metadata.MetadataBaseNode"; + TVM_DECLARE_BASE_OBJECT_INFO(MetadataBaseNode, ::tvm::runtime::Object); +}; + +class MetadataBase : public ::tvm::runtime::ObjectRef { + public: + TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS(MetadataBase, ::tvm::runtime::ObjectRef, MetadataBaseNode); +}; + +template <typename C, class Ref> Review comment: i'll address this in #10283 -- 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]
