| 1006 | } |
| 1007 | |
| 1008 | bool test_graph_reset() { |
| 1009 | CactusGraph graph; |
| 1010 | |
| 1011 | size_t input_a = graph.input({2}, Precision::FP16); |
| 1012 | size_t result_id = graph.scalar_add(input_a, 5.0f); |
| 1013 | |
| 1014 | std::vector<__fp16> data_a = {1, 2}; |
| 1015 | graph.set_input(input_a, data_a.data(), Precision::FP16); |
| 1016 | graph.execute(); |
| 1017 | |
| 1018 | __fp16* output1 = static_cast<__fp16*>(graph.get_output(result_id)); |
| 1019 | if (std::abs(static_cast<float>(output1[0]) - 6.0f) > 1e-2f || |
| 1020 | std::abs(static_cast<float>(output1[1]) - 7.0f) > 1e-2f) return false; |
| 1021 | |
| 1022 | graph.hard_reset(); |
| 1023 | if (graph.get_node_count() != 0) return false; |
| 1024 | |
| 1025 | size_t new_input = graph.input({2}, Precision::FP16); |
| 1026 | size_t new_result = graph.scalar_add(new_input, 5.0f); |
| 1027 | |
| 1028 | std::vector<__fp16> data_b = {10, 20}; |
| 1029 | graph.set_input(new_input, data_b.data(), Precision::FP16); |
| 1030 | graph.execute(); |
| 1031 | |
| 1032 | __fp16* output2 = static_cast<__fp16*>(graph.get_output(new_result)); |
| 1033 | return (std::abs(static_cast<float>(output2[0]) - 15.0f) < 1e-2f && |
| 1034 | std::abs(static_cast<float>(output2[1]) - 25.0f) < 1e-2f); |
| 1035 | } |
| 1036 | |
| 1037 | bool test_gather_operation() { |
| 1038 | // Gather uses INT8 indices but can work with FP16 data |
no test coverage detected