Skip to content

Commit 830fdd6

Browse files
authored
update C++ api (#5576)
1 parent 7684218 commit 830fdd6

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

docs/guides/custom_op/new_cpp_op_cn.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ PADDLE_API Tensor abs(const Tensor& x);
237237
PADDLE_API Tensor acos(const Tensor& x);
238238
PADDLE_API Tensor acosh(const Tensor& x);
239239
PADDLE_API Tensor add(const Tensor& x, const Tensor& y);
240+
PADDLE_API Tensor addmm(const Tensor& input, const Tensor& x, const Tensor& y, float beta = 1.0, float alpha = 1.0);
240241
PADDLE_API Tensor allclose(const Tensor& x, const Tensor& y, const Scalar& rtol, const Scalar& atol, bool equal_nan);
241242
PADDLE_API std::tuple<Tensor,Tensor> argsort(const Tensor& x, int axis, bool descending);
242243
PADDLE_API Tensor asin(const Tensor& x);
@@ -264,6 +265,7 @@ PADDLE_API Tensor dot(const Tensor& x, const Tensor& y);
264265
PADDLE_API Tensor elu(const Tensor& x, float alpha);
265266
PADDLE_API Tensor empty(const IntArray& shape, DataType dtype=DataType::FLOAT32, const Place& place=CPUPlace());
266267
PADDLE_API Tensor empty_like(const Tensor& x, DataType dtype=DataType::UNDEFINED, const Place& place={});
268+
PADDLE_API Tensor equal(const Tensor& x, const Tensor& y);
267269
PADDLE_API Tensor equal_all(const Tensor& x, const Tensor& y);
268270
PADDLE_API Tensor erf(const Tensor& x);
269271
PADDLE_API Tensor erfinv(const Tensor& x);
@@ -274,11 +276,18 @@ PADDLE_API std::tuple<Tensor,Tensor> flatten(const Tensor& x, int start_axis, in
274276
PADDLE_API Tensor flip(const Tensor& x, const std::vector<int>& axis);
275277
PADDLE_API Tensor floor(const Tensor& x);
276278
PADDLE_API Tensor floor_divide(const Tensor& x, const Tensor& y);
279+
PADDLE_API Tensor fmax(const Tensor& x, const Tensor& y);
280+
PADDLE_API Tensor fmin(const Tensor& x, const Tensor& y);
281+
PADDLE_API Tensor frame(const Tensor& x, int frame_length, int hop_length, int axis = -1);
277282
PADDLE_API Tensor full(const IntArray& shape, const Scalar& value, DataType dtype=DataType::FLOAT32, const Place& place=CPUPlace());
278283
PADDLE_API Tensor gather(const Tensor& x, const Tensor& index, const Scalar& axis=0);
279284
PADDLE_API Tensor gather_nd(const Tensor& x, const Tensor& index);
280285
PADDLE_API Tensor gelu(const Tensor& x, bool approximate);
286+
PADDLE_API Tensor greater_equal(const Tensor& x, const Tensor& y);
287+
PADDLE_API Tensor greater_than(const Tensor& x, const Tensor& y);
281288
PADDLE_API Tensor gumbel_softmax(const Tensor& x, float temperature, bool hard, int axis);
289+
PADDLE_API Tensor hardswish(const Tensor& x);
290+
PADDLE_API Tensor hardtanh(const Tensor& x, float t_min, float t_max);
282291
PADDLE_API Tensor imag(const Tensor& x);
283292
PADDLE_API Tensor increment(const Tensor& x, float value);
284293
PADDLE_API Tensor index_sample(const Tensor& x, const Tensor& index);
@@ -291,6 +300,8 @@ PADDLE_API Tensor kron(const Tensor& x, const Tensor& y);
291300
PADDLE_API std::tuple<Tensor,Tensor> kthvalue(const Tensor& x, int k, int axis, bool keepdim);
292301
PADDLE_API Tensor label_smooth(const Tensor& label, paddle::optional<const Tensor&> prior_dist, float epsilon);
293302
PADDLE_API Tensor lerp(const Tensor& x, const Tensor& y, const Tensor& weight);
303+
PADDLE_API Tensor less_equal(const Tensor& x, const Tensor& y);
304+
PADDLE_API Tensor less_than(const Tensor& x, const Tensor& y);
294305
PADDLE_API Tensor lgamma(const Tensor& x);
295306
PADDLE_API Tensor log(const Tensor& x);
296307
PADDLE_API Tensor log10(const Tensor& x);
@@ -302,27 +313,37 @@ PADDLE_API Tensor matmul(const Tensor& x, const Tensor& y, bool transpose_x=fals
302313
PADDLE_API Tensor matrix_power(const Tensor& x, int n);
303314
PADDLE_API Tensor maximum(const Tensor& x, const Tensor& y);
304315
PADDLE_API Tensor maxout(const Tensor& x, int groups, int axis);
316+
PADDLE_API std::vector<Tensor> meshgrid(const std::vector<Tensor>& inputs);
305317
PADDLE_API Tensor minimum(const Tensor& x, const Tensor& y);
306318
PADDLE_API std::tuple<Tensor,Tensor> mode(const Tensor& x, int axis, bool keepdim);
307319
PADDLE_API Tensor multi_dot(const std::vector<Tensor>& x);
308320
PADDLE_API Tensor multinomial(const Tensor& x, int num_samples, bool replacement);
309321
PADDLE_API Tensor multiply(const Tensor& x, const Tensor& y);
310322
PADDLE_API Tensor mv(const Tensor& x, const Tensor& vec);
311323
PADDLE_API std::tuple<Tensor,Tensor> nll_loss(const Tensor& input, const Tensor& label, paddle::optional<const Tensor&> weight, int64_t ignore_index, const std::string& reduction);
324+
PADDLE_API Tensor not_equal(const Tensor& x, const Tensor& y);
312325
PADDLE_API Tensor one_hot(const Tensor& x, const Scalar& num_classes);
326+
PADDLE_API Tensor ones(const IntArray& shape, DataType dtype = DataType::FLOAT32, const Place& place = CPUPlace());
327+
PADDLE_API Tensor overlap_add(const Tensor& x, int hop_length, int axis = -1);
313328
PADDLE_API Tensor pixel_shuffle(const Tensor& x, int upscale_factor, const std::string& data_format);
314329
PADDLE_API Tensor poisson(const Tensor& x);
330+
PADDLE_API Tensor put_along_axis(const Tensor& arr, const Tensor& indices, const Tensor& values, int axis, const std::string& reduce = "assign");
315331
PADDLE_API std::tuple<Tensor,Tensor> qr(const Tensor& x, const std::string& mode);
316332
PADDLE_API Tensor real(const Tensor& x);
317333
PADDLE_API Tensor reciprocal(const Tensor& x);
318334
PADDLE_API Tensor relu(const Tensor& x);
335+
PADDLE_API Tensor relu6(const Tensor& x);
336+
PADDLE_API Tensor remainder(const Tensor& x, const Tensor& y);
319337
PADDLE_API Tensor reshape(const Tensor& x, const IntArray& shape);
320338
PADDLE_API Tensor roll(const Tensor& x, const IntArray& shifts, const std::vector<int64_t>& axis);
321339
PADDLE_API Tensor round(const Tensor& x);
322340
PADDLE_API Tensor rsqrt(const Tensor& x);
323341
PADDLE_API Tensor scatter(const Tensor& x, const Tensor& index, const Tensor& updates, bool overwrite);
324342
PADDLE_API Tensor scatter_nd_add(const Tensor& x, const Tensor& index, const Tensor& updates);
325343
PADDLE_API Tensor selu(const Tensor& x, float scale, float alpha);
344+
PADDLE_API Tensor send_u_recv(const Tensor& x, const Tensor& src_index, const Tensor& dst_index, const std::string& reduce_op = "SUM", const IntArray& out_size = {0});
345+
PADDLE_API Tensor send_ue_recv(const Tensor& x, const Tensor& y, const Tensor& src_index, const Tensor& dst_index, const std::string& message_op, const std::string& reduce_op, const IntArray& out_size);
346+
PADDLE_API Tensor send_uv(const Tensor& x, const Tensor& y, const Tensor& src_index, const Tensor& dst_index, const std::string& message_op = "ADD");
326347
PADDLE_API Tensor sign(const Tensor& x);
327348
PADDLE_API Tensor silu(const Tensor& x);
328349
PADDLE_API Tensor sin(const Tensor& x);
@@ -333,20 +354,23 @@ PADDLE_API Tensor square(const Tensor& x);
333354
PADDLE_API Tensor stack(const std::vector<Tensor>& x, int axis);
334355
PADDLE_API Tensor strided_slice(const Tensor& x, const std::vector<int>& axes, const IntArray& starts, const IntArray& ends, const IntArray& strides);
335356
PADDLE_API Tensor subtract(const Tensor& x, const Tensor& y);
357+
PADDLE_API Tensor swish(const Tensor& x);
336358
PADDLE_API Tensor tanh(const Tensor& x);
337359
PADDLE_API Tensor thresholded_relu(const Tensor& x, float threshold);
338360
PADDLE_API Tensor tile(const Tensor& x, const IntArray& repeat_times);
339361
PADDLE_API Tensor trace(const Tensor& x, int offset, int axis1, int axis2);
340362
PADDLE_API Tensor triangular_solve(const Tensor& x, const Tensor& y, bool upper, bool transpose, bool unitriangular);
363+
PADDLE_API Tensor tril(const Tensor& x, int diagonal);
341364
PADDLE_API std::vector<Tensor> unbind(const Tensor& input, int axis);
342365
PADDLE_API std::tuple<Tensor,Tensor,Tensor,Tensor> unique(const Tensor& x, bool return_index, bool return_inverse, bool return_counts, const std::vector<int>& axis, DataType dtype=DataType::INT64);
343366
PADDLE_API std::tuple<Tensor,Tensor> unsqueeze(const Tensor& x, const IntArray& axis);
344367
PADDLE_API Tensor where(const Tensor& condition, const Tensor& x, const Tensor& y);
368+
PADDLE_API Tensor zeros(const IntArray& shape, DataType dtype = DataType::FLOAT32, const Place& place = CPUPlace());
345369
```
346370

347371
> 注:后续我们会提供更方便的查阅 C++ API 文档的入口。
348372
349-
在 2.3 版本,我们共支持了大约 250 个类似的 C++ API,能够覆盖大部分的基础运算,但是除前述的 109 个 C++ API 之外,剩余的 C++ API 由于一些历史原因,其参数列表尚未和相应的 Python API 对齐,因此目前剩余这些 API 只能作为 experimental 的 API 使用,需要通过 `paddle::experimental::xxx` 进行调用,且这些 experimental API 在下个版本可能会有不兼容的升级,如果不介意随下一版本升级的话,可以使用,追求稳定的话则不建议使用。
373+
在 2.3 版本,我们共支持了大约 250 个类似的 C++ API,能够覆盖大部分的基础运算,但是除前述的 133 个 C++ API 之外,剩余的 C++ API 由于一些历史原因,其参数列表尚未和相应的 Python API 对齐,因此目前剩余这些 API 只能作为 experimental 的 API 使用,需要通过 `paddle::experimental::xxx` 进行调用,且这些 experimental API 在下个版本可能会有不兼容的升级,如果不介意随下一版本升级的话,可以使用,追求稳定的话则不建议使用。
350374

351375
如有需要,目前支持的全量 API 列表(包含 experimental API)请参考 paddle 安装路径下的 api.h 头文件,以 Python3.7 为例,其路径是 `python3.7/site-packages/paddle/include/paddle/phi/api/include/api.h`
352376

0 commit comments

Comments
 (0)