op_params.h 48.7 KB
Newer Older
Y
Yan Chunwei 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// Copyright (c) 2019 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.

#pragma once
16
#include <memory>
Y
Yan Chunwei 已提交
17
#include <string>
18
#include <utility>
Y
Yan Chunwei 已提交
19
#include <vector>
20
#include "lite/api/paddle_place.h"
Y
Yan Chunwei 已提交
21 22
#include "lite/core/scope.h"
#include "lite/core/tensor.h"
23
#include "lite/core/types.h"
24 25
#include "lite/model_parser/base/apis.h"
#include "lite/model_parser/cpp_desc.h"
Y
Yan Chunwei 已提交
26 27 28 29 30 31 32 33 34
#include "lite/utils/all.h"
/*
 * This file contains all the argument parameter data structure for operators.
 */

namespace paddle {
namespace lite {
namespace operators {

35 36
struct ParamBase {
 public:
37 38 39 40 41
  virtual ~ParamBase() {}
  virtual const std::vector<const Tensor*>* input_tensor_ptrs() {
    return nullptr;
  }
  virtual std::vector<Tensor*>* output_tensor_ptrs() { return nullptr; }
42 43 44 45 46 47

 protected:
  std::shared_ptr<std::vector<const Tensor*>> input_tensor_ptrs_cache_{nullptr};
  std::shared_ptr<std::vector<Tensor*>> output_tensor_ptrs_cache_{nullptr};
};

Y
Yan Chunwei 已提交
48 49 50
using param_t = Any;
#define WITH_INT8_CONFIG             \
  bool enable_int8{false};           \
51
  float input_scale{1.0f};           \
Y
Yan Chunwei 已提交
52
  std::vector<float> weight_scale{}; \
53
  float output_scale{1.0f};          \
54
  int bit_length{8};
Y
Yan Chunwei 已提交
55 56

/// ----------------------- Functional operators ------------------------------
57
struct FeedParam : ParamBase {
Y
Yan Chunwei 已提交
58 59 60 61 62
  std::vector<lite::Tensor>* feed_list{};
  lite::Tensor* out{};
  int col;
};

63
struct FetchParam : ParamBase {
Y
Yan Chunwei 已提交
64 65 66 67 68 69
  const lite::Tensor* input{};
  std::vector<lite::Tensor>* fetch_list{};
  int col;
};

// Helper op for lite framework
70
struct IoCopyParam : ParamBase {
Y
Yan Chunwei 已提交
71 72
  const lite::Tensor* x{};
  lite::Tensor* y{};
73
  int process_type{0};
Y
Yan Chunwei 已提交
74 75
};

76
struct LayoutParam : ParamBase {
Y
Yan Chunwei 已提交
77 78
  const lite::Tensor* x{};
  lite::Tensor* y{};
79
  int process_type{0};
Y
Yan Chunwei 已提交
80 81
};

82
struct CalibParam : ParamBase {
Y
Yan Chunwei 已提交
83 84 85 86 87
  const lite::Tensor* input{};
  lite::Tensor* output{};
  float scale;
};

88
struct SubgraphParam : ParamBase {
89 90 91 92
  std::vector<std::string> input_names{};
  std::vector<std::string> output_names{};
  std::vector<std::string> input_data_names{};
  std::vector<std::string> output_data_names{};
93 94 95
  int block_idx{-1};
  std::shared_ptr<const cpp::ProgramDesc> program_desc{nullptr};
  Scope* exec_scope{nullptr};
Y
Yan Chunwei 已提交
96 97 98 99
};

/// -------------------------- NN operators ------------------------------------

100
struct FcParam : ParamBase {
Y
Yan Chunwei 已提交
101 102 103 104 105 106
  lite::Tensor* input{nullptr};
  lite::Tensor* w{nullptr};
  lite::Tensor* bias{nullptr};
  lite::Tensor* output{nullptr};
  lite::DDim in_mat_dims;
  int in_num_col_dims{1};
107
  std::string activation_type{""};
108
  bool padding_weights{false};
Y
Yan Chunwei 已提交
109 110
  // for int8
  WITH_INT8_CONFIG
111 112
  ///////////////////////////////////////////////////////////////////////////////////
  // get a vector of input tensors
113 114
  const std::vector<const Tensor*>* input_tensor_ptrs() override {
    if (!input_tensor_ptrs_cache_) {
115 116 117 118 119
      input_tensor_ptrs_cache_.reset(new std::vector<const Tensor*>({input}));
    }
    return input_tensor_ptrs_cache_.get();
  }
  // get a vector of output tensors
120 121
  std::vector<Tensor*>* output_tensor_ptrs() override {
    if (!output_tensor_ptrs_cache_) {
122 123 124 125 126 127 128
      output_tensor_ptrs_cache_.reset(new std::vector<lite::Tensor*>({output}));
    }
    return output_tensor_ptrs_cache_.get();
  }
};

struct SearchSeqFcParam : ParamBase {
129 130 131 132 133 134 135
  lite::Tensor* x{nullptr};
  lite::Tensor* w{nullptr};
  lite::Tensor* b{nullptr};
  lite::Tensor* out{nullptr};
  int out_size;
};

Y
Yan Chunwei 已提交
136
// For Interpolate Op
137
struct InterpolateParam : ParamBase {
Y
Yan Chunwei 已提交
138 139 140
  lite::Tensor* X{};
  lite::Tensor* OutSize{};
  lite::Tensor* Out{};
L
liu zhengxi 已提交
141
  std::vector<const lite::Tensor*> SizeTensor;
142
  lite::Tensor* Scale{};
Y
Yan Chunwei 已提交
143 144 145 146 147

  float scale{0.f};
  int out_h{-1};
  int out_w{-1};
  bool align_corners{true};
148
  int align_mode{1};
Y
Yan Chunwei 已提交
149
  std::string interp_method{"Nearest"};
L
liu zhengxi 已提交
150
  DataLayoutType data_layout{DATALAYOUT(kNCHW)};
Y
Yan Chunwei 已提交
151 152 153
};

// For Mul Op
154
struct MulParam : ParamBase {
Y
Yan Chunwei 已提交
155 156 157 158 159 160 161 162
  const lite::Tensor* x{};
  const lite::Tensor* y{};
  lite::Tensor* output{};

  int x_num_col_dims{1};
  int y_num_col_dims{1};
  // for int8
  WITH_INT8_CONFIG
163 164
  ///////////////////////////////////////////////////////////////////////////////////
  // get a vector of input tensors
165 166
  const std::vector<const Tensor*>* input_tensor_ptrs() override {
    if (!input_tensor_ptrs_cache_) {
167 168 169 170 171
      input_tensor_ptrs_cache_.reset(new std::vector<const Tensor*>({x, y}));
    }
    return input_tensor_ptrs_cache_.get();
  }
  // get a vector of output tensors
172 173
  std::vector<Tensor*>* output_tensor_ptrs() override {
    if (!output_tensor_ptrs_cache_) {
174 175 176 177
      output_tensor_ptrs_cache_.reset(new std::vector<lite::Tensor*>({output}));
    }
    return output_tensor_ptrs_cache_.get();
  }
Y
Yan Chunwei 已提交
178 179
};

180
struct MulGradParam : ParamBase {
Y
Yan Chunwei 已提交
181 182 183 184 185 186 187 188 189 190
  const lite::Tensor* x{};
  const lite::Tensor* y{};
  const lite::Tensor* output_grad{};
  lite::Tensor* x_grad{};
  lite::Tensor* y_grad{};

  int x_num_col_dims{1};
  int y_num_col_dims{1};
};

191
// For ReduceMean Op
192
struct ReduceMeanParam : ParamBase {
193 194 195 196 197 198 199 200
  lite::Tensor* X{};
  lite::Tensor* Out{};

  std::vector<int> dim;
  bool keep_dim{false};
};

// For Stack Op
201
struct StackParam : ParamBase {
202 203 204 205 206 207
  std::vector<lite::Tensor*> X;
  lite::Tensor* Out{};

  int axis{0};
};

Y
Yan Chunwei 已提交
208
// For Power Op
209
struct PowerParam : ParamBase {
Y
Yan Chunwei 已提交
210 211 212 213 214 215 216 217
  const lite::Tensor* X{};
  lite::Tensor* Out{};

  float scale{};
  float shift{};
  float power{};
};

218
struct ShuffleChannelParam : ParamBase {
Y
Yan Chunwei 已提交
219 220 221 222 223 224 225
  const lite::Tensor* X{};
  lite::Tensor* Out{};

  int group;
};

// For Yolobox
226
struct YoloBoxParam : ParamBase {
Y
Yan Chunwei 已提交
227 228 229 230 231 232 233 234 235 236 237 238
  lite::Tensor* X{};
  lite::Tensor* ImgSize{};
  lite::Tensor* Boxes{};
  lite::Tensor* Scores{};

  std::vector<int> anchors{};
  int class_num{0};
  float conf_thresh{0.f};
  int downsample_ratio{0};
};

// For Scale Op
239
struct ScaleParam : ParamBase {
Y
Yan Chunwei 已提交
240 241 242 243 244 245
  lite::Tensor* x{};
  lite::Tensor* output{};

