refactor(tulip): move cenet/math/ to tulip/

This commit is contained in:
2026-11-22 12:54:57 +01:00
parent 14292b1d97
commit dea973ddd6
19 changed files with 157 additions and 167 deletions
+4 -4
View File
@@ -15,7 +15,7 @@
#include <random>
#include <vector>
using network_type = cenet::network<cenet::math::tensor<float, 1, 28, 28>,
using network_type = cenet::network<tulip::tensor<float, 1, 28, 28>,
cenet::layers::conv2d<8, 3, 1, 1>,
cenet::layers::relu,
cenet::layers::maxpool<>,
@@ -29,14 +29,14 @@ using network_type = cenet::network<cenet::math::tensor<float, 1, 28, 28>,
static std::uniform_real_distribution<> dist(-1, 1);
struct data {
cenet::math::tensor<float, 1, 28, 28> xs{};
cenet::math::matrix<float, 1, 10> ys{};
tulip::tensor<float, 1, 28, 28> xs{};
tulip::matrix<float, 1, 10> ys{};
};
using dataset = std::vector<data>;
template <std::size_t N, typename T>
static std::size_t col_largest_idx(const cenet::math::tensor_view<T, N>& col) {
static std::size_t col_largest_idx(const tulip::tensor_view<T, N>& col) {
std::size_t maxIdx = 0;
std::remove_cv_t<T> max = col[0];
for (std::size_t i = 1; i < N; ++i) {
+5 -5
View File
@@ -1,6 +1,6 @@
#include "cenet/layers/dense.hpp"
#include "cenet/loss/mse.hpp"
#include "cenet/math/tensor_fwd.hpp"
#include "tulip/tensor_fwd.hpp"
#include <cenet/cenet.hpp>
#include <cstddef>
@@ -11,7 +11,7 @@
static std::uniform_real_distribution<> dist(-1, 1);
int main(void) {
static cenet::math::matrix<cenet::math::inline_storage<float>, 1, 1> s_trainData[4] = {};
static tulip::matrix<tulip::inline_storage<float>, 1, 1> s_trainData[4] = {};
for (std::size_t i = 0; i < 4; ++i) {
const bool x0 = (i & 1U) != 0;
const bool x1 = (i & 2U) != 0;
@@ -20,7 +20,7 @@ int main(void) {
}
// network net;
using network_type = cenet::network<cenet::math::matrix<cenet::math::inline_storage<float>, 1, 2>,
using network_type = cenet::network<tulip::matrix<tulip::inline_storage<float>, 1, 2>,
cenet::layers::dense<2>,
cenet::layers::sigmoid,
cenet::layers::dense<1>,
@@ -45,7 +45,7 @@ int main(void) {
learningState.reset();
for (std::size_t i = 0; i < 4; ++i) {
cenet::math::matrix<cenet::math::inline_storage<float>, 1, 2> xs;
tulip::matrix<tulip::inline_storage<float>, 1, 2> xs;
xs.coeff(0) = static_cast<float>(i & 1);
xs.coeff(1) = static_cast<float>(i > 1);
@@ -60,7 +60,7 @@ int main(void) {
double acc = 0.0;
for (std::size_t i = 0; i < 4; ++i) {
cenet::math::matrix<cenet::math::inline_storage<float>, 1, 2> xs;
tulip::matrix<tulip::inline_storage<float>, 1, 2> xs;
xs.coeff(0) = static_cast<float>(i & 1);
xs.coeff(1) = static_cast<float>(i > 1);