| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858 |
- import os.path
- import struct
- import numpy as np
- def normalize(a):
- return(a/np.max(np.abs(a)))
- TAILONLY = 1
- BODYONLY = 2
- BODYANDTAIL = 3
- # Datatype formats
- F64 = 64
- F32 = 0
- F16 = 16
- Q31 = 31
- Q15 = 15
- Q7 = 7
- def loopnb(format,loopkind):
- nb = 0
- if loopkind == TAILONLY:
- if format == 64:
- nb = 2
- if format == 0 or format == 31:
- nb = 3
- if format == 15 or format == 16:
- nb = 7
- if format == 7:
- nb = 15
- if loopkind == BODYONLY:
- if format == 64:
- nb = 4
- if format == 0 or format == 31:
- nb = 8
- if format == 15 or format == 16:
- nb = 16
- if format == 7:
- nb = 32
- if loopkind == BODYANDTAIL:
- if format == 64:
- nb = 5
- if format == 0 or format == 31:
- nb = 11 # 9
- if format == 15 or format == 16:
- nb = 23 # 17
- if format == 7:
- nb = 47 # 33
- return(nb)
- # Tools to generate pattern files
- def createMissingDir(destPath):
- theDir=os.path.normpath(destPath)
- if not os.path.exists(theDir):
- os.makedirs(theDir)
- # Pack an array of boolean into uint32
- def packset(a):
- b = np.packbits(a)
- newSize = int(np.ceil(b.shape[0] / 4.0)) * 4
- c = np.copy(b)
- c.resize(newSize)
- #print(c)
- vecSize = round(newSize/4)
- c=c.reshape(vecSize,4)
- #print(c)
- r = np.zeros(vecSize)
- result = []
- for i in range(0,vecSize):
- #print(c[i,:])
- #print("%X %X %X %X" % (c[i,0],c[i,1],c[i,2],c[i,3]))
- d = (c[i,0] << 24) | (c[i,1] << 16) | (c[i,2] << 8) | c[i,3]
- result.append(np.uint32(d))
- return(result)
- def float_to_hex(f):
- """ Convert and x86 float to an ARM unsigned long int.
-
- Args:
- f (float): value to be converted
- Raises:
- Nothing
- Returns:
- str : representation of the hex value
- """
- return hex(struct.unpack('<I', struct.pack('<f', f))[0])
- def float16_to_hex(f):
- """ Convert and x86 float to an ARM unsigned long int.
-
- Args:
- f (float): value to be converted
- Raises:
- Nothing
- Returns:
- str : representation of the hex value
- """
- return hex(struct.unpack('<H', struct.pack('<e', f))[0])
- def float64_to_hex(f):
- """ Convert and x86 float to an ARM unsigned long int.
-
- Args:
- f (float): value to be converted
- Raises:
- Nothing
- Returns:
- str : representation of the hex value
- """
- return hex(struct.unpack('<Q', struct.pack('<d', f))[0])
- def to_q63(v):
- r = int(round(v * 2**63))
- if (r > 0x07FFFFFFFFFFFFFFF):
- r = 0x07FFFFFFFFFFFFFFF
- if (r < -0x08000000000000000):
- r = -0x08000000000000000
- return ("0x%s" % format(struct.unpack('<Q', struct.pack('<q', r))[0],'016X'))
- def to_q31(v):
- r = int(round(v * 2**31))
- if (r > 0x07FFFFFFF):
- r = 0x07FFFFFFF
- if (r < -0x080000000):
- r = -0x080000000
- return ("0x%s" % format(struct.unpack('<I', struct.pack('<i', r))[0],'08X'))
- def to_q15(v):
- r = int(round(v * 2**15))
- if (r > 0x07FFF):
- r = 0x07FFF
- if (r < -0x08000):
- r = -0x08000
- return ("0x%s" % format(struct.unpack('<H', struct.pack('<h', r))[0],'04X'))
- def to_q7(v):
- r = int(round(v * 2**7))
- if (r > 0x07F):
- r = 0x07F
- if (r < -0x080):
- r = -0x080
- return ("0x%s" % format(struct.unpack('<B', struct.pack('<b', r))[0],'02X'))
- def s8(r):
- return ("0x%s" % format(struct.unpack('<B', struct.pack('<b', r))[0],'02X'))
- def s16(r):
- return ("0x%s" % format(struct.unpack('<H', struct.pack('<h', r))[0],'04X'))
- def s32(r):
- return ("0x%s" % format(struct.unpack('<I', struct.pack('<i', r))[0],'08X'))
- def u32(r):
- return ("0x%s" % format(struct.unpack('<I', struct.pack('<I', r))[0],'08X'))
- class Config:
- def __init__(self,patternDir,paramDir,ext):
- self._patternDir = "%s%s" % (patternDir,ext.upper())
- self._paramDir = "%s%s" % (paramDir,ext.upper())
- self._ext = ext
- self._overwrite=True
- createMissingDir(self._patternDir)
- createMissingDir(self._paramDir)
- def setOverwrite(self,v):
- self._overwrite=v
- def canOverwrite(self,path):
- return(self._overwrite or not os.path.exists(path))
- def inputP(self,i,name=None):
- """ Path to a reference pattern from the ID
-
- Args:
- i (int): ID to the reference pattern
- Raises:
- Nothing
- Returns:
- str : path to the file where to generate the pattern data
- """
- if name:
- return(os.path.join(self._patternDir,"%s%d_%s.txt" % (name,i,self._ext)))
- else:
- return(os.path.join(self._patternDir,"Input%d_%s.txt" % (i,self._ext)))
- def inputS32P(self,i,name=None):
- """ Path to a reference pattern from the ID
-
- Args:
- i (int): ID to the reference pattern
- Raises:
- Nothing
- Returns:
- str : path to the file where to generate the pattern data
- """
- if name:
- return(os.path.join(self._patternDir,"%s%d_%s.txt" % (name,i,"s32")))
- else:
- return(os.path.join(self._patternDir,"Input%d_%s.txt" % (i,"s32")))
- def inputS16P(self,i,name=None):
- """ Path to a reference pattern from the ID
-
- Args:
- i (int): ID to the reference pattern
- Raises:
- Nothing
- Returns:
- str : path to the file where to generate the pattern data
- """
- if name:
- return(os.path.join(self._patternDir,"%s%d_%s.txt" % (name,i,"s16")))
- else:
- return(os.path.join(self._patternDir,"Input%d_%s.txt" % (i,"s16")))
- def inputS8P(self,i,name=None):
- """ Path to a reference pattern from the ID
-
- Args:
- i (int): ID to the reference pattern
- Raises:
- Nothing
- Returns:
- str : path to the file where to generate the pattern data
- """
- if name:
- return(os.path.join(self._patternDir,"%s%d_%s.txt" % (name,i,"s8")))
- else:
- return(os.path.join(self._patternDir,"Input%d_%s.txt" % (i,"s8")))
- def inputF32P(self,i,name=None):
- """ Path to a reference pattern from the ID
-
- Args:
- i (int): ID to the reference pattern
- Raises:
- Nothing
- Returns:
- str : path to the file where to generate the pattern data
- """
- if name:
- return(os.path.join(self._patternDir,"%s%d_%s.txt" % (name,i,"f32")))
- else:
- return(os.path.join(self._patternDir,"Input%d_%s.txt" % (i,"f32")))
- def inputF16P(self,i,name=None):
- """ Path to a reference pattern from the ID
-
- Args:
- i (int): ID to the reference pattern
- Raises:
- Nothing
- Returns:
- str : path to the file where to generate the pattern data
- """
- if name:
- return(os.path.join(self._patternDir,"%s%d_%s.txt" % (name,i,"f16")))
- else:
- return(os.path.join(self._patternDir,"Input%d_%s.txt" % (i,"f16")))
- def inputQ31P(self,i,name=None):
- """ Path to a reference pattern from the ID
-
- Args:
- i (int): ID to the reference pattern
- Raises:
- Nothing
- Returns:
- str : path to the file where to generate the pattern data
- """
- if name:
- return(os.path.join(self._patternDir,"%s%d_%s.txt" % (name,i,"q31")))
- else:
- return(os.path.join(self._patternDir,"Input%d_%s.txt" % (i,"q31")))
- def inputQ15P(self,i,name=None):
- """ Path to a reference pattern from the ID
-
- Args:
- i (int): ID to the reference pattern
- Raises:
- Nothing
- Returns:
- str : path to the file where to generate the pattern data
- """
- if name:
- return(os.path.join(self._patternDir,"%s%d_%s.txt" % (name,i,"q15")))
- else:
- return(os.path.join(self._patternDir,"Input%d_%s.txt" % (i,"q15")))
- def inputQ7P(self,i,name=None):
- """ Path to a reference pattern from the ID
-
- Args:
- i (int): ID to the reference pattern
- Raises:
- Nothing
- Returns:
- str : path to the file where to generate the pattern data
- """
- if name:
- return(os.path.join(self._patternDir,"%s%d_%s.txt" % (name,i,"q7")))
- else:
- return(os.path.join(self._patternDir,"Input%d_%s.txt" % (i,"q7")))
- def inputU32P(self,i,name=None):
- """ Path to a reference pattern from the ID
-
- Args:
- i (int): ID to the reference pattern
- Raises:
- Nothing
- Returns:
- str : path to the file where to generate the pattern data
- """
- if name:
- return(os.path.join(self._patternDir,"%s%d_%s.txt" % (name,i,"u32")))
- else:
- return(os.path.join(self._patternDir,"Input%d_%s.txt" % (i,"u32")))
- def refP(self,i,name=None):
- """ Path to a reference pattern from the ID
-
- Args:
- i (int): ID to the reference pattern
- Raises:
- Nothing
- Returns:
- str : path to the file where to generate the pattern data
- """
- if name:
- return(os.path.join(self._patternDir,"%s%d_%s.txt" % (name,i,self._ext)))
- else:
- return(os.path.join(self._patternDir,"Reference%d_%s.txt" % (i,self._ext)))
- def refS8P(self,i,name=None):
- """ Path to a reference pattern from the ID
-
- Args:
- i (int): ID to the reference pattern
- Raises:
- Nothing
- Returns:
- str : path to the file where to generate the pattern data
- """
- if name:
- return(os.path.join(self._patternDir,"%s%d_%s.txt" % (name,i,"s8")))
- else:
- return(os.path.join(self._patternDir,"Reference%d_%s.txt" % (i,"s8")))
- def refS16P(self,i,name=None):
- """ Path to a reference pattern from the ID
-
- Args:
- i (int): ID to the reference pattern
- Raises:
- Nothing
- Returns:
- str : path to the file where to generate the pattern data
- """
- if name:
- return(os.path.join(self._patternDir,"%s%d_%s.txt" % (name,i,"s16")))
- else:
- return(os.path.join(self._patternDir,"Reference%d_%s.txt" % (i,"s16")))
- def refS32P(self,i,name=None):
- """ Path to a reference pattern from the ID
-
- Args:
- i (int): ID to the reference pattern
- Raises:
- Nothing
- Returns:
- str : path to the file where to generate the pattern data
- """
- if name:
- return(os.path.join(self._patternDir,"%s%d_%s.txt" % (name,i,"s32")))
- else:
- return(os.path.join(self._patternDir,"Reference%d_%s.txt" % (i,"s32")))
- def refQ63P(self,i,name=None):
- """ Path to a reference pattern from the ID
-
- Args:
- i (int): ID to the reference pattern
- Raises:
- Nothing
- Returns:
- str : path to the file where to generate the pattern data
- """
- if name:
- return(os.path.join(self._patternDir,"%s%d_%s.txt" % (name,i,"q63")))
- else:
- return(os.path.join(self._patternDir,"Reference%d_%s.txt" % (i,"q63")))
- def refQ31P(self,i,name=None):
- """ Path to a reference pattern from the ID
-
- Args:
- i (int): ID to the reference pattern
- Raises:
- Nothing
- Returns:
- str : path to the file where to generate the pattern data
- """
- if name:
- return(os.path.join(self._patternDir,"%s%d_%s.txt" % (name,i,"q31")))
- else:
- return(os.path.join(self._patternDir,"Reference%d_%s.txt" % (i,"q31")))
- def refF32P(self,i,name=None):
- """ Path to a reference pattern from the ID
-
- Args:
- i (int): ID to the reference pattern
- Raises:
- Nothing
- Returns:
- str : path to the file where to generate the pattern data
- """
- if name:
- return(os.path.join(self._patternDir,"%s%d_%s.txt" % (name,i,"f32")))
- else:
- return(os.path.join(self._patternDir,"Reference%d_%s.txt" % (i,"f32")))
- def refF16P(self,i,name=None):
- """ Path to a reference pattern from the ID
-
- Args:
- i (int): ID to the reference pattern
- Raises:
- Nothing
- Returns:
- str : path to the file where to generate the pattern data
- """
- if name:
- return(os.path.join(self._patternDir,"%s%d_%s.txt" % (name,i,"f16")))
- else:
- return(os.path.join(self._patternDir,"Reference%d_%s.txt" % (i,"f16")))
- def paramP(self,i,name=None):
- """ Path to a parameters from the ID
-
- Args:
- i (int): ID to the params
- Raises:
- Nothing
- Returns:
- str : path to the file where to generate the pattern data
- """
- if name:
- return(os.path.join(self._paramDir,"%s%d.txt" % (name,i)))
- else:
- return(os.path.join(self._paramDir,"Params%d.txt" % i))
- def _writeVectorF64(self,i,data):
- """ Write pattern data
-
- The format is recognized by the text framework script.
- First line is the sample width (B,H or W,D for 8,16,32 or 64 bits)
- Second line is number of samples
- Other lines are hexadecimal representation of the samples in format
- which can be read on big endian ARM.
-
- Args:
- j (int): ID of pattern file
- data (array): Vector containing the data
- Raises:
- Nothing
- Returns:
- Nothing
- """
- if self.canOverwrite(i):
- with open(i,"w") as f:
- # Write sample dimension nb sample header
- #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
- f.write("D\n%d\n" % len(data))
- for v in data:
- f.write("// %f\n" % v)
- f.write("%s\n" % float64_to_hex(v))
- def _writeVectorF32(self,i,data):
- """ Write pattern data
-
- The format is recognized by the text framework script.
- First line is the sample width (B,H or W for 8,16 or 32 bits)
- Second line is number of samples
- Other lines are hexadecimal representation of the samples in format
- which can be read on big endian ARM.
-
- Args:
- j (int): ID of pattern file
- data (array): Vector containing the data
- Raises:
- Nothing
- Returns:
- Nothing
- """
- if self.canOverwrite(i):
- with open(i,"w") as f:
- # Write sample dimension nb sample header
- #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
- f.write("W\n%d\n" % len(data))
- for v in data:
- f.write("// %f\n" % v)
- f.write("%s\n" % float_to_hex(v))
- def _writeVectorF16(self,i,data):
- """ Write pattern data
-
- The format is recognized by the text framework script.
- First line is the sample width (B,H or W for 8,16 or 32 bits)
- Second line is number of samples
- Other lines are hexadecimal representation of the samples in format
- which can be read on big endian ARM.
-
- Args:
- j (int): ID of pattern file
- data (array): Vector containing the data
- Raises:
- Nothing
- Returns:
- Nothing
- """
- if self.canOverwrite(i):
- with open(i,"w") as f:
- # Write sample dimension nb sample header
- #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
- f.write("H\n%d\n" % len(data))
- for v in data:
- f.write("// %f\n" % v)
- f.write("%s\n" % float16_to_hex(v))
- def _writeVectorQ63(self,i,data):
- """ Write pattern data
-
- The format is recognized by the text framework script.
- First line is the sample width (B,H or W for 8,16 or 32 bits)
- Second line is number of samples
- Other lines are hexadecimal representation of the samples in format
- which can be read on big endian ARM.
-
- Args:
- j (int): ID of pattern file
- data (array): Vector containing the data
- Raises:
- Nothing
- Returns:
- Nothing
- """
- if self.canOverwrite(i):
- with open(i,"w") as f:
- # Write sample dimension nb sample header
- #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
- f.write("D\n%d\n" % len(data))
- for v in data:
- f.write("// %f\n" % v)
- f.write("%s\n" % to_q63(v))
- def _writeVectorQ31(self,i,data):
- """ Write pattern data
-
- The format is recognized by the text framework script.
- First line is the sample width (B,H or W for 8,16 or 32 bits)
- Second line is number of samples
- Other lines are hexadecimal representation of the samples in format
- which can be read on big endian ARM.
-
- Args:
- j (int): ID of pattern file
- data (array): Vector containing the data
- Raises:
- Nothing
- Returns:
- Nothing
- """
- if self.canOverwrite(i):
- with open(i,"w") as f:
- # Write sample dimension nb sample header
- #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
- f.write("W\n%d\n" % len(data))
- for v in data:
- f.write("// %f\n" % v)
- f.write("%s\n" % to_q31(v))
- def _writeVectorQ15(self,i,data):
- """ Write pattern data
-
- The format is recognized by the text framework script.
- First line is the sample width (B,H or W for 8,16 or 32 bits)
- Second line is number of samples
- Other lines are hexadecimal representation of the samples in format
- which can be read on big endian ARM.
-
- Args:
- j (int): ID of pattern file
- data (array): Vector containing the data
- Raises:
- Nothing
- Returns:
- Nothing
- """
- if self.canOverwrite(i):
- with open(i,"w") as f:
- # Write sample dimension nb sample header
- #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
- f.write("H\n%d\n" % len(data))
- for v in data:
- f.write("// %f\n" % v)
- f.write("%s\n" % to_q15(v))
- def _writeVectorS16(self,i,data):
- """ Write pattern data
-
- The format is recognized by the text framework script.
- First line is the sample width (B,H or W for 8,16 or 32 bits)
- Second line is number of samples
- Other lines are hexadecimal representation of the samples in format
- which can be read on big endian ARM.
-
- Args:
- j (int): ID of pattern file
- data (array): Vector containing the data
- Raises:
- Nothing
- Returns:
- Nothing
- """
- if self.canOverwrite(i):
- with open(i,"w") as f:
- # Write sample dimension nb sample header
- #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
- f.write("H\n%d\n" % len(data))
- for v in data:
- f.write("// %d\n" % v)
- f.write("%s\n" % s16(v))
- def _writeVectorS32(self,i,data):
- """ Write pattern data
-
- The format is recognized by the text framework script.
- First line is the sample width (B,H or W for 8,16 or 32 bits)
- Second line is number of samples
- Other lines are hexadecimal representation of the samples in format
- which can be read on big endian ARM.
-
- Args:
- j (int): ID of pattern file
- data (array): Vector containing the data
- Raises:
- Nothing
- Returns:
- Nothing
- """
- if self.canOverwrite(i):
- with open(i,"w") as f:
- # Write sample dimension nb sample header
- #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
- f.write("W\n%d\n" % len(data))
- for v in data:
- f.write("// %d\n" % v)
- f.write("%s\n" % s32(v))
- def _writeVectorU32(self,i,data):
- """ Write pattern data
-
- The format is recognized by the text framework script.
- First line is the sample width (B,H or W for 8,16 or 32 bits)
- Second line is number of samples
- Other lines are hexadecimal representation of the samples in format
- which can be read on big endian ARM.
-
- Args:
- j (int): ID of pattern file
- data (array): Vector containing the data
- Raises:
- Nothing
- Returns:
- Nothing
- """
- if self.canOverwrite(i):
- with open(i,"w") as f:
- # Write sample dimension nb sample header
- #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
- f.write("W\n%d\n" % len(data))
- for v in data:
- f.write("// %s\n" % v)
- f.write("%s\n" % u32(v))
- def _writeVectorQ7(self,i,data):
- """ Write pattern data
-
- The format is recognized by the text framework script.
- First line is the sample width (B,H or W for 8,16 or 32 bits)
- Second line is number of samples
- Other lines are hexadecimal representation of the samples in format
- which can be read on big endian ARM.
-
- Args:
- j (int): ID of pattern file
- data (array): Vector containing the data
- Raises:
- Nothing
- Returns:
- Nothing
- """
- if self.canOverwrite(i):
- with open(i,"w") as f:
- # Write sample dimension nb sample header
- #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
- f.write("B\n%d\n" % len(data))
- for v in data:
- f.write("// %f\n" % v)
- f.write("%s\n" % to_q7(v))
- def _writeVectorS8(self,i,data):
- """ Write pattern data
-
- The format is recognized by the text framework script.
- First line is the sample width (B,H or W for 8,16 or 32 bits)
- Second line is number of samples
- Other lines are hexadecimal representation of the samples in format
- which can be read on big endian ARM.
-
- Args:
- j (int): ID of pattern file
- data (array): Vector containing the data
- Raises:
- Nothing
- Returns:
- Nothing
- """
- if self.canOverwrite(i):
- with open(i,"w") as f:
- # Write sample dimension nb sample header
- #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
- f.write("B\n%d\n" % len(data))
- for v in data:
- f.write("// %d\n" % v)
- f.write("%s\n" % s8(v))
- def writeReference(self,j,data,name=None):
- if (self._ext == "f64"):
- self._writeVectorF64(self.refP(j,name),data)
- if (self._ext == "f32"):
- self._writeVectorF32(self.refP(j,name),data)
- if (self._ext == "f16"):
- self._writeVectorF16(self.refP(j,name),data)
- if (self._ext == "q63"):
- self._writeVectorQ63(self.refP(j,name),data)
- if (self._ext == "q31"):
- self._writeVectorQ31(self.refP(j,name),data)
- if (self._ext == "q15"):
- self._writeVectorQ15(self.refP(j,name),data)
- if (self._ext == "q7"):
- self._writeVectorQ7(self.refP(j,name),data)
- if (self._ext == "u32"):
- self._writeVectorU32(self.refP(j,name),data)
- if (self._ext == "s8"):
- self._writeVectorS8(self.refP(j,name),data)
- def writeReferenceQ63(self,j,data,name=None):
- self._writeVectorQ63(self.refQ63P(j,name),data)
- def writeReferenceQ31(self,j,data,name=None):
- self._writeVectorQ31(self.refQ31P(j,name),data)
- def writeReferenceS8(self,j,data,name=None):
- self._writeVectorS8(self.refS8P(j,name),data)
- def writeReferenceS16(self,j,data,name=None):
- self._writeVectorS16(self.refS16P(j,name),data)
-
- def writeReferenceS32(self,j,data,name=None):
- self._writeVectorS32(self.refS32P(j,name),data)
- def writeReferenceF32(self,j,data,name=None):
- self._writeVectorF32(self.refF32P(j,name),data)
- def writeReferenceF16(self,j,data,name=None):
- self._writeVectorF16(self.refF16P(j,name),data)
- def writeInput(self,j,data,name=None):
- if (self._ext == "f64"):
- self._writeVectorF64(self.inputP(j,name),data)
- if (self._ext == "f32"):
- self._writeVectorF32(self.inputP(j,name),data)
- if (self._ext == "f16"):
- self._writeVectorF16(self.inputP(j,name),data)
- if (self._ext == "q31"):
- self._writeVectorQ31(self.inputP(j,name),data)
- if (self._ext == "q15"):
- self._writeVectorQ15(self.inputP(j,name),data)
- if (self._ext == "q7"):
- self._writeVectorQ7(self.inputP(j,name),data)
- if (self._ext == "u32"):
- self._writeVectorU32(self.inputP(j,name),data)
- if (self._ext == "s8"):
- self._writeVectorS8(self.inputP(j,name),data)
- def writeInputF32(self,j,data,name=None):
- self._writeVectorF32(self.inputF32P(j,name),data)
- def writeInputF16(self,j,data,name=None):
- self._writeVectorF16(self.inputF16P(j,name),data)
- def writeInputQ31(self,j,data,name=None):
- self._writeVectorQ31(self.inputQ31P(j,name),data)
- def writeInputQ15(self,j,data,name=None):
- self._writeVectorQ15(self.inputQ15P(j,name),data)
- def writeInputQ7(self,j,data,name=None):
- self._writeVectorQ7(self.inputQ7P(j,name),data)
- def writeInputS32(self,j,data,name=None):
- self._writeVectorS32(self.inputS32P(j,name),data)
- def writeInputS16(self,j,data,name=None):
- self._writeVectorS16(self.inputS16P(j,name),data)
- def writeInputS8(self,j,data,name=None):
- self._writeVectorS8(self.inputS8P(j,name),data)
- def writeInputU32(self,j,data,name=None):
- self._writeVectorU32(self.inputU32P(j,name),data)
- def writeParam(self,j,data,name=None):
- """ Write pattern data
-
- The format is recognized by the text framework script.
- First line is the sample width (B,H or W for 8,16 or 32 bits)
- Second line is number of samples
- Other lines are hexadecimal representation of the samples in format
- which can be read on big endian ARM.
-
- Args:
- j (int): ID of parameter file
- data (array): Vector containing the data
- Raises:
- Nothing
- Returns:
- Nothing
- """
- i=self.paramP(j,name)
- if self.canOverwrite(i):
- with open(i,"w") as f:
- # Write sample dimension nb sample header
- #np.savetxt(i, data, newline="\n", header="W\n%d" % len(data),comments ="" )
- f.write("%d\n" % len(data))
- for v in data:
- f.write("%d\n" % v)
|