Skip to content

Commit

Permalink
Fix compatibility issues and add colab notebook link (#18)
Browse files Browse the repository at this point in the history
* Bug fixes

* Add no of workers in sample run

* Move import

* Add workers and injections to the networks command

* Add Colab notebook link in README

---------

Co-authored-by: sharad339 <[email protected]>
  • Loading branch information
sharad461 and sharad339 authored Oct 22, 2024
1 parent b9f53f1 commit 6ecd77a
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 21 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ GoldenEye is a functional simulator with fault injection capabilities for common
## Usage

Take a look at our documentation [here](https://goldeneyedocs.readthedocs.io/en/stable/index.html).
Check this [Colab notebook](https://colab.research.google.com/drive/1Om-Wg6wLOeaAKRWaDcpjoZZdF1LwXcCI) for a demo.

### Installing

Expand Down
5 changes: 3 additions & 2 deletions scripts/accuracy_profile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ BATCH=${2} #128
FORMAT=${3} # simulated format
BITWIDTH=${4}
RADIX=${5}
WORKERS=${6} # 16

DATASET="IMAGENET"
OUTPUT_PATH="../output/"
SRC_PATH="../src/"
LOG_PATH="./log/"
SCRIPT1="../src/preprocess.py"
SCRIPT2="../src/profile.py"
SCRIPT2="../src/profile_model.py"
SCRIPT3="../src/split_data.py"
SCRIPT4="../src/injections.py"
SCRIPT5="../src/postprocess.py"
Expand All @@ -23,7 +24,7 @@ PRECISION="FP32" # compute fabric
QUANT="" # -q leave empty if you do not want quantization
#BIT_FLIP="-e" # -e leave empty if you do not want bit flip model. NOTE: -q MUST BE ENABLED TOO WITH THIS
TRAINSET="" # -r. leave empty if using testset
WORKERS=16
#WORKERS=16

if [[ ${FORMAT} -eq "INT" ]]
then
Expand Down
9 changes: 5 additions & 4 deletions scripts/end_to_end.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ FORMAT=${4} #"fp_n" # simulated format
BITWIDTH=${5} #32
RADIX=${6} #23
INJECTIONS_LOC=${7} # {0, no injection}. {1: value} or {2, META}
WORKERS=${8} #16


OUTPUT_PATH="../output/"
SRC_PATH="../src/"
LOG_PATH="./log/"
SCRIPT1="../src/preprocess.py"
SCRIPT2="../src/profile.py"
SCRIPT2="../src/profile_model.py"
SCRIPT3="../src/split_data.py"
SCRIPT4="../src/injections.py"
SCRIPT5="../src/postprocess.py"
Expand All @@ -25,9 +26,9 @@ BIAS="" # leave empty, or include the flag with the number: "-a -8" | ""
QUANT="" # -q leave empty if you do not want quantization
#BIT_FLIP="-e" # -e leave empty if you do not want bit flip model. NOTE: -q MUST BE ENABLED TOO WITH THIS
TRAINSET="" # -r. leave empty if using testset
WORKERS=16
#WORKERS=16

INJECTIONS=102400 #${BATCH}
INJECTIONS=${9} #102400 #${BATCH}
#INJECTIONS_LOC=1 # {0, no injection}. {1: value} or {2, META}
#OLD {2, INT value}, or {3, INT scaling}, or {4, block meta}, or {5, adaptive meta}

Expand Down Expand Up @@ -102,5 +103,5 @@ python3 ${SCRIPT4} -b ${BATCH} -n ${NETWORK} -d ${DATASET} -o ${OUTPUT_PATH} ${T

# postprocessing
echo -n "Postprocessing ... "
python3 ${SCRIPT5} -b ${BATCH} -n ${NETWORK} -d ${DATASET} -o ${OUTPUT_PATH} ${TRAINSET} ${VERBOSE} ${DEBUG} -w ${WORKERS} -P ${PRECISION} -i ${INJECTIONS} -f ${FORMAT} -B ${BITWIDTH} -R ${RADIX} ${BIAS} ${QUANT}
python3 ${SCRIPT5} -b ${BATCH} -n ${NETWORK} -d ${DATASET} -o ${OUTPUT_PATH} ${TRAINSET} ${VERBOSE} ${DEBUG} -w ${WORKERS} -P ${PRECISION} -i ${INJECTIONS} -f ${FORMAT} -B ${BITWIDTH} -R ${RADIX} -I ${INJECTIONS_LOC} ${BIAS} ${QUANT}
echo -n "Done! "
4 changes: 3 additions & 1 deletion scripts/networks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ script="./end_to_end.sh"
network=${1}
dataset=${2}
batchsize=${3}
workers=${4:-8}
injections=${5:-102400}

time ${script} ${network} ${dataset} ${batchsize} fp32 32 23 1 #2&> ./log/alexnet.log
time ${script} ${network} ${dataset} ${batchsize} fp32 32 23 1 ${workers} ${injections} #2&> ./log/alexnet.log

#time ${script} ${dataset} ${network} ${batchsize} block_fp 12 7 1 #2&> ./log/alexnet.log
#time ${script} ${dataset} ${network} ${batchsize} adaptive_fp 8 3 1 #2&> ./log/alexnet.log
Expand Down
2 changes: 1 addition & 1 deletion src/injections.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def rand_neurons_batch(pfi_model, layer, shape, maxval, batchsize, function=-1):
pbar.update(samples)

# prep images
images, labels, img_ids, index = dataiter.next()
images, labels, img_ids, index = next(dataiter)
if getCUDA_en():
labels = labels.cuda()
images = images.cuda()
Expand Down
File renamed without changes.
28 changes: 15 additions & 13 deletions src/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import timm
import numpy as np
from num_sys_class import *
from othermodels import resnet, vgg, cifar10_nn

'''
Environment Variables
Expand Down Expand Up @@ -282,19 +281,22 @@ def getNetwork(networkName, DATASET):

elif DATASET == 'CIFAR10' or DATASET == 'CIFAR100':
if networkName == "resnet18":
MODEL = resnet.resnet18(pretrained=True)
elif networkName == "vgg19_bn":
MODEL = vgg.vgg19_bn(pretrained=True)
elif networkName == "cifar10_nn_baseline":
MODEL = cifar10_nn.baseline(pretrained=True, output_size=getNumClasses(DATASET))
elif networkName == "cifar10_nn_v1":
MODEL = cifar10_nn.v1(pretrained=True, output_size=getNumClasses(DATASET))
elif networkName == "cifar10_nn_v2":
MODEL = cifar10_nn.v2(pretrained=True, output_size=getNumClasses(DATASET))

# Error
MODEL = models.resnet18(pretrained=True, progress=True)
else:
sys.exit("Network does not exist")
from othermodels import vgg, cifar10_nn

if networkName == "vgg19_bn":
MODEL = vgg.vgg19_bn(pretrained=True)
elif networkName == "cifar10_nn_baseline":
MODEL = cifar10_nn.baseline(pretrained=True, output_size=getNumClasses(DATASET))
elif networkName == "cifar10_nn_v1":
MODEL = cifar10_nn.v1(pretrained=True, output_size=getNumClasses(DATASET))
elif networkName == "cifar10_nn_v2":
MODEL = cifar10_nn.v2(pretrained=True, output_size=getNumClasses(DATASET))

# Error
else:
sys.exit("Network does not exist")

# model upgrades
if getCUDA_en():
Expand Down

0 comments on commit 6ecd77a

Please sign in to comment.