-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3032489
commit a2df727
Showing
2 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <glog/logging.h> | ||
#include <gtest/gtest.h> | ||
#include <tensor/tensor.h> | ||
#include "base/buffer.h" | ||
#include "../kuiper/source/op/kernels/add_kernel.h" | ||
|
||
TEST(test_op, add) { | ||
using namespace base; | ||
auto alloc_cu = base::CPUDeviceAllocatorFactory::get_instance(); | ||
|
||
int32_t size = 32 * 151; | ||
|
||
tensor::Tensor t1(base::DataType::kDataTypeFp32, size, true, alloc_cu); | ||
tensor::Tensor t2(base::DataType::kDataTypeFp32, size, true, alloc_cu); | ||
tensor::Tensor out(base::DataType::kDataTypeFp32, size, true, alloc_cu); | ||
for (int i = 0; i < t1.size(); ++i) { | ||
t1.index<float>(i) = 1; | ||
t2.index<float>(i) = 2; | ||
} | ||
|
||
kernel::get_add_kernel(base::DeviceType::kDeviceCPU)(t1, t2, out); | ||
for (int i = 0; i < size; ++i) { | ||
ASSERT_EQ(out.index<float>(i), 3.f); | ||
} | ||
} |