mbaret commented on a change in pull request #6222: URL: https://github.com/apache/incubator-tvm/pull/6222#discussion_r471597402
########## File path: src/relay/backend/contrib/ethosn/codegen_ethosn.h ########## @@ -0,0 +1,328 @@ +/* + * 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 src/relay/backend/contrib/ethosn/codegen_ethosn.h + * \brief The Relay -> Ethos-N command stream compiler. + */ + +#ifndef TVM_RELAY_BACKEND_CONTRIB_ETHOSN_CODEGEN_ETHOSN_H_ +#define TVM_RELAY_BACKEND_CONTRIB_ETHOSN_CODEGEN_ETHOSN_H_ + +#include <dmlc/memory_io.h> +#include <tvm/relay/attrs/nn.h> +#include <tvm/relay/expr_functor.h> +#include <tvm/relay/transform.h> +#include <tvm/relay/type.h> +#include <tvm/runtime/module.h> +#include <tvm/runtime/registry.h> + +#include <algorithm> +#include <fstream> +#include <map> +#include <memory> +#include <sstream> +#include <string> +#include <unordered_map> +#include <utility> +#include <vector> + +#include "../../../../runtime/contrib/ethosn/ethosn_runtime.h" +#include "../codegen_c/codegen_c.h" +#include "ethosn_api.h" +#include "ethosn_support_library/Support.hpp" +#include "ethosn_support_library/SupportQueries.hpp" + +namespace tvm { +namespace relay { +namespace contrib { +namespace ethosn { + +namespace sl = ::ethosn::support_library; + +/*! + * \brief A struct to hold an uncompiled support library network alongside + * the desired order of input and output operation ids. + */ +struct NetworkWithIDs { + struct hash_pair { + template <class T_0, class T_1> + size_t operator()(const std::pair<T_0, T_1>& p) const { + return std::hash<T_0>{}(p.first) ^ std::hash<T_1>{}(p.second); + } + }; + std::shared_ptr<sl::Network> network; + std::unordered_map<uint32_t, unsigned int> input_ids; + std::unordered_map<std::pair<uint32_t, uint32_t>, unsigned int, hash_pair> output_ids; +}; + +/*! + * \brief A base class for error handling using ErrorReporter. + */ +class ErrorReportingPass { Review comment: This error reporter is primarily to assist us in debugging. Do you know of any existing passes that have been migrated? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
