提交 c5d9ca86 编写于 作者: Q qijun

fix eigen include path

上级 ab91232c
......@@ -2,13 +2,13 @@ INCLUDE(ExternalProject)
SET(EIGEN_SOURCE_DIR ${THIRD_PARTY_PATH}/eigen3)
INCLUDE_DIRECTORIES(${EIGEN_SOURCE_DIR}/src/)
INCLUDE_DIRECTORIES(${EIGEN_SOURCE_DIR}/src/eigen3)
ExternalProject_Add(
eigen3
${EXTERNAL_PROJECT_LOG_ARGS}
URL "https://bitbucket.org/eigen/eigen/get/f3a22f35b044.tar.gz"
URL_MD5 "4645c66075982da6fa0bcf6b20f3e8f7"
URL "https://bitbucket.org/eigen/eigen/get/3.3.4.tar.gz"
URL_MD5 "1a47e78efe365a97de0c022d127607c3"
PREFIX ${EIGEN_SOURCE_DIR}
UPDATE_COMMAND ""
CONFIGURE_COMMAND ""
......
#include <sstream>
#include <vector>
#include "eigen3/Eigen/Core"
#include "eigen3/Eigen/Dense"
#include "eigen3/unsupported/Eigen/CXX11/Tensor"
#include "gtest/gtest.h"
#include "paddle/framework/ddim.h"
......@@ -64,44 +61,3 @@ TEST(DDim, Print) {
ss << ddim;
EXPECT_EQ("2, 3, 4", ss.str());
}
template <typename T>
using Vec =
Eigen::TensorMap<Eigen::Tensor<T, 1, Eigen::RowMajor, Eigen::DenseIndex>,
Eigen::Aligned>;
template <typename T>
using Matrix =
Eigen::TensorMap<Eigen::Tensor<T, 2, Eigen::RowMajor, Eigen::DenseIndex>,
Eigen::Aligned>;
template <typename T>
void print(T* input, int size) {
for (int i = 0; i < size; i++) {
std::cout << input[i] << " ";
}
std::cout << std::endl;
}
TEST(Eigen, start) {
int size = 4;
float* t_a = (float*)malloc(size * sizeof(float));
float* t_b = (float*)malloc(size * sizeof(float));
float* t_c = (float*)malloc(size * sizeof(float));
for (int i = 0; i < size; i++) {
t_a[i] = i;
t_b[i] = i;
}
Vec<float> a(t_a, size);
Vec<float> b(t_b, size);
Vec<float> c(t_c, size);
Eigen::DefaultDevice dd;
c.device(dd) = a + b;
print<float>(t_c, size);
free(t_a);
free(t_b);
free(t_c);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册