tvm
Loading...
Searching...
No Matches
base.h
Go to the documentation of this file.
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
20/*
21 * \file tvm/runtime/base.h
22 * \brief base macros
23 */
24#ifndef TVM_RUNTIME_BASE_H_
25#define TVM_RUNTIME_BASE_H_
26
27// TVM runtime fully relies on TVM FFI C API
28// we will avoid defining extra C APIs here
29#include <tvm/ffi/c_api.h>
30
31// TIRx version. CMake defines it from the setuptools-scm version under scikit-build-core or
32// from the git tag. The literal below is the fallback for a build with no definition.
33#ifndef TVM_TIRX_VERSION
34#define TVM_TIRX_VERSION "0.1.0.dev0"
35#endif
36
37// Core runtime visibility is independent of TIRx compiler visibility.
38// TVM_RUNTIME_EXPORTS selects core-runtime exports on MSVC; downstream
39// consumers import them. Embedders may override each library policy.
40#ifdef __EMSCRIPTEN__
41#include <emscripten/emscripten.h>
42#endif
43
44// Core IR, TIRx and shared compiler infrastructure live in libtvm_tirx_compiler.
45#ifndef TVM_TIRX_DLL
46#if defined(__EMSCRIPTEN__)
47#define TVM_TIRX_DLL EMSCRIPTEN_KEEPALIVE
48#elif defined(_MSC_VER)
49#ifdef TVM_TIRX_EXPORTS
50#define TVM_TIRX_DLL __declspec(dllexport)
51#else
52#define TVM_TIRX_DLL __declspec(dllimport)
53#endif
54#else
55#define TVM_TIRX_DLL __attribute__((visibility("default")))
56#endif
57#endif
58
59// --- TVM_RUNTIME_DLL family (libtvm_runtime) ---
60#if !defined(TVM_RUNTIME_DLL) && defined(__EMSCRIPTEN__)
61#define TVM_RUNTIME_DLL EMSCRIPTEN_KEEPALIVE
62#define TVM_RUNTIME_DLL_EXPORT EMSCRIPTEN_KEEPALIVE
63#endif
64#if !defined(TVM_RUNTIME_DLL) && defined(_MSC_VER)
65#ifdef TVM_RUNTIME_EXPORTS
66#define TVM_RUNTIME_DLL __declspec(dllexport)
67#else
68#define TVM_RUNTIME_DLL __declspec(dllimport)
69#endif
70#define TVM_RUNTIME_DLL_EXPORT __declspec(dllexport)
71#endif
72#ifndef TVM_RUNTIME_DLL
73#define TVM_RUNTIME_DLL __attribute__((visibility("default")))
74#define TVM_RUNTIME_DLL_EXPORT __attribute__((visibility("default")))
75#endif
76
77#endif // TVM_RUNTIME_BASE_H_