mxnet
c_runtime_api.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 c_runtime_api.h
22  * \brief MXNet runtime library.
23  */
24 // Acknowledgement: This file originates from incubator-tvm
25 #ifndef MXNET_RUNTIME_C_RUNTIME_API_H_
26 #define MXNET_RUNTIME_C_RUNTIME_API_H_
27 
28 #include <dlpack/dlpack.h>
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 #include <mxnet/c_api.h>
34 #include <stdint.h>
35 #include <stddef.h>
36 
37 
42 typedef enum {
43  // The type code of other types are compatible with DLPack.
44  // The next few fields are extension types
45  // that is used by MXNet API calls.
46  kHandle = 3U,
47  kNull = 4U,
48  kMXNetType = 5U,
53  kFuncHandle = 10U,
54  kStr = 11U,
55  kBytes = 12U,
58  // Extension codes for other frameworks to integrate MXNet PackedFunc.
59  // To make sure each framework's id do not conflict, use first and
60  // last sections to mark ranges.
61  // Open an issue at the repo if you need a section of code.
62  kExtBegin = 15U,
63  kNNVMFirst = 16U,
64  kNNVMLast = 20U,
65  // The following section of code is used for non-reserved types.
67  kExtEnd = 128U,
68  // The rest of the space is used for custom, user-supplied datatypes
69  kCustomBegin = 129U,
71 
76 typedef union {
77  int64_t v_int64;
78  double v_float64;
79  void* v_handle;
80  const char* v_str;
82 } MXNetValue;
83 
88 typedef struct {
89  const char* data;
90  size_t size;
92 
94 typedef void* MXNetFunctionHandle;
96 typedef void* MXNetObjectHandle;
97 
103 MXNET_DLL int MXNetFuncFree(MXNetFunctionHandle func);
104 
125 MXNET_DLL int MXNetFuncCall(MXNetFunctionHandle func,
126  MXNetValue* arg_values,
127  int* type_codes,
128  int num_args,
129  MXNetValue* ret_val,
130  int* ret_type_code);
131 
141 MXNET_DLL int MXNetFuncGetGlobal(const char* name, MXNetFunctionHandle* out);
142 
149 MXNET_DLL int MXNetFuncListGlobalNames(int* out_size,
150  const char*** out_array);
151 
160 MXNET_DLL int MXNetObjectFree(MXNetObjectHandle obj);
161 
162 #ifdef __cplusplus
163 } // extern "C"
164 #endif
165 #endif // MXNET_RUNTIME_C_RUNTIME_API_H_
Definition: c_runtime_api.h:46
void * v_handle
Definition: c_runtime_api.h:79
The common header of DLPack.
Definition: c_runtime_api.h:64
Definition: c_runtime_api.h:62
Definition: c_runtime_api.h:63
Definition: c_runtime_api.h:52
Definition: c_runtime_api.h:69
Definition: c_runtime_api.h:47
Definition: c_runtime_api.h:49
double v_float64
Definition: c_runtime_api.h:78
Definition: c_runtime_api.h:53
MXNET_DLL int MXNetFuncListGlobalNames(int *out_size, const char ***out_array)
List all the globally registered function name.
int64_t v_int64
Definition: c_runtime_api.h:77
const char * v_str
Definition: c_runtime_api.h:80
Definition: c_runtime_api.h:67
Definition: c_runtime_api.h:50
Definition: c_runtime_api.h:66
DLDataType v_type
Definition: c_runtime_api.h:81
void * MXNetObjectHandle
Handle to Object.
Definition: c_runtime_api.h:96
MXNET_DLL int MXNetFuncFree(MXNetFunctionHandle func)
Free the function when it is no longer needed.
Union type of values being passed through API and function calls.
Definition: c_runtime_api.h:76
MXNET_DLL int MXNetFuncCall(MXNetFunctionHandle func, MXNetValue *arg_values, int *type_codes, int num_args, MXNetValue *ret_val, int *ret_type_code)
Call a Packed MXNet Function.
Definition: c_runtime_api.h:55
Definition: c_runtime_api.h:51
Byte array type used to pass in byte array When kBytes is used as data type.
Definition: c_runtime_api.h:88
#define MXNET_DLL
MXNET_DLL prefix for windows.
Definition: c_api.h:54
MXNET_DLL int MXNetFuncGetGlobal(const char *name, MXNetFunctionHandle *out)
Get a global function.
Definition: c_runtime_api.h:57
Definition: c_runtime_api.h:54
const char * data
Definition: c_runtime_api.h:89
The data type the tensor can hold.
Definition: dlpack.h:94
void * MXNetFunctionHandle
Handle to packed function handle.
Definition: c_runtime_api.h:94
size_t size
Definition: c_runtime_api.h:90
MXNET_DLL int MXNetObjectFree(MXNetObjectHandle obj)
Free the object.
Definition: c_runtime_api.h:56
Definition: c_runtime_api.h:48
MXNetTypeCode
The type code in MXNetType.
Definition: c_runtime_api.h:42