Tensor_test.cpp 404 字节
Newer Older
D
dzhwinter 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#include "Tensor.h"
#include <iostream>
#include "gtest/gtest.h"

using namespace paddle;
using namespace paddle::optimizer;

TEST(Tensor, indexer) {
  real* ptr = new real[3];
  Tensor t(ptr, 3);
  for (auto i = 0; i < t.size(); ++i) {
    t[i] = i;
  }
  ASSERT_EQ(t[2], 2);
  ASSERT_EQ(t[1], 1);
}

int main(int argc, char** argv) {
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}