Metadata-Version: 2.4
Name: Younger-Logics-IR
Version: 0.1.0
Summary: Provides a Unified Intermediate Representation For Neural Networks, Enabling Framework-Agnostic Analysis, Conversion, and Optimization.
Author-email: Jason-Young-AI <AI.Jason.Young@outlook.com>
Maintainer-email: Jason-Young-AI <AI.Jason.Young@outlook.com>
License-Expression: Apache-2.0
Project-URL: Homepage, https://younger.yangs.ai/logics/ir
Project-URL: Issues, https://github.com/Yangs-AI/Younger-Logics-IR/issues
Project-URL: Source, https://github.com/Yangs-AI/Younger-Logics-IR
Project-URL: Repository, https://github.com/Yangs-AI/Younger-Logics-IR.git
Keywords: Younger,Logic,Deep Learning,DAG,Intermediate Representation
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: onnx
Requires-Dist: tqdm
Requires-Dist: click
Requires-Dist: younger<0.2.0,>=0.1.0
Requires-Dist: networkx
Provides-Extra: scripts-hubs-hf
Requires-Dist: huggingface_hub; extra == "scripts-hubs-hf"
Requires-Dist: torch; extra == "scripts-hubs-hf"
Requires-Dist: tf2onnx; extra == "scripts-hubs-hf"
Requires-Dist: optimum-onnx[onnxruntime]; extra == "scripts-hubs-hf"
Requires-Dist: transformers; extra == "scripts-hubs-hf"
Requires-Dist: diffusers[torch]; extra == "scripts-hubs-hf"
Requires-Dist: sentence-transformers; extra == "scripts-hubs-hf"
Requires-Dist: timm; extra == "scripts-hubs-hf"
Requires-Dist: stable-baselines3[extra]; extra == "scripts-hubs-hf"
Provides-Extra: scripts-hubs-ox
Provides-Extra: scripts-hubs-tr
Requires-Dist: torch; extra == "scripts-hubs-tr"
Requires-Dist: torchvision; extra == "scripts-hubs-tr"
Provides-Extra: scripts-hubs
Requires-Dist: numpy; extra == "scripts-hubs"
Requires-Dist: pandas; extra == "scripts-hubs"
Requires-Dist: isocodes; extra == "scripts-hubs"
Requires-Dist: huggingface_hub; extra == "scripts-hubs"
Requires-Dist: tf2onnx; extra == "scripts-hubs"
Requires-Dist: optimum-onnx[onnxruntime]; extra == "scripts-hubs"
Requires-Dist: transformers; extra == "scripts-hubs"
Requires-Dist: diffusers[torch]; extra == "scripts-hubs"
Requires-Dist: sentence-transformers; extra == "scripts-hubs"
Requires-Dist: timm; extra == "scripts-hubs"
Requires-Dist: torch; extra == "scripts-hubs"
Requires-Dist: torchvision; extra == "scripts-hubs"
Requires-Dist: stable-baselines3[extra]; extra == "scripts-hubs"
Provides-Extra: scripts-bootstrap
Requires-Dist: numpy; extra == "scripts-bootstrap"
Requires-Dist: pandas; extra == "scripts-bootstrap"
Requires-Dist: scipy; extra == "scripts-bootstrap"
Requires-Dist: scikit-learn; extra == "scripts-bootstrap"
Requires-Dist: umap; extra == "scripts-bootstrap"
Requires-Dist: seaborn; extra == "scripts-bootstrap"
Requires-Dist: matplotlib; extra == "scripts-bootstrap"
Requires-Dist: hdbscan; extra == "scripts-bootstrap"
Provides-Extra: tools-vs
Requires-Dist: graphviz; extra == "tools-vs"
Provides-Extra: tools
Requires-Dist: graphviz; extra == "tools"
Provides-Extra: develop
Requires-Dist: pytest; extra == "develop"
Requires-Dist: sphinx; extra == "develop"
Requires-Dist: python-semantic-release; extra == "develop"
Requires-Dist: build; extra == "develop"
Requires-Dist: twine; extra == "develop"
Dynamic: license-file

# Younger-Logics-IR
Younger - Logics - Intermediate Representation

Younger-Logics-IR is a submodule of the Younger project designed to construct a unified Intermediate Representation (IR) for abstracting and describing the logic structure of deep learning models. It supports extracting model information from various frameworks (e.g., PyTorch and ONNX) and abstracts the operators and data flows into a unified graph structure. Younger-Logics-IR enables framework-agnostic model analysis, conversion, and optimization, serving as a foundational tool for deep learning workflows.

