refactor: add type parameter to layer inputs

This commit is contained in:
2026-10-25 15:55:07 +01:00
parent aa438bfac7
commit 490661ebc0
6 changed files with 72 additions and 56 deletions
+6 -4
View File
@@ -14,7 +14,7 @@ struct layer_input {
static constexpr std::uint32_t TENSOR_TAG = 0x544E5352;
};
template <std::size_t Features>
template <std::size_t Features, typename T = float>
class dense_input : public layer_input {
template <typename Input, typename... Layers>
friend class network;
@@ -26,7 +26,8 @@ private:
static constexpr std::size_t FEATURES = Features;
using type = mat<1, FEATURES>;
using inner_type = T;
using type = mat<1, FEATURES, T>;
template <typename... Args, typename = std::enable_if_t<std::is_constructible_v<type, Args...>>>
inner(Args&&... args)
@@ -42,7 +43,7 @@ private:
};
};
template <std::size_t... Dims>
template <typename T, std::size_t... Dims>
class tensor_input : public layer_input {
template <typename Input, typename... Layers>
friend class network;
@@ -52,7 +53,8 @@ private:
struct inner final {
static constexpr std::uint32_t TAG = TENSOR_TAG;
using type = tensor<double, Dims...>;
using inner_type = T;
using type = tensor<T, Dims...>;
template <typename... Args, typename = std::enable_if_t<std::is_constructible_v<type, Args...>>>
inner(Args&&... args)