arguments.h 5.6 KB
Newer Older
1
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
Y
Yu Yang 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14

Licensed 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. */

Y
Yu Yang 已提交
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
#ifndef __PADDLE_CAPI_ARGUMENTS_H__
#define __PADDLE_CAPI_ARGUMENTS_H__

#include <stdint.h>
#include "config.h"
#include "error.h"
#include "matrix.h"
#include "vector.h"

/**
 * Arguments functions. Each argument means layer output. Arguments means a
 * array of arguemnt.
 */
typedef void* paddle_arguments;

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @brief paddle_arguments_create_none Create a array of arguments, which size
 * is zero.
 * @return Arguemnts
 */
PD_API paddle_arguments paddle_arguments_create_none();

/**
 * @brief paddle_arguments_destroy Destroy the arguments
 * @param args arguments to destroy
 * @return paddle_error
 */
PD_API paddle_error paddle_arguments_destroy(paddle_arguments args);

/**
Y
Yu Yang 已提交
49
 * @brief paddle_arguments_get_size Get size of arguments array
Y
Yu Yang 已提交
50 51 52 53
 * @param [in] args arguments array
 * @param [out] size array size
 * @return paddle_error
 */
Y
Yu Yang 已提交
54 55
PD_API paddle_error paddle_arguments_get_size(paddle_arguments args,
                                              uint64_t* size);
Y
Yu Yang 已提交
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85

/**
 * @brief PDArgsResize Resize a arguments array.
 * @param args arguments array.
 * @param size target size of array
 * @return paddle_error
 */
PD_API paddle_error paddle_arguments_resize(paddle_arguments args,
                                            uint64_t size);

/**
 * @brief PDArgsSetValue Set value matrix of one argument in array, which index
 *        is `ID`.
 * @param args arguments array
 * @param ID array index
 * @param mat matrix pointer
 * @return paddle_error
 */
PD_API paddle_error paddle_arguments_set_value(paddle_arguments args,
                                               uint64_t ID,
                                               paddle_matrix mat);

/**
 * @brief PDArgsGetValue Get value matrix of one argument in array, which index
 *        is `ID`.
 * @param [in] args arguments array
 * @param [in] ID array index
 * @param [out] mat matrix pointer
 * @return paddle_error
 */
Y
Yu Yang 已提交
86 87 88
PD_API paddle_error paddle_arguments_get_value(paddle_arguments args,
                                               uint64_t ID,
                                               paddle_matrix mat);
Y
Yu Yang 已提交
89

Y
yuyang18 已提交
90 91 92 93 94 95 96 97 98 99 100 101
/**
 * @brief paddle_arguments_get_prob Get the prob matrix of beam search, which
 *        slot ID is `ID`
 * @param [in] args arguments array
 * @param [in] ID array index
 * @param [out] mat matrix pointer
 * @return paddle_error
 */
PD_API paddle_error paddle_arguments_get_prob(paddle_arguments args,
                                              uint64_t ID,
                                              paddle_matrix mat);

Y
Yu Yang 已提交
102 103 104 105 106 107 108 109
/**
 * @brief PDArgsGetIds Get the integer vector of one argument in array, which
 *        index is `ID`.
 * @param args arguments array
 * @param ID array index
 * @param ids integer vector pointer
 * @return paddle_error
 */
Y
Yu Yang 已提交
110 111 112
PD_API paddle_error paddle_arguments_get_ids(paddle_arguments args,
                                             uint64_t ID,
                                             paddle_ivector ids);
Y
Yu Yang 已提交
113 114 115 116 117 118 119 120 121 122 123 124 125

/**
 * @brief PDArgsSetIds Set the integer vector of one argument in array, which
 *        index is `ID`.
 * @param [in] args arguments array
 * @param [in] ID array index
 * @param [out] ids integer vector pointer
 * @return paddle_error
 */
PD_API paddle_error paddle_arguments_set_ids(paddle_arguments args,
                                             uint64_t ID,
                                             paddle_ivector ids);

126 127 128 129 130
/**
 * @brief paddle_arguments_set_frame_shape Set the fram size of one argument
 *        in array, which index is `ID`.
 * @param [in] args arguments array
 * @param [in] ID array index
131 132
 * @param [in] frameHeight maximum height of input images
 * @param [in] frameWidth maximum width of input images
133 134 135 136 137 138 139
 * @return paddle_error
 */
PD_API paddle_error paddle_arguments_set_frame_shape(paddle_arguments args,
                                                     uint64_t ID,
                                                     uint64_t frameHeight,
                                                     uint64_t frameWidth);

Y
Yu Yang 已提交
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
/**
 * @brief PDArgsSetSequenceStartPos Set sequence start position vector of one
 *        argument in array, which index is `ID`.
 * @param args arguments array
 * @param ID array index
 * @param seqPos sequence position array.
 * @return paddle_error
 */
PD_API paddle_error
paddle_arguments_set_sequence_start_pos(paddle_arguments args,
                                        uint64_t ID,
                                        uint32_t nestedLevel,
                                        paddle_ivector seqPos);
/**
 * @brief PDArgsGetSequenceStartPos Get sequence start position vector of one
 *        argument in array, which index is `ID`.
 * @param [in] args arguments array
 * @param [in] ID array index
 * @param [out] seqPos sequence position array
 * @return paddle_error
 */
Y
Yu Yang 已提交
161 162 163 164 165
PD_API paddle_error
paddle_arguments_get_sequence_start_pos(paddle_arguments args,
                                        uint64_t ID,
                                        uint32_t nestedLevel,
                                        paddle_ivector seqPos);
Y
Yu Yang 已提交
166 167 168 169 170 171

#ifdef __cplusplus
}
#endif

#endif