2022-09-29 10:29:24 +08:00
|
|
|
#include "core/graph.h"
|
|
|
|
#include "core/runtime.h"
|
|
|
|
#include "operators/pad.h"
|
|
|
|
#include "test.h"
|
|
|
|
|
|
|
|
namespace infini {
|
|
|
|
TEST(Pad, ShapeInference) {
|
2023-03-27 21:28:49 +08:00
|
|
|
Runtime cpuRuntime = NativeCpuRuntimeObj::getInstance();
|
2022-09-29 10:29:24 +08:00
|
|
|
{
|
|
|
|
Graph g = make_ref<GraphObj>(cpuRuntime);
|
|
|
|
Tensor i = g->addTensor({1, 64, 162, 162}, DataType::UInt32);
|
|
|
|
auto op = g->addOp<PadObj>(
|
|
|
|
i, nullptr, vector<int>{2, 10, 1, 5, 0, 10, 1, 5}, std::nullopt);
|
|
|
|
EXPECT_EQ(op->getOutput()->getDims(), (Shape{3, 84, 164, 172}));
|
|
|
|
}
|
|
|
|
{
|
|
|
|
Graph g = make_ref<GraphObj>(cpuRuntime);
|
|
|
|
Tensor i = g->addTensor({1, 64, 162, 162}, DataType::UInt32);
|
|
|
|
auto op = g->addOp<PadObj>(i, nullptr, vector<int>{2, 10, 1, 5},
|
|
|
|
vector<int>{0, 3});
|
|
|
|
EXPECT_EQ(op->getOutput()->getDims(), (Shape{4, 64, 162, 177}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-15 16:29:28 +08:00
|
|
|
} // namespace infini
|