2022-09-21 14:04:30 +08:00
|
|
|
#include "core/graph.h"
|
|
|
|
#include "core/kernel.h"
|
|
|
|
#include "core/runtime.h"
|
|
|
|
#include "operators/reshape.h"
|
|
|
|
|
|
|
|
#include "test.h"
|
|
|
|
|
|
|
|
namespace infini {
|
|
|
|
|
|
|
|
TEST(Reshape, ShapeInference) {
|
2023-03-27 21:28:49 +08:00
|
|
|
Runtime runtime = NativeCpuRuntimeObj::getInstance();
|
2022-09-21 14:04:30 +08:00
|
|
|
{
|
|
|
|
Graph g = make_ref<GraphObj>(runtime);
|
|
|
|
Tensor i = g->addTensor({2, 3, 3, 4}, DataType::Float32);
|
|
|
|
auto op = g->addOp<ReshapeObj>(i, nullptr, Shape{3, 2, 4, 3});
|
|
|
|
EXPECT_EQ(op->getOutput()->getDims(), (Shape{3, 2, 4, 3}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TEST(Flatten, ShapeInference) {
|
2023-03-27 21:28:49 +08:00
|
|
|
Runtime runtime = NativeCpuRuntimeObj::getInstance();
|
2022-09-21 14:04:30 +08:00
|
|
|
{
|
|
|
|
Graph g = make_ref<GraphObj>(runtime);
|
|
|
|
Tensor i = g->addTensor({2, 3, 3, 4}, DataType::Float32);
|
|
|
|
auto op = g->addOp<FlattenObj>(i, nullptr);
|
|
|
|
EXPECT_EQ(op->getOutput()->getDims(), (Shape{72}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Identity, ShapeInference) {
|
2023-03-27 21:28:49 +08:00
|
|
|
Runtime runtime = NativeCpuRuntimeObj::getInstance();
|
2022-09-21 14:04:30 +08:00
|
|
|
{
|
|
|
|
Graph g = make_ref<GraphObj>(runtime);
|
|
|
|
Tensor i = g->addTensor({2, 3, 3, 4}, DataType::Float32);
|
|
|
|
auto op = g->addOp<IdentityObj>(i, nullptr);
|
|
|
|
EXPECT_EQ(op->getOutput()->getDims(), (Shape{2, 3, 3, 4}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-15 16:29:28 +08:00
|
|
|
} // namespace infini
|