1 /** 2 * Copyright 2022 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef MINDSPORE_CCSRC_C_API_INCLUDE_VALUE_H_ 18 #define MINDSPORE_CCSRC_C_API_INCLUDE_VALUE_H_ 19 20 #include <stdbool.h> 21 #include <stdlib.h> 22 #include "include/c_api/ms/base/macros.h" 23 #include "include/c_api/ms/base/handle_types.h" 24 #include "include/c_api/ms/base/types.h" 25 #include "include/c_api/ms/context.h" 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 /// \brief Create new Int64 scalar value. 32 /// 33 /// \param[in] res_mgr Resource Handle that manages the nodes of the funcGraph. 34 /// \param[in] v Given value. 35 /// 36 /// \return Value handle. 37 MIND_C_API ValueHandle MSNewValueInt64(ResMgrHandle res_mgr, const int64_t v); 38 39 /// \brief Create new flaot32 scalar value. 40 /// 41 /// \param[in] res_mgr Resource Handle that manages the nodes of the funcGraph. 42 /// \param[in] v Given value. 43 /// 44 /// \return Value handle. 45 MIND_C_API ValueHandle MSNewValueFloat32(ResMgrHandle res_mgr, const float v); 46 47 /// \brief Create new Bool scalar value. 48 /// 49 /// \param[in] res_mgr Resource Handle that manages the nodes of the funcGraph. 50 /// \param[in] v Given value. 51 /// 52 /// \return Value handle. 53 MIND_C_API ValueHandle MSNewValueBool(ResMgrHandle res_mgr, const bool v); 54 55 /// \brief Create new value of DataType. 56 /// 57 /// \param[in] res_mgr Resource Handle that manages the nodes of the funcGraph. 58 /// \param[in] type Given data type. 59 /// 60 /// \return Value handle. 61 MIND_C_API ValueHandle MSNewValueType(ResMgrHandle res_mgr, DataTypeC type); 62 63 /// \brief Create new vector of Strings Value. 64 /// 65 /// \param[in] res_mgr Resource Handle that manages the nodes of the funcGraph. 66 /// \param[in] strs Given value. 67 /// \param[in] vec_len Length of the string vector. 68 /// 69 /// \return Value handle. 70 MIND_C_API ValueHandle MSNewValueStrings(ResMgrHandle res_mgr, const char *strs[], size_t vec_len); 71 72 /// \brief Create new Value with array. 73 /// 74 /// \param[in] res_mgr Resource Handle that manages the nodes of the funcGraph. 75 /// \param[in] value Given array. 76 /// \param[in] vec_size Given array size. 77 /// \param[in] data_type Datatype of the array. 78 /// 79 /// \return Value handle 80 MIND_C_API ValueHandle MSNewValueArray(ResMgrHandle res_mgr, void *value, size_t vec_size, DataTypeC data_type); 81 #ifdef __cplusplus 82 } 83 #endif 84 #endif // MINDSPORE_CCSRC_C_API_INCLUDE_VALUE_H_ 85