# tomh0011/neuralnetworkinc architecture

> Architecture diagram of the GitHub repository tomh0011/neuralnetworkinc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tomh0011/neuralnetworkinc
- Repository: https://github.com/tomh0011/neuralnetworkinc

## Overview

DeepC is a C/CUDA neural-network demonstration with a runnable language-model-style pipeline. Its principal workflow generates sample text, tokenizes it with BPE merges, builds token embeddings with positional encodings, then runs GPU self-attention and an MLP before copying the final tensor back to the host for inspection. The graph also shows the tensor and compute layers used by those stages. The README is empty; some subsystem details are inferred from the tree, so uncertain connections are omitted.

Main entry points: [`src/core/pipeline.c`](https://github.com/tomh0011/neuralnetworkinc/blob/main/src/core/pipeline.c) (Pipeline Orchestrator), [`src/core/tensor.c`](https://github.com/tomh0011/neuralnetworkinc/blob/main/src/core/tensor.c) (Tensor Operations), [`src/nn/layers/attention.c`](https://github.com/tomh0011/neuralnetworkinc/blob/main/src/nn/layers/attention.c) (Self-Attention), [`src/nn/modules/mlp.c`](https://github.com/tomh0011/neuralnetworkinc/blob/main/src/nn/modules/mlp.c) (MLP Layer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Input Preparation"]
  node_generator["Text Generator<br/>[generator.c]"]
  node_tokeniser["BPE Tokeniser<br/>[tokeniser.c]"]
  node_encoding["Positional Encoding<br/>[encoding.c]"]
end

subgraph group_model["Model Pipeline"]
  node_pipeline["Pipeline Orchestrator<br/>[pipeline.c]"]
  node_attention["Self-Attention<br/>[attention.c]"]
  node_mlp["MLP Layer<br/>[mlp.c]"]
  node_result["Host Output Tensor<br/>[pipeline.c]"]
end

subgraph group_compute["Tensor Compute"]
  node_tensor["Tensor Operations<br/>[tensor.c]"]
  node_cuda["CUDA Kernels"]
  node_softmax["CPU Softmax<br/>[softmax.c]"]
end

subgraph group_runtime["Runtime Support"]
  node_main["CLI Entry<br/>[main.c]"]
  node_config["Configuration<br/>[config.c]"]
  node_initialization["Weight Initialization<br/>[init.c]"]
end

node_operator(("Operator"))
node_gpu(("CUDA Device"))

node_operator -->|"starts"| node_main
node_main -->|"calls"| node_pipeline
node_pipeline -->|"initializes"| node_config
node_pipeline -->|"generates text"| node_generator
node_pipeline -->|"tokenizes text"| node_tokeniser
node_pipeline -->|"adds positions"| node_encoding
node_pipeline -->|"creates weights"| node_initialization
node_pipeline -->|"runs attention"| node_attention
node_pipeline -->|"runs MLP"| node_mlp
node_pipeline -->|"allocates and transfers"| node_tensor
node_attention -->|"calls tensor ops"| node_tensor
node_mlp -->|"calls tensor ops"| node_tensor
node_tensor -->|"dispatches GPU ops"| node_cuda
node_cuda -->|"executes on"| node_gpu
node_pipeline -.->|"uses for CPU softmax"| node_softmax
node_pipeline -->|"copies final output"| node_result
node_result -->|"displays preview"| node_operator

click node_main "https://github.com/tomh0011/neuralnetworkinc/blob/main/main.c"
click node_pipeline "https://github.com/tomh0011/neuralnetworkinc/blob/main/src/core/pipeline.c"
click node_config "https://github.com/tomh0011/neuralnetworkinc/blob/main/src/core/config.c"
click node_generator "https://github.com/tomh0011/neuralnetworkinc/blob/main/src/data/generator.c"
click node_tokeniser "https://github.com/tomh0011/neuralnetworkinc/blob/main/src/data/tokeniser.c"
click node_encoding "https://github.com/tomh0011/neuralnetworkinc/blob/main/src/data/encoding.c"
click node_initialization "https://github.com/tomh0011/neuralnetworkinc/blob/main/src/core/init.c"
click node_attention "https://github.com/tomh0011/neuralnetworkinc/blob/main/src/nn/layers/attention.c"
click node_mlp "https://github.com/tomh0011/neuralnetworkinc/blob/main/src/nn/modules/mlp.c"
click node_tensor "https://github.com/tomh0011/neuralnetworkinc/blob/main/src/core/tensor.c"
click node_cuda "https://github.com/tomh0011/neuralnetworkinc/tree/main/src/backend/ops_cuda"
click node_softmax "https://github.com/tomh0011/neuralnetworkinc/blob/main/src/backend/ops_cpu/softmax.c"
click node_result "https://github.com/tomh0011/neuralnetworkinc/blob/main/src/core/pipeline.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_generator,node_tokeniser,node_encoding toneBlue
class node_pipeline,node_attention,node_mlp,node_result toneAmber
class node_tensor,node_cuda,node_softmax toneMint
class node_main,node_config,node_initialization toneRose
class node_operator,node_gpu toneIndigo
```

## Components

### Input Preparation

- [Text Generator](https://github.com/tomh0011/neuralnetworkinc/blob/main/src/data/generator.c): `src/data/generator.c`
- [BPE Tokeniser](https://github.com/tomh0011/neuralnetworkinc/blob/main/src/data/tokeniser.c): `src/data/tokeniser.c`
- [Positional Encoding](https://github.com/tomh0011/neuralnetworkinc/blob/main/src/data/encoding.c): `src/data/encoding.c`

### Model Pipeline

- [Pipeline Orchestrator](https://github.com/tomh0011/neuralnetworkinc/blob/main/src/core/pipeline.c): `src/core/pipeline.c`
- [Self-Attention](https://github.com/tomh0011/neuralnetworkinc/blob/main/src/nn/layers/attention.c): `src/nn/layers/attention.c`
- [MLP Layer](https://github.com/tomh0011/neuralnetworkinc/blob/main/src/nn/modules/mlp.c): `src/nn/modules/mlp.c`
- [Host Output Tensor](https://github.com/tomh0011/neuralnetworkinc/blob/main/src/core/pipeline.c): `src/core/pipeline.c`

### Tensor Compute

- [Tensor Operations](https://github.com/tomh0011/neuralnetworkinc/blob/main/src/core/tensor.c): `src/core/tensor.c`
- [CUDA Kernels](https://github.com/tomh0011/neuralnetworkinc/tree/main/src/backend/ops_cuda): `src/backend/ops_cuda`
- [CPU Softmax](https://github.com/tomh0011/neuralnetworkinc/blob/main/src/backend/ops_cpu/softmax.c): `src/backend/ops_cpu/softmax.c`

### Runtime Support

- [CLI Entry](https://github.com/tomh0011/neuralnetworkinc/blob/main/main.c): `main.c`
- [Configuration](https://github.com/tomh0011/neuralnetworkinc/blob/main/src/core/config.c): `src/core/config.c`
- [Weight Initialization](https://github.com/tomh0011/neuralnetworkinc/blob/main/src/core/init.c): `src/core/init.c`

### Other components

- **Operator**
- **CUDA Device**

## Connections

- Operator → CLI Entry: starts
- CLI Entry → Pipeline Orchestrator: calls
- Pipeline Orchestrator → Configuration: initializes
- Pipeline Orchestrator → Text Generator: generates text
- Pipeline Orchestrator → BPE Tokeniser: tokenizes text
- Pipeline Orchestrator → Positional Encoding: adds positions
- Pipeline Orchestrator → Weight Initialization: creates weights
- Pipeline Orchestrator → Self-Attention: runs attention
- Pipeline Orchestrator → MLP Layer: runs MLP
- Pipeline Orchestrator → Tensor Operations: allocates and transfers
- Self-Attention → Tensor Operations: calls tensor ops
- MLP Layer → Tensor Operations: calls tensor ops
- Tensor Operations → CUDA Kernels: dispatches GPU ops
- CUDA Kernels → CUDA Device: executes on
- Pipeline Orchestrator → CPU Softmax: uses for CPU softmax
- Pipeline Orchestrator → Host Output Tensor: copies final output
- Host Output Tensor → Operator: displays preview
