1# model 2model = Model() 3sparseData = Input("sparseData", "TENSOR_FLOAT32", "{210}") 4traversalOrder = Parameter("traversalOrder", "TENSOR_INT32", "{4}", [0, 1, 2, 3]) 5blockMap = Parameter("blockMap", "TENSOR_INT32", "{2}", [0, 1]) 6dimFormat = Parameter("dimFormat", "TENSOR_INT32", "{4}", [0, 0, 0, 0]) 7dimensions = Parameter("dimensions", "TENSOR_INT32", "{4}", [2, 3, 5, 7]) 8d0ArrSegments = Parameter("d0ArrSegments", "TENSOR_INT32", "{0}", []) 9d0ArrIndices = Parameter("d0ArrIndices", "TENSOR_INT32", "{0}", []) 10d1ArrSegments = Parameter("d1ArrSegments", "TENSOR_INT32", "{0}", []) 11d1ArrIndices = Parameter("d1ArrIndices", "TENSOR_INT32", "{0}", []) 12d2ArrSegments = Parameter("d2ArrSegments", "TENSOR_INT32", "{0}", []) 13d2ArrIndices = Parameter("d2ArrIndices", "TENSOR_INT32", "{0}", []) 14d3ArrSegments = Parameter("d3ArrSegments", "TENSOR_INT32", "{0}", []) 15d3ArrIndices = Parameter("d3ArrIndices", "TENSOR_INT32", "{0}", []) 16denseOut = Output("denseOut", "TENSOR_FLOAT32", "{10, 21}") 17model = model.Operation("DENSIFY", sparseData, traversalOrder, blockMap, 18 dimFormat, dimensions, d0ArrSegments, d0ArrIndices, d1ArrSegments, 19 d1ArrIndices, d2ArrSegments, d2ArrIndices, d3ArrSegments, 20 d3ArrIndices).To(denseOut) 21 22inputData = [0.0] * 210 23inputData[0:22:7] = [11.0, 13.0, 17.0, 19.0] 24# Example 1. Input in operand 0, 25input0 = {sparseData: # input 0 26 inputData} 27 28outputData = [0.0] * 210 29outputData[0:64:21] = [11.0, 13.0, 17.0, 19.0] 30output0 = {denseOut: # output 0 31 outputData} 32 33quant8_symm = DataTypeConverter().Identify({ 34 sparseData: ("TENSOR_QUANT8_SYMM", 2.0), 35 denseOut: ("TENSOR_QUANT8_SYMM", 2.0) 36}) 37 38quant8_asymm = DataTypeConverter().Identify({ 39 sparseData: ("TENSOR_QUANT8_ASYMM", 0.5, 4), 40 denseOut: ("TENSOR_QUANT8_ASYMM", 0.5, 4) 41}) 42 43quant8_asymm_signed = DataTypeConverter().Identify({ 44 sparseData: ("TENSOR_QUANT8_ASYMM_SIGNED", 2.5, -9), 45 denseOut: ("TENSOR_QUANT8_ASYMM_SIGNED", 2.5, -9) 46}) 47 48quant16_symm = DataTypeConverter().Identify({ 49 sparseData: ("TENSOR_QUANT16_SYMM", 3.0), 50 denseOut: ("TENSOR_QUANT16_SYMM", 3.0) 51}) 52 53quant16_asymm = DataTypeConverter().Identify({ 54 sparseData: ("TENSOR_QUANT16_ASYMM", 2.0, 4), 55 denseOut: ("TENSOR_QUANT16_ASYMM", 2.0, 4) 56}) 57 58# Instantiate an example 59Example((input0, output0)).AddVariations("relaxed", "float16", "int32", quant8_symm, 60 quant8_asymm, quant8_asymm_signed, quant16_symm, 61 quant16_asymm) 62