Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linting fixes for PEP-8 conformance. #1260

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions MIVisionX-setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@
if "centos-7" in platfromInfo or "redhat-7" in platfromInfo:
linuxCMake = 'cmake3'
os.system(linuxSystemInstall+' install cmake3')
if not "centos" in platfromInfo or not "redhat" in platfromInfo:
if "centos" not in platfromInfo or "redhat" not in platfromInfo:
platfromInfo = platfromInfo+'-redhat'
elif "Ubuntu" in platfromInfo or os.path.exists('/usr/bin/apt-get'):
linuxSystemInstall = 'apt-get -y'
linuxSystemInstall_check = '--allow-unauthenticated'
linuxFlag = '-S'
if not "Ubuntu" in platfromInfo:
if "Ubuntu" not in platfromInfo:
platfromInfo = platfromInfo+'-Ubuntu'
elif os.path.exists('/usr/bin/zypper'):
linuxSystemInstall = 'zypper -n'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
(153,76,0), # Top3
(0,128,255), # Top4
(255,102,102), # Top5
];
]

# AMD Neural Net python wrapper
class AnnAPI:
Expand Down Expand Up @@ -68,7 +68,7 @@ def __init__(self, annpythonlib, weightsfile):
output,opName,n_o,c_o,h_o,w_o = output_info.split(',')
else:
output,opName,n_o,c_o= output_info.split(',')
h_o = '1'; w_o = '1';
h_o = '1'; w_o = '1'
self.hdl = self.api.annCreateInference(weightsfile.encode('utf-8'))
self.dim = (int(w_i),int(h_i))
self.outputDim = (int(n_o),int(c_o),int(h_o),int(w_o))
Expand Down Expand Up @@ -351,7 +351,7 @@ def processClassificationOutput(inputImage, modelName, modelOutput):
classifier = annieObjectWrapper(pythonLib, weightsFile)

# check for image val text
totalImages = 0;
totalImages = 0
if(imageVal == ''):
print("\nFlow without Image Validation Text..Creating a file with no ground truths\n")
imageList = os.listdir(inputImageDir)
Expand Down Expand Up @@ -380,7 +380,7 @@ def processClassificationOutput(inputImage, modelName, modelOutput):
sys.stdout = orig_stdout

# process images
correctTop5 = 0; correctTop1 = 0; wrong = 0; noGroundTruth = 0;
correctTop5 = 0; correctTop1 = 0; wrong = 0; noGroundTruth = 0
for x in range(totalImages):
imageFileName,grountTruth = imageValidation[x].split(' ')
groundTruthIndex = int(grountTruth)
Expand Down
2 changes: 1 addition & 1 deletion apps/mivisionx_validation_tool/inference_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, annpythonlib, weightsfile):
output,opName,n_o,c_o,h_o,w_o = output_info.split(',')
else:
output,opName,n_o,c_o= output_info.split(',')
h_o = '1'; w_o = '1';
h_o = '1'; w_o = '1'
self.hdl = self.api.annCreateInference(weightsfile.encode('utf-8'))
self.dim = (int(w_i),int(h_i))
self.outputDim = (int(n_o),int(c_o),int(h_o),int(w_o))
Expand Down
4 changes: 2 additions & 2 deletions apps/mivisionx_validation_tool/inference_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ def showImage(self):
qOrigImageResized = qOrigImage.scaled(self.image_label.width(), self.image_label.height(), QtCore.Qt.IgnoreAspectRatio)
index = self.imgCount % self.frameCount
self.origImage_layout.itemAt(index).widget().setPixmap(QtGui.QPixmap.fromImage(qOrigImageResized))
self.origImage_layout.itemAt(index).widget().setStyleSheet("border: 5px solid yellow;");
self.origImage_layout.itemAt(self.lastIndex).widget().setStyleSheet("border: 0");
self.origImage_layout.itemAt(index).widget().setStyleSheet("border: 5px solid yellow;")
self.origImage_layout.itemAt(self.lastIndex).widget().setStyleSheet("border: 0")
self.imgCount += 1
self.lastIndex = index

Expand Down
18 changes: 9 additions & 9 deletions model_compiler/python/nnir.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ def __init__(self):
self.dict_set = []

