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

Function test_precision_conversion

tests/test_graph.cpp:590–607  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

588}
589
590bool test_precision_conversion() {
591 TestUtils::FP16TestFixture fixture("Precision Conversion");
592
593 size_t fp16_id = fixture.create_input({2, 2}, Precision::FP16);
594 std::vector<__fp16> data = {1, 2, 3, 4};
595 fixture.set_input_data(fp16_id, data);
596
597 size_t fp32_converted_id = fixture.graph().precision_cast(fp16_id, Precision::FP32);
598 fixture.execute();
599
600 auto* fp32_data = static_cast<float*>(fixture.graph().get_output(fp32_converted_id));
601
602 for (size_t i = 0; i < 4; ++i) {
603 assert(std::abs(fp32_data[i] - static_cast<float>(data[i])) < 1e-3f);
604 }
605
606 return true;
607}
608
609bool test_node_save_load() {
610 try {

Callers 1

mainFunction · 0.85

Calls 5

create_inputMethod · 0.80
set_input_dataMethod · 0.80
precision_castMethod · 0.80
executeMethod · 0.45
get_outputMethod · 0.45

Tested by

no test coverage detected