sparseTensor(sparseTensorWithType:tensors:shape:dataType:name:)
Creates a sparse tensor representation.
Declaration
func sparseTensor(sparseTensorWithType sparseStorageType: MPSGraphSparseStorageType, tensors inputTensorArray: [MPSGraphTensor], shape: [NSNumber], dataType: MPSDataType, name: String?) -> MPSGraphTensorParameters
- sparseStorageType:
A sparseStorageType.
- inputTensorArray:
An array of input tensors as [sparseVals, indexTensor0, indexTensor1].
- shape:
The shape of the sparse tensor.
- dataType:
The dataType of the sparse tensor.
- name:
A name for the operation.
Return Value
A valid MPSGraphTensor object.
Discussion
sparseVals corresponds to non zero values in matrix. indexTensor0 and indexTensor1 are indices used for indexing into sparse data structure. For COO, indexTensor0 is x index and indexTensor1 is y index. For CSC, indexTensor0 and indexTensor1 correspond to rowIndex and colStarts respectively. For CSR, indexTensor0 and indexTensor1 correspond to colIndex and rowStarts respectively. You must set input tensors appropriately for each sparse storage type.