How to use get_failures method in autotest

Best Python code snippet using autotest_python

plot_lstm.py

Source: plot_lstm.py Github

copy

Full Screen

...14import matplotlib.pyplot as plt15import numpy as np16N = 817M = 204818def get_failures(array, expected):19 failures = np.zeros((array.shape[0],16))20 for i in range(array.shape[0]):21 for j in range(16):22 if int(get_bit(array[i],j))!=expected:23 failures[i,j] = 124 return failures.reshape(-1)25def get_bit(uint16_word, index):26 word = np.uint16(uint16_word) # force just in case27 s = bin(word)[2:]28 if len(s)<16:29 s = "0"*(16-len(s))+s30 return s[index]31def get_masks(prefix,time="19710"):32 zeros = [[] for i in range(N)]33 for i in range(N):34 if (i==5 and "no" in prefix):35 f = open(prefix + str(i) + "_v2/​" + time + "trace_10c_0.txt",'r')36 else:37 f = open(prefix + str(i) + "/​" + time + "trace_10c_0.txt",'r')38 for j in range(N):39 f.readline() # skip the "physical chip #" print40 for k in range(M/​16): #while True:41 row = f.readline()42 row = row.split(' ') # ',' for csv43 row = [int(x,16) for x in row]44 if ("no" in prefix): zeros[i].extend(row) # phys chip 0 for NR45 elif (i==j): zeros[i].extend(row) # wait for phys chip i for DE46 if "no" in prefix or i==j:47 f.close()48 break49 forced_zeros_memory = np.array(zeros, dtype=np.int16).view(dtype=np.uint16)50 ones = [[] for i in range(N)]51 for i in range(N):52 if (i==5 and "no" in prefix):53 f = open(prefix + str(i) + "_v2/​" + time + "trace_10c_1.txt",'r')54 else:55 f = open(prefix + str(i) + "/​" + time + "trace_10c_1.txt",'r')56 for j in range(N):57 f.readline() # skip the "physical chip #" print58 for k in range(M/​16): #while True:59 row = f.readline()60 row = row.split(' ') # ',' for csv61 row = [int(x,16) for x in row]62 if ("no" in prefix): ones[i].extend(row)63 elif (i==j): ones[i].extend(row)64 if "no" in prefix or i==j:65 f.close()66 break67 forced_ones_memory = np.array(ones, dtype=np.int16).view(dtype=np.uint16)68 return forced_ones_memory, forced_zeros_memory69bit_failures = np.zeros((8,2048*16))70start_addr_tmp = 071data_length = M72fig, axs = plt.subplots(2,8,sharex=True,sharey=True,figsize=(14,10))73cmap = "gnuplot" #"brg"#"gnuplot"74start_addr_tmp = 10#0x30075data_length = 10 #1076mask_ones = np.zeros((8,2048*2),dtype=np.int16)77mask_zeros = np.zeros((8,2048*2),dtype=np.int16)78f = open("../​c_models_test/​c_lstm2/​activation_mask_NR_TENYEAR.c","r")79for i in range(8):80 f.readline()81 mask_zeros[i,10:10+data_length] = eval("["+f.readline()[1:-3]+"]")82 f.readline()83 mask_ones[i,10:10+data_length] = eval("["+f.readline()[1:-3]+"]")84f.close() 85mask_ones = mask_ones.view(dtype=np.int16)86mask_zeros = mask_zeros.view(dtype=np.int16)87for i in range(8):88 set_failures = get_failures(mask_ones[i,start_addr_tmp:start_addr_tmp+data_length],1)89 reset_failures = get_failures(mask_zeros[i,start_addr_tmp:start_addr_tmp+data_length],0)90 bit_failures[i,100*16:100*16+16*data_length] = np.logical_or(set_failures,reset_failures)91 axs[0,i].imshow(1-bit_failures[i].reshape((128,16*16)),extent=(0,16*16,0,128),aspect="auto", cmap=cmap ,vmin=0,vmax=1)92start_addr_tmp = 093data_length = M94bit_failures = np.zeros((8,2048*16))95mask_ones,mask_zeros = get_masks("../​data/​processed/​lstm_de_clean_c")96mask_ones0,mask_zeros0 = get_masks("../​data/​processed/​lstm_de_clean_c","0")97for i in range(8):98 set_failures = get_failures(mask_ones[i,start_addr_tmp:start_addr_tmp+data_length],1)99 reset_failures = get_failures(mask_zeros[i,start_addr_tmp:start_addr_tmp+data_length],0)100 bit_failures[i,0:16*data_length] = np.logical_or(set_failures,reset_failures)101 set_failures = get_failures(mask_ones0[i,start_addr_tmp:start_addr_tmp+data_length],1)102 reset_failures = get_failures(mask_zeros0[i,start_addr_tmp:start_addr_tmp+data_length],0)103 bit_failures[i,0:16*data_length] -= np.logical_or(set_failures,reset_failures)104 axs[1,i].imshow(1-bit_failures[i].reshape((128,16*16)),extent=(0,16*16,0,128),aspect="auto", cmap=cmap,vmin=0,vmax=1)105for i in range(8):106 axs[1,i].set_xlabel("Chip " +str(i),fontsize=18)107 for j in range(2):108 axs[j,i].set_xticks(np.arange(0,16*16,4*16))109 #axs[j,i].set_xticklabels(np.arange(0,16*16,4*16))110 #axs[j,i].set_xlim((0,16))111axs[0,0].set_ylabel("Without any\nResiliency Technique",fontsize=18)112axs[1,0].set_ylabel("With\nDistributed ENDURER",fontsize=18)113fig.suptitle("Permanent Bit Failures - 10-Years: LSTM",fontsize=28)...

