MCPcopy Create free account
hub / github.com/cactus-compute/cactus / test_layernorm

Function test_layernorm

tests/test_graph.cpp:1451–1472  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1449}
1450
1451bool test_layernorm() {
1452 struct Case { size_t batch, feat; bool fp32, with_bias; float epsilon, weight_scale, bias_val; };
1453 const std::vector<Case> cases = {
1454 {1, 1, false, false, 1e-5f, 1.0f, 0.0f},
1455 {1, 7, false, false, 1e-5f, 1.0f, 0.0f},
1456 {1, 8, false, false, 1e-5f, 1.0f, 0.0f},
1457 {4, 8, false, false, 1e-5f, 1.0f, 0.0f},
1458 {4, 8, false, true, 1e-5f, 1.0f, 0.0f},
1459 {4, 8, true, false, 1e-5f, 1.0f, 0.0f},
1460 {4, 8, true, true, 1e-5f, 1.0f, 0.0f},
1461 {1, 8, false, false, 1.0f, 1.0f, 0.0f},
1462 {2, 16, false, true, 1e-5f, 0.5f, 0.3f},
1463 };
1464
1465 for (const auto& c : cases) {
1466 bool ok = c.fp32
1467 ? run_layernorm_case<float>(c.batch, c.feat, c.with_bias, c.epsilon, c.weight_scale, c.bias_val)
1468 : run_layernorm_case<__fp16>(c.batch, c.feat, c.with_bias, c.epsilon, c.weight_scale, c.bias_val);
1469 if (!ok) return false;
1470 }
1471 return true;
1472}
1473
1474int main() {
1475 TestUtils::TestRunner runner("Graph Operations Tests");

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected