Skip to content
This repository has been archived by the owner on Mar 2, 2024. It is now read-only.

Commit

Permalink
Merge branch 'TorchEI:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Force1ess authored Mar 2, 2024
2 parents 840ac69 + c3f86fd commit aaf05d8
Show file tree
Hide file tree
Showing 45 changed files with 9,227 additions and 1,568 deletions.
12 changes: 1 addition & 11 deletions .deepsource.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,9 @@ version = 1

[[analyzers]]
name = "python"
enabled = true

[analyzers.meta]
runtime_version = "3.x.x"

[[transformers]]
name = "black"
enabled = true

[[transformers]]
name = "isort"
enabled = true

test_patterns = [
"test/**"
]
name = "black"
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:
# The branches below must be a subset of the branches above
branches: [ "main" ]
schedule:
- cron: '0 21 * * 0'
- cron: '0 21 * * *'

jobs:
analyze:
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/doc-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Doc
on: [push]
jobs:
doc-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master

- name: api-generate
run: |
sed -i 's/\[中文\](.\/README-zh.md)/ /' README.md
cp README.md ./docs/index.md
cp README-zh.md ./docs/zh/index.md
pip3 install pydoc-markdown torchei
pip3 install typing-extensions==3.10.0.2
echo '# API Reference' > docs/api.md
sed -i 's/**kwargs,/**kwargs/' torchei/fault_model.py
more torchei/fault_model.py
pydoc-markdown -p torchei '{renderer:{type: markdown,descriptive_class_title: false,render_toc: false, header_level_by_type: { Module: 2, Class: 2, Method: 3, Function: 3} } }' > temp.md
sed -n '1,3p;6,9999p' temp.md >> docs/api.md
echo '> Auto Generated by pydoc-markdown' >> docs/api.md
ls -lR
- name: vuepress-deploy
uses: jenkey2011/vuepress-deploy@master
env:
ACCESS_TOKEN: ${{ secrets.REPO_TOKEN }}
TARGET_BRANCH: gh-pages
BUILD_SCRIPT: yarn && yarn docs:build
BUILD_DIR: docs/.vuepress/dist
20 changes: 20 additions & 0 deletions .github/workflows/sync-gitee.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: sync-gitee
on:
push:
branches:
- main
jobs:
repo-sync:
runs-on: ubuntu-latest
steps:
- name: Mirror the Github organization repos to Gitee.
uses: Yikun/hub-mirror-action@master
with:
src: 'github/TorchEI'
dst: 'gitee/TorchEI'
dst_key: ${{ secrets.SSH_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_PRIVATE_KEY }}
static_list: "TorchEI"
account_type: org
force_update: true
debug: true
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Docs
node_modules
.temp
.docs/
.vuepress/

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down Expand Up @@ -133,6 +131,5 @@ dmypy.json

# Pyre type checker
.pyre/
/docs
.vscode/settings.json
/.vscode
9 changes: 9 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cff-version: 1.0.0
message: "If this repo helped you, please cite it as below."
authors:
- family-names: "Zheng"
given-names: "Hao"
title: "TorchEI"
version: 1.0.0
date-released: 2022-5-24
url: "https://github.com/TorchEI/TorchEI"
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT LICENSE

Copyright (c) 2022 Hao Zheng(Forceless)
Copyright (c) 2022 Hao Zheng(Force1ess/Forceless)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
Expand Down
106 changes: 106 additions & 0 deletions README-zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<div align="center">
<img src="https://raw.githubusercontent.com/TorchEI/TorchEI/main/assets/torchei.svg" alt="torchei_logo" align="center" style="width:30%;" />
</div>

<h1 style = "margin:0;" align="center">TorchEI⚡</h1>

<div align = "center" style="font-weight: bold;"><a href="#introduction">Intro</a> ● <a href="#quick-example">Usage</a> ● <a href="https://TorchEI.github.com.io/TorchEI/">Doc</a> ● <a href="#citation">Cite</a> ● <a href="#contribution" >Contribution</a> ● <a href="#license">License</a></div>

------

