CoolFace
Modelpublic

cwenzi/neuroflow-cpp

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
1likes
minimal_test.cpp39 linesDownload Raw Back to tests
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 << "Minimal test..." << std::endl;9    10    // Test basic tensor reshape11    Tensor t({2, 64});12    float* data = t.as_fp32();13    for (size_t i = 0; i < t.numel(); ++i) data[i] = 0.1f * i;14    15    std::cout << "Original shape: [" << t.shape_[0] << ", " << t.shape_[1] << "]" << std::endl;16    17    // Reshape18    Tensor reshaped = t.reshape({128});19    std::cout << "Reshaped: [" << reshaped.shape_[0] << "]" << std::endl;20    21    // Test Linear layer22    std::cout << "Testing Linear..." << std::endl;23    Linear linear(64, 32);24    Tensor input({2, 64});25    for (size_t i = 0; i < input.numel(); ++i) input.as_fp32()[i] = 0.1f * i;26    27    Tensor output = linear.forward(input);28    std::cout << "Linear output: [" << output.shape_[0] << ", " << output.shape_[1] << "]" << std::endl;29    30    // Test LayerNorm31    std::cout << "Testing LayerNorm..." << std::endl;32    LayerNorm norm(32);33    Tensor norm_out = norm.forward(output);34    std::cout << "LayerNorm output: [" << norm_out.shape_[0] << ", " << norm_out.shape_[1] << "]" << std::endl;35    36    std::cout << "Success!" << std::endl;37    return 0;38}39