  float scale{1.};
  float bias{};
  bool bias_after_scale{true};
246 247 248
  std::string activation_type{""};
  bool fuse_relu{false};
  float alpha{6.};
249 250
  ///////////////////////////////////////////////////////////////////////////////////
  // get a vector of input tensors
251 252
  const std::vector<const Tensor*>* input_tensor_ptrs() override {
    if (!input_tensor_ptrs_cache_) {
253 254 255 256 257
      input_tensor_ptrs_cache_.reset(new std::vector<const Tensor*>({x}));
    }
    return input_tensor_ptrs_cache_.get();
  }
  // get a vector of output tensors
258 259
  std::vector<Tensor*>* output_tensor_ptrs() override {
    if (!output_tensor_ptrs_cache_) {
260 261 262 263
      output_tensor_ptrs_cache_.reset(new std::vector<lite::Tensor*>({output}));
    }
    return output_tensor_ptrs_cache_.get();
  }
Y
Yan Chunwei 已提交
264 265 266
};

// For Softmax op
267
struct SoftmaxParam : ParamBase {
Y
Yan Chunwei 已提交
268 269 270
  lite::Tensor* x{};
  lite::Tensor* output{};
  int axis{-1};
271 272
  ///////////////////////////////////////////////////////////////////////////////////
  // get a vector of input tensors
273 274
  const std::vector<const Tensor*>* input_tensor_ptrs() override {
    if (!input_tensor_ptrs_cache_) {
275 276 277 278 279
      input_tensor_ptrs_cache_.reset(new std::vector<const Tensor*>({x}));
    }
    return input_tensor_ptrs_cache_.get();
  }
  // get a vector of output tensors
280 281
  std::vector<Tensor*>* output_tensor_ptrs() override {
    if (!output_tensor_ptrs_cache_) {
282 283 284 285
      output_tensor_ptrs_cache_.reset(new std::vector<lite::Tensor*>({output}));
    }
    return output_tensor_ptrs_cache_.get();
  }
Y
Yan Chunwei 已提交
286 287 288
};

// For Reshape and Reshape2 Op
289
struct ReshapeParam : ParamBase {
Y
Yan Chunwei 已提交
290
  const lite::Tensor* x{};
291 292 293
  std::vector<const lite::Tensor*> shape_tensor_vct{};
  const lite::Tensor* shape_tensor{};
  std::vector<int> shape_vct{};
Y
Yan Chunwei 已提交
294 295
  lite::Tensor* output{};

296
  lite::Tensor* xshape{};
Y
Yan Chunwei 已提交
297
  bool inplace{false};
298 299
  ///////////////////////////////////////////////////////////////////////////////////
  // get a vector of input tensors
300 301
  const std::vector<const Tensor*>* input_tensor_ptrs() override {
    if (!input_tensor_ptrs_cache_) {
302 303 304 305 306
      input_tensor_ptrs_cache_.reset(new std::vector<const Tensor*>({x}));
    }
    return input_tensor_ptrs_cache_.get();
  }
  // get a vector of output tensors
307 308
  std::vector<Tensor*>* output_tensor_ptrs() override {
    if (!output_tensor_ptrs_cache_) {
309 310 311 312
      output_tensor_ptrs_cache_.reset(new std::vector<lite::Tensor*>({output}));
    }
    return output_tensor_ptrs_cache_.get();
  }
Y
Yan Chunwei 已提交
313 314 315
};

// For Concat op
316
struct ConcatParam : ParamBase {
Y
Yan Chunwei 已提交
317 318 319
  std::vector<lite::Tensor*> x{};
  lite::Tensor* output{};
  int axis{0};
320
  lite::Tensor* axis_tensor{};
321
  // get a vector of input tensors
322 323
  const std::vector<const Tensor*>* input_tensor_ptrs() override {
    if (!input_tensor_ptrs_cache_) {
324 325 326 327 328 329 330 331 332
      std::vector<const Tensor*> vec;
      for (auto in : x) {
        vec.push_back(in);
      }
      input_tensor_ptrs_cache_.reset(new std::vector<const Tensor*>(vec));
    }
    return input_tensor_ptrs_cache_.get();
  }
  // get a vector of output tensors
333 334
  std::vector<Tensor*>* output_tensor_ptrs() override {
    if (!output_tensor_ptrs_cache_) {
335 336 337 338
      output_tensor_ptrs_cache_.reset(new std::vector<lite::Tensor*>({output}));
    }
    return output_tensor_ptrs_cache_.get();
  }
Y
Yan Chunwei 已提交
339 340
};

341
/// ----------------------- activation operators ----------------------
342
struct ActivationParam : ParamBase {
343
  const lite::Tensor* X{};
344
  lite::Tensor* Out{};
345
  lite_api::ActivationType active_type{lite_api::ActivationType::kIndentity};
346
  bool has_active{false};
347 348 349 350 351 352
  float Leaky_relu_alpha{0};   // leaky_relu param
  float Relu_clipped_coef{6};  // relu_clipped param
  std::string Prelu_mode{
      "channel"};  // prelu param, can be "all", "channel" or "element"
  lite::Tensor* Prelu_alpha{};  // prelu param
  float Swish_beta;             // swish param
353
  // hard_sigmoid param
354 355
  float hard_sigmoid_slope{0.2f};
  float hard_sigmoid_offset{0.5f};
356 357 358 359
  // hard_swish param
  float hard_swish_threshold{6.0};
  float hard_swish_scale{6.0};
  float hard_swish_offset{3.0};
360 361
  // thresholded_relu
  float relu_threshold{1.0f};
H
HappyAngel 已提交
362 363
  // elu
  float Elu_alpha{1.0f};
364 365
};

366
struct ActivationGradParam : ParamBase {
367 368 369 370 371 372 373
  const lite::Tensor* X{};
  const lite::Tensor* Out{};
  // for backward
  lite::Tensor* X_grad{};
  const lite::Tensor* Out_grad{};
};

Y
Yan Chunwei 已提交
374
// For Convolution op
375
struct ConvParam : ParamBase {
Y
Yan Chunwei 已提交
376 377 378 379 380 381
  lite::Tensor* x{};
  lite::Tensor* filter{};
  lite::Tensor* bias{nullptr};
  lite::Tensor* residualData{nullptr};
  lite::Tensor* output{};
  std::vector<int> strides{1, 1};
H
HappyAngel 已提交
382
  /* paddings type change
383 384 385 386
   * from std::vector<int> to std::shared_ptr<std::vector<int>>
   * to support dynamically modify padding
   * let kernel param and operator param Synchronous update
   */
H
HappyAngel 已提交
387
  std::shared_ptr<std::vector<int>> paddings;
Y
Yan Chunwei 已提交
388
  int groups{1};
H
HappyAngel 已提交
389
  /* dilations type change
390 391 392 393
   * from std::vector<int> to std::shared_ptr<std::vector<int>>
   * to support dynamically modify padding
   * let kernel param and operator param Synchronous update
   */
H
HappyAngel 已提交
394
  std::shared_ptr<std::vector<int>> dilations;
Y
Yan Chunwei 已提交
395 396 397 398 399 400 401 402 403 404 405 406
  bool fuse_relu_before_depthwise_conv{false};
  bool use_mkldnn{false};
  bool fuse_relu{false};  // only used in mkldnn kernel
  bool use_quantizer{
      false};  // set true for op that should be quantized, only used for cpu
  bool fuse_residual_connection{false};
  float scale_in{1.0f};           // only used with mkl-dnn int8
  float scale_out{1.0f};          // only used with mkl-dnn int8
  float scale_in_eltwise{1.0f};   // only used with mkl-dnn int8
  float scale_weights{1.0f};      // only used with mkl-dnn int8
  bool force_fp32_output{false};  // only used in mkl-dnn int8
  std::string data_format{"Anylayout"};
407 408
  // for activation
  ActivationParam activation_param;
W
Wilber 已提交
409 410
  // support var_length or not
  bool var_length{false};
411 412
  // only used in conv_transpose.
  std::vector<int> output_size;
Y
Yan Chunwei 已提交
413 414
  // for int8
  WITH_INT8_CONFIG
415 416 417

