CoolFace
Modelpublic

cwenzi/neuroflow-cpp

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
1likes
clone_test.cpp28 linesDownload Raw Back to tests
1#include <iostream>2#include "../include/neuroflow/tensor.hpp"3 4using namespace neuroflow;5 6int main() {7    std::cout << "Clone test..." << std::endl;8    9    Tensor x({2, 32});10    float* xd = x.as_fp32();11    for (size_t i = 0; i < x.numel(); ++i) xd[i] = 0.1f * i;12    13    std::cout << "Cloning..." << std::endl;14    Tensor cloned = x.clone();15    16    std::cout << "cloned shape: [" << cloned.shape_[0] << ", " << cloned.shape_[1] << "]" << std::endl;17    std::cout << "cloned numel: " << cloned.numel() << std::endl;18    std::cout << "cloned data_size: " << cloned.data_size_ << std::endl;19    20    float* cd = cloned.as_fp32();21    std::cout << "First 5 values: ";22    for (size_t i = 0; i < 5; ++i) std::cout << cd[i] << " ";23    std::cout << std::endl;24    25    std::cout << "Success!" << std::endl;26    return 0;27}28