1/*
2 * SPDX-License-Identifier: Apache-2.0
3 */
4
5#ifndef ONNX_ONNX_PB_H
6#define ONNX_ONNX_PB_H
7
8// Defines ONNX_EXPORT and ONNX_IMPORT. On Windows, this corresponds to
9// different declarations (dllexport and dllimport). On Linux/Mac, it just
10// resolves to the same "default visibility" setting.
11#if defined(_MSC_VER)
12#if defined(ONNX_BUILD_SHARED_LIBS) || defined(ONNX_BUILD_MAIN_LIB)
13#define ONNX_EXPORT __declspec(dllexport)
14#define ONNX_IMPORT __declspec(dllimport)
15#else
16#define ONNX_EXPORT
17#define ONNX_IMPORT
18#endif
19#else
20#if defined(__GNUC__)
21#define ONNX_EXPORT __attribute__((__visibility__("default")))
22#else
23#define ONNX_EXPORT
24#endif
25#define ONNX_IMPORT ONNX_EXPORT
26#endif
27
28// ONNX_API is a macro that, depends on whether you are building the
29// main ONNX library or not, resolves to either ONNX_EXPORT or
30// ONNX_IMPORT.
31//
32// This is used in e.g. ONNX's protobuf files: when building the main library,
33// it is defined as ONNX_EXPORT to fix a Windows global-variable-in-dll
34// issue, and for anyone dependent on ONNX it will be defined as
35// ONNX_IMPORT. ONNX_BUILD_MAIN_LIB can also be set when being built
36// statically if ONNX is being linked into a shared library that wants
37// to export the ONNX APIs and classes.
38//
39// More details on Windows dllimport / dllexport can be found at
40// https://msdn.microsoft.com/en-us/library/3y1sfaz2.aspx
41//
42// This solution is similar to
43// https://github.com/pytorch/pytorch/blob/master/caffe2/core/common.h
44#if defined(ONNX_BUILD_SHARED_LIBS) || defined(ONNX_BUILD_MAIN_LIB)
45#define ONNX_API ONNX_EXPORT
46#else
47#define ONNX_API ONNX_IMPORT
48#endif
49
50#ifdef ONNX_ML
51#include "onnx/onnx-ml.pb.h"
52#else
53#include "onnx/onnx.pb.h"
54#endif
55
56#endif // ! ONNX_ONNX_PB_H
57