  ///////////////////////////////////////////////////////////////////////////////////
  // get a vector of input tensors
418 419
  const std::vector<const Tensor*>* input_tensor_ptrs() override {
    if (!input_tensor_ptrs_cache_) {
420 421 422 423 424
      input_tensor_ptrs_cache_.reset(new std::vector<const Tensor*>({x}));
    }
    return input_tensor_ptrs_cache_.get();
  }
  // get a vector of output tensors
425 426
  std::vector<Tensor*>* output_tensor_ptrs() override {
    if (!output_tensor_ptrs_cache_) {
427 428 429 430
      output_tensor_ptrs_cache_.reset(new std::vector<lite::Tensor*>({output}));
    }
    return output_tensor_ptrs_cache_.get();
  }
Y
Yan Chunwei 已提交
431 432 433
};

// For BatchNorm op
434
struct BatchNormParam : ParamBase {
Y
Yan Chunwei 已提交
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449
  lite::Tensor* x{};
  lite::Tensor* bias{};
  lite::Tensor* scale{};
  lite::Tensor* mean{};
  lite::Tensor* variance{};
  lite::Tensor* y{};
  lite::Tensor* mean_out{};
  lite::Tensor* variance_out{};
  lite::Tensor* saved_mean{};
  lite::Tensor* saved_variance{};
  bool is_test{true};
  bool use_global_stats{false};
  float epsilon;
  float momentum;
  DataLayoutType data_layout{DATALAYOUT(kNCHW)};
450 451
  ///////////////////////////////////////////////////////////////////////////////////
  // get a vector of input tensors
452 453
  const std::vector<const Tensor*>* input_tensor_ptrs() override {
    if (!input_tensor_ptrs_cache_) {
454 455 456 457 458
      input_tensor_ptrs_cache_.reset(new std::vector<const Tensor*>({x}));
    }
    return input_tensor_ptrs_cache_.get();
  }
  // get a vector of output tensors
459 460
  std::vector<Tensor*>* output_tensor_ptrs() override {
    if (!output_tensor_ptrs_cache_) {
461 462 463 464
      output_tensor_ptrs_cache_.reset(new std::vector<lite::Tensor*>({y}));
    }
    return output_tensor_ptrs_cache_.get();
  }
Y
Yan Chunwei 已提交
465 466 467
};

// For Pooling op
468
struct PoolParam : ParamBase {
Y
Yan Chunwei 已提交
469 470 471 472 473 474 475
  lite::Tensor* x{};
  lite::Tensor* output{};
  std::string pooling_type{""};
  std::vector<int> ksize{};
  bool global_pooling{
      false};  // if true, knernel size and paddings will be ignored
  std::vector<int> strides{1, 1};
476
  /* paddings type change
477 478 479 480
   * from std::vector<int> to std::shared_ptr<std::vector<int>>
   * to support dynamically modify padding
   * let kernel param and operator param Synchronous update
   */
481
  std::shared_ptr<std::vector<int>> paddings;
Y
Yan Chunwei 已提交
482 483 484 485 486
  bool exclusive{true};
  bool adaptive{false};
  bool ceil_mode{false};
  bool use_quantizer{false};
  std::string data_format{"AnyLayout"};
J
juncaipeng 已提交
487 488
  // for int8
  WITH_INT8_CONFIG
489 490
  ///////////////////////////////////////////////////////////////////////////////////
  // get a vector of input tensors
491 492
  const std::vector<const Tensor*>* input_tensor_ptrs() override {
    if (!input_tensor_ptrs_cache_) {
493 494 495 496 497
      input_tensor_ptrs_cache_.reset(new std::vector<const Tensor*>({x}));
    }
    return input_tensor_ptrs_cache_.get();
  }
  // get a vector of output tensors
498 499
  std::vector<Tensor*>* output_tensor_ptrs() override {
    if (!output_tensor_ptrs_cache_) {
500 501 502 503
      output_tensor_ptrs_cache_.reset(new std::vector<lite::Tensor*>({output}));
    }
    return output_tensor_ptrs_cache_.get();
  }
Y
Yan Chunwei 已提交
504 505 506
};

// For Dropout op
507
struct DropoutParam : ParamBase {
Y
Yan Chunwei 已提交
508 509 510 511 512 513 514 515 516 517 518
  const lite::Tensor* x{};
  lite::Tensor* output{};
  lite::Tensor* mask{};
  float dropout_prob{.5f};
  bool is_test{false};
  bool fix_seed{false};
  int seed{0};
  std::string dropout_implementation{"downgrade_in_infer"};
};

// For Split op
519
struct SplitParam : ParamBase {
Y
Yan Chunwei 已提交
520 521
  lite::Tensor* x{};
  std::vector<lite::Tensor*> output{};
522 523 524
  lite::Tensor* axis_tensor;
  std::vector<lite::Tensor*> sections_tensor_list{};

Y
Yan Chunwei 已提交
525 526 527
  int axis{-1};
  int num{0};
  std::vector<int> sections;
528 529
  ///////////////////////////////////////////////////////////////////////////////////
  // get a vector of input tensors
530 531
  const std::vector<const Tensor*>* input_tensor_ptrs() override {
    if (!input_tensor_ptrs_cache_) {
532 533 534 535 536
      input_tensor_ptrs_cache_.reset(new std::vector<const Tensor*>({x}));
    }
    return input_tensor_ptrs_cache_.get();
  }
  // get a vector of output tensors
537 538
  std::vector<Tensor*>* output_tensor_ptrs() override {
    if (!output_tensor_ptrs_cache_) {
539 540 541 542
      output_tensor_ptrs_cache_.reset(new std::vector<lite::Tensor*>({output}));
    }
    return output_tensor_ptrs_cache_.get();
  }
Y
Yan Chunwei 已提交
543 544 545
};

// For Transpose op
546
struct TransposeParam : ParamBase {
Y
Yan Chunwei 已提交
547 548
  const lite::Tensor* x{};
  lite::Tensor* output{};
549 550
  lite::Tensor* xshape{};

Y
Yan Chunwei 已提交
551 552 553
  std::vector<int> axis;
  bool use_mkldnn{false};
  std::string data_format{"AnyLayout"};
554 555
  ///////////////////////////////////////////////////////////////////////////////////
  //  // get a vector of input tensors
556 557
  const std::vector<const Tensor*>* input_tensor_ptrs() override {
    if (!input_tensor_ptrs_cache_) {
558 559 560 561 562
      input_tensor_ptrs_cache_.reset(new std::vector<const Tensor*>({x}));
    }
    return input_tensor_ptrs_cache_.get();
  }
  // get a vector of output tensors
563 564
  std::vector<Tensor*>* output_tensor_ptrs() override {
    if (!output_tensor_ptrs_cache_) {
565 566 567 568
      output_tensor_ptrs_cache_.reset(new std::vector<lite::Tensor*>({output}));
    }
    return output_tensor_ptrs_cache_.get();
  }
Y
Yan Chunwei 已提交
569 570 571
};

/// ----------------------- element wise operators ----------------------
572
struct ElementwiseParam : ParamBase {
Y
Yan Chunwei 已提交
573 574 575 576
  const lite::Tensor* X{};
  const lite::Tensor* Y{};
  lite::Tensor* Out{};
  int axis{-1};  // for broadcasting.
J
juncaipeng 已提交
577
  // for int8
Z
Zhaolong Xing 已提交
578
  WITH_INT8_CONFIG
J
juncaipeng 已提交
579 580
  float x_input_scale{1.0};
  float y_input_scale{1.0};
581 582
  ///////////////////////////////////////////////////////////////////////////////////
  // get a vector of input tensors
583 584
  const std::vector<const Tensor*>* input_tensor_ptrs() override {
    if (!input_tensor_ptrs_cache_) {
585 586 587 588 589
      input_tensor_ptrs_cache_.reset(new std::vector<const Tensor*>({X, Y}));
    }
    return input_tensor_ptrs_cache_.get();
  }
  // get a vector of output tensors
590 591
  std::vector<Tensor*>* output_tensor_ptrs() override {
    if (!output_tensor_ptrs_cache_) {
592 593 594 595 596 597 598
      output_tensor_ptrs_cache_.reset(new std::vector<lite::Tensor*>({Out}));
    }
    return output_tensor_ptrs_cache_.get();
  }
};

struct ElementwiseGradParam : ParamBase {
X
xiaogang 已提交
599
  const lite::Tensor* X{};
Y
Yan Chunwei 已提交
600
  const lite::Tensor* Y{};
X
xiaogang 已提交
601 602 603
  const lite::Tensor* OutGrad{};
  lite::Tensor* XGrad{};
  lite::Tensor* YGrad{};
Y
Yan Chunwei 已提交
604 605 606 607 608 609 610 611 612 613 614 615
  int axis{-1};  // for broadcasting.
};

struct FusionElementwiseActivationParam : public ElementwiseParam {
  std::string act_type;
};

struct FusionElementwiseActivationGradParam : public ElementwiseGradParam {
  std::string act_type;
};

/// ----------------------- mean operators ----------------------
616
struct MeanParam : ParamBase {
Y
Yan Chunwei 已提交
617 618 619 620
  const lite::Tensor* X{};
  lite::Tensor* Out{};
};

621
struct MeanGradParam : ParamBase {
Y
Yan Chunwei 已提交
622 623 624 625 626 627 628
  const lite::Tensor* X{};
  const lite::Tensor* Out_grad{};
  // for backward
  lite::Tensor* X_grad{};
};

/// ----------------------- fill_constant operators ----------------------
629
struct FillConstantParam : ParamBase {
Y
Yan Chunwei 已提交
630 631
  int dtype{static_cast<int>(VarDescAPI::VarDataType::FP32)};
  std::vector<int64_t> shape{};
632
  lite::Tensor* shape_tensor{nullptr};
633 634
  std::vector<lite::Tensor*> shape_tensor_list{};

T
TianXiaogang 已提交
635 636 637 638 639
  float value{0.0f};
  // useless for x86, keep it for compatibility
  bool force_cpu{false};
  lite::Tensor* out{};
};
Y
Yan Chunwei 已提交
640

641
struct FillConstantBatchSizeLikeParam : ParamBase {
642 643
  const lite::Tensor* input{nullptr};
  lite::Tensor* out{nullptr};
644

645
  std::vector<int> shape{};
646 647 648 649
  int input_dim_idx{0};
  int output_dim_idx{0};
  int dtype{static_cast<int>(VarDescAPI::VarDataType::FP32)};
  float value{0.0f};
650 651
  // useless for x86, keep it for compatibility
  bool force_cpu{false};
652 653
};

Y
Yan Chunwei 已提交
654
//
655
struct FakeQuantizeMovingAvgMaxAbsParam : ParamBase {
Y
Yan Chunwei 已提交
656 657 658 659 660 661 662 663 664 665
  const lite::Tensor* x{};
  const lite::Tensor* in_scale{};
  const lite::Tensor* in_accum{};
  const lite::Tensor* in_state{};
  lite::Tensor* out{};
  lite::Tensor* out_scale{};
  lite::Tensor* out_state{};
  lite::Tensor* out_accum{};
  int bit_length;
  bool is_test{true};
666
  float moving_rate{0.9f};
Y
Yan Chunwei 已提交
667 668
};

669
struct FakeDequantizeMaxAbsParam : ParamBase {
Y
Yan Chunwei 已提交
670 671 672 673 674 675
  const lite::Tensor* x{};
  const lite::Tensor* in_scale{};
  lite::Tensor* out{};
  float max_range;
};

676
struct FakeChannelWiseDequantizeMaxAbsParam : ParamBase {
677 678 679 680 681 682
  const lite::Tensor* x{};
  std::vector<const lite::Tensor*> scale_tensors{};
  lite::Tensor* out{};
  std::vector<int> quant_bits;
};

683 684 685 686 687 688 689
struct FakeQuantDequantAbsMaxParam : ParamBase {
  const lite::Tensor* x{};
  lite::Tensor* out{};
  lite::Tensor* out_scale{};
  int bit_length;
};

Y
Yan Chunwei 已提交
690
/// ----------------------- sgd operators ----------------------
691
struct SGDParam : ParamBase {
Y
Yan Chunwei 已提交
692 693 694 695 696 697 698 699 700
  int dtype{static_cast<int>(VarDescAPI::VarDataType::FP32)};

  const lite::Tensor* Param{};
  const lite::Tensor* LearningRate{};
  const lite::Tensor* Grad{};
  lite::Tensor* ParamOut{};
};

/// ----------------------- uniform_random operators ----------------------
701
struct UniformRandomParam : ParamBase {
Y
Yan Chunwei 已提交
702 703 704 705 706 707 708 709
  std::vector<int64_t> shape{};
  float min{-1.0f};
  float max{1.0f};
  int seed{0};
  int dtype{static_cast<int>(VarDescAPI::VarDataType::FP32)};
  lite::Tensor* Out{};
};
/// ----------------------- negative operators --------------
710
struct NegativeParam : ParamBase {
Y
Yan Chunwei 已提交
711 712 713 714
  const lite::Tensor* X{};
  lite::Tensor* Out{};
};
/// ----------------------- pad2d operators ----------------------
715
struct Pad2dParam : ParamBase {
Y
Yan Chunwei 已提交
716 717 718 719 720 721 722 723 724
  const lite::Tensor* X{};
  lite::Tensor* Out{};
  std::vector<int> paddings{0, 0, 0, 0};
  std::string mode{"constant"};
  float pad_value = 0.f;
  std::string data_format{"NCHW"};
};

/// ----------------------- Crop operators ----------------------
725
struct CropParam : ParamBase {
Y
Yan Chunwei 已提交
726 727 728 729 730 731 732
  const lite::Tensor* X{};
  lite::Tensor* Out{};
  std::vector<int> offsets;
  std::vector<int> shape;
};

///----------------------- argmax operators ----------------------
733
struct ArgmaxParam : ParamBase {
Y
Yan Chunwei 已提交
734 735 736 737 738 739
  lite::Tensor* X{};
  lite::Tensor* Out{};
  int Axis{0};
};

///----------------------- axpy operators ----------------------
740
struct AxpyParam : ParamBase {
Y
Yan Chunwei 已提交
741 742 743 744 745 746
  lite::Tensor* Scale{};
  lite::Tensor* X{};
  lite::Tensor* Bias{};
  lite::Tensor* Out{};
};
/// ----------------------- GRU unit operators ----------------------f
747
struct GRUUnitParam : ParamBase {
Y
Yan Chunwei 已提交
748 749 750 751 752 753 754 755 756 757 758 759 760 761 762
  enum ActType { identity, sigmoid, tanh, relu };
  const lite::Tensor* input{nullptr};
  const lite::Tensor* hidden_prev{nullptr};
  const lite::Tensor* weight{nullptr};
  const lite::Tensor* bias{nullptr};
  lite::Tensor* gate{nullptr};
  lite::Tensor* reset_hidden_prev{nullptr};
  lite::Tensor* hidden{nullptr};

  int gate_activation{ActType::sigmoid};
  int activation{ActType::tanh};
  bool origin_mode{false};
};

/// ------------------------------ lrn operators ------------------------------
763
struct LrnParam : ParamBase {
Y
Yan Chunwei 已提交
764 765
  const lite::Tensor* X{};
  lite::Tensor* Out{};
766
  int n{5};
767 768 769
  float alpha{1e-4f};
  float beta{0.75f};
  float k{1.f};
Y
Yan Chunwei 已提交
770 771 772 773
  std::string norm_region{"AcrossChannels"};
};

/// ----------------------- decode_bboxes operators ----------------------
774
struct DecodeBboxesParam : ParamBase {
Y
Yan Chunwei 已提交
775 776 777 778 779 780 781 782 783 784 785 786 787 788 789
  const lite::Tensor* loc_data{};
  const lite::Tensor* prior_data{};
  lite::Tensor* bbox_data{};

  int batch_num;
  int num_priors;
  int num_loc_classes{0};
  int background_label_id{0};
  bool share_location{true};
  bool variance_encoded_in_target;
  // code_type:  corner, cente_size, corner_size
  std::string code_type;
};

/// ----------------------- box_coder operators ----------------------
790
struct BoxCoderParam : ParamBase {
Y
Yan Chunwei 已提交
791 792 793 794 795
  const lite::Tensor* prior_box{};
  const lite::Tensor* prior_box_var{};
  const lite::Tensor* target_box{};
  lite::Tensor* proposals{};
  // code_type: encode_center_size and decode_center_size
796 797 798 799
  std::string code_type{"encode_center_size"};
  bool box_normalized{true};
  int axis{0};
  std::vector<float> variance{};
Y
Yan Chunwei 已提交
800 801 802
};

/// ----------------------- multiclass_nms operators ----------------------
803
struct MulticlassNmsParam : ParamBase {
804 805 806
  const lite::Tensor* bboxes{};
  const lite::Tensor* scores{};
  lite::Tensor* out{};
807
  lite::Tensor* index{};
808 809 810
  int background_label{0};
  float score_threshold{};
  int nms_top_k{};
811 812
  float nms_threshold{0.3f};
  float nms_eta{1.0f};
Y
Yan Chunwei 已提交
813
  int keep_top_k;
814
  bool normalized{true};
Y
Yan Chunwei 已提交
815 816 817
};

/// ----------------------- priorbox operators ----------------------
818
struct PriorBoxParam : ParamBase {
Y
Yan Chunwei 已提交
819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837
  lite::Tensor* input{};
  lite::Tensor* image{};
  lite::Tensor* boxes{};
  lite::Tensor* variances{};

  bool flip;
  bool clip;
  std::vector<float> min_sizes;
  std::vector<float> max_sizes;
  std::vector<float> aspect_ratios;
  std::vector<float> variances_;
  int img_w{0};
  int img_h{0};
  float step_w{0};
  float step_h{0};
  float offset{0.5};
  int prior_num{0};
  // priortype: prior_min, prior_max, prior_com
  std::vector<std::string> order;
838
  bool min_max_aspect_ratios_order{false};
Y
Yan Chunwei 已提交
839 840 841 842 843
};

struct DensityPriorBoxParam : public PriorBoxParam {
  std::vector<float> fixed_sizes;
  std::vector<float> fixed_ratios;
T
TianXiaogang 已提交
844
  std::vector<int> density_sizes;
Y
Yan Chunwei 已提交
845 846
};
/// ----------------------- GRU operators ----------------------f
847
struct GRUParam : ParamBase {
Y
Yan Chunwei 已提交
848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863
  const lite::Tensor* input{nullptr};
  const lite::Tensor* h0{nullptr};
  const lite::Tensor* weight{nullptr};
  const lite::Tensor* bias{nullptr};
  lite::Tensor* batch_gate{nullptr};
  lite::Tensor* batch_reset_hidden_prev{nullptr};
  lite::Tensor* batch_hidden{nullptr};
  lite::Tensor* hidden{nullptr};

