tensor_test.cc 18.0 KB
Newer Older
1
//  Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
D
dzhwinter 已提交
2 3 4 5 6 7 8 9 10 11 12 13
//
// 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.
F
fengjiayi 已提交
14

Y
Yi Wang 已提交
15
#include "paddle/fluid/framework/tensor.h"
W
wanghuancoder 已提交
16

F
fengjiayi 已提交
17
#include <gtest/gtest.h>
18
#include <string>
W
wanghuancoder 已提交
19

20 21 22
namespace framework = paddle::framework;
namespace platform = paddle::platform;

F
fengjiayi 已提交
23
TEST(Tensor, Dims) {
24
  framework::Tensor tt;
25
  tt.Resize({2, 3, 4});
26
  framework::DDim dims = tt.dims();
F
fengjiayi 已提交
27 28 29 30 31 32 33
  ASSERT_EQ(arity(dims), 3);
  for (int i = 0; i < 3; ++i) {
    EXPECT_EQ(i + 2, dims[i]);
  }
}

TEST(Tensor, DataAssert) {
34
  framework::Tensor src_tensor;
F
fengjiayi 已提交
35

36 37
  bool caught = false;
  try {
F
fengjiayi 已提交
38
    src_tensor.data<double>();
39
  } catch (platform::EnforceNotMet& err) {
40
    caught = true;
41
    std::string ex_msg = err.what();
42
    EXPECT_TRUE(ex_msg.find("Tensor holds no memory. Call "
43
                            "Tensor::mutable_data firstly.") !=
44
                std::string::npos);
45 46
  }
  ASSERT_TRUE(caught);
F
fengjiayi 已提交
47 48 49
}

