pd_config.h 23.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
// Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
//
// 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.

///
/// \file pd_config.h
///
/// \brief interface for paddle config
///
/// \author paddle-infer@baidu.com
/// \date 2021-04-21
/// \since 2.1
///

#pragma once

#include "pd_common.h"  // NOLINT
28
#include "pd_types.h"   // NOLINT
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157

typedef struct PD_Config PD_Config;

#ifdef __cplusplus
extern "C" {
#endif

///
/// \brief Create a paddle config
///
/// \return new config.
///
PADDLE_CAPI_EXPORT extern __pd_give PD_Config* PD_ConfigCreate();
///
/// \brief Destroy the paddle config
///
/// \param[in] pd_onfig config
///
PADDLE_CAPI_EXPORT extern void PD_ConfigDestroy(__pd_take PD_Config* pd_config);
///
/// \brief Set the combined model with two specific pathes for program and
/// parameters.
///
/// \param[in] pd_onfig config
/// \param[in] prog_file_path model file path of the combined model.
/// \param[in] params_file_path params file path of the combined model.
///
PADDLE_CAPI_EXPORT extern void PD_ConfigSetModel(__pd_keep PD_Config* pd_config,
                                                 const char* prog_file_path,
                                                 const char* params_file_path);
///
/// \brief Set the model file path of a combined model.
///
/// \param[in] pd_onfig config
/// \param[in] prog_file_path model file path.
///
PADDLE_CAPI_EXPORT extern void PD_ConfigSetProgFile(
    __pd_keep PD_Config* pd_config, const char* prog_file_path);
///
/// \brief Set the params file path of a combined model.
///
/// \param[in] pd_onfig config
/// \param[in] params_file_path params file path.
///
PADDLE_CAPI_EXPORT extern void PD_ConfigSetParamsFile(
    __pd_keep PD_Config* pd_config, const char* params_file_path);
///
/// \brief Set the path of optimization cache directory.
/// \param[in] pd_onfig config
/// \param[in] opt_cache_dir the path of optimization cache directory.
///
PADDLE_CAPI_EXPORT extern void PD_ConfigSetOptimCacheDir(
    __pd_keep PD_Config* pd_config, const char* opt_cache_dir);
///
/// \brief Set the no-combined model dir path.
/// \param[in] pd_onfig config
/// \param[in] model_dir model dir path.
///
PADDLE_CAPI_EXPORT extern void PD_ConfigSetModelDir(
    __pd_keep PD_Config* pd_config, const char* model_dir);
///
/// \brief Get the model directory path.
///
/// \param[in] pd_onfig config
/// \return The model directory path.
///
PADDLE_CAPI_EXPORT extern const char* PD_ConfigGetModelDir(
    __pd_keep PD_Config* pd_config);
///
/// \brief Get the program file path.
///
/// \param[in] pd_onfig config
/// \return The program file path.
///
PADDLE_CAPI_EXPORT extern const char* PD_ConfigGetProgFile(
    __pd_keep PD_Config* pd_config);
///
/// \brief Get the params file path.
///
/// \param[in] pd_onfig config
/// \return The params file path.
///
PADDLE_CAPI_EXPORT extern const char* PD_ConfigGetParamsFile(
    __pd_keep PD_Config* pd_config);
///
/// \brief Turn off FC Padding.
///
/// \param[in] pd_onfig config
///
PADDLE_CAPI_EXPORT extern void PD_ConfigDisableFCPadding(
    __pd_keep PD_Config* pd_config);
///
/// \brief A boolean state telling whether fc padding is used.
///
/// \param[in] pd_onfig config
/// \return Whether fc padding is used.
///
PADDLE_CAPI_EXPORT extern PD_Bool PD_ConfigUseFcPadding(
    __pd_keep PD_Config* pd_config);
///
/// \brief Turn on GPU.
///
/// \param[in] pd_onfig config
/// \param[in] memory_pool_init_size_mb initial size of the GPU memory pool in
/// MB.
/// \param[in] device_id device_id the GPU card to use.
///
PADDLE_CAPI_EXPORT extern void PD_ConfigEnableUseGpu(
    __pd_keep PD_Config* pd_config, uint64_t memory_pool_init_size_mb,
    int32_t device_id);
///
/// \brief Turn off GPU.
///
/// \param[in] pd_onfig config
///
PADDLE_CAPI_EXPORT extern void PD_ConfigDisableGpu(
    __pd_keep PD_Config* pd_config);
///
/// \brief A boolean state telling whether the GPU is turned on.
///
/// \brief Turn off GPU.
/// \return Whether the GPU is turned on.
///
PADDLE_CAPI_EXPORT extern PD_Bool PD_ConfigUseGpu(
    __pd_keep PD_Config* pd_config);
///
/// \brief Turn on XPU.
///
/// \param[in] pd_onfig config
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
/// \param l3_workspace_size The size of the video memory allocated by the l3
///         cache, the maximum is 16M.
/// \param locked Whether the allocated L3 cache can be locked. If false,
///       it means that the L3 cache is not locked, and the allocated L3
///       cache can be shared by multiple models, and multiple models
///       sharing the L3 cache will be executed sequentially on the card.
/// \param autotune Whether to autotune the conv operator in the model. If
///       true, when the conv operator of a certain dimension is executed
///       for the first time, it will automatically search for a better
///       algorithm to improve the performance of subsequent conv operators
///       of the same dimension.
/// \param autotune_file Specify the path of the autotune file. If
///       autotune_file is specified, the algorithm specified in the
///       file will be used and autotune will not be performed again.
/// \param precision Calculation accuracy of multi_encoder
/// \param adaptive_seqlen Is the input of multi_encoder variable length
174 175
///
PADDLE_CAPI_EXPORT extern void PD_ConfigEnableXpu(
176 177 178
    __pd_keep PD_Config* pd_config, int32_t l3_workspace_size, PD_Bool locked,
    PD_Bool autotune, const char* autotune_file, const char* precision,
    PD_Bool adaptive_seqlen);
179
///
W
Wilber 已提交
180 181 182 183 184 185 186 187
/// \brief Turn on NPU.
///
/// \param[in] pd_onfig config
/// \param[in] device_id device_id the NPU card to use.
///
PADDLE_CAPI_EXPORT extern void PD_ConfigEnableNpu(
    __pd_keep PD_Config* pd_config, int32_t device_id);
///
188 189 190 191 192 193 194 195
/// \brief A boolean state telling whether the XPU is turned on.
///
/// \param[in] pd_onfig config
/// \return Whether the XPU is turned on.
///
PADDLE_CAPI_EXPORT extern PD_Bool PD_ConfigUseXpu(
    __pd_keep PD_Config* pd_config);
///
W
Wilber 已提交
196 197 198 199 200 201 202 203
/// \brief A boolean state telling whether the NPU is turned on.
///
/// \param[in] pd_onfig config
/// \return Whether the NPU is turned on.
///
PADDLE_CAPI_EXPORT extern PD_Bool PD_ConfigUseNpu(
    __pd_keep PD_Config* pd_config);
///
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
/// \brief Get the GPU device id.
///
/// \param[in] pd_onfig config
/// \return The GPU device id.
///
PADDLE_CAPI_EXPORT extern int32_t PD_ConfigGpuDeviceId(
    __pd_keep PD_Config* pd_config);
///
/// \brief Get the XPU device id.
///
/// \param[in] pd_onfig config
/// \return The XPU device id.
///
PADDLE_CAPI_EXPORT extern int32_t PD_ConfigXpuDeviceId(
    __pd_keep PD_Config* pd_config);
///
W
Wilber 已提交
220 221 222 223 224 225 226 227
/// \brief Get the NPU device id.
///
/// \param[in] pd_onfig config
/// \return The NPU device id.
///
PADDLE_CAPI_EXPORT extern int32_t PD_ConfigNpuDeviceId(
    __pd_keep PD_Config* pd_config);
///
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
/// \brief Get the initial size in MB of the GPU memory pool.
///
/// \param[in] pd_onfig config
/// \return The initial size in MB of the GPU memory pool.
///
PADDLE_CAPI_EXPORT extern int32_t PD_ConfigMemoryPoolInitSizeMb(
    __pd_keep PD_Config* pd_config);
///
/// \brief Get the proportion of the initial memory pool size compared to the
/// device.
///
/// \param[in] pd_onfig config
/// \return The proportion of the initial memory pool size.
///
PADDLE_CAPI_EXPORT extern float PD_ConfigFractionOfGpuMemoryForPool(
    __pd_keep PD_Config* pd_config);
///
/// \brief Turn on CUDNN.
///
/// \param[in] pd_onfig config
///
PADDLE_CAPI_EXPORT extern void PD_ConfigEnableCudnn(
    __pd_keep PD_Config* pd_config);
///
/// \brief A boolean state telling whether to use CUDNN.
///
/// \param[in] pd_onfig config
/// \return Whether to use CUDNN.
///
PADDLE_CAPI_EXPORT extern PD_Bool PD_ConfigCudnnEnabled(
    __pd_keep PD_Config* pd_config);
///
/// \brief Control whether to perform IR graph optimization.
/// If turned off, the AnalysisConfig will act just like a NativeConfig.
///
/// \param[in] pd_onfig config
/// \param[in] x Whether the ir graph optimization is actived.
///
PADDLE_CAPI_EXPORT extern void PD_ConfigSwitchIrOptim(
    __pd_keep PD_Config* pd_config, PD_Bool x);
///
/// \brief A boolean state telling whether the ir graph optimization is
/// actived.
///
/// \param[in] pd_onfig config
/// \return Whether to use ir graph optimization.
///
PADDLE_CAPI_EXPORT extern PD_Bool PD_ConfigIrOptim(
    __pd_keep PD_Config* pd_config);
///
/// \brief Turn on the TensorRT engine.
/// The TensorRT engine will accelerate some subgraphes in the original Fluid
/// computation graph. In some models such as resnet50, GoogleNet and so on,
/// it gains significant performance acceleration.
///
/// \param[in] pd_onfig config
/// \param[in] workspace_size The memory size(in byte) used for TensorRT
/// workspace.
/// \param[in] max_batch_size The maximum batch size of this prediction task,
/// better set as small as possible for less performance loss.
/// \param[in] min_subgrpah_size The minimum TensorRT subgraph size needed, if a
/// subgraph is smaller than this, it will not be transferred to TensorRT
/// engine.
/// \param[in] precision The precision used in TensorRT.
/// \param[in] use_static Serialize optimization information to disk for
/// reusing.
/// \param[in] use_calib_mode Use TRT int8 calibration(post training
/// quantization).
///
PADDLE_CAPI_EXPORT extern void PD_ConfigEnableTensorRtEngine(
    __pd_keep PD_Config* pd_config, int32_t workspace_size,
    int32_t max_batch_size, int32_t min_subgraph_size,
    PD_PrecisionType precision, PD_Bool use_static, PD_Bool use_calib_mode);
///
/// \brief A boolean state telling whether the TensorRT engine is used.
///
/// \param[in] pd_onfig config
/// \return Whether the TensorRT engine is used.
///
PADDLE_CAPI_EXPORT extern PD_Bool PD_ConfigTensorRtEngineEnabled(
    __pd_keep PD_Config* pd_config);
///
/// \brief Set min, max, opt shape for TensorRT Dynamic shape mode.
///
/// \param[in] pd_onfig config
/// \param[in] tensor_num The number of the subgraph input.
/// \param[in] tensor_name The name of every subgraph input.
/// \param[in] shapes_num The shape size of every subgraph input.
/// \param[in] min_shape The min input shape of every subgraph input.
/// \param[in] max_shape The max input shape of every subgraph input.
/// \param[in] optim_shape The opt input shape of every subgraph input.
/// \param[in] disable_trt_plugin_fp16 Setting this parameter to true means that
/// TRT plugin will not run fp16.
///
PADDLE_CAPI_EXPORT extern void PD_ConfigSetTrtDynamicShapeInfo(
    __pd_keep PD_Config* pd_config, size_t tensor_num, const char** tensor_name,
    size_t* shapes_num, int32_t** min_shape, int32_t** max_shape,
    int32_t** optim_shape, PD_Bool disable_trt_plugin_fp16);
///
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
/// \brief A boolean state telling whether the trt dynamic_shape is used.
///
/// \param[in] pd_onfig config
///
PADDLE_CAPI_EXPORT extern PD_Bool PD_ConfigTensorRtDynamicShapeEnabled(
    __pd_keep PD_Config* pd_config);
///
/// \brief Enable tuned tensorrt dynamic shape.
///
/// \param[in] pd_onfig config
/// \param[in] shape_range_info_path the path to shape_info file got in
/// CollectShapeInfo mode.
/// \param[in] allow_build_at_runtime allow build trt engine at runtime.
///
PADDLE_CAPI_EXPORT extern void PD_ConfigEnableTunedTensorRtDynamicShape(
    __pd_keep PD_Config* pd_config, const char* shape_range_info_path,
    PD_Bool allow_build_at_runtime);

///
/// \brief A boolean state telling whether to use tuned tensorrt dynamic
/// shape.
///
/// \param[in] pd_onfig config
///
PADDLE_CAPI_EXPORT extern PD_Bool PD_ConfigTunedTensorRtDynamicShape(
    __pd_keep PD_Config* pd_config);

///
/// \brief A boolean state telling whether to allow building trt engine at
/// runtime.
///
/// \param[in] pd_onfig config
///
PADDLE_CAPI_EXPORT extern PD_Bool PD_ConfigTrtAllowBuildAtRuntime(
    __pd_keep PD_Config* pd_config);

///
/// \brief Collect shape info of all tensors in compute graph.
///
/// \param[in] pd_onfig config
/// \param[in] shape_range_info_path the path to save shape info.
///
PADDLE_CAPI_EXPORT extern void PD_ConfigCollectShapeRangeInfo(
    __pd_keep PD_Config* pd_config, const char* shape_range_info_path);

///
/// \brief the shape info path in CollectShapeInfo mode.
/// Attention, Please release the string manually.
///
/// \param[in] pd_onfig config
///
PADDLE_CAPI_EXPORT extern const char* PD_ConfigShapeRangeInfoPath(
    __pd_keep PD_Config* pd_config);

///
/// \brief A boolean state telling whether to collect shape info.
///
/// \param[in] pd_onfig config
///
PADDLE_CAPI_EXPORT extern PD_Bool PD_ConfigShapeRangeInfoCollected(
    __pd_keep PD_Config* pd_config);

///
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607
/// \brief Prevent ops running in Paddle-TRT
/// NOTE: just experimental, not an official stable API, easy to be broken.
///
/// \param[in] pd_onfig config
/// \param[in] ops_num ops number
/// \param[in] ops_name ops name
///
PADDLE_CAPI_EXPORT extern void PD_ConfigDisableTensorRtOPs(
    __pd_keep PD_Config* pd_config, size_t ops_num, const char** ops_name);
///
/// \brief Replace some TensorRT plugins to TensorRT OSS(
/// https://github.com/NVIDIA/TensorRT), with which some models's inference
/// may be more high-performance. Libnvinfer_plugin.so greater than
/// V7.2.1 is needed.
///
/// \param[in] pd_onfig config
///
PADDLE_CAPI_EXPORT extern void PD_ConfigEnableTensorRtOSS(
    __pd_keep PD_Config* pd_config);
///
/// \brief A boolean state telling whether to use the TensorRT OSS.
///
/// \param[in] pd_onfig config
/// \return Whether to use the TensorRT OSS.
///
PADDLE_CAPI_EXPORT extern PD_Bool PD_ConfigTensorRtOssEnabled(
    __pd_keep PD_Config* pd_config);
///
/// \brief Enable TensorRT DLA
///
/// \param[in] pd_onfig config
/// \param[in] dla_core ID of DLACore, which should be 0, 1,
///        ..., IBuilder.getNbDLACores() - 1
///
PADDLE_CAPI_EXPORT extern void PD_ConfigEnableTensorRtDla(
    __pd_keep PD_Config* pd_config, int32_t dla_core);
///
/// \brief A boolean state telling whether to use the TensorRT DLA.
///
/// \param[in] pd_onfig config
/// \return Whether to use the TensorRT DLA.
///
PADDLE_CAPI_EXPORT extern PD_Bool PD_ConfigTensorRtDlaEnabled(
    __pd_keep PD_Config* pd_config);
///
/// \brief Turn on the usage of Lite sub-graph engine.
///
/// \param[in] pd_onfig config
/// \param[in] precision Precion used in Lite sub-graph engine.
/// \param[in] zero_copy whether use zero copy.
/// \param[in] passes_filter_num The number of passes used in Lite sub-graph
/// engine.
/// \param[in] passes_filter The name of passes used in Lite sub-graph engine.
/// \param[in] ops_filter_num The number of operators not supported by Lite.
/// \param[in] ops_filter The name of operators not supported by Lite.
///
PADDLE_CAPI_EXPORT extern void PD_ConfigEnableLiteEngine(
    __pd_keep PD_Config* pd_config, PD_PrecisionType precision,
    PD_Bool zero_copy, size_t passes_filter_num, const char** passes_filter,
    size_t ops_filter_num, const char** ops_filter);
///
/// \brief A boolean state indicating whether the Lite sub-graph engine is
/// used.
///
/// \param[in] pd_onfig config
/// \return Whether the Lite sub-graph engine is used.
///
PADDLE_CAPI_EXPORT extern PD_Bool PD_ConfigLiteEngineEnabled(
    __pd_keep PD_Config* pd_config);
///
/// \brief Control whether to debug IR graph analysis phase.
/// This will generate DOT files for visualizing the computation graph after
/// each analysis pass applied.
///
/// \param[in] pd_onfig config
/// \param[in] x whether to debug IR graph analysis phase.
///
PADDLE_CAPI_EXPORT extern void PD_ConfigSwitchIrDebug(
    __pd_keep PD_Config* pd_config, PD_Bool x);
///
/// \brief Turn on MKLDNN.
///
/// \param[in] pd_onfig config
///
PADDLE_CAPI_EXPORT extern void PD_ConfigEnableMKLDNN(
    __pd_keep PD_Config* pd_config);
///
/// \brief Set the cache capacity of different input shapes for MKLDNN.
/// Default value 0 means not caching any shape.
/// Please see MKL-DNN Data Caching Design Document:
/// https://github.com/PaddlePaddle/FluidDoc/blob/develop/doc/fluid/design/mkldnn/caching/caching.md
///
/// \param[in] pd_onfig config
/// \param[in] capacity The cache capacity.
///
PADDLE_CAPI_EXPORT extern void PD_ConfigSetMkldnnCacheCapacity(
    __pd_keep PD_Config* pd_config, int32_t capacity);
///
/// \brief A boolean state telling whether to use the MKLDNN.
///
/// \param[in] pd_onfig config
/// \return Whether to use the MKLDNN.
///
PADDLE_CAPI_EXPORT extern PD_Bool PD_ConfigMkldnnEnabled(
    __pd_keep PD_Config* pd_config);
///
/// \brief Set the number of cpu math library threads.
///
/// \param[in] pd_onfig config
/// \param cpu_math_library_num_threads The number of cpu math library
/// threads.
///
PADDLE_CAPI_EXPORT extern void PD_ConfigSetCpuMathLibraryNumThreads(
    __pd_keep PD_Config* pd_config, int32_t cpu_math_library_num_threads);
///
/// \brief An int state telling how many threads are used in the CPU math
/// library.
///
/// \param[in] pd_onfig config
/// \return The number of threads used in the CPU math library.
///
PADDLE_CAPI_EXPORT extern int32_t PD_ConfigGetCpuMathLibraryNumThreads(
    __pd_keep PD_Config* pd_config);
///
/// \brief Specify the operator type list to use MKLDNN acceleration.
///
/// \param[in] pd_onfig config
/// \param[in] ops_num The number of operator type list.
/// \param[in] op_list The name of operator type list.
///
PADDLE_CAPI_EXPORT extern void PD_ConfigSetMkldnnOp(
    __pd_keep PD_Config* pd_config, size_t ops_num, const char** op_list);
///
/// \brief Turn on MKLDNN quantization.
///
/// \param[in] pd_onfig config
///
PADDLE_CAPI_EXPORT extern void PD_ConfigEnableMkldnnQuantizer(
    __pd_keep PD_Config* pd_config);
///
/// \brief A boolean state telling whether the MKLDNN quantization is enabled.
///
/// \param[in] pd_onfig config
/// \return Whether the MKLDNN quantization is enabled.
///
PADDLE_CAPI_EXPORT extern PD_Bool PD_ConfigMkldnnQuantizerEnabled(
    __pd_keep PD_Config* pd_config);
///
/// \brief Turn on MKLDNN bfloat16.
///
/// \param[in] pd_onfig config
///
PADDLE_CAPI_EXPORT extern void PD_ConfigEnableMkldnnBfloat16(
    __pd_keep PD_Config* pd_config);
///
/// \brief A boolean state telling whether to use the MKLDNN Bfloat16.
///
/// \param[in] pd_onfig config
/// \return Whether to use the MKLDNN Bfloat16.
///
PADDLE_CAPI_EXPORT extern PD_Bool PD_ConfigMkldnnBfloat16Enabled(
    __pd_keep PD_Config* pd_config);
/// \brief Specify the operator type list to use Bfloat16 acceleration.
///
/// \param[in] pd_onfig config
/// \param[in] ops_num The number of operator type list.
/// \param[in] op_list The name of operator type list.
///
PADDLE_CAPI_EXPORT extern void PD_ConfigSetBfloat16Op(
    __pd_keep PD_Config* pd_config, size_t ops_num, const char** op_list);
///
/// \brief Enable the GPU multi-computing stream feature.
/// NOTE: The current behavior of this interface is to bind the computation
/// stream to the thread, and this behavior may be changed in the future.
///
/// \param[in] pd_onfig config
///
PADDLE_CAPI_EXPORT extern void PD_ConfigEnableGpuMultiStream(
    __pd_keep PD_Config* pd_config);
///
/// \brief A boolean state telling whether the thread local CUDA stream is
/// enabled.
///
/// \param[in] pd_onfig config
/// \return Whether the thread local CUDA stream is enabled.
///
PADDLE_CAPI_EXPORT extern PD_Bool PD_ConfigThreadLocalStreamEnabled(
    __pd_keep PD_Config* pd_config);
///
/// \brief Specify the memory buffer of program and parameter.
/// Used when model and params are loaded directly from memory.
///
/// \param[in] pd_onfig config
/// \param[in] prog_buffer The memory buffer of program.
/// \param[in] prog_buffer_size The size of the model data.
/// \param[in] params_buffer The memory buffer of the combined parameters file.
/// \param[in] params_buffer_size The size of the combined parameters data.
///
PADDLE_CAPI_EXPORT extern void PD_ConfigSetModelBuffer(
    __pd_keep PD_Config* pd_config, const char* prog_buffer,
    size_t prog_buffer_size, const char* params_buffer,
    size_t params_buffer_size);
///
/// \brief A boolean state telling whether the model is set from the CPU
/// memory.
///
/// \param[in] pd_onfig config
/// \return Whether model and params are loaded directly from memory.
///
PADDLE_CAPI_EXPORT extern PD_Bool PD_ConfigModelFromMemory(
    __pd_keep PD_Config* pd_config);
///
/// \brief Turn on memory optimize
/// NOTE still in development.
///
/// \param[in] pd_onfig config
///
PADDLE_CAPI_EXPORT extern void PD_ConfigEnableMemoryOptim(
608
    __pd_keep PD_Config* pd_config, PD_Bool x);
609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672
///
/// \brief A boolean state telling whether the memory optimization is
/// activated.
///
/// \param[in] pd_onfig config
/// \return Whether the memory optimization is activated.
///
PADDLE_CAPI_EXPORT extern PD_Bool PD_ConfigMemoryOptimEnabled(
    __pd_keep PD_Config* pd_config);
///
/// \brief Turn on profiling report.
/// If not turned on, no profiling report will be generated.
///
/// \param[in] pd_onfig config
///
PADDLE_CAPI_EXPORT extern void PD_ConfigEnableProfile(
    __pd_keep PD_Config* pd_config);
///
/// \brief A boolean state telling whether the profiler is activated.
///
/// \param[in] pd_onfig config
/// \return bool Whether the profiler is activated.
///
PADDLE_CAPI_EXPORT extern PD_Bool PD_ConfigProfileEnabled(
    __pd_keep PD_Config* pd_config);
///
/// \brief Mute all logs in Paddle inference.
///
/// \param[in] pd_onfig config
///
PADDLE_CAPI_EXPORT extern void PD_ConfigDisableGlogInfo(
    __pd_keep PD_Config* pd_config);
///
/// \brief A boolean state telling whether logs in Paddle inference are muted.
///
/// \param[in] pd_onfig config
/// \return Whether logs in Paddle inference are muted.
///
PADDLE_CAPI_EXPORT extern PD_Bool PD_ConfigGlogInfoDisabled(
    __pd_keep PD_Config* pd_config);
///
/// \brief Set the Config to be invalid.
/// This is to ensure that an Config can only be used in one
/// Predictor.
///
/// \param[in] pd_onfig config
///
PADDLE_CAPI_EXPORT extern void PD_ConfigSetInvalid(
    __pd_keep PD_Config* pd_config);
///
/// \brief A boolean state telling whether the Config is valid.
///
/// \param[in] pd_onfig config
/// \return Whether the Config is valid.
///
PADDLE_CAPI_EXPORT extern PD_Bool PD_ConfigIsValid(
    __pd_keep PD_Config* pd_config);
///
/// \brief Partially release the memory
///
/// \param[in] pd_onfig config
///
PADDLE_CAPI_EXPORT extern void PD_ConfigPartiallyRelease(
    __pd_keep PD_Config* pd_config);
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701
///
/// \brief Delete all passes that has a certain type 'pass'.
///
/// \param[in] pass the certain pass type to be deleted.
///
PADDLE_CAPI_EXPORT extern void PD_ConfigDeletePass(
    __pd_keep PD_Config* pd_config, const char* pass);
///
/// \brief  Insert a pass to a specific position
///
/// \param[in] idx the position to insert.
/// \param[in] pass the new pass.
///
PADDLE_CAPI_EXPORT extern void PD_ConfigInsertPass(
    __pd_keep PD_Config* pd_config, size_t idx, const char* pass);
///
/// \brief Append a pass to the end of the passes
///
/// \param[in] pass the new pass.
///
PADDLE_CAPI_EXPORT extern void PD_ConfigAppendPass(
    __pd_keep PD_Config* pd_config, const char* pass);
///
/// \brief Get information of passes.
///
/// \return Return list of the passes.
///
PADDLE_CAPI_EXPORT extern __pd_give PD_OneDimArrayCstr* PD_ConfigAllPasses(
    __pd_keep PD_Config* pd_config);
702 703 704 705 706 707 708 709
///
/// \brief Get information of config.
/// Attention, Please release the string manually.
///
/// \return Return config info.
///
PADDLE_CAPI_EXPORT extern const char* PD_ConfigSummary(
    __pd_keep PD_Config* pd_config);
710 711 712 713

#ifdef __cplusplus
}  // extern "C"
#endif