  std::string gate_activation{"sigmoid"};
  std::string activation{"tanh"};
  bool is_reverse{false};
  bool origin_mode{false};
};

/// ----------------------- BeamSearchDecode operators ----------------------f
864
struct BeamSearchDecodeParam : ParamBase {
Y
Yan Chunwei 已提交
865 866 867 868 869 870 871 872 873
  std::vector<lite::Tensor>* ids{nullptr};
  std::vector<lite::Tensor>* scores{nullptr};
  lite::Tensor* sentence_ids{nullptr};
  lite::Tensor* sentence_scores{nullptr};
  int beam_size;
  int end_id;
};

/// ----------------------- LookupTable operators ----------------------f
874
struct LookupTableParam : ParamBase {
875 876
  const lite::Tensor* W{nullptr};
  const lite::Tensor* Ids{nullptr};
Y
Yan Chunwei 已提交
877 878 879 880
  lite::Tensor* Out{nullptr};
  int64_t padding_idx{-1};
};

881
struct LookupTableDequantParam : ParamBase {
M
mapingshuo 已提交
882 883 884 885 886 887
  lite::Tensor* W{nullptr};
  lite::Tensor* Ids{nullptr};
  lite::Tensor* Out{nullptr};
  int64_t padding_idx{-1};
};

888
struct Im2SequenceParam : ParamBase {
Y
Yan Chunwei 已提交
889 890 891 892 893 894 895 896 897
  const lite::Tensor* X{};
  const lite::Tensor* Y{};
  lite::Tensor* Out{};
  std::vector<int> kernels{3, 3};
  std::vector<int> strides{1, 1};
  std::vector<int> paddings{0, 0, 0, 0};
  std::vector<int> out_strides{1, 1};
};

898
struct SequenceSoftmaxParam : ParamBase {
Y
Yan Chunwei 已提交
899 900
  const lite::Tensor* X{};
  lite::Tensor* Out{};
901 902
  ///////////////////////////////////////////////////////////////////////////////////
  //  // get a vector of input tensors
903 904
  const std::vector<const Tensor*>* input_tensor_ptrs() override {
    if (!input_tensor_ptrs_cache_) {
905 906 907 908 909
      input_tensor_ptrs_cache_.reset(new std::vector<const Tensor*>({X}));
    }
    return input_tensor_ptrs_cache_.get();
  }
  // get a vector of output tensors
910 911
  std::vector<Tensor*>* output_tensor_ptrs() override {
    if (!output_tensor_ptrs_cache_) {
912 913 914 915
      output_tensor_ptrs_cache_.reset(new std::vector<lite::Tensor*>({Out}));
    }
    return output_tensor_ptrs_cache_.get();
  }
Y
Yan Chunwei 已提交
916 917
};

918
struct NormParam : ParamBase {
Y
Yan Chunwei 已提交
919 920
  const lite::Tensor* X{};
  lite::Tensor* Out{};
921
  lite::Tensor* Norm{};
Y
Yan Chunwei 已提交
922
  int axis{1};
923
  float epsilon{1e-10f};
Y
Yan Chunwei 已提交
924
};
925
struct LayerNormParam : ParamBase {
T
TianXiaogang 已提交
926 927 928 929 930 931 932
  const lite::Tensor* X{};
  const lite::Tensor* Scale{};
  const lite::Tensor* Bias{};
  lite::Tensor* Y{};
  lite::Tensor* Mean{};
  lite::Tensor* Variance{};
  int begin_norm_axis{1};
933
  float epsilon{1e-5f};
T
TianXiaogang 已提交
934
};
Y
Yan Chunwei 已提交
935

936
struct LogicalParam : ParamBase {
Y
Yan Chunwei 已提交
937 938 939 940 941
  const lite::Tensor* X{};
  const lite::Tensor* Y{};
  lite::Tensor* Out{};
};

942
struct CompareParam : ParamBase {
Y
Yan Chunwei 已提交
943 944 945 946 947 948 949
  const lite::Tensor* X{};
  const lite::Tensor* Y{};
  bool force_cpu{0};
  int axis{-1};
  lite::Tensor* Out{};
};

950
struct WhileParam : ParamBase {
Y
Yan Chunwei 已提交
951
  Tensor* cond{};
952 953 954
  int block_idx{-1};
  std::shared_ptr<const cpp::ProgramDesc> program_desc{nullptr};
  Scope* exec_scope{nullptr};
Y
Yan Chunwei 已提交
955 956
};

957
struct TopkParam : ParamBase {
Y
Yan Chunwei 已提交
958 959 960 961 962 963
  const lite::Tensor* X{};
  lite::Tensor* Out{};
  lite::Tensor* Indices{};
  int K{1};
};

964
struct IncrementParam : ParamBase {
Y
Yan Chunwei 已提交
965 966 967 968 969
  const lite::Tensor* X{};
  lite::Tensor* Out{};
  float step{1};
};

970
struct WriteToArrayParam : ParamBase {
971 972 973
  const lite::Tensor* X{nullptr};
  const lite::Tensor* I{nullptr};
  std::vector<lite::Tensor>* Out{nullptr};
Y
Yan Chunwei 已提交
974 975
};

976
struct ReadFromArrayParam : ParamBase {
977 978 979
  const std::vector<lite::Tensor>* X{nullptr};
  const lite::Tensor* I{nullptr};
  lite::Tensor* Out{nullptr};
Y
Yan Chunwei 已提交
980 981
};

982
struct BeamSearchParam : ParamBase {
Y
Yan Chunwei 已提交
983 984 985 986 987 988 989 990 991 992 993 994 995
  const lite::Tensor* pre_ids{};
  const lite::Tensor* pre_scores{};
  const lite::Tensor* ids{};
  const lite::Tensor* scores{};
  lite::Tensor* selected_ids{};
  lite::Tensor* selected_scores{};
  lite::Tensor* parent_idx{};
  int level;
  int beam_size;
  int end_id;
  bool is_accumulated;
};

996
struct SequencePoolParam : ParamBase {
Y
Yan Chunwei 已提交
997 998
  const lite::Tensor* X{};
  lite::Tensor* Out{};
999 1000 1001
  std::string pool_type{"AVERAGE"};
#ifdef LITE_WITH_X86
  float pad_value{0.0};
1002
  lite::Tensor* MaxIndex{};
1003
#endif
Y
Yan Chunwei 已提交
1004 1005
};

1006
struct SequenceConvParam : ParamBase {
1007 1008 1009 1010 1011 1012 1013 1014
  const lite::Tensor* X{};
  const lite::Tensor* Filter{};
  lite::Tensor* Out{};
  int contextStart{0};
  int contextStride{1};
  int contextLength;
};

1015
struct SequencePoolConcatParam : ParamBase {
1016 1017 1018 1019 1020
  std::vector<lite::Tensor*> X{};
  lite::Tensor* Out{};
  std::vector<std::string> pool_type{};
};

1021
struct SearchGroupPaddingParam : ParamBase {
1022 1023 1024 1025 1026 1027 1028
  lite::Tensor* x{};
  lite::Tensor* out_emb_padding{};
  lite::Tensor* out_new{};
  lite::Tensor* out_padding{};
  int pad_id;
};

1029
struct SequenceReshapeParam : ParamBase {
1030 1031 1032 1033 1034
  lite::Tensor* x{};
  lite::Tensor* output{};
  int new_dim;
};

1035
struct SequenceExpandParam : ParamBase {
Y
Yan Chunwei 已提交
1036 1037 1038 1039 1040 1041
  const lite::Tensor* X{};
  const lite::Tensor* Y{};
  lite::Tensor* Out{};
  int ref_level{-1};
};

1042 1043 1044 1045 1046 1047 1048 1049
struct SequencePadParam : ParamBase {
  const lite::Tensor* X{};
  const lite::Tensor* PadValue{};
  lite::Tensor* Out{};
  lite::Tensor* Length{};
  int padded_length{-1};
};

1050 1051 1052 1053 1054 1055
struct SequenceUnpadParam : ParamBase {
  const lite::Tensor* X{};
  const lite::Tensor* Length{};
  lite::Tensor* Out{};
};

1056 1057 1058 1059 1060 1061 1062 1063
struct SequenceMaskParam : ParamBase {
  const lite::Tensor* X{};
  const lite::Tensor* MaxLenTensor{nullptr};
  lite::Tensor* Y{};
  int maxlen{-1};
  int out_dtype;
};

1064
struct SequenceExpandAsParam : ParamBase {
L
lhl960107 已提交
1065 1066 1067 1068 1069
  const lite::Tensor* x{nullptr};
  const lite::Tensor* y{nullptr};
  lite::Tensor* out{nullptr};
};

1070
struct SequenceReverseParam : ParamBase {
1071 1072 1073 1074
  const lite::Tensor* X{};
  lite::Tensor* Out{};
};

1075
struct SequenceConcatParam : ParamBase {
1076 1077 1078 1079
  std::vector<lite::Tensor*> X{};
  lite::Tensor* Out{};
};

1080
struct AttentionPaddingMaskParam : ParamBase {
1081 1082 1083 1084 1085 1086 1087 1088
  const lite::Tensor* X{};
  const lite::Tensor* Y{};
  int pad_id;
  float mask;
  lite::Tensor* Out{};
  lite::Tensor* pad_begin{};
};

1089
struct SequenceArithmeticParam : ParamBase {
1090 1091 1092 1093 1094 1095
  const lite::Tensor* X{};
  const lite::Tensor* Y{};
  int op_type{1};
  lite::Tensor* Out{};
};

1096
struct ReduceMaxParam : ParamBase {
Y
Yan Chunwei 已提交
1097 1098 1099 1100 1101 1102
  const lite::Tensor* X{};
  lite::Tensor* Out{};
  std::vector<int> dim{};
  bool keep_dim{false};
};

1103
struct LodResetParam : ParamBase {
Y
Yan Chunwei 已提交
1104 1105 1106 1107 1108 1109 1110
  const lite::Tensor* X{};
  const lite::Tensor* Y{};
  lite::Tensor* Out{};
  std::vector<int> target_lod;
  bool append;
};

1111
struct IsEmptyParam : ParamBase {
Y
Yan Chunwei 已提交
1112 1113 1114
  const lite::Tensor* X{};
  lite::Tensor* Out{};
};
1115

1116
struct ReduceParam : ParamBase {
1117 1118 1119 1120 1121 1122 1123
  lite::Tensor* x{};
  lite::Tensor* output{};
  std::vector<int> dim{0};
  bool keep_dim{false};
  bool reduce_all{false};
};

1124
struct VarConv2DParam : ParamBase {
1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137
  const lite::Tensor* X{};
  const lite::Tensor* ROW{};
  const lite::Tensor* COLUMN{};
  const lite::Tensor* W{};
  lite::Tensor* Out{};
  lite::Tensor* Col{};

  int input_channel;
  int output_channel;
  int stride_h;
  int stride_w;
  int kernel_h;
  int kernel_w;
1138 1139

  bool fuse_relu{false};
1140 1141 1142 1143 1144

#ifdef LITE_WITH_XPU
  bool __xpu__float_to_fix{false};  // Is W already converted to int16/int8
  float __xpu__w_max{0.0f};         // Abs max in W
#endif
1145 1146
};

Y
Yan Chunwei 已提交
1147
/// ----------------------- shape operators ----------------------
1148
struct ShapeParam : ParamBase {
Y
Yan Chunwei 已提交
1149 1150 1151 1152
  const lite::Tensor* X{};
  lite::Tensor* Out{};
};

1153
struct CastParam : ParamBase {
Y
Yan Chunwei 已提交
1154 1155 1156 1157 1158 1159
  const lite::Tensor* X{};
  lite::Tensor* Out{};
  int out_dtype{2};
  int in_dtype{2};
};

1160
struct SliceParam : ParamBase {
Y
Yan Chunwei 已提交
1161 1162 1163 1164 1165 1166
  const lite::Tensor* X{};
  lite::Tensor* Out{};
  std::vector<int> axes{};
  std::vector<int> starts{};
  std::vector<int> ends{};
  std::vector<int> decrease_axis{};
1167 1168 1169 1170 1171
  std::vector<int> infer_flags{};
  std::vector<lite::Tensor*> StartsTensorList{};
  std::vector<lite::Tensor*> EndsTensorList{};
  lite::Tensor* StartsTensor{nullptr};
  lite::Tensor* EndsTensor{nullptr};
1172 1173
  ///////////////////////////////////////////////////////////////////////////////////
  // get a vector of input tensors
1174 1175
  const std::vector<const Tensor*>* input_tensor_ptrs() override {
    if (!input_tensor_ptrs_cache_) {
1176 1177 1178 1179 1180
      input_tensor_ptrs_cache_.reset(new std::vector<const Tensor*>({X}));
    }
    return input_tensor_ptrs_cache_.get();
  }
  // get a vector of output tensors
1181 1182
  std::vector<Tensor*>* output_tensor_ptrs() override {
    if (!output_tensor_ptrs_cache_) {
1183 1184 1185 1186
      output_tensor_ptrs_cache_.reset(new std::vector<lite::Tensor*>({Out}));
    }
    return output_tensor_ptrs_cache_.get();
  }
Y
Yan Chunwei 已提交
1187
};
Y
Yan Chunwei 已提交
1188

1189
struct AffineChannelParam : ParamBase {
1190 1191 1192 1193 1194 1195 1196
  const lite::Tensor* X{};  // X is 4D tensor
  const lite::Tensor* Scale{};
  const lite::Tensor* Bias{};
  std::string data_layout{"NCHW"};  // optional string from: NHWC, NCHW.
  lite::Tensor* Out{};
};

1197 1198 1199 1200 1201 1202 1203
struct AffineGridParam : ParamBase {
  const lite::Tensor* X{};  // Theta:shape {?, 2, 3}
  std::vector<int> output_shape;
  const lite::Tensor* OutputShape;
  lite::Tensor* Out{};
};

1204
struct AnchorGeneratorParam : ParamBase {
1205 1206 1207 1208
  const lite::Tensor* Input{};
  std::vector<float> anchor_sizes{};
  std::vector<float> aspect_ratios{};
  std::vector<float> stride{};
1209 1210
  std::vector<float> variances{{0.1f, 0.1f, 0.2f, 0.2f}};
  float offset{0.5f};
1211 1212 1213 1214 1215

  lite::Tensor* Anchors{};
  lite::Tensor* Variances{};
};

1216
struct GenerateProposalsParam : ParamBase {
1217 1218 1219 1220 1221 1222 1223 1224 1225 1226
  // inputs
  const lite::Tensor* Scores{};
  const lite::Tensor* BboxDeltas{};
  const lite::Tensor* ImInfo{};
  lite::Tensor* Anchors{};
  lite::Tensor* Variances{};

  // attrs
  int pre_nms_topN{6000};
  int post_nms_topN{1000};
1227 1228 1229
  float nms_thresh{0.5f};
  float min_size{0.1f};
  float eta{1.0f};
1230 1231 1232 1233 1234

  // outputs
  lite::Tensor* RpnRois{};
  lite::Tensor* RpnRoiProbs{};
};
W
Wilber 已提交
1235
/// ----------------------- squeeze operators ----------------------
1236
struct SqueezeParam : ParamBase {
Y
Yan Chunwei 已提交
1237 1238 1239 1240
  const lite::Tensor* X{};
  lite::Tensor* Out{};
  lite::Tensor* XShape{};
  std::vector<int> axes{};
1241 1242
  ///////////////////////////////////////////////////////////////////////////////////
  // get a vector of input tensors
1243 1244
  const std::vector<const Tensor*>* input_tensor_ptrs() override {
    if (!input_tensor_ptrs_cache_) {
1245 1246 1247 1248 1249
      input_tensor_ptrs_cache_.reset(new std::vector<const Tensor*>({X}));
    }
    return input_tensor_ptrs_cache_.get();
  }
  // get a vector of output tensors
1250 1251
  std::vector<Tensor*>* output_tensor_ptrs() override {
    if (!output_tensor_ptrs_cache_) {
1252 1253 1254 1255
      output_tensor_ptrs_cache_.reset(new std::vector<lite::Tensor*>({Out}));
    }
    return output_tensor_ptrs_cache_.get();
  }
Y
Yan Chunwei 已提交
1256 1257
};

1258
struct UnsqueezeParam : ParamBase {
1259 1260 1261 1262
  const lite::Tensor* X{};
  lite::Tensor* Out{};
  lite::Tensor* XShape{};
  std::vector<int> axes{};
1263
  const lite::Tensor* axes_tensor{};
1264
  std::vector<const lite::Tensor*> axes_tensor_vct{};
1265 1266
  ///////////////////////////////////////////////////////////////////////////////////
  // get a vector of input tensors
1267 1268
  const std::vector<const Tensor*>* input_tensor_ptrs() override {
    if (!input_tensor_ptrs_cache_) {
1269 1270 1271 1272 1273
      input_tensor_ptrs_cache_.reset(new std::vector<const Tensor*>({X}));
    }
    return input_tensor_ptrs_cache_.get();
  }
  // get a vector of output tensors
1274 1275
  std::vector<Tensor*>* output_tensor_ptrs() override {
    if (!output_tensor_ptrs_cache_) {
1276 1277 1278 1279
      output_tensor_ptrs_cache_.reset(new std::vector<lite::Tensor*>({Out}));
    }
    return output_tensor_ptrs_cache_.get();
  }
1280 1281
};

Y
Yan Chunwei 已提交
1282
/// ----------------------- expand operators ----------------------
1283
struct ExpandParam : ParamBase {
Y
Yan Chunwei 已提交
1284 1285 1286 1287 1288 1289
  const lite::Tensor* X{};
  lite::Tensor* Out{};
  std::vector<int> expand_times{};
};

/// ----------------------- matmul operators ----------------------
1290
struct MatMulParam : ParamBase {
Y
Yan Chunwei 已提交
1291 1292 1293 1294 1295 1296
  const lite::Tensor* X{};
  const lite::Tensor* Y{};
  lite::Tensor* Out{};
  bool transpose_X{false};
  bool transpose_Y{false};
  float alpha{1.0f};
1297 1298
  ///////////////////////////////////////////////////////////////////////////////////
  // get a vector of input tensors
1299 1300
  const std::vector<const Tensor*>* input_tensor_ptrs() override {
    if (!input_tensor_ptrs_cache_) {
1301 1302 1303 1304 1305
      input_tensor_ptrs_cache_.reset(new std::vector<const Tensor*>({X, Y}));
    }
    return input_tensor_ptrs_cache_.get();
  }
  // get a vector of output tensors
1306 1307
  std::vector<Tensor*>* output_tensor_ptrs() override {
    if (!output_tensor_ptrs_cache_) {
1308 1309 1310 1311
      output_tensor_ptrs_cache_.reset(new std::vector<lite::Tensor*>({Out}));
    }
    return output_tensor_ptrs_cache_.get();
  }
Y
Yan Chunwei 已提交
1312
};
1313

1314
struct GatherParam : ParamBase {
T
TianXiaogang 已提交
1315 1316 1317 1318 1319
  const lite::Tensor* X{};
  const lite::Tensor* Index{};
  lite::Tensor* Out{};
};

1320
/// ----------------------- assign operators -----------------------
1321
struct AssignParam : ParamBase {
1322 1323 1324 1325 1326 1327 1328
  // for tensor
  const lite::Tensor* X{nullptr};
  lite::Tensor* Out{nullptr};