TEST(Tensor, MutableData) {
50
  {
51
    framework::Tensor src_tensor;
52 53 54
    float* p1 = nullptr;
    float* p2 = nullptr;
    // initialization
55 56
    p1 = src_tensor.mutable_data<float>(framework::make_ddim({1, 2, 3}),
                                        platform::CPUPlace());
57
    auto p1_holder = src_tensor.Holder();
58
    EXPECT_NE(p1, nullptr);
F
fengjiayi 已提交
59
    // set src_tensor a new dim with large size
60
    // momery is supposed to be re-allocated
61 62
    p2 = src_tensor.mutable_data<float>(framework::make_ddim({3, 4}),
                                        platform::CPUPlace());
63
    EXPECT_NE(p2, nullptr);
64 65
    auto p2_holder1 = src_tensor.Holder();
    EXPECT_NE(p1_holder.get(), p2_holder1.get());
F
fengjiayi 已提交
66
    // set src_tensor a new dim with same size
67
    // momery block is supposed to be unchanged
68 69
    p1 = src_tensor.mutable_data<float>(framework::make_ddim({2, 2, 3}),
                                        platform::CPUPlace());
70 71
    auto p2_holder2 = src_tensor.Holder();
    EXPECT_EQ(p2_holder1.get(), p2_holder2.get());
F
fengjiayi 已提交
72
    // set src_tensor a new dim with smaller size
73
    // momery block is supposed to be unchanged
74 75
    p2 = src_tensor.mutable_data<float>(framework::make_ddim({2, 2}),
                                        platform::CPUPlace());
76
    auto p2_holder3 = src_tensor.Holder();
77
    EXPECT_EQ(p1, p2);
78
    EXPECT_EQ(p2_holder2.get(), p2_holder3.get());
D
dzhwinter 已提交
79 80 81 82 83 84 85 86

    float* p3 = nullptr;
    float* p4 = nullptr;
    // set src_tensor a different type but smaller size.
    // memory block is supposed to be unchanged.
    auto* tmp = src_tensor.mutable_data<uint8_t>(framework::make_ddim({2, 2}),
                                                 platform::CPUPlace());
    p3 = reinterpret_cast<float*>(tmp);
87
    auto p3_holder1 = src_tensor.Holder();
D
dzhwinter 已提交
88
    EXPECT_EQ(p1, p3);
89
    EXPECT_EQ(p2_holder3.get(), p3_holder1.get());
D
dzhwinter 已提交
90 91 92 93 94

    // set src_tensor a different type but bigger size.
    // memory block is supposed to be changed.
    auto* tmp2 = src_tensor.mutable_data<double>(
        framework::make_ddim({2, 2, 3}), platform::CPUPlace());
95
    auto p3_holder2 = src_tensor.Holder();
D
dzhwinter 已提交
96 97
    p4 = reinterpret_cast<float*>(tmp2);
    EXPECT_NE(p1, p4);
98
    EXPECT_NE(p3_holder1.get(), p3_holder2.get());
99
  }
X
Xin Pan 已提交
100 101 102 103 104 105 106 107 108 109 110 111 112
  // Not sure if it's desired, but currently, Tensor type can be changed.
  {
    framework::Tensor src_tensor;
    int8_t* p1 = src_tensor.mutable_data<int8_t>(framework::make_ddim({1}),
                                                 platform::CPUPlace());
    EXPECT_NE(p1, nullptr);
    *p1 = 1;

    uint8_t* p2 = src_tensor.mutable_data<uint8_t>(framework::make_ddim({1}),
                                                   platform::CPUPlace());
    EXPECT_NE(p2, nullptr);
    EXPECT_EQ(static_cast<int>(p2[0]), 1);
  }
L
liaogang 已提交
113

114
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
115
  {
116
    framework::Tensor src_tensor;
117 118 119
    float* p1 = nullptr;
    float* p2 = nullptr;
    // initialization
120
    p1 = src_tensor.mutable_data<float>(framework::make_ddim({1, 2, 3}),
121
                                        platform::CUDAPlace(0));
122
    auto p1_holder = src_tensor.Holder();
123 124 125
    EXPECT_NE(p1, nullptr);
    // set src_tensor a new dim with large size
    // momery is supposed to be re-allocated
126
    p2 = src_tensor.mutable_data<float>(framework::make_ddim({3, 1024}),
127
                                        platform::CUDAPlace(0));
128
    auto p2_holder = src_tensor.Holder();
129
    EXPECT_NE(p2, nullptr);
130
    EXPECT_NE(p1_holder.get(), p2_holder.get());
131 132
    // set src_tensor a new dim with same size
    // momery block is supposed to be unchanged
133
    p1 = src_tensor.mutable_data<float>(framework::make_ddim({2, 2, 3}),
134
                                        platform::CUDAPlace(0));
135 136 137
    EXPECT_EQ(p1, p2);
    // set src_tensor a new dim with smaller size
    // momery block is supposed to be unchanged
138
    p2 = src_tensor.mutable_data<float>(framework::make_ddim({2, 2}),
139 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
                                        platform::CUDAPlace(0));
    EXPECT_EQ(p1, p2);
  }
#endif
#ifdef PADDLE_WITH_ASCEND_CL
  {
    framework::Tensor src_tensor;
    float* p1 = nullptr;
    float* p2 = nullptr;
    // initialization
    p1 = src_tensor.mutable_data<float>(framework::make_ddim({1, 2, 3}),
                                        platform::NPUPlace(0));
    auto p1_holder = src_tensor.Holder();
    EXPECT_NE(p1, nullptr);
    // set src_tensor a new dim with large size
    // momery is supposed to be re-allocated
    p2 = src_tensor.mutable_data<float>(framework::make_ddim({3, 1024}),
                                        platform::NPUPlace(0));
    auto p2_holder = src_tensor.Holder();
    EXPECT_NE(p2, nullptr);
    EXPECT_NE(p1_holder.get(), p2_holder.get());
    // set src_tensor a new dim with same size
    // momery block is supposed to be unchanged
    p1 = src_tensor.mutable_data<float>(framework::make_ddim({2, 2, 3}),
                                        platform::NPUPlace(0));
    EXPECT_EQ(p1, p2);
    // set src_tensor a new dim with smaller size
    // momery block is supposed to be unchanged
    p2 = src_tensor.mutable_data<float>(framework::make_ddim({2, 2}),
                                        platform::NPUPlace(0));
169 170 171
    EXPECT_EQ(p1, p2);
  }
#endif
F
fengjiayi 已提交
172
}
F
fengjiayi 已提交
173

F
fengjiayi 已提交
174
TEST(Tensor, ShareDataWith) {
F
fengjiayi 已提交
175
  {
176 177
    framework::Tensor src_tensor;
    framework::Tensor dst_tensor;
F
fengjiayi 已提交
178 179 180
    // Try to share data form uninitialized tensor
    bool caught = false;
    try {
181
      dst_tensor.ShareDataWith(src_tensor);
182
    } catch (paddle::platform::EnforceNotMet& err) {
F
fengjiayi 已提交
183
      caught = true;
184
      std::string ex_msg = err.what();
185
      EXPECT_TRUE(ex_msg.find("Tensor holds no memory. Call "
186
                              "Tensor::mutable_data firstly.") !=
187
                  std::string::npos);
F
fengjiayi 已提交
188 189 190
    }
    ASSERT_TRUE(caught);

191 192
    src_tensor.mutable_data<int>(framework::make_ddim({2, 3, 4}),
                                 platform::CPUPlace());
193
    dst_tensor.ShareDataWith(src_tensor);
F
fengjiayi 已提交
194 195 196
    ASSERT_EQ(src_tensor.data<int>(), dst_tensor.data<int>());
  }

197
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
198
  {
199 200 201
    framework::Tensor src_tensor;
    framework::Tensor dst_tensor;
    src_tensor.mutable_data<int>(framework::make_ddim({2, 3, 4}),
202 203 204 205 206 207 208 209 210 211 212
                                 platform::CUDAPlace(0));
    dst_tensor.ShareDataWith(src_tensor);
    ASSERT_EQ(src_tensor.data<int>(), dst_tensor.data<int>());
  }
#endif
#ifdef PADDLE_WITH_ASCEND_CL
  {
    framework::Tensor src_tensor;
    framework::Tensor dst_tensor;
    src_tensor.mutable_data<int>(framework::make_ddim({2, 3, 4}),
                                 platform::NPUPlace(0));
213
    dst_tensor.ShareDataWith(src_tensor);
214 215 216
    ASSERT_EQ(src_tensor.data<int>(), dst_tensor.data<int>());
  }
#endif
F
fengjiayi 已提交
217 218 219 220
}