## Contributing
This repository is a submodule of the parent project. For the canonical workflow and submodule pointer rules, see [CONTRIBUTING.md](https://github.com/Yangs-AI/Younger/CONTRIBUTING.md).

If you are working inside a parent clone:
- Commit changes in this submodule repo and open a PR to the submodule upstream.
- Do not update the parent repo submodule pointer unless a maintainer asks; mention any required pointer bump in your PR description.

If you are working standalone:
- Fork this repo, add `upstream`, create a feature branch, then open a PR back to upstream.

### Git workflow (sync with upstream)
```bash
# 1) Sync with upstream
git remote -v               # confirm origin/upstream are set correctly
git fetch --prune upstream   # sync upstream refs and drop deleted branches
git checkout dev             # ensure you are on the main dev branch
git pull --rebase upstream dev  # replay local dev on top of upstream/dev

# If you keep local commits on dev, rebase explicitly:
git rebase upstream/dev      # same as above, but explicit and easier to debug
# If conflicts happen:
git status                   # see which files are conflicted
# resolve files, then
git add <conflicted-file>    # mark conflicts as resolved
git rebase --continue        # continue replaying commits
# to abort:
git rebase --abort           # roll back to pre-rebase state

# 2) Create a feature branch
git checkout -b feat/my-change

# 3) Make changes and commit
git add .
git commit -m "feat: my change"

# 4) Push to your fork
git push origin feat/my-change
```

### Fixing edits made on a detached HEAD
If you forgot to switch branches and edited files on a `Previous HEAD position`, stash the changes, switch to the target branch, then restore them:

```bash
# 1) Stash the current changes
git stash push -m "temp: bench local edits"

# 2) Switch to dev
git checkout dev

# 3) Restore the changes
git stash pop
```

### Local development
From this repo root:

```bash
# 1) Install with dev tools
pip install -e .[develop]

# 2) Run tests
pytest tests
```

### Common commands
```bash
younger-logics-ir --help
younger logics ir create onnx retrieve huggingface \
    --mode Metric_Infos \
    --save-dirpath /path/to/working_directory/ \
    --token <HF_API_TOKEN> \
    --number-per-file 100000 \
    --logging-filepath /path/to/working_directory/.younger.log
```

### More docs
- [Homepage](https://younger.yangs.ai/logics/ir)

## Optional Dependencies (Extras)
This package defines several optional dependency groups for different scripts/tools.

Install an extra with:

```
pip install "younger-logics-ir[EXTRA_NAME]"
```

Available extras:

- `scripts-hubs-hf`: Crawl models and metadata from Hugging Face Hub and build Younger IR-Dataset (FromONNX). Each sample is organized as LogicX or Instance (DAG + related info).
- `scripts-hubs-ox`: Crawl models and metadata from the ONNX Model Zoo. This is no longer maintained since most models moved to Hugging Face Hub.
- `scripts-hubs-tr`: Crawl models and metadata from Torch Hub. This hub contains very few models compared to Hugging Face Hub.
- `scripts-hubs`: Full hub stack (combined set).
- `scripts-bootstrap`: Filter, normalize, post-process, and some other feature engineering on collected DAG datasets.
- `tools-vs`: Visualize DAGs (Graphviz).
- `tools`: Full toolset (combined set).
- `develop`: Developer tools (docs, pytest, release tooling).


### For the Use of Assorts
#### Requirements

`Graphviz` must be installed:

* Mac
```
brew install graphviz
```

* Debian/Ubuntu
```
sudo apt install graphviz
```

* Conda
```
conda install conda-forge::python-graphviz
```

##### Usage

```
younger logics ir create onnx retrieve huggingface \
    --mode Metric_Infos \
    --save-dirpath /path/to/working_directory/ \
    --token <HF_API_TOKEN> \
    --number-per-file 100000 \
    --logging-filepath /path/to/working_directory/.younger.log
```


## Releases

This repository publishes its Python package independently to GitHub and PyPI.
The release version is defined in `pyproject.toml`; a matching `v<version>` tag
runs `.github/workflows/release.yml`. Pull requests and manual runs validate the
build without publishing. Internal dependency bounds declare which Younger and
component versions are compatible.

Before the first release, configure the PyPI Trusted Publisher for this repository,
workflow `release.yml`, and GitHub environment `pypi`. Publish required Younger/IR
versions before dependent packages. See the
[Younger release guide](https://github.com/Yangs-AI/Younger/blob/dev/RELEASE.md)
for setup, dependency order, and combination validation. Conda distribution is
deferred.