Full Screen

Full Screen

plot_svhn.py

Source: plot_svhn.py Github

copy

Full Screen

...14import matplotlib.pyplot as plt15import numpy as np16N = 817M = 204818def get_failures(array, expected):19 failures = np.zeros((array.shape[0],16))20 for i in range(array.shape[0]):21 for j in range(16):22 if int(get_bit(array[i],j))!=expected:23 failures[i,j] = 124 return failures.reshape(-1)25def get_bit(uint16_word, index):26 word = np.uint16(uint16_word) # force just in case27 s = bin(word)[2:]28 if len(s)<16:29 s = "0"*(16-len(s))+s30 return s[index]31def get_masks(prefix,time="2010"):#19710"):32 zeros = [[] for i in range(N)]33 f = open(prefix + "/​" + time + "trace_10c_0.txt",'r')34 for i in range(N):35 f.readline() # skip the "physical chip #" print36 for k in range(M/​16): #while True:37 row = f.readline()38 row = row.split(' ') # ',' for csv39 row = [int(x,16) for x in row]40 zeros[i].extend(row)41 f.close()42 forced_zeros_memory = np.array(zeros, dtype=np.int16).view(dtype=np.uint16)43 ones = [[] for i in range(N)]44 f = open(prefix + "/​" + time + "trace_10c_1.txt",'r')45 for i in range(N):46 f.readline() # skip the "physical chip #" print47 for k in range(M/​16): #while True:48 row = f.readline()49 row = row.split(' ') # ',' for csv50 row = [int(x,16) for x in row]51 ones[i].extend(row)52 f.close()53 forced_ones_memory = np.array(ones, dtype=np.int16).view(dtype=np.uint16)54 return forced_ones_memory, forced_zeros_memory55bit_failures = np.zeros((8,2048*16))56start_addr_tmp = 057data_length = M58fig, axs = plt.subplots(2,8,sharex=True,sharey=True,figsize=(14,10))59cmap = "gnuplot" #"coolwarm_r"#"RdYlGn"60start_addr_tmp = 10#M-6461data_length = 6462mask_ones = np.zeros((8,2048*2),dtype=np.int8)63mask_zeros = np.zeros((8,2048*2),dtype=np.int8)64i=065f = open("../​c_models_test/​c_svhn/​activation_mask_NR_TENYEAR.c","r")66data = f.readline()67full_data = ''68while ';' not in data:69 data = f.readline()70 full_data += data71mask_zeros[i,10:10+data_length*2] 72arr = eval("["+full_data[1:-3]+"]")73mask_zeros[i,10:10+data_length*2] = arr74data = f.readline()75full_data = ''76while ';' not in data:77 data = f.readline()78 full_data += data79arr = eval("["+full_data[1:-3]+"]")80mask_ones[i,10:10+data_length*2] = arr81f.close() 82start_addr_tmp = 1083for i in range(8):84 if (i==0):85 set_failures = get_failures(mask_ones[i,start_addr_tmp:start_addr_tmp+data_length],1)86 reset_failures = get_failures(mask_zeros[i,start_addr_tmp:start_addr_tmp+data_length],0)87 bit_failures[i,100*16:100*16+16*data_length] = np.logical_or(set_failures,reset_failures)88 #bit_failures[i,0:16*data_length] = np.logical_or(set_failures,reset_failures)89 #print(bit_failures.sum())90 axs[0,i].imshow(1-bit_failures[i].reshape((128,16*16)),extent=(0,16,0,128),aspect="auto", cmap=cmap ,vmin=0,vmax=1)91start_addr_tmp = 092data_length = M93bit_failures = np.zeros((8,2048*16))94mask_ones,mask_zeros = get_masks("../​data/​processed/​svhn_de_clean")95mask_ones0,mask_zeros0 = get_masks("../​data/​processed/​svhn_de_clean","0")96for i in range(8):97 set_failures = get_failures(mask_ones[i,start_addr_tmp:start_addr_tmp+data_length],1)98 reset_failures = get_failures(mask_zeros[i,start_addr_tmp:start_addr_tmp+data_length],0)99 bit_failures[i,0:16*data_length] = np.logical_or(set_failures,reset_failures)100 set_failures = get_failures(mask_ones0[i,start_addr_tmp:start_addr_tmp+data_length],1)101 reset_failures = get_failures(mask_zeros0[i,start_addr_tmp:start_addr_tmp+data_length],0)102 bit_failures[i,0:16*data_length] -= np.logical_or(set_failures,reset_failures)103 axs[1,i].imshow(1-bit_failures[i].reshape((128,16*16)),extent=(0,16,0,128),aspect="auto", cmap=cmap,vmin=0,vmax=1)104for i in range(8):105 axs[1,i].set_xlabel("Chip " +str(i),fontsize=18)106 for j in range(2):107 axs[j,i].set_xticks(np.arange(0,16,4))108 axs[j,i].set_xticklabels(np.arange(0,16*16,4*16))109 #axs[j,i].set_xlim((0,16))110axs[0,0].set_ylabel("Without any\nResiliency Technique",fontsize=18)111axs[1,0].set_ylabel("With\nDistributed ENDURER",fontsize=18)112fig.suptitle("Permanent Bit Failures - 10-Years: SVHN",fontsize=28)...