  // for tensor_array
  const std::vector<lite::Tensor>* X_array{nullptr};
  std::vector<lite::Tensor>* Out_array{nullptr};
1329
};
1330

1331
/// ----------------------- roi_align operators -----------------------
1332
struct RoiAlignParam : ParamBase {
1333 1334 1335 1336 1337 1338 1339 1340 1341
  lite::Tensor* X{};
  lite::Tensor* ROIs{};
  lite::Tensor* Out{};
  float spatial_scale{1.0};
  int pooled_height{1};
  int pooled_width{1};
  int sampling_ratio{-1};
};

1342
/// ----------------------- box_clip operators -----------------------
1343
struct BoxClipParam : ParamBase {
1344 1345 1346 1347 1348
  const lite::Tensor* Input{};
  const lite::Tensor* ImInfo{};
  lite::Tensor* Output{};
};

1349
struct RangeParam : ParamBase {
1350 1351 1352 1353 1354 1355
  const lite::Tensor* Start;
  const lite::Tensor* End;
  const lite::Tensor* Step;
  lite::Tensor* Out;
};

1356
/// ----------------------- assign_value operators -----------------------
1357
struct AssignValueParam : ParamBase {
1358 1359 1360 1361
  std::vector<int> shape{};
  int dtype{};
  std::vector<float> fp32_values{};
  std::vector<int> int32_values{};
1362 1363
  std::vector<int64_t> int64_values{};
  std::vector<int> bool_values{};
1364 1365 1366
  lite::Tensor* Out{};
};

1367
/// --------------- sequence_topk_avg_pooling operators ------------------
1368
struct SequenceTopkAvgPoolingParam : ParamBase {
1369 1370 1371 1372 1373 1374 1375 1376 1377
  const lite::Tensor* X{};
  const lite::Tensor* ROW{};
  const lite::Tensor* COLUMN{};
  lite::Tensor* Out{};
  lite::Tensor* pos{};
  int channel_num{};
  std::vector<int> topks{};
};

1378 1379 1380 1381 1382 1383 1384 1385 1386
/// --------------- topk_pooling operators ------------------
struct TopkPoolingParam : ParamBase {
  const lite::Tensor* X{};
  const lite::Tensor* Y{};
  lite::Tensor* Out{};
  int top_k{1};
  int feat_map_num{1};
};

1387
/// --------------- search_fc operators ------------------
1388
struct SearchFcParam : ParamBase {
1389 1390 1391 1392 1393
  const lite::Tensor* X{};
  const lite::Tensor* W{};
  const lite::Tensor* b{};
  lite::Tensor* Out{};
  int out_size{};
1394 1395 1396 1397 1398 1399 1400

  bool fuse_relu{false};

#ifdef LITE_WITH_XPU
  bool __xpu__float_to_fix{false};  // Is W already converted to int16/int8
  float __xpu__w_max{0.0f};         // Abs max in W
#endif
1401
};
J
juncaipeng 已提交
1402
/// --------------------- match_matrix_tensor operators --------------------
1403
struct MatchMatrixTensorParam : ParamBase {
J
juncaipeng 已提交
1404 1405 1406 1407 1408 1409 1410
  const lite::Tensor* x{};
  const lite::Tensor* y{};
  const lite::Tensor* w{};
  lite::Tensor* out{};
  lite::Tensor* tmp{};

  int dim_t;
1411 1412 1413 1414 1415 1416
  bool fuse_relu{false};

#ifdef LITE_WITH_XPU
  bool __xpu__float_to_fix{false};  // Is w already converted to int16/int8
  float __xpu__w_max{0.0f};         // Abs max in w
#endif
J
juncaipeng 已提交
1417 1418 1419
};

/// --------------------- search_seq_depadding operators --------------------
1420
struct SearchSeqDepaddingParam : ParamBase {
J
juncaipeng 已提交
1421 1422 1423 1424 1425 1426
  const lite::Tensor* pad{};
  const lite::Tensor* src{};
  lite::Tensor* out{};
};

/// --------------------- search_grnn operators --------------------
1427
struct SearchGrnnParam : ParamBase {
J
juncaipeng 已提交
1428 1429 1430 1431 1432 1433 1434 1435 1436 1437
  const lite::Tensor* x{};
  const lite::Tensor* wi{};
  const lite::Tensor* wh{};
  int num_input;
  int num_hidden;

  lite::Tensor* out{};
  lite::Tensor* tmp_buffer{};
  lite::Tensor* idx_sorted_by_width{};
  lite::Tensor* layout_input{};
1438 1439 1440 1441 1442 1443

#ifdef LITE_WITH_XPU
  bool __xpu__float_to_fix{false};   // Is wi/wh already converted to int16/int8
  std::vector<float> __xpu__wi_max;  // Abs max in wi
  std::vector<float> __xpu__wh_max;  // Abs max in wh
#endif
J
juncaipeng 已提交
1444 1445
};

1446
struct SplitLodTensorParam : ParamBase {
J
juncaipeng 已提交
1447 1448 1449 1450 1451 1452 1453
  const lite::Tensor* x{};
  const lite::Tensor* mask{};
  lite::Tensor* out_true{};
  lite::Tensor* out_false{};
  int level{};
};

1454
struct MergeLodTensorParam : ParamBase {
J
juncaipeng 已提交
1455 1456 1457 1458 1459 1460 1461 1462
  const lite::Tensor* x{};
  const lite::Tensor* mask{};
  const lite::Tensor* in_true{};
  const lite::Tensor* in_false{};
  lite::Tensor* out{};
  int level{};
};

1463
struct ConditionalBlockParam : ParamBase {
J
juncaipeng 已提交
1464
  const lite::Tensor* cond{};
1465
  std::vector<lite::Tensor*> inputs{};
J
juncaipeng 已提交
1466
  std::vector<lite::Tensor*> outs{};
1467 1468 1469
  int block_idx{-1};
  std::shared_ptr<const cpp::ProgramDesc> program_desc{nullptr};
  Scope* exec_scope{nullptr};
J
juncaipeng 已提交
1470 1471 1472
  bool is_scalar_condition{};
};

1473
struct CollectFpnProposalsParam : ParamBase {
J
juncaipeng 已提交
1474 1475 1476 1477 1478 1479
  std::vector<lite::Tensor*> multi_level_rois{};
  std::vector<lite::Tensor*> multi_level_scores{};
  lite::Tensor* fpn_rois{};
  int post_nms_topN{};
};

1480
struct DistributeFpnProposalsParam : ParamBase {
J
juncaipeng 已提交
1481 1482 1483 1484 1485 1486 1487 1488 1489
  const lite::Tensor* fpn_rois{};
  std::vector<lite::Tensor*> multi_fpn_rois{};
  lite::Tensor* restore_index{};
  int min_level{};
  int max_level{};
  int refer_level{};
  int refer_scale{};
};

1490
/// --------------------- instance_norm operators --------------------
1491
struct InstanceNormParam : ParamBase {
1492 1493 1494 1495 1496 1497 1498 1499
  lite::Tensor* x{};
  lite::Tensor* out{};
  lite::Tensor* bias{};
  lite::Tensor* scale{};
  lite::Tensor* saved_mean{};
  lite::Tensor* saved_variance{};
  float epsilon;
};
H
HappyAngel 已提交
1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512
/// --------------------- group_norm operators --------------------
struct GroupNormParam : ParamBase {
  lite::Tensor* x{};
  lite::Tensor* out{};
  lite::Tensor* bias{};
  lite::Tensor* scale{};
  lite::Tensor* saved_mean{};
  lite::Tensor* saved_variance{};
  float epsilon;
  int groups;
  int channels;
};

1513
/// --------------------- grid sampler operators --------------------
1514
struct GridSamplerParam : ParamBase {
1515 1516 1517 1518
  lite::Tensor* x{};
  lite::Tensor* out{};
  lite::Tensor* grid{};
};
1519
struct LstmParam : ParamBase {
X
xiaogang 已提交
1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534
  lite::Tensor* Input{};
  lite::Tensor* Weight{};
  lite::Tensor* Bias{};
  lite::Tensor* Hidden{};
  lite::Tensor* Cell{};
  lite::Tensor* BatchGate{};
  lite::Tensor* BatchCellPreAct{};
  lite::Tensor* H0{nullptr};
  lite::Tensor* C0{nullptr};
  bool use_peepholes;
  bool is_reverse;
  std::string gate_activation;
  std::string cell_activation;
  std::string candidate_activation;
};
1535

1536
struct CrfDecodingParam : ParamBase {
C
cc 已提交
1537 1538 1539 1540 1541 1542 1543
  lite::Tensor* emission{};
  lite::Tensor* transition{};
  lite::Tensor* label{};
  lite::Tensor* length{};
  lite::Tensor* viterbi_path{};
};

1544 1545 1546 1547 1548 1549 1550 1551 1552 1553
struct CtcAlignParam : ParamBase {
  lite::Tensor* input{};
  lite::Tensor* input_length{};
  lite::Tensor* output{};
  lite::Tensor* output_length{};
  int blank{0};
  bool merge_repeated{true};
  int padding_value{0};
};

1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575
struct XPUResNet50Param : ParamBase {
  lite::Tensor* input{};
  std::vector<lite::Tensor*> filter;
  std::vector<lite::Tensor*> bias;
  std::vector<lite::Tensor*> max_filter;
  lite::Tensor* output{};
};

struct XPUMultiEncoderParam : ParamBase {
  lite::Tensor* input{};
  std::vector<lite::Tensor*> fc_weight;
  std::vector<lite::Tensor*> fc_bias;
  std::vector<lite::Tensor*> ln_scale;
  std::vector<lite::Tensor*> ln_bias;
  lite::Tensor* fc_weight_max{};
  lite::Tensor* mask{};
  lite::Tensor* output{};