<div align = "center">
<a href = "https://github.com/TorchEI/TorchEI/actions/workflows/pytest-cov.yml">
<img src="https://github.com/TorchEI/TorchEI/actions/workflows/pytest-cov.yml/badge.svg"/></a>
<a href = "https://github.com/TorchEI/TorchEI/actions/workflows/doc-deploy.yml">
<img src="https://github.com/TorchEI/TorchEI/actions/workflows/doc-deploy.yml/badge.svg"/></a>
<a href="https://codecov.io/gh/TorchEI/TorchEI" >
<img src="https://codecov.io/gh/TorchEI/TorchEI/branch/main/graph/badge.svg?token=0ADLQFHLCJ"/></a>
<a href="https://www.codacy.com/gh/TorchEI/TorchEI/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=TorchEI/TorchEI&amp;utm_campaign=Badge_Grade">
<img src="https://app.codacy.com/project/badge/Grade/c4067d004b934d49bb4386b650c57808"/></a>
<a href="https://pypi.org/project/torchei/" target=”_blank”>
<img src="https://img.shields.io/pypi/v/torchei" alt="Pypi"></a>
<a href="https://pypi.org/project/torchei/" target=”_blank”>
<img src="https://pepy.tech/badge/torchei"/></a>
<a href="#license">
<img src="https://img.shields.io/github/license/torchei/torchei" alt="License"></a>
</div>


## Introduction

