c_dsl_api.h 2.41 KB
Newer Older
tqchen committed
1 2
/*!
 *  Copyright (c) 2016 by Contributors
tqchen committed
3
 * \file tvm/c_dsl_api.h
4
 *
5
 * \brief TVM DSL Node C API, used to interact to DSL compilation.
6
 *
7 8 9 10 11 12
 *  These are only a few functions needed for DSL construction time.
 *  These function are only available when link libtvm.
 *  If only TVM runtime is linked, calling these function will trigger error.
 *
 * \note Most API functions are registerd as PackedFunc and
 *  can be grabbed via TVMFuncGetGlobal
tqchen committed
13
 */
14 15
#ifndef TVM_C_DSL_API_H_
#define TVM_C_DSL_API_H_
tqchen committed
16

17
#include "./runtime/c_runtime_api.h"
tqchen committed
18

19
#ifdef __cplusplus
20
extern "C" {
21 22
#endif

tqchen committed
23 24 25
/*! \brief handle to node */
typedef void* NodeHandle;

tqchen committed
26 27 28
/*!
 * \brief free the node handle
 * \param handle The node handle to be freed.
29
 * \return 0 when success, -1 when failure happens
tqchen committed
30 31 32 33
 */
TVM_DLL int TVMNodeFree(NodeHandle handle);

/*!
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
 * \brief Convert type key to type index.
 * \param type_key The key of the type.
 * \param out_index the corresponding type index.
 * \return 0 when success, -1 when failure happens
 */
TVM_DLL int TVMNodeTypeKey2Index(const char* type_key,
                                 int* out_index);

/*!
 * \brief Get runtime type index of the node.
 * \param handle the node handle.
 * \param out_index the corresponding type index.
 * \return 0 when success, -1 when failure happens
 */
TVM_DLL int TVMNodeGetTypeIndex(NodeHandle handle,
                                int* out_index);

/*!
tqchen committed
52 53 54 55
 * \brief get attributes given key
 * \param handle The node handle
 * \param key The attribute name
 * \param out_value The attribute value
56
 * \param out_type_code The type code of the attribute.
57
 * \param out_success Whether get is successful.
58 59
 * \return 0 when success, -1 when failure happens
 * \note API calls always exchanges with type bits=64, lanes=1
tqchen committed
60 61 62
 */
TVM_DLL int TVMNodeGetAttr(NodeHandle handle,
                           const char* key,
63 64
                           TVMValue* out_value,
                           int* out_type_code,
65
                           int* out_success);
tqchen committed
66

tqchen committed
67 68 69 70 71
/*!
 * \brief get attributes names in the node.
 * \param handle The node handle
 * \param out_size The number of functions
 * \param out_array The array of function names.
72
 * \return 0 when success, -1 when failure happens
tqchen committed
73 74 75 76
 */
TVM_DLL int TVMNodeListAttrNames(NodeHandle handle,
                                 int *out_size,
                                 const char*** out_array);
77
#ifdef __cplusplus
78
}  // TVM_EXTERN_C
79 80
#endif
#endif  // TVM_C_DSL_API_H_