  int n_layers{};
  int head_num{};
  int size_per_head{};
  std::string act_type{};
1576
  std::string precision{};
1577 1578
};

C
Cwndmiao 已提交
1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598
struct XPUEmbeddingWithEltwiseAddParam : ParamBase {
  std::vector<lite::Tensor*> Ids;
  std::vector<lite::Tensor*> Tables;
  lite::Tensor* Out{};
  int64_t padding_idx{-1};
};

struct XPUFcParam : ParamBase {
  lite::Tensor* input{nullptr};
  lite::Tensor* w{nullptr};
  lite::Tensor* bias{nullptr};
  lite::Tensor* output{nullptr};

  int in_num_col_dims{1};
  lite::DDim in_mat_dims;
  float w_max{0.0f};
  bool transpose_w{true};
  std::string activation_type{""};
};

1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638
struct XPUResNetCbamParam : ParamBase {
  lite::Tensor* input{};
  std::vector<lite::Tensor*> filter;
  std::vector<lite::Tensor*> bias;
  std::vector<lite::Tensor*> max_filter;
  lite::Tensor* output{};

  float pool_p{1.0f};
};

struct XPUMmdnnSearchAttentionParam : ParamBase {
  lite::Tensor* X{};
  lite::Tensor* W{};
  lite::Tensor* b{};
  lite::Tensor* Out{};

  float W_max{0.0f};
  int pad_id{0};
  float alpha0{1.0f};
  float alpha1{1.0f};
  float mask{1.0f};
};

struct XPUMmdnnBidEmbGrnnAttParam : ParamBase {
  lite::Tensor* id0{};
  lite::Tensor* id1{};
  lite::Tensor* emb_tbl{};
  lite::Tensor* grnn_fw_wh{};
  lite::Tensor* grnn_fw_wi{};
  lite::Tensor* grnn_rv_wh{};
  lite::Tensor* grnn_rv_wi{};
  lite::Tensor* att_fc_w{};
  lite::Tensor* att_fc_b{};

  std::vector<float> grnn_fw_wh_maxs;
  std::vector<float> grnn_fw_wi_maxs;
  std::vector<float> grnn_rv_wh_maxs;
  std::vector<float> grnn_rv_wi_maxs;
  float att_fc_w_max{0.0f};

1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668
  lite::Tensor* grnn_fw_pool_out{};
  lite::Tensor* grnn_rv_pool_out{};
  lite::Tensor* att_pool_out{};
  lite::Tensor* concat_3in1_out{};
  lite::Tensor* emb_fw_out{};
};

struct XPUMmdnnBidEmbGrnnAttParam2 : ParamBase {
  lite::Tensor* id0{};
  lite::Tensor* id1{};
  lite::Tensor* emb_tbl{};
  lite::Tensor* grnn_fw_wh{};
  lite::Tensor* grnn_fw_wi{};
  lite::Tensor* grnn_rv_wh{};
  lite::Tensor* grnn_rv_wi{};
  lite::Tensor* att_fc_w{};
  lite::Tensor* att_fc_b{};

  std::vector<float> grnn_fw_wh_maxs;
  std::vector<float> grnn_fw_wi_maxs;
  std::vector<float> grnn_rv_wh_maxs;
  std::vector<float> grnn_rv_wi_maxs;
  float att_fc_w_max{0.0f};

  lite::Tensor* emb0_out{};
  lite::Tensor* grnn_fw_pool_out{};
  lite::Tensor* grnn_rv_pool_out{};
  lite::Tensor* att_pool_out{};
  lite::Tensor* concat_3in1_out{};
  lite::Tensor* emb_fw_out{};
1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679
};

struct XPUMmdnnBidEmbAttParam : ParamBase {
  lite::Tensor* id0{};
  lite::Tensor* id1{};
  lite::Tensor* emb_tbl{};
  lite::Tensor* att_fc_w{};
  lite::Tensor* att_fc_b{};

  float att_fc_w_max{0.0f};

1680 1681
  lite::Tensor* att_pool_out{};
  lite::Tensor* emb_fw_out{};
1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692
};

struct XPUMmdnnMatchConvTopkParam : ParamBase {
  lite::Tensor* input_x{};
  lite::Tensor* input_y{};
  lite::Tensor* input_w{};
  lite::Tensor* conv_w{};

  float input_w_max{0.0f};
  float conv_w_max{0.0f};
  std::vector<int> topks;
1693
  int output_channel{0};
1694 1695 1696 1697 1698 1699 1700 1701
  int channel_num{0};
  int dim_t{0};

  lite::Tensor* topk_out{};
};

struct XPUMmdnnMergeAllParam : ParamBase {
  std::vector<lite::Tensor*> concat_7in1_x;
1702
  std::vector<lite::Tensor*> concat_topk_x;
1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724
  lite::Tensor* grnn_fw_wh{};
  lite::Tensor* grnn_fw_wi{};
  lite::Tensor* grnn_rv_wh{};
  lite::Tensor* grnn_rv_wi{};
  lite::Tensor* fc0_w{};
  lite::Tensor* fc0_b{};
  lite::Tensor* fc1_w{};
  lite::Tensor* fc1_b{};
  lite::Tensor* fc2_w{};
  lite::Tensor* fc2_b{};

  std::vector<float> grnn_fw_wh_maxs;
  std::vector<float> grnn_fw_wi_maxs;
  std::vector<float> grnn_rv_wh_maxs;
  std::vector<float> grnn_rv_wi_maxs;
  float fc0_w_max{0.0f};
  float fc1_w_max{0.0f};
  float fc2_w_max{0.0f};

  lite::Tensor* out{};
};

H
HappyAngel 已提交
1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757
// For DeformableConvolution op
struct DeformableConvParam : ParamBase {
  lite::Tensor* x{};
  lite::Tensor* offset{};
  lite::Tensor* mask{};
  lite::Tensor* output{};
  int deformable_groups{1};
  int im2col_step{1};
  bool modulated{true};  // True-v2 False-v1
  std::string data_format{"Anylayout"};
  // convolution parameter
  ConvParam conv_param;
  // support var_length or not
  bool var_length{false};
  // only used in conv_transpose.
  std::vector<int> output_size;
  ///////////////////////////////////////////////////////////////////////////////////
  // get a vector of input tensors
  const std::vector<const Tensor*>* input_tensor_ptrs() override {
    if (!input_tensor_ptrs_cache_) {
      input_tensor_ptrs_cache_.reset(new std::vector<const Tensor*>({x}));
    }
    return input_tensor_ptrs_cache_.get();
  }
  // get a vector of output tensors
  std::vector<Tensor*>* output_tensor_ptrs() override {
    if (!output_tensor_ptrs_cache_) {
      output_tensor_ptrs_cache_.reset(new std::vector<lite::Tensor*>({output}));
    }
    return output_tensor_ptrs_cache_.get();
  }
};

1758 1759 1760 1761 1762
struct PixelShuffleParam : ParamBase {
  lite::Tensor* x{nullptr};
  lite::Tensor* output{nullptr};
  int upscale_factor{1};
};
1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776

struct RetinanetDetectionOutputParam : ParamBase {
  std::vector<Tensor*> bboxes{};
  std::vector<Tensor*> scores{};
  std::vector<Tensor*> anchors{};
  Tensor* im_info{};
  Tensor* out{};
  float score_threshold{};
  int nms_top_k{};
  float nms_threshold{};
  float nms_eta{};
  int keep_top_k{};
};

Y
yiicy 已提交
1777 1778 1779 1780 1781
struct WhereIndexParam : ParamBase {
  const lite::Tensor* input{nullptr};
  lite::Tensor* output{nullptr};
};

C
cc 已提交
1782 1783 1784 1785 1786 1787 1788 1789 1790
struct ClipParam : ParamBase {
  Tensor* x{};
  Tensor* min_tensor{};
  Tensor* max_tensor{};
  Tensor* out{};
  float min{};
  float max{};
};

1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806
struct PrintParam : ParamBase {
  const lite::Tensor* in{};
  lite::Tensor* out{};
  std::string name;
  int first_n{-1};
  std::string message;
  int summarize{20};
  bool print_tensor_name{true};
  bool print_tensor_type{true};
  bool print_tensor_shape{true};
  bool print_tensor_lod{true};
  bool print_tensor_layout{true};
  std::string print_phase;
  bool is_forward{true};
};

Y
Yan Chunwei 已提交
1807 1808 1809
}  // namespace operators
}  // namespace lite
}  // namespace paddle