👋TorchEI, 发音为*/ˈtôrCHər/*(like torture), 是Pytorch Error Injection的缩写, 一个围绕DNN Reliability 研究的高速工具箱. TorchEI 使您能够快速简单地将错误注入 DNN,收集您需要的信息并强化您的 DNN。


## Features

- 完善的类型提示和文档支持
- 包含来自 DNN 可靠性论文的方法
- 高度定制化

## Quick Example

在这里,我们将向您展示一个简单的示例,或者您可以尝试 [interactive demo](https://colab.research.google.com/github/TorchEI/TorchEI/blob/main/example.ipynb)[online editor](https://github.dev/TorchEI/TorchEI)

#### Installing

你可以使用 `pip3 install torchei` 安装或 [下载](https://github.com/TorchEI/TorchEI/archive/refs/heads/main.zip)

#### Example

初始化故障模型

```python
import torch
from torchvision import models
import torchei
model = models.resnet18(pretrained=True)
data = torch.load('data/ilsvrc_valid8.pt')
fault_model = torchei.fault_model(model,data)
```

使用emat方法计算可靠性

```python
fault_model.emat_attack(10,1e-3)
```

使用[SERN](https://dl.acm.org/doi/abs/10.1145/3386263.3406938)方法计算可靠性

```python
fault_model.sern_calc(output_class=1000)
```

使用ODR方法加固DNN

```python
fault_model.outlierDR_protection()
fault_model.emat_attack(10,1e-3)
```

## Contribution

![contributors](https://img.shields.io/github/contributors/torchei/torchei)

如果您发现🧐任何错误或有🖐️任何建议,请告诉我们。

这个 repo 欢迎所有想要一起维护的人。

You can helps us with follow things:

- PR your implemented methods in your or others' papers
- Complete our project
- Translate our docs to your language
- Other

我们希望将 TorchEI 构建为 DNN 可靠性方面的最佳工具箱,用于位翻转、对抗性攻击等。

:e-mail: forcessless@foxmail.com

## Citation

Our paper is under delivering.

## License

> [MIT](https://github.com/TorchEI/TorchEI/blob/main/LICENSE) License.
> Copyright:copyright:2022/5/23-present, Hao Zheng.
67 changes: 32 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,40 @@
<img src="https://raw.githubusercontent.com/TorchEI/TorchEI/main/assets/torchei.svg" alt="torchei_logo" align="center" style="width:30%;" />
</div>


<h1 style = "margin:0;" align="center">TorchEI⚡</h1>

<div align = "center" style="font-weight: bold;"><a href="#introduction">Intro</a> ● <a href="#quick-example">Usage</a> ● <a href="https://TorchEI.github.com.io/TorchEI/">Doc</a> ● <a href="#citation">Cite</a> ● <a href="#contribution" >Contribution</a> ● <a href="#license">License</a></div>

------

<div align = "center">
<a href = "https://github.com/TorchEI/TorchEI/actions/workflows/pytest-cov.yml">
<img src="https://github.com/TorchEI/TorchEI/actions/workflows/pytest-cov.yml/badge.svg"/></a>
<a href="https://codecov.io/gh/TorchEI/TorchEI" >
<img src="https://codecov.io/gh/TorchEI/TorchEI/branch/main/graph/badge.svg?token=0ADLQFHLCJ"/></a>
<a href="https://www.codacy.com/gh/TorchEI/TorchEI/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=TorchEI/TorchEI&amp;utm_campaign=Badge_Grade">
<img src="https://app.codacy.com/project/badge/Grade/c4067d004b934d49bb4386b650c57808"/></a>
<a href="https://pypi.org/project/torchei/" target=”_blank”>
<img src="https://img.shields.io/pypi/v/torchei" alt="Pypi"></a>
<img src="https://github.com/TorchEI/TorchEI/actions/workflows/pytest-cov.yml/badge.svg"/></a>
<a href = "https://github.com/TorchEI/TorchEI/actions/workflows/doc-deploy.yml">
<img src="https://github.com/TorchEI/TorchEI/actions/workflows/doc-deploy.yml/badge.svg"/></a>
<a href="https://codecov.io/gh/TorchEI/TorchEI" >
<img src="https://codecov.io/gh/TorchEI/TorchEI/branch/main/graph/badge.svg?token=0ADLQFHLCJ"/></a>
<a href="https://www.codacy.com/gh/TorchEI/TorchEI/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=TorchEI/TorchEI&amp;utm_campaign=Badge_Grade">
<img src="https://app.codacy.com/project/badge/Grade/c4067d004b934d49bb4386b650c57808"/></a>
<a href="https://pypi.org/project/torchei/" target=”_blank”>
<img src="https://img.shields.io/pypi/v/torchei" alt="Pypi"></a>
<a href="https://pypi.org/project/torchei/" target=”_blank”>
<img src="https://pepy.tech/badge/torchei"/></a>
<a href="#license">
<img src="https://img.shields.io/github/license/torchei/torchei" alt="License"></a>
<img src="https://pepy.tech/badge/torchei"/></a>
<a href="#license">
<img src="https://img.shields.io/github/license/torchei/torchei" alt="License"></a>
</div>

## Introduction
[中文](./README-zh.md)

## Introduction

👋TorchEI, pronounced*/ˈtôrCHər/*, short for Pytorch Error Injection, is a high-speed toolbox around DNN Reliability's Research and Development. TorchEI enables you quickly and simply inject errors into DNN, collects information you needed, and harden your DNN.

TorchEI implemented incredible parallel evaluation system which could allow you adequately utilize device computing performance with tolerance to non-catastrophic faults.
👋TorchEI, pronounced*/ˈtôrCHər/*(like torture), short for Pytorch Error Injection, is a high-speed toolbox for DNN Reliability's Research and Development. TorchEI enables you quickly and simply inject errors into DNN, collects information you needed, and harden your DNN.

## Features

- Full typing system supported
- Contains methods from papers in DNN Reliability
- High-efficiency, fault-tolerant parallel system
- Implemented methods from papers
- Highly customizable

## Quick Example

Expand All @@ -52,7 +54,7 @@ import torch
from torchvision import models
import torchei
model = models.resnet18(pretrained=True)
data = torch.load('./datasets/ilsvrc_valid8.pt')
data = torch.load('data/ilsvrc_valid8.pt')
fault_model = torchei.fault_model(model,data)
```

Expand All @@ -62,48 +64,43 @@ Calc reliability using emat method
fault_model.emat_attack(10,1e-3)
```



Calc reliability using Parallel Mechanism (under developing)

```python

```



Calc reliability using [SERN](https://dl.acm.org/doi/abs/10.1145/3386263.3406938)
Calc reliability using [SERN](https://dl.acm.org/doi/abs/10.1145/3386263.3406938)

```python
fault_model.sern_calc(output_class=1000)
```


Harden DNN by ODR

```python
fault_model.outlierDR_protection()
fault_model.emat_attack(10,1e-3)
```

## Contribution![contributors](https://img.shields.io/github/contributors/torchei/torchei)
## Contribution

![contributors](https://img.shields.io/github/contributors/torchei/torchei)

If you found🧐 any bugs or have🖐️ any suggestions, please tell us.

This repo is open to everyone wants to maintain together.

You can helps us with follow things:

- PR your implemented methods in your or others' papers
- Complete our project
- Translate our docs to your language
- Other

We want to build TorchEI to best toolbox in DNN Reliability around bit flip, adversarial attack, and others.
We want to build TorchEI to best toolbox in DNN Reliability for bit flip, adversarial attack, and others.

:e-mail: forcessless@foxmail.com

## Citation

Our paper is under reviewing.
Our paper is under delivering.

## License
> [MIT](./LICENSE) License.
> Copyright:copyright:2022/5/23-present, Hao Zheng.

> [MIT](https://github.com/TorchEI/TorchEI/blob/main/LICENSE) License.
> Copyright:copyright:2022/5/23-present, Hao Zheng.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit aaf05d8

Please sign in to comment.