2022-10-15 16:29:28 +08:00
|
|
|
#include "core/graph.h"
|
|
|
|
#include "core/runtime.h"
|
|
|
|
#include "operators/batch_norm.h"
|
|
|
|
#include "test.h"
|
|
|
|
|
|
|
|
namespace infini {
|
2023-08-07 11:17:05 +08:00
|
|
|
TEST(BatchNormalization, ShapeInference) {
|
2023-03-27 21:28:49 +08:00
|
|
|
Runtime cpuRuntime = NativeCpuRuntimeObj::getInstance();
|
2022-10-15 16:29:28 +08:00
|
|
|
{
|
|
|
|
Graph g = make_ref<GraphObj>(cpuRuntime);
|
|
|
|
Tensor i = g->addTensor({1, 3, 2, 2}, DataType::UInt32);
|
2023-02-23 11:48:28 +08:00
|
|
|
Tensor mean = g->addTensor({3}, DataType::Float32);
|
|
|
|
Tensor var = g->addTensor({3}, DataType::Float32);
|
|
|
|
Tensor scaler = g->addTensor({3}, DataType::Float32);
|
|
|
|
Tensor bias = g->addTensor({3}, DataType::Float32);
|
2022-10-15 16:29:28 +08:00
|
|
|
auto op = g->addOp<BatchNormObj>(i, nullptr, mean, var, scaler, bias,
|
|
|
|
0.9, 1e-5);
|
|
|
|
EXPECT_EQ(op->getOutput()->getDims(), (Shape{1, 3, 2, 2}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // namespace infini
|