TEST(Tensor, Slice) {
  {
221 222 223 224 225
    framework::Tensor src_tensor;
    src_tensor.mutable_data<int>(framework::make_ddim({5, 3, 4}),
                                 platform::CPUPlace());
    framework::Tensor slice_tensor = src_tensor.Slice(1, 3);
    framework::DDim slice_dims = slice_tensor.dims();
F
fengjiayi 已提交
226 227 228 229 230 231 232 233
    ASSERT_EQ(arity(slice_dims), 3);
    EXPECT_EQ(slice_dims[0], 2);
    EXPECT_EQ(slice_dims[1], 3);
    EXPECT_EQ(slice_dims[2], 4);

    uintptr_t src_data_address =
        reinterpret_cast<uintptr_t>(src_tensor.data<int>());
    uintptr_t src_mutable_data_address = reinterpret_cast<uintptr_t>(
234
        src_tensor.mutable_data<int>(src_tensor.dims(), platform::CPUPlace()));
F
fengjiayi 已提交
235 236
    uintptr_t slice_data_address =
        reinterpret_cast<uintptr_t>(slice_tensor.data<int>());
237 238 239
    uintptr_t slice_mutable_data_address =
        reinterpret_cast<uintptr_t>(slice_tensor.mutable_data<int>(
            slice_tensor.dims(), platform::CPUPlace()));
F
fengjiayi 已提交
240 241 242 243 244
    EXPECT_EQ(src_data_address, src_mutable_data_address);
    EXPECT_EQ(slice_data_address, slice_mutable_data_address);
    EXPECT_EQ(src_data_address + 3 * 4 * 1 * sizeof(int), slice_data_address);
  }

245
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
246
  {
247 248
    framework::Tensor src_tensor;
    src_tensor.mutable_data<double>(framework::make_ddim({6, 9}),
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
                                    platform::CUDAPlace(0));
    framework::Tensor slice_tensor = src_tensor.Slice(2, 6);
    framework::DDim slice_dims = slice_tensor.dims();
    ASSERT_EQ(arity(slice_dims), 2);
    EXPECT_EQ(slice_dims[0], 4);
    EXPECT_EQ(slice_dims[1], 9);

    uintptr_t src_data_address =
        reinterpret_cast<uintptr_t>(src_tensor.data<double>());
    uintptr_t src_mutable_data_address =
        reinterpret_cast<uintptr_t>(src_tensor.mutable_data<double>(
            src_tensor.dims(), platform::CUDAPlace(0)));
    uintptr_t slice_data_address =
        reinterpret_cast<uintptr_t>(slice_tensor.data<double>());
    uintptr_t slice_mutable_data_address =
        reinterpret_cast<uintptr_t>(slice_tensor.mutable_data<double>(
            slice_tensor.dims(), platform::CUDAPlace(0)));
    EXPECT_EQ(src_data_address, src_mutable_data_address);
    EXPECT_EQ(slice_data_address, slice_mutable_data_address);
    EXPECT_EQ(src_data_address + 9 * 2 * sizeof(double), slice_data_address);
  }
#endif

#ifdef PADDLE_WITH_ASCEND_CL
  {
    framework::Tensor src_tensor;
    src_tensor.mutable_data<double>(framework::make_ddim({6, 9}),
                                    platform::NPUPlace(0));
277 278
    framework::Tensor slice_tensor = src_tensor.Slice(2, 6);
    framework::DDim slice_dims = slice_tensor.dims();
279 280 281
    ASSERT_EQ(arity(slice_dims), 2);
    EXPECT_EQ(slice_dims[0], 4);
    EXPECT_EQ(slice_dims[1], 9);
F
fengjiayi 已提交
282

283 284
    uintptr_t src_data_address =
        reinterpret_cast<uintptr_t>(src_tensor.data<double>());
285 286
    uintptr_t src_mutable_data_address =
        reinterpret_cast<uintptr_t>(src_tensor.mutable_data<double>(
287
            src_tensor.dims(), platform::NPUPlace(0)));
288 289
    uintptr_t slice_data_address =
        reinterpret_cast<uintptr_t>(slice_tensor.data<double>());
290 291
    uintptr_t slice_mutable_data_address =
        reinterpret_cast<uintptr_t>(slice_tensor.mutable_data<double>(
292
            slice_tensor.dims(), platform::NPUPlace(0)));
293 294 295 296 297
    EXPECT_EQ(src_data_address, src_mutable_data_address);
    EXPECT_EQ(slice_data_address, slice_mutable_data_address);
    EXPECT_EQ(src_data_address + 9 * 2 * sizeof(double), slice_data_address);
  }
#endif
F
fengjiayi 已提交
298 299
}

F
fengjiayi 已提交
300
TEST(Tensor, ReshapeToMatrix) {
301 302
  framework::Tensor src;
  int* src_ptr = src.mutable_data<int>({2, 3, 4, 9}, platform::CPUPlace());
F
WIP  
fengjiayi 已提交
303 304 305
  for (int i = 0; i < 2 * 3 * 4 * 9; ++i) {
    src_ptr[i] = i;
  }
306
  framework::Tensor res = framework::ReshapeToMatrix(src, 2);
F
WIP  
fengjiayi 已提交
307 308
  ASSERT_EQ(res.dims()[0], 2 * 3);
  ASSERT_EQ(res.dims()[1], 4 * 9);
Z
zchen0211 已提交
309
}
D
dzhwinter 已提交
310 311

TEST(Tensor, Layout) {
312
  framework::Tensor src;
M
mozga-intel 已提交
313
  ASSERT_EQ(src.layout(), framework::DataLayout::kNCHW);
314 315
  src.set_layout(framework::DataLayout::kAnyLayout);
  ASSERT_EQ(src.layout(), framework::DataLayout::kAnyLayout);
D
dzhwinter 已提交
316
}
D
dzhwinter 已提交
317 318 319 320 321 322 323 324 325 326 327 328 329 330

TEST(Tensor, FP16) {
  using platform::float16;
  framework::Tensor src;
  float16* src_ptr = src.mutable_data<float16>({2, 3}, platform::CPUPlace());
  for (int i = 0; i < 2 * 3; ++i) {
    src_ptr[i] = static_cast<float16>(i);
  }
  EXPECT_EQ(src.memory_size(), 2 * 3 * sizeof(float16));
  // EXPECT a human readable error message
  // src.data<uint8_t>();
  // Tensor holds the wrong type, it holds N6paddle8platform7float16E at
  // [/paddle/Paddle/paddle/fluid/framework/tensor_impl.h:43]
}
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 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

TEST(Tensor, Split) {
  {
    framework::Tensor src_tensor;
    src_tensor.mutable_data<int>(framework::make_ddim({6, 2}),
                                 platform::CPUPlace());
    std::vector<framework::Tensor> split_tensor_list = src_tensor.Split(2, 0);
    ASSERT_EQ(split_tensor_list.size(), 3UL);
    EXPECT_EQ(split_tensor_list[0].dims()[0], 2);
    EXPECT_EQ(split_tensor_list[1].dims()[0], 2);
    EXPECT_EQ(split_tensor_list[2].dims()[0], 2);
    EXPECT_EQ(split_tensor_list[0].dims()[1], 2);
    EXPECT_EQ(split_tensor_list[1].dims()[1], 2);
    EXPECT_EQ(split_tensor_list[2].dims()[1], 2);

    uintptr_t src_data_address =
        reinterpret_cast<uintptr_t>(src_tensor.data<int>());
    uintptr_t src_mutable_data_address = reinterpret_cast<uintptr_t>(
        src_tensor.mutable_data<int>(src_tensor.dims(), platform::CPUPlace()));
    EXPECT_EQ(src_data_address, src_mutable_data_address);
    for (int i = 0; i < 3; ++i) {
      uintptr_t split_data_address =
          reinterpret_cast<uintptr_t>(split_tensor_list[i].data<int>());
      uintptr_t split_mutable_data_address =
          reinterpret_cast<uintptr_t>(split_tensor_list[i].mutable_data<int>(
              split_tensor_list[i].dims(), platform::CPUPlace()));
      EXPECT_EQ(split_data_address, split_mutable_data_address);
      EXPECT_EQ(src_data_address + 2 * 2 * i * sizeof(int), split_data_address);
    }
  }
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
  {
    framework::Tensor src_tensor;
    src_tensor.mutable_data<double>(framework::make_ddim({6, 4}),
                                    platform::CUDAPlace(0));
    std::vector<framework::Tensor> split_tensor_list = src_tensor.Split(2, 0);
    ASSERT_EQ(split_tensor_list.size(), 3UL);
    EXPECT_EQ(split_tensor_list[0].dims()[0], 2);
    EXPECT_EQ(split_tensor_list[1].dims()[0], 2);
    EXPECT_EQ(split_tensor_list[2].dims()[0], 2);
    EXPECT_EQ(split_tensor_list[0].dims()[1], 4);
    EXPECT_EQ(split_tensor_list[1].dims()[1], 4);
    EXPECT_EQ(split_tensor_list[2].dims()[1], 4);

    uintptr_t src_data_address =
        reinterpret_cast<uintptr_t>(src_tensor.data<double>());
    uintptr_t src_mutable_data_address =
        reinterpret_cast<uintptr_t>(src_tensor.mutable_data<double>(
            src_tensor.dims(), platform::CUDAPlace(0)));
    EXPECT_EQ(src_data_address, src_mutable_data_address);
    for (int i = 0; i < 3; ++i) {
      uintptr_t split_data_address =
          reinterpret_cast<uintptr_t>(split_tensor_list[i].data<double>());
      uintptr_t split_mutable_data_address =
          reinterpret_cast<uintptr_t>(split_tensor_list[i].mutable_data<double>(
              split_tensor_list[i].dims(), platform::CUDAPlace(0)));
      EXPECT_EQ(split_data_address, split_mutable_data_address);
      EXPECT_EQ(src_data_address + 2 * 4 * i * sizeof(double),
                split_data_address);
    }
  }
#endif
}

