the beginning of the implementation of Vulkan

This commit is contained in:
2026-04-30 01:35:33 +07:00
parent 8abdea6b77
commit 92a595b2f1
4 changed files with 63 additions and 14 deletions
+17 -2
View File
@@ -4,7 +4,6 @@
#include "typedef.hpp"
#include <vector>
#include <cmath>
#include "core.hpp"
#include <cstdlib>
#include <omp.h>
#include <vulkan/vulkan.hpp>
@@ -13,28 +12,44 @@
class NeuralNetwork {
private:
// Параметры нейросети
int numLayers;
std::vector<int> sizes;
std::vector<std::vector<std::vector<double>>> weights;
std::vector<std::vector<double>> biases;
std::vector<std::vector<double>> outputs;
// Объекты Vulkan
bool useVulkan; // Сохраняем выбор пользователя
vk::Instance instance;
vk::PhysicalDevice physDev;
vk::Device device;
vk::Queue queue;
vk::CommandPool cmdPool;
uint32_t computeQueueFamilyIndex; // Индекс очереди для команд
uint32_t NeuralNetwork::findMemoryType(uint32_t typeFilter, vk::MemoryPropertyFlags properties);
// Вспомогательные методы Vulkan
uint32_t findMemoryType(uint32_t typeFilter, vk::MemoryPropertyFlags properties);
std::vector<char> readFile(const std::string& filename);
// Математика CPU
double sigmoid(double x) { return 1.0 / (1.0 + exp(-x)); }
double sigmoidDeriv(double x) { return x * (1.0 - x); }
public:
int cpu_count = 1;
// Конструктор
NeuralNetwork(LayerStructure_t layers[], int count, bool useVulkan = false);
// Деструктор (ВАЖНО для очистки Vulkan)
~NeuralNetwork();
// Методы работы
std::vector<double> feedForward(const std::vector<double>& input);
double train(const std::vector<double>& input, const std::vector<double>& target, double lr);
// Наш тест Vulkan
double trainVulkan();
};