forked from PFCCLab/PaddleCppAPITest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTensorTest_compare.cpp
More file actions
39 lines (31 loc) · 844 Bytes
/
TensorTest_compare.cpp
File metadata and controls
39 lines (31 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <ATen/ATen.h>
#include <ATen/core/Tensor.h>
#include <ATen/ops/ones.h>
#include <gtest/gtest.h>
#include <torch/all.h>
#include <string>
#include <vector>
#include "../src/file_manager.h"
extern paddle_api_test::ThreadSafeParam g_custom_param;
namespace at {
namespace test {
using paddle_api_test::FileManerger;
using paddle_api_test::ThreadSafeParam;
class TensorTest : public ::testing::Test {
protected:
void SetUp() override {
std::vector<int64_t> shape = {2, 3, 4};
tensor = at::ones(shape, at::kFloat);
}
at::Tensor tensor;
};
TEST_F(TensorTest, test) {
auto file_name = g_custom_param.get();
FileManerger file(file_name);
file.createFile();
file << std::to_string(tensor.dim()) << " ";
file << std::to_string(tensor.numel()) << " ";
file.saveFile();
}
} // namespace test
} // namespace at