Full Screen

Full Screen

plot_d2nn.py

Source: plot_d2nn.py Github

copy

Full Screen

...14import matplotlib.pyplot as plt15import numpy as np16N = 817M = 204818def get_failures(array, expected):19 failures = np.zeros((array.shape[0],16))20 for i in range(array.shape[0]):21 for j in range(16):22 if int(get_bit(array[i],j))!=expected:23 failures[i,j] = 124 return failures.reshape(-1)25def get_bit(uint16_word, index):26 word = np.uint16(uint16_word) # force just in case27 s = bin(word)[2:]28 if len(s)<16:29 s = "0"*(16-len(s))+s30 return s[index]31def get_masks(prefix,time="19710"):32 zeros = [[] for i in range(N)]33 f = open(prefix + "/​" + time + "trace_10c_0.txt",'r')34 for i in range(N):35 f.readline() # skip the "physical chip #" print36 for k in range(M/​16): #while True:37 row = f.readline()38 row = row.split(' ') # ',' for csv39 row = [int(x,16) for x in row]40 zeros[i].extend(row)41 f.close()42 forced_zeros_memory = np.array(zeros, dtype=np.int16).view(dtype=np.uint16)43 ones = [[] for i in range(N)]44 f = open(prefix + "/​" + time + "trace_10c_1.txt",'r')45 for i in range(N):46 f.readline() # skip the "physical chip #" print47 for k in range(M/​16): #while True:48 row = f.readline()49 row = row.split(' ') # ',' for csv50 row = [int(x,16) for x in row]51 ones[i].extend(row)52 f.close()53 forced_ones_memory = np.array(ones, dtype=np.int16).view(dtype=np.uint16)54 return forced_ones_memory, forced_zeros_memory55bit_failures = np.zeros((8,2048*16))56start_addr_tmp = 057data_length = M58fig, axs = plt.subplots(2,8,sharex=True,sharey=True,figsize=(14,10))59cmap = "gnuplot"60start_addr_tmp = M-102461data_length = 21662mask_ones,mask_zeros = get_masks("../​data/​processed/​d2nn_no_resilience_clean","59130")63for i in range(8):64 if i==0:65 set_failures = get_failures(mask_ones[i,start_addr_tmp:start_addr_tmp+data_length],1)66 reset_failures = get_failures(mask_zeros[i,start_addr_tmp:start_addr_tmp+data_length],0)67 bit_failures[i,100*16:100*16+16*data_length] = np.logical_or(set_failures,reset_failures)68 axs[0,i].imshow(1-bit_failures[i].reshape((128,16*16)),extent=(0,16,0,128),aspect="auto", cmap=cmap ,vmin=0,vmax=1)69start_addr_tmp = 070data_length = M71bit_failures = np.zeros((8,2048*16))72mask_ones,mask_zeros = get_masks("../​data/​processed/​d2nn_de_clean","59130")73mask_ones0,mask_zeros0 = get_masks("../​data/​processed/​d2nn_de_clean","0")74for i in range(8):75 set_failures = get_failures(mask_ones[i,start_addr_tmp:start_addr_tmp+data_length],1)76 reset_failures = get_failures(mask_zeros[i,start_addr_tmp:start_addr_tmp+data_length],0)77 bit_failures[i,0:16*data_length] = np.logical_or(set_failures,reset_failures)78 set_failures = get_failures(mask_ones0[i,start_addr_tmp:start_addr_tmp+data_length],1)79 reset_failures = get_failures(mask_zeros0[i,start_addr_tmp:start_addr_tmp+data_length],0)80 bit_failures[i,0:16*data_length] -= np.logical_or(set_failures,reset_failures)81 axs[1,i].imshow(1-bit_failures[i].reshape((128,16*16)),extent=(0,16,0,128),aspect="auto", cmap=cmap,vmin=0,vmax=1)82for i in range(8):83 axs[1,i].set_xlabel("Chip " +str(i),fontsize=18)84 for j in range(2):85 axs[j,i].set_xticks(np.arange(0,16,4))86 axs[j,i].set_xticklabels(np.arange(0,16*16,4*16))87 #axs[j,i].set_xlim((0,16))88axs[0,0].set_ylabel("Without any\nResiliency Technique",fontsize=18)89axs[1,0].set_ylabel("With\nDistributed ENDURER",fontsize=18)90fig.suptitle("Permanent Bit Failures - 10-Years: D2NN",fontsize=28)...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Scala Testing: A Comprehensive Guide

Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.

What Agile Testing (Actually) Is

So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.

How To Choose The Right Mobile App Testing Tools

Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools

A Complete Guide To CSS Houdini

As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????

Appium Testing Tutorial For Mobile Applications

The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful