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

Function test_basic_operations

tests/test_graph.cpp:122–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120}
121
122bool test_basic_operations() {
123 TestUtils::FP16TestFixture fixture("Basic Operations");
124
125 size_t input_a = fixture.create_input({2, 3});
126 size_t input_b = fixture.create_input({2, 3});
127 size_t add_result = fixture.graph().add(input_a, input_b);
128 size_t mul_result = fixture.graph().multiply(add_result, input_a);
129 size_t scalar_result = fixture.graph().scalar_multiply(mul_result, 2.0f);
130
131 std::vector<__fp16> data_a = {1, 2, 3, 4, 5, 6};
132 std::vector<__fp16> data_b = {2, 3, 4, 5, 6, 7};
133
134 fixture.set_input_data(input_a, data_a);
135 fixture.set_input_data(input_b, data_b);
136 fixture.execute();
137
138 std::vector<__fp16> expected(6);
139 for (int i = 0; i < 6; i++) {
140 float result = ((static_cast<float>(data_a[i]) + static_cast<float>(data_b[i])) * static_cast<float>(data_a[i])) * 2.0f;
141 expected[i] = static_cast<__fp16>(result);
142 }
143
144 return fixture.verify_output(scalar_result, expected);
145}
146
147bool test_basic_addition() {
148 return TestUtils::test_basic_operation(

Callers 1

mainFunction · 0.85

Calls 7

create_inputMethod · 0.80
scalar_multiplyMethod · 0.80
set_input_dataMethod · 0.80
verify_outputMethod · 0.80
addMethod · 0.45
multiplyMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected