Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d7a72b8
Add code generation infrastructure and template system
claude Dec 27, 2025
809d715
Add PyTorch Jinja2 templates for all layer types
claude Dec 27, 2025
7a6f167
Implement PyTorch code generation for Conv2D node
claude Dec 27, 2025
f50b411
Implement PyTorch code generation for Linear node
claude Dec 27, 2025
7464dcc
Implement PyTorch code generation for MaxPool2D node
claude Dec 27, 2025
ff0f977
Implement PyTorch code generation for Flatten, Dropout, BatchNorm2D, …
claude Dec 27, 2025
68938a6
Implement PyTorch code generation for Concat node
claude Dec 27, 2025
f721349
Create PyTorch code generation orchestrator
claude Dec 27, 2025
6a84592
Integrate PyTorch orchestrator into public API
claude Dec 27, 2025
14fb670
Add TensorFlow Jinja2 templates for all layer types
claude Dec 27, 2025
4d69fdc
Implement TensorFlow code generation for all node types
claude Dec 27, 2025
c34acfe
Create TensorFlow code generation orchestrator
claude Dec 27, 2025
075caa2
Integrate TensorFlow orchestrator into public API
claude Dec 27, 2025
4a4cec9
Fix critical bugs in orchestrators
claude Dec 27, 2025
53695ea
Fix import error in tensorflow_codegen
claude Dec 28, 2025
9fa625d
Remove unused imports from tensorflow_codegen
claude Dec 28, 2025
cf8b997
Add group blolck codegen + add missing blocks
RETR0-OS Dec 28, 2025
3c30704
Add PyTorch layer node definitions for Conv1D, Conv3D, LSTM, GRU, and…
RETR0-OS Dec 28, 2025
c12f46c
Refactor PyTorch and TensorFlow orchestrators to optimize variable us…
RETR0-OS Dec 28, 2025
676d482
Update CodeQL workflow to include 'deploy' branch
RETR0-OS Dec 28, 2025
43a1b26
Delete .github/workflows directory
RETR0-OS Dec 28, 2025
3be727d
Update CodeQL workflow to include 'deploy' branch
RETR0-OS Dec 28, 2025
ecfe249
Merge pull request #47 from ForgeOpus/deploy
RETR0-OS Dec 28, 2025
df2f1b5
Merge branch 'main' into claude/refactor-pytorch-codegen-ZROiF
RETR0-OS Dec 28, 2025
6c62f81
Merge pull request #46 from ForgeOpus/claude/refactor-pytorch-codegen…
RETR0-OS Dec 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL Advanced"

on:
push:
branches: [ "main", "deploy" ]
pull_request:
branches: [ "main", "deploy" ]
workflow_dispatch:

jobs:
analyze:
name: Analyze (${{ matrix.language }})
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners (GitHub.com only)
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
permissions:
# required for all workflows
security-events: write

# required to fetch internal or private CodeQL packs
packages: read

# only required for workflows in private repositories
actions: read
contents: read

strategy:
fail-fast: false
matrix:
include:
- language: javascript-typescript
build-mode: none
- language: python
build-mode: none
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift'
# Use `c-cpp` to analyze code written in C, C++ or both
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
steps:
- name: Checkout repository
uses: actions/checkout@v4

# Add any setup steps before running the `github/codeql-action/init` action.
# This includes steps like installing compilers or runtimes (`actions/setup-node`
# or others). This is typically only required for manual builds.
# - name: Setup runtime (example)
# uses: actions/setup-example@v1

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

# If the analyze step fails for one of the languages you are analyzing with
# "We were unable to automatically build your code", modify the matrix above
# to set the build mode to "manual" for that language. Then modify this step
# to build your code.
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
- name: Run manual build steps
if: matrix.build-mode == 'manual'
shell: bash
run: |
echo 'If you are using a "manual" build mode for one or more of the' \
'languages you are analyzing, replace this with the commands to build' \
'your code, for example:'
echo ' make bootstrap'
echo ' make release'
exit 1

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{matrix.language}}"
6 changes: 6 additions & 0 deletions project/block_manager/services/codegen/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""Code generation orchestration package"""

from .pytorch_orchestrator import PyTorchCodeOrchestrator
from .tensorflow_orchestrator import TensorFlowCodeOrchestrator

__all__ = ['PyTorchCodeOrchestrator', 'TensorFlowCodeOrchestrator']
79 changes: 79 additions & 0 deletions project/block_manager/services/codegen/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
"""
Base utilities for code generation
Shared functions for both PyTorch and TensorFlow code generation
"""

from collections import deque
from typing import List, Dict, Any


def topological_sort(nodes: List[Dict], edges: List[Dict]) -> List[Dict]:
"""
Sort nodes in topological order based on edges using Kahn's algorithm.

Args:
nodes: List of node definitions
edges: List of edge definitions

Returns:
List of nodes in topological order
"""
node_map = {node['id']: node for node in nodes}

# Build adjacency list and in-degree count
graph = {node['id']: [] for node in nodes}
in_degree = {node['id']: 0 for node in nodes}

for edge in edges:
source = edge.get('source')
target = edge.get('target')
if source in graph and target in graph:
graph[source].append(target)
in_degree[target] += 1

# Kahn's algorithm
queue = deque([node_id for node_id, degree in in_degree.items() if degree == 0])
sorted_ids = []

while queue:
node_id = queue.popleft()
sorted_ids.append(node_id)

for neighbor in graph[node_id]:
in_degree[neighbor] -= 1
if in_degree[neighbor] == 0:
queue.append(neighbor)

# Return nodes in sorted order
return [node_map[node_id] for node_id in sorted_ids if node_id in node_map]


def get_input_variable(incoming: List[str], var_map: Dict[str, str]) -> str:
"""
Determine input variable name based on incoming connections.

Args:
incoming: List of incoming node IDs
var_map: Map of node ID to variable name

Returns:
Variable name or list of variable names for multiple inputs
"""
if not incoming:
return 'x'
elif len(incoming) == 1:
return var_map.get(incoming[0], 'x')
else:
# Multiple inputs (for concat, add, etc.)
input_vars = [var_map.get(src, 'x') for src in incoming]
return f"[{', '.join(input_vars)}]"


def get_node_type(node: Dict[str, Any]) -> str:
"""Extract node type from node definition"""
return node.get('data', {}).get('blockType', 'unknown')


def get_node_config(node: Dict[str, Any]) -> Dict[str, Any]:
"""Extract configuration from node definition"""
return node.get('data', {}).get('config', {})
Loading