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_api_test.h
22  * \brief C API of mxnet for ease of testing backend in Python
23  */
24 #ifndef MXNET_C_API_TEST_H_
25 #define MXNET_C_API_TEST_H_
26 
27 /*! \brief Inhibit C++ name-mangling for MXNet functions. */
28 #ifdef __cplusplus
29 extern "C" {
30 #endif  // __cplusplus
31 
32 #include <mxnet/c_api.h>
33 
34 /*!
35  * \brief This API partitions a graph only by the operator names
36  * provided by users. This will attach a DefaultSubgraphProperty
37  * to the input graph for partitioning. This function should be
38  * used only for the testing purpose.
39  */
40 MXNET_DLL int MXBuildSubgraphByOpNames(SymbolHandle sym_handle,
41                                         const char* prop_name,
42                                         const uint32_t num_ops,
43                                         const char** op_names,
44                                         SymbolHandle* ret_sym_handle);
45 
46 /*!
47  * \brief Given a subgraph property name, use the provided op names
48  * as the op_names attribute for that subgraph property, instead of
49  * the predefined one. This is only for the purpose of testing.
50  */
51 MXNET_DLL int MXSetSubgraphPropertyOpNames(const char* prop_name,
52                                            const uint32_t num_ops,
53                                            const char** op_names);
54 
55 /*!
56  * \brief Given a subgraph property name, use the provided op names
57  * as the op_names attribute for that subgraph property, instead of
58  * the predefined one. This is only for the purpose of testing.
59  * Compared to MXSetSubgraphPropertyOpNames(), this API will add
60  * op_names to the backend property.
61  */
62 MXNET_DLL int MXSetSubgraphPropertyOpNamesV2(const char* prop_name,
63                                            const uint32_t num_ops,
64                                            const char** op_names);
65 /*!
66  * \brief Given a subgraph property name, delete the op name set
67  * in the SubgraphPropertyOpNameSet.
68  */
69 MXNET_DLL int MXRemoveSubgraphPropertyOpNames(const char* prop_name);
70 /*!
71  * \brief Given a subgraph property name, remove op_names attribute of
72  * the in the SubgraphBackend property.
73  */
74 MXNET_DLL int MXRemoveSubgraphPropertyOpNamesV2(const char* prop_name);
75 
76 
77 /*!
78  * \brief Get the value of an environment variable as seen by the backend.
79  * \param name The name of the environment variable
80  * \param value The returned value of the environment variable
81  */
82 MXNET_DLL int MXGetEnv(const char* name,
83                        const char** value);
84 
85 /*!
86  * \brief Set the value of an environment variable from the backend.
87  * \param name The name of the environment variable
88  * \param value The desired value to set the environment variable `name`
89  */
90 MXNET_DLL int MXSetEnv(const char* name,
91                        const char* value);
92 
93 #ifdef __cplusplus
94 }
95 #endif  // __cplusplus
96 
97 #endif  // MXNET_C_API_TEST_H_
98