test_RecurrentLayer.cpp 18.6 KB
Newer Older
1
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
Z
zhangjinchao01 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15

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

#include <gtest/gtest.h>
X
Xin Pan 已提交
16
#include <paddle/legacy/utils/Version.h>
Y
Yu Yang 已提交
17 18
#include <vector>
#include "ModelConfig.pb.h"
X
Xin Pan 已提交
19 20
#include "paddle/legacy/gserver/layers/DataLayer.h"
#include "paddle/legacy/gserver/layers/Layer.h"
Z
zhangjinchao01 已提交
21

22
#include "paddle/testing/TestUtil.h"
Z
zhangjinchao01 已提交
23 24 25

using namespace paddle;  // NOLINT
using namespace std;     // NOLINT
26 27 28
DECLARE_bool(use_gpu);
DECLARE_bool(rnn_use_batch);
DECLARE_int32(fixed_seq_length);
Z
zhangjinchao01 已提交
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

void checkError(const Matrix& matrix1, const Matrix& matrix2) {
  CHECK(matrix1.getHeight() == matrix2.getHeight());
  CHECK(matrix1.getWidth() == matrix2.getWidth());
#ifndef PADDLE_TYPE_DOUBLE
  real err = 1e-3;
#else
  real err = 1e-10;
#endif

  int height = matrix1.getHeight();
  int width = matrix1.getWidth();
  const real* data1 = matrix1.getData();
  const real* data2 = matrix2.getData();
  int count = 0;
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      if (fabs(data1[i * width + j] - data2[i * width + j]) > err) {
        count++;
      }
    }
  }
  EXPECT_EQ(count, 0) << "There are " << count << " different element.";
}

void checkError(const CpuVector& vector1, const CpuVector& vector2) {
  CHECK(vector1.getSize() == vector2.getSize());
#ifndef PADDLE_TYPE_DOUBLE
  real err = 1e-3;
#else
  real err = 1e-10;
#endif

  int size = vector1.getSize();
  const real* data1 = vector1.getData();
  const real* data2 = vector2.getData();
  int count = 0;
  for (int i = 0; i < size; i++) {
    if (fabs(data1[i] - data2[i]) > err) {
      count++;
    }
  }
  EXPECT_EQ(count, 0) << "There are " << count << " different element.";
}

74 75 76
LayerPtr creatDataLayer(string name,
                        size_t batchSize,
                        int layerSize,
Z
zhangjinchao01 已提交
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
                        bool useGpu) {
  LayerConfig dataConfig;
  dataConfig.set_name(name);
  dataConfig.set_type("data");
  dataConfig.set_size(layerSize);
  LayerPtr layer = LayerPtr(new DataLayer(dataConfig));

  Argument data;
  data.value = Matrix::create(batchSize, layer->getSize(), false, useGpu);
  data.grad = Matrix::create(batchSize, layer->getSize(), false, useGpu);
  data.value->randomizeUniform();
  data.value->add(-0.5);
  data.value->sigmoid(*data.value);
  data.grad->zeroMem();

  generateSequenceStartPositions(batchSize, data.sequenceStartPositions);

  DataLayerPtr dataLayer = std::dynamic_pointer_cast<DataLayer>(layer);
  dataLayer->setData(data);
  dataLayer->forward(PASS_GC);

  return layer;
}

101 102 103
ParameterPtr creatParameter(string name,
                            int pid,
                            size_t paraSize,
Z
zhangjinchao01 已提交
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
                            bool useGpu) {
  ParameterConfig paraConfig;
  paraConfig.set_name(name);
  paraConfig.set_size(paraSize);

  ParameterPtr parameter =
      std::make_shared<Parameter>(paraConfig, useGpu, /*initialize */ false);
  parameter->enableType(PARAMETER_VALUE);
  parameter->enableType(PARAMETER_GRADIENT);
  parameter->randomize();
  parameter->setID(pid);

  return parameter;
}

