Download tests/linear_forward_test.cpp from cwenzi/neuroflow-cpp: direct link, hf CLI and curl.
- Browser
- Download file 969 Bytes
-
https://huggingface.co/cwenzi/neuroflow-cpp/resolve/main/tests/linear_forward_test.cpp
- Command line
-
hf download hf://cwenzi/neuroflow-cpp/tests/linear_forward_test.cpp
-
curl -L -o linear_forward_test.cpp https://huggingface.co/cwenzi/neuroflow-cpp/resolve/main/tests/linear_forward_test.cpp
969 Bytes
| using namespace neuroflow; | |
| int main() { | |
| std::cout << "Linear forward test..." << std::endl; | |
| Linear linear(64, 64, false); // use_bias = false | |
| std::cout << "weight shape: [" << linear.weight.shape_[0] << ", " << linear.weight.shape_[1] << "]" << std::endl; | |
| std::cout << "quantized: " << linear.quantized << std::endl; | |
| Tensor input({1, 64}); | |
| std::cout << "input shape: [" << input.shape_[0] << ", " << input.shape_[1] << "]" << std::endl; | |
| float* d = input.as_fp32(); | |
| for (size_t i = 0; i < input.numel(); ++i) d[i] = 0.1f * i; | |
| std::cout << "Calling linear.forward(input)..." << std::endl; | |
| Tensor output = linear.forward(input); | |
| std::cout << "output shape: [" << output.shape_[0] << ", " << output.shape_[1] << "]" << std::endl; | |
| std::cout << "Success!" << std::endl; | |
| return 0; | |
| } | |