c_dsl_api.h 3.16 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

tqchen committed
20
/*!
tqchen committed
21
 * \file tvm/c_dsl_api.h
22
 *
23
 * \brief TVM DSL Node C API, used to interact to DSL compilation.
24
 *
25 26 27 28 29 30
 *  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
31
 */
32 33
#ifndef TVM_C_DSL_API_H_
#define TVM_C_DSL_API_H_
tqchen committed
34

35
#include "runtime/c_runtime_api.h"
tqchen committed
36

37
#ifdef __cplusplus
38
extern "C" {
39 40
#endif

tqchen committed
41 42 43
/*! \brief handle to node */
typedef void* NodeHandle;

tqchen committed
44 45 46
/*!
 * \brief free the node handle
 * \param handle The node handle to be freed.
47
 * \return 0 when success, -1 when failure happens
tqchen committed
48 49 50 51
 */
TVM_DLL int TVMNodeFree(NodeHandle handle);

/*!
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
 * \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
70 71 72 73
 * \brief get attributes given key
 * \param handle The node handle
 * \param key The attribute name
 * \param out_value The attribute value
74
 * \param out_type_code The type code of the attribute.
75
 * \param out_success Whether get is successful.
76 77
 * \return 0 when success, -1 when failure happens
 * \note API calls always exchanges with type bits=64, lanes=1
tqchen committed
78 79 80
 */
TVM_DLL int TVMNodeGetAttr(NodeHandle handle,
                           const char* key,
81 82
                           TVMValue* out_value,
                           int* out_type_code,
83
                           int* out_success);
tqchen committed
84

tqchen committed
85 86 87 88 89
/*!
 * \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.
90
 * \return 0 when success, -1 when failure happens
tqchen committed
91 92 93 94
 */
TVM_DLL int TVMNodeListAttrNames(NodeHandle handle,
                                 int *out_size,
                                 const char*** out_array);
95
#ifdef __cplusplus
96
}  // TVM_EXTERN_C
97 98
#endif
#endif  // TVM_C_DSL_API_H_