Set AssertStride*Equal in convolution setup
@@ -85,7 +85,7 @@ class Convolution:
def __repr__(self):
return self.shortChar
- SummaryProperties=[\
+ SummaryProblemProperties=[\
'OperationType','DestDataType','DataType','HighPrecisionAccumulate',\
'TensorAFormat','TensorBFormat','TensorDFormat',\
'Filter', 'Stride','Dilation','PadStart','PadEnd','GroupCount',\
@@ -94,8 +94,14 @@ class Convolution:
'SetConstStrideA', 'SetConstStrideB',\
'UseBeta', 'UseInitialStridesAB', 'UseInitialStridesCD', \
]
+ SummarySolutionProperties=[\
+ 'AssertStrideAEqual', 'AssertStrideBEqual', 'AssertSizeEqual', \
+ ]
def __init__(self, problemTypeOut, convolutionType, config):
+ """
+ problemTypeOut contains problem type parms created by this constructor.
+ """
self.convolutionDims={};
self.convolutionType = convolutionType
@@ -299,17 +305,27 @@ class Convolution:
problemTypeOut["IndexAssignmentsB"] = [x[0] for x in self.indexB]
problemTypeOut["UseBeta"] = False # MI kernels don't use beta
+ self.solutionParms = {}
+
problemTypeOut["SetConstStrideA"]=[]
for (idx,fbs,dim) in self.indexA:
if dim.strideA != -1:
problemTypeOut["SetConstStrideA"].append([idx,dim.strideA])
problemTypeOut["SetConstStrideA"].sort()
+ if problemTypeOut["SetConstStrideA"]:
+ self.solutionParms["AssertStrideAEqual"] = \
+ ",".join(["%d:%d"%(problemTypeOut["IndexAssignmentsA"].index(s[0]),s[1]) \
+ for s in problemTypeOut["SetConstStrideA"]])
problemTypeOut["SetConstStrideB"]=[]
for (idx,fbs,dim) in self.indexB:
if dim.strideB != -1:
problemTypeOut["SetConstStrideB"].append([idx,dim.strideB])
problemTypeOut["SetConstStrideB"].sort()
+ if problemTypeOut["SetConstStrideB"]:
+ self.solutionParms["AssertStrideBEqual"] = \
+ ",".join(["%d:%d"%(problemTypeOut["IndexAssignmentsB"].index(s[0]),s[1]) \
+ for s in problemTypeOut["SetConstStrideB"]])
if [x for x in problemTypeOut["SetConstStrideA"] if x==[0,1]] or \
[x for x in problemTypeOut["SetConstStrideB"] if x==[0,1]]:
@@ -517,12 +533,21 @@ class Convolution:
print ()
print ("ProblemType Definition:")
- for k in Convolution.SummaryProperties:
+ for k in Convolution.SummaryProblemProperties:
try:
print (" ", k, ":", problemType[k])
except KeyError:
pass
+ print ()
+ print ("Solution Assertions:")
+ for k in Convolution.SummarySolutionProperties:
+ try:
+ print (" ", k, ":", self.solutionParms[k])
+ except KeyError:
+ pass
+
+
def checkDims(self, freeIndices, batchIndices, sumIndices):
for dimList in (self.indexA, self.indexB):
for (idx,fbs,dim) in dimList:
@@ -1567,6 +1592,7 @@ class Solution:
@staticmethod
def addConstStride(state, key, value):
try:
+ if value not in state[key].replace(' ','').split(','):
state[key] = state[key] + ", " + value
except KeyError:
state[key] = value
@@ -1637,7 +1663,8 @@ class Solution:
except KeyError:
None
if not found:
- Solution.addConstStride(state, "AssertStride%sEqual"%tc, "%d:0"%bi)
+ Solution.addConstStride(state, "AssertStride%sEqual"%tc, \
+ "%d:0" % problemType["IndexAssignments%s"%tc].index(bi))
for idx in problemType["IndexAssignmentsA"]:
if isPackedIndex(state, idx, 0x1):