119 120 121
ParameterPtr creatParameterBias(string name,
                                int pid,
                                size_t paraSize,
Z
zhangjinchao01 已提交
122 123 124 125 126 127 128 129 130 131 132 133 134 135
                                bool useGpu) {
  ParameterConfig paraConfig;
  paraConfig.set_name(name);
  paraConfig.set_size(paraSize);
  paraConfig.set_initial_std(1);

  ParameterPtr parameter =
      std::make_shared<Parameter>(paraConfig, useGpu, /*initialize */ true);
  parameter->randomize();
  parameter->setID(pid);

  return parameter;
}

136 137 138 139
LayerPtr initRecurrentLayer(LayerConfig layerConfig,
                            size_t batchSize,
                            int layerSize,
                            bool useGpu) {
Z
zhangjinchao01 已提交
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
  FLAGS_use_gpu = useGpu;
  LayerMap layerMap;
  ParameterMap parameterMap;
  LayerPtr dataLayer = creatDataLayer("layer_0", batchSize, layerSize, useGpu);
  layerMap[dataLayer->getName()] = dataLayer;

  ParameterPtr para =
      creatParameter("para_0", 0, layerSize * layerSize, useGpu);
  parameterMap[para->getName()] = para;

  layerConfig.add_inputs();
  LayerInputConfig& input = *(layerConfig.mutable_inputs(0));
  input.set_input_layer_name("layer_0");
  input.set_input_parameter_name("para_0");
  LayerPtr testLayer = Layer::create(layerConfig);
  layerMap[testLayer->getName()] = testLayer;

  testLayer->init(layerMap, parameterMap);
  testLayer->setNeedGradient(true);

  return testLayer;
}

void checkRecurrentLayer(LayerPtr testLayer) {
  const VectorPtr& weightGrad =
      (testLayer->getParameters()[0])->getBuf(PARAMETER_GRADIENT);
  const MatrixPtr& inputGrad = testLayer->getPrev(0)->getOutputGrad();
  CpuVector seqPara(weightGrad->getSize());
  CpuVector batPara(weightGrad->getSize());
  CpuMatrix seqInputGrad(inputGrad->getHeight(), inputGrad->getWidth());
  CpuMatrix batInputGrad(inputGrad->getHeight(), inputGrad->getWidth());

  CpuMatrix outputGrad(inputGrad->getHeight(), inputGrad->getWidth());
  outputGrad.randomizeUniform();

  /* use sequence calculate */
  FLAGS_rnn_use_batch = false;
  weightGrad->zero();
  inputGrad->zero();
  testLayer->forward(PASS_GC);
  testLayer->getOutputGrad()->copyFrom(outputGrad);
  testLayer->backward();
  seqPara.copyFrom(*weightGrad);
  seqInputGrad.copyFrom(*inputGrad);

  /* use batch calculate */
  FLAGS_rnn_use_batch = true;
  weightGrad->zero();
  inputGrad->zero();
  testLayer->forward(PASS_GC);
  testLayer->getOutputGrad()->copyFrom(outputGrad);
  testLayer->backward();
  batPara.copyFrom(*weightGrad);
  batInputGrad.copyFrom(*inputGrad);

  /* check */
  checkError(seqInputGrad, batInputGrad);
  checkError(seqPara, batPara);
}

TEST(Layer, RecurrentLayer) {
  LayerConfig layerConfig;
  layerConfig.set_name("rnn");
  layerConfig.set_type("recurrent");
  layerConfig.set_active_type("tanh");
  for (auto layerSize : {1, 10, 64, 128, 256, 512}) {
    for (auto batchSize : {1, 5, 20, 100, 128}) {
      for (auto useGpu : {false, true}) {
        for (auto reversed : {false, true}) {
          LOG(INFO) << " layerSize=" << layerSize << " batchSize=" << batchSize
                    << " useGpu=" << useGpu << " reversed=" << reversed;
          layerConfig.set_size(layerSize);
          layerConfig.set_reversed(reversed);
          LayerPtr testLayer =
              initRecurrentLayer(layerConfig, batchSize, layerSize, useGpu);
          checkRecurrentLayer(testLayer);
        }
      }
    }
  }
}

