1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19#ifndef TVM_RELAY_BACKEND_AOT_AOT_LOWER_MAIN_H_
20#define TVM_RELAY_BACKEND_AOT_AOT_LOWER_MAIN_H_
21
22#include <tvm/ir/transform.h>
23#include <tvm/target/compilation_config.h>
24
25#include <tuple>
26#include <unordered_map>
27#include <vector>
28
29#include "../utils.h"
30
31namespace tvm {
32namespace relay {
33namespace backend {
34namespace aot {
35
36using StorageMap =
37 std::unordered_map<Expr, StorageInfo, runtime::ObjectPtrHash, runtime::ObjectPtrEqual>;
38
39/*! \brief Exposed for testing, part of the implementation of AOTLowerMain */
40std::tuple<StorageMap, std::vector<int>> CreateStorage(const Function& func);
41
42/*! \brief Lower the Relay main function into TIR for use with the AOT executor.
43 *
44 * This pass expects that all operators have already been lowered to TIR and
45 * so only Calls to 'call_lowered' are present in main.
46 *
47 * \param mod_name The name of the module.
48 * \param config The compilation config.
49 * \param call_type The call type to use when calling functions.
50 */
51transform::Pass AOTLowerMain(String mod_name, tvm::CompilationConfig config, CallType call_type);
52
53} // namespace aot
54} // namespace backend
55} // namespace relay
56} // namespace tvm
57
58#endif // TVM_RELAY_BACKEND_AOT_AOT_LOWER_MAIN_H_
59