TEST(Tensor, Chunk) {
  {
    framework::Tensor src_tensor;
    src_tensor.mutable_data<int>(framework::make_ddim({6, 2}),
                                 platform::CPUPlace());
    std::vector<framework::Tensor> split_tensor_list = src_tensor.Chunk(3, 0);
    ASSERT_EQ(split_tensor_list.size(), 3UL);
    EXPECT_EQ(split_tensor_list[0].dims()[0], 2);
    EXPECT_EQ(split_tensor_list[1].dims()[0], 2);
    EXPECT_EQ(split_tensor_list[2].dims()[0], 2);
    EXPECT_EQ(split_tensor_list[0].dims()[1], 2);
    EXPECT_EQ(split_tensor_list[1].dims()[1], 2);
    EXPECT_EQ(split_tensor_list[2].dims()[1], 2);

    uintptr_t src_data_address =
        reinterpret_cast<uintptr_t>(src_tensor.data<int>());
    uintptr_t src_mutable_data_address = reinterpret_cast<uintptr_t>(
        src_tensor.mutable_data<int>(src_tensor.dims(), platform::CPUPlace()));
    for (int i = 0; i < 3; ++i) {
      uintptr_t split_data_address =
          reinterpret_cast<uintptr_t>(split_tensor_list[i].data<int>());
      uintptr_t split_mutable_data_address =
          reinterpret_cast<uintptr_t>(split_tensor_list[i].mutable_data<int>(
              split_tensor_list[i].dims(), platform::CPUPlace()));
      EXPECT_EQ(src_data_address, src_mutable_data_address);
      EXPECT_EQ(split_data_address, split_mutable_data_address);
      EXPECT_EQ(src_data_address + 2 * 2 * i * sizeof(int), split_data_address);
    }
  }
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
  {
    framework::Tensor src_tensor;
    src_tensor.mutable_data<double>(framework::make_ddim({6, 4}),
                                    platform::CUDAPlace(0));
    std::vector<framework::Tensor> split_tensor_list = src_tensor.Chunk(3, 0);
    ASSERT_EQ(split_tensor_list.size(), 3UL);
    EXPECT_EQ(split_tensor_list[0].dims()[0], 2);
    EXPECT_EQ(split_tensor_list[1].dims()[0], 2);
    EXPECT_EQ(split_tensor_list[2].dims()[0], 2);
    EXPECT_EQ(split_tensor_list[0].dims()[1], 4);
    EXPECT_EQ(split_tensor_list[1].dims()[1], 4);
    EXPECT_EQ(split_tensor_list[2].dims()[1], 4);

    uintptr_t src_data_address =
        reinterpret_cast<uintptr_t>(src_tensor.data<double>());
    uintptr_t src_mutable_data_address =
        reinterpret_cast<uintptr_t>(src_tensor.mutable_data<double>(
            src_tensor.dims(), platform::CUDAPlace(0)));
    EXPECT_EQ(src_data_address, src_mutable_data_address);
    for (int i = 0; i < 3; ++i) {
      uintptr_t split_data_address =
          reinterpret_cast<uintptr_t>(split_tensor_list[i].data<double>());
      uintptr_t split_mutable_data_address =
          reinterpret_cast<uintptr_t>(split_tensor_list[i].mutable_data<double>(
              split_tensor_list[i].dims(), platform::CUDAPlace(0)));
      EXPECT_EQ(split_data_address, split_mutable_data_address);
      EXPECT_EQ(src_data_address + 2 * 4 * i * sizeof(double),
                split_data_address);
    }
  }
#endif
}