def set(self,name,value):
if not name in self.dict_values:
if name not in self.dict_values:
raise ValueError("Unsupported IR attribute: {}".format(name))
if type(value) != type(self.dict_values[name]):
raise ValueError("Invalid IR attribute value type: {} for {}".format(type(value).__name__, name))
self.dict_values[name] = value
if not name in self.dict_set:
if name not in self.dict_set:
self.dict_set.append(name)

def is_set(self,name):
Expand Down Expand Up @@ -227,7 +227,7 @@ def __init__(self):
}

def set(self,type,inputs,outputs,attr):
if not type in self.dict_types or self.dict_types[type] == 0:
if type not in self.dict_types or self.dict_types[type] == 0:
print('ERROR: IrNode.set: operation "%s" not supported' % (type))
sys.exit(1)
self.type = type
Expand Down Expand Up @@ -307,7 +307,7 @@ def addLocal(self,tensor):
self.all_F032 = False
if self.all_F016 == True and tensor.type == 'F032':
self.all_F016 = False
if not tensor.name in self.output_names:
if tensor.name not in self.output_names:
self.locals.append(tensor)

def addNode(self,node):
Expand Down Expand Up @@ -873,7 +873,7 @@ def removeUnusedTensors(self):
for name in self.tensor_dict:
fullTensorList.append(name)
for name in fullTensorList:
if not name in usedTensorList:
if name not in usedTensorList:
self.removeTensor(name)

def updateBatchSize(self,batchSize):
Expand Down Expand Up @@ -1037,15 +1037,15 @@ def fuseOps(self):
prevNode = node
prevOutput = node.outputs[0]
elif node.type == 'copy':
if prevSkipNode != None:
if prevSkipNode is not None:
prevSkipNode.outputs[0] = node.outputs[0]
else:
prevNode.outputs[0] = node.outputs[0]
prevOutput = node.outputs[0]
nodesToRemove.append(node)
fusedAnOp = True
elif node.type == 'transpose':
if prevSkipNode != None:
if prevSkipNode is not None:
prevSkipNode.outputs[0] = node.outputs[0]
else:
prevNode.outputs[0] = node.outputs[0]
Expand Down Expand Up @@ -1124,7 +1124,7 @@ def fuseOps(self):
weight = weight * np.repeat(scale, N)
self.addBinary(prevNode.inputs[1], weight.view())
self.addBinary(prevNode.inputs[2], bias.view())
if prevSkipNode != None:
if prevSkipNode is not None:
prevSkipNode.outputs[0] = node.outputs[0]
else:
prevNode.outputs[0] = node.outputs[0]
Expand All @@ -1145,7 +1145,7 @@ def fuseOps(self):
leaky_alpha = 0.0
prevNode.attr.set('mode', 1)
prevNode.attr.set('alpha', leaky_alpha)
if prevSkipNode != None:
if prevSkipNode is not None:
prevSkipNode.outputs[0] = node.outputs[0]
else:
prevNode.outputs[0] = node.outputs[0]
Expand Down
4 changes: 2 additions & 2 deletions model_compiler/python/nnir_to_clib.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ def generateModuleCPP(graph, fileName):
for tensor in graph.outputs:
outputList.append(tensor.name)
for idx, tensor in enumerate(graph.locals):
if (not tensor.name in outputList) and (not tensor.name in localList[:idx]):
if (tensor.name not in outputList) and (tensor.name not in localList[:idx]):
f.write(
""" vx_size dims_%s[%d] = { %s };
vx_tensor %s = vxCreateVirtualTensor(graph, %d, dims_%s, %s, 0);
Expand Down Expand Up @@ -927,7 +927,7 @@ def generateModuleCPP(graph, fileName):
// release local tensors
""")
for idx, tensor in enumerate(graph.locals):
if (not tensor.name in outputList) and (not tensor.name in localList[:idx]):
if (tensor.name not in outputList) and (tensor.name not in localList[:idx]):
f.write(
""" ERROR_CHECK_STATUS(vxReleaseTensor(&%s));
""" % (tensor.name))
Expand Down
Loading