cwenzi/neuroflow-cpp
1
1#include <iostream>2#include "../include/neuroflow/tensor.hpp"3#include "../include/neuroflow/networks.hpp"4 5using namespace neuroflow;6 7int main() {8 std::cout << "Linear forward test..." << std::endl;9 10 Linear linear(64, 64, false); // use_bias = false11 12 std::cout << "weight shape: [" << linear.weight.shape_[0] << ", " << linear.weight.shape_[1] << "]" << std::endl;13 std::cout << "quantized: " << linear.quantized << std::endl;14 15 Tensor input({1, 64});16 std::cout << "input shape: [" << input.shape_[0] << ", " << input.shape_[1] << "]" << std::endl;17 18 float* d = input.as_fp32();19 for (size_t i = 0; i < input.numel(); ++i) d[i] = 0.1f * i;20 21 std::cout << "Calling linear.forward(input)..." << std::endl;22 Tensor output = linear.forward(input);23 24 std::cout << "output shape: [" << output.shape_[0] << ", " << output.shape_[1] << "]" << std::endl;25 std::cout << "Success!" << std::endl;26 return 0;27}28 