#define protected public
X
Xin Pan 已提交
223 224 225
#include "paddle/legacy/gserver/layers/GatedRecurrentLayer.h"
#include "paddle/legacy/gserver/layers/LstmLayer.h"
#include "paddle/legacy/gserver/layers/RecurrentLayer.h"
226
template <class T>
Z
zhangjinchao01 已提交
227
class TestRecurrentLayer {
W
Wu Yi 已提交
228
 public:
Z
zhangjinchao01 已提交
229 230 231 232 233 234 235 236 237 238
  LayerConfig config_;
  bool useGpu_;
  bool useBatch_;
  LayerPtr testLayer_;
  LayerPtr dataLayer_;
  ParameterPtr para_;
  ParameterPtr bias_;
  LayerMap layerMap_;
  ParameterMap parameterMap_;
  TestRecurrentLayer(const LayerConfig& config,
239 240 241
                     bool useGpu,
                     bool useBatch = false)
      : config_(config), useGpu_(useGpu), useBatch_(useBatch) {}
Z
zhangjinchao01 已提交
242 243 244 245 246
  void init(size_t batchSize) {
    FLAGS_use_gpu = useGpu_;
    testLayer_ = Layer::create(config_);
    if (typeid(T) == typeid(GatedRecurrentLayer)) {
      dataLayer_ = creatDataLayer(config_.mutable_inputs(0)->input_layer_name(),
247 248 249
                                  batchSize,
                                  config_.size() * 3,
                                  useGpu_);
Z
zhangjinchao01 已提交
250
      para_ = creatParameter(config_.mutable_inputs(0)->input_parameter_name(),
251 252 253 254 255
                             0,
                             config_.size() * config_.size() * 3,
                             useGpu_);
      bias_ = creatParameterBias(
          config_.bias_parameter_name(), 1, config_.size() * 3, useGpu_);
Z
zhangjinchao01 已提交
256 257
    } else if (typeid(T) == typeid(LstmLayer)) {
      dataLayer_ = creatDataLayer(config_.mutable_inputs(0)->input_layer_name(),
258 259 260
                                  batchSize,
                                  config_.size() * 4,
                                  useGpu_);
Z
zhangjinchao01 已提交
261
      para_ = creatParameter(config_.mutable_inputs(0)->input_parameter_name(),
262 263 264 265 266
                             0,
                             config_.size() * config_.size() * 4,
                             useGpu_);
      bias_ = creatParameterBias(
          config_.bias_parameter_name(), 1, config_.size() * 7, useGpu_);
Z
zhangjinchao01 已提交
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
    }
    layerMap_[dataLayer_->getName()] = dataLayer_;
    parameterMap_[para_->getName()] = para_;
    parameterMap_[bias_->getName()] = bias_;

    layerMap_[testLayer_->getName()] = testLayer_;
    testLayer_->init(layerMap_, parameterMap_);
    testLayer_->setNeedGradient(true);
    (dynamic_cast<T*>(testLayer_.get()))->useBatch_ = useBatch_;
  }
  void forward() {
    FLAGS_use_gpu = useGpu_;
    testLayer_->forward(PASS_GC);
  }
  void backward() {
    FLAGS_use_gpu = useGpu_;
    testLayer_->backward(nullptr);
  }
};

287 288 289 290 291
template <class T>
void checkRecurrentLayer(LayerConfig layerConfig,
                         size_t batchSize,
                         bool cpuBatch,
                         bool gpuBatch) {
Z
zhangjinchao01 已提交
292 293 294 295
  TestRecurrentLayer<T> testCpu(layerConfig, false, cpuBatch);
  TestRecurrentLayer<T> testGpu(layerConfig, true, gpuBatch);
  testCpu.init(batchSize);
  testGpu.init(batchSize);
296 297
  auto checkError = [](
      MatrixPtr cpu, MatrixPtr gpu, int numSequences, const char* str) {
Z
zhangjinchao01 已提交
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
    CpuMatrix check(gpu->getHeight(), gpu->getWidth());
    check.copyFrom(*gpu);
    int height = cpu->getHeight();
    int width = cpu->getWidth();
    const real* data1 = cpu->getData();
    const real* data2 = check.getData();
    int count = 0;
    for (int i = 0; i < height; i++) {
      for (int j = 0; j < width; j++) {
        if (fabs(data1[i * width + j] - data2[i * width + j]) / numSequences >
            1e-4) {
          count++;
        }
      }
    }
313 314
    EXPECT_EQ(count, 0) << "[" << str << "]"
                        << "There are " << count << " different element.";
Z
zhangjinchao01 已提交
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
  };
  T* cpuLayer = dynamic_cast<T*>(testCpu.testLayer_.get());
  T* gpuLayer = dynamic_cast<T*>(testGpu.testLayer_.get());

  Argument& cpuInput = testCpu.dataLayer_->getOutput();
  Argument& gpuInput = testGpu.dataLayer_->getOutput();
  gpuInput.resizeAndCopyFrom(cpuInput, true);

  const VectorPtr& cpuVec = testCpu.para_->getBuf(PARAMETER_VALUE);
  const VectorPtr& gpuVec = testGpu.para_->getBuf(PARAMETER_VALUE);
  gpuVec->copyFrom(*cpuVec);

  const VectorPtr& cpuBiasVec = testCpu.bias_->getBuf(PARAMETER_VALUE);
  const VectorPtr& gpuBiasVec = testGpu.bias_->getBuf(PARAMETER_VALUE);
  gpuBiasVec->copyFrom(*cpuBiasVec);

  /* check forward */
  testCpu.forward();
  testGpu.forward();

335 336
  checkError(
      cpuLayer->getOutputValue(), gpuLayer->getOutputValue(), 1, "outputValue");
Z
zhangjinchao01 已提交
337 338 339 340 341 342 343 344 345 346 347 348 349

  /* check backward */
  cpuLayer->getOutputGrad()->randomizeUniform();
  gpuLayer->getOutputGrad()->copyFrom(*cpuLayer->getOutputGrad());
  hl_stream_synchronize(HPPL_STREAM_DEFAULT);

  testCpu.backward();
  testGpu.backward();

  // check input grad
  checkError(cpuInput.grad, gpuInput.grad, 1, "inputGrad");
  // check weight grad
  int numSequences = cpuInput.getNumSequences();
350 351 352 353
  checkError(cpuLayer->weight_->getWGrad(),
             gpuLayer->weight_->getWGrad(),
             numSequences,
             "weightGrad");
Z
zhangjinchao01 已提交
354
  // check bias grad
355 356 357 358
  checkError(cpuLayer->bias_->getWGrad(),
             gpuLayer->bias_->getWGrad(),
             numSequences,
             "biasGrad");
Z
zhangjinchao01 已提交
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
}

TEST(Layer, GatedRecurrentLayer) {
  LayerConfig layerConfig;
  layerConfig.set_type("gated_recurrent");
  layerConfig.set_active_type("sigmoid");
  layerConfig.set_active_gate_type("sigmoid");

  layerConfig.add_inputs();
  LayerInputConfig& input = *(layerConfig.mutable_inputs(0));
  input.set_input_layer_name("layer_0");
  input.set_input_parameter_name("para_0");
  layerConfig.set_bias_parameter_name("bias");

  for (auto frameSize : {32, 64, 128, 256, 512}) {
    for (auto batchSize : {1, 5, 100, 500}) {
      for (auto reversed : {false, true}) {
        for (auto cpuBatch : {false, true}) {
          for (auto gpuBatch : {false, true}) {
            LOG(INFO) << " batchSize=" << batchSize
                      << " frameSize=" << frameSize << " reversed=" << reversed
                      << " cpuBatch=" << cpuBatch << " gpuBatch=" << gpuBatch;
            layerConfig.set_size(frameSize);
            layerConfig.set_reversed(reversed);
            checkRecurrentLayer<GatedRecurrentLayer>(
384
                layerConfig, batchSize, cpuBatch, gpuBatch);
Z
zhangjinchao01 已提交
385 386 387 388 389 390 391 392 393 394 395
          }
        }
      }
    }
  }
}

TEST(Layer, LstmLayer) {
  LayerConfig layerConfig;
  layerConfig.set_type("lstmemory");
  layerConfig.set_active_type("relu");
396
  layerConfig.set_active_state_type("tanh");
Z
zhangjinchao01 已提交
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
  layerConfig.set_active_gate_type("sigmoid");

  layerConfig.add_inputs();
  LayerInputConfig& input = *(layerConfig.mutable_inputs(0));
  input.set_input_layer_name("layer_0");
  input.set_input_parameter_name("para_0");
  layerConfig.set_bias_parameter_name("bias");

  for (auto frameSize : {32, 64, 128, 256, 512}) {
    for (auto batchSize : {1, 5, 100, 500}) {
      for (auto reversed : {false, true}) {
        for (auto cpuBatch : {false, true}) {
          for (auto gpuBatch : {false, true}) {
            LOG(INFO) << " batchSize=" << batchSize
                      << " frameSize=" << frameSize << " reversed=" << reversed
                      << " cpuBatch=" << cpuBatch << " gpuBatch=" << gpuBatch;
            layerConfig.set_size(frameSize);
            layerConfig.set_reversed(reversed);
415 416
            checkRecurrentLayer<LstmLayer>(
                layerConfig, batchSize, cpuBatch, gpuBatch);
Z
zhangjinchao01 已提交
417 418 419 420 421 422 423
          }
        }
      }
    }
  }
}

424 425
#ifdef PADDLE_WITH_MKLML

X
Xin Pan 已提交
426
#include "paddle/legacy/gserver/layers/MKLPackedRecurrentLayer.h"
T
tensor-tang 已提交
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
LayerPtr initMKLPackedLayer(LayerConfig layerConfig,
                            bool reversed,
                            int layerSize,
                            LayerPtr dataLayer,
                            ParameterPtr para,
                            ParameterPtr bias = nullptr) {
  LayerMap layerMap;
  ParameterMap parameterMap;
  layerMap[dataLayer->getName()] = dataLayer;
  parameterMap[para->getName()] = para;
  if (bias) {
    parameterMap[bias->getName()] = bias;
    layerConfig.set_bias_parameter_name("bias_0");
  }

  layerConfig.set_size(layerSize);
  layerConfig.set_reversed(reversed);
  layerConfig.add_inputs();
  LayerInputConfig& input = *(layerConfig.mutable_inputs(0));
  input.set_input_layer_name("layer_0");
  input.set_input_parameter_name("para_0");

  LayerPtr testLayer = Layer::create(layerConfig);
  layerMap[testLayer->getName()] = testLayer;

  testLayer->init(layerMap, parameterMap);
  testLayer->setNeedGradient(true);

  return testLayer;
}

T
tensor-tang 已提交
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
void checkMKLPackedLayer(LayerConfig layerConfig1,
                         LayerConfig layerConfig2,
                         bool reversed,
                         int layerSize,
                         int batchSize,
                         bool useBatch1,
                         bool useBatch2) {
  LayerPtr dataLayer;
  ParameterPtr para, bias;

  if (layerConfig1.type() == "recurrent") {
    dataLayer = creatDataLayer("layer_0", batchSize, layerSize, false);
    para = creatParameter("para_0", 0, layerSize * layerSize, false);
    bias = nullptr;
  } else if (layerConfig1.type() == "gated_recurrent") {
    dataLayer = creatDataLayer("layer_0", batchSize, layerSize * 3, false);
    para = creatParameter("para_0", 0, layerSize * layerSize * 3, false);
    bias = creatParameterBias("bias_0", 1, layerSize * 3, false);
  }

  LayerPtr testLayer1 = initMKLPackedLayer(
      layerConfig1, reversed, layerSize, dataLayer, para, bias);
  LayerPtr testLayer2 = initMKLPackedLayer(
      layerConfig2, reversed, layerSize, dataLayer, para, bias);

484 485 486 487 488 489 490 491 492
  const VectorPtr& weightGrad =
      (testLayer1->getParameters()[0])->getBuf(PARAMETER_GRADIENT);
  const MatrixPtr& inputGrad = testLayer1->getPrev(0)->getOutputGrad();
  CpuVector wgt_grad1(weightGrad->getSize());
  CpuVector wgt_grad2(weightGrad->getSize());
  CpuMatrix input_grad1(inputGrad->getHeight(), inputGrad->getWidth());
  CpuMatrix input_grad2(inputGrad->getHeight(), inputGrad->getWidth());

  for (int i = 0; i < 2; i++) {
T
tensor-tang 已提交
493
    FLAGS_rnn_use_batch = useBatch1;
494 495 496

    testLayer1->forward(PASS_GC);

T
tensor-tang 已提交
497
    FLAGS_rnn_use_batch = useBatch2;
498 499
    testLayer2->forward(PASS_GC);

T
tensor-tang 已提交
500 501
    testLayer1->getOutputGrad()->randomizeUniform();
    testLayer2->getOutputGrad()->copyFrom(*testLayer1->getOutputGrad());
502 503 504

    weightGrad->zero();
    inputGrad->zero();
T
tensor-tang 已提交
505 506
    FLAGS_rnn_use_batch = useBatch1;
    testLayer1->backward(nullptr);
507 508 509 510 511 512

    wgt_grad1.copyFrom(*weightGrad);
    input_grad1.copyFrom(*inputGrad);

    weightGrad->zero();
    inputGrad->zero();
T
tensor-tang 已提交
513
    FLAGS_rnn_use_batch = useBatch2;
514 515 516 517 518
    testLayer2->backward(nullptr);

    wgt_grad2.copyFrom(*weightGrad);
    input_grad2.copyFrom(*inputGrad);

T
tensor-tang 已提交
519
    checkError(*testLayer1->getOutputValue(), *testLayer2->getOutputValue());
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536
    checkError(wgt_grad1, wgt_grad2);
    checkError(input_grad1, input_grad2);
  }
}

TEST(MKLPackedLayer, RecurrentLayer) {
  LayerConfig layerConfig1;
  LayerConfig layerConfig2;

  layerConfig1.set_name("paddle-rnn");
  layerConfig1.set_type("recurrent");
  layerConfig1.set_active_type("relu");

  layerConfig2.set_name("mkl-packed-rnn");
  layerConfig2.set_type("mkl_packed_recurrent");
  layerConfig2.set_active_type("relu");

537 538
  FLAGS_use_gpu = false;

539 540 541
  for (auto layerSize : {32, 64, 128, 256, 512}) {
    for (auto batchSize : {1, 5, 100, 500}) {
      for (auto reversed : {true, false}) {
T
tensor-tang 已提交
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557
        for (auto paddle_use_batch : {true, false}) {
          for (auto MKLPacked_use_batch : {true, false}) {
            LOG(INFO) << " layerSize=" << layerSize
                      << " batchSize=" << batchSize << " reversed=" << reversed
                      << " paddle_use_batch=" << paddle_use_batch
                      << " MKLPacked_use_batch=" << MKLPacked_use_batch;

            checkMKLPackedLayer(layerConfig1,
                                layerConfig2,
                                reversed,
                                layerSize,
                                batchSize,
                                paddle_use_batch,
                                MKLPacked_use_batch);
          }
        }
558 559 560 561 562 563
      }
    }
  }
}
#endif

Z
zhangjinchao01 已提交
564
int main(int argc, char** argv) {
565 566 567 568
  testing::InitGoogleTest(&argc, argv);
  initMain(argc, argv);
  if (!version::isWithGpu()) {
    testing::GTEST_FLAG(filter) = "-Layer.*";
Z
zhangjinchao01 已提交
569
  }
570
  return RUN_ALL_TESTS();
Z
zhangjinchao01 已提交
571
}