A SWKStorage is collection of Float data type.
There are also predefined storages for other primitive data types:
SWKByteStorage, corresponding to Swift's Int8 type;
SWKCharStorage, corresponding to Swift's Character type;
SWKShortStorage, corresponding to Swift's Int16 type;
SWKIntStorage, corresponding to Swift's Int32 type;
SWKLongStorage, corresponding to Swift's Int64 type;
SWKFloatStorage (same as SWKStorage), corresponding to Swift's Float type;
SWKDoubleStorage, corresponding to Swift's Double type.
You don't usually create SWKStorage as it's automatically allocated in tensors.
In case you still need to create storage yourself, there are two ways how to do it:
// 1. Creates uninitialized storage of size 10
var storage = SWKStorage(10)
// 2. Creates storage of size 4 with elements initialized from the array
var storage = SWKStorage([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
// Some properties of the storage.
print(storage.size) // 10 -- number of elements
print(storage.elementSize) // 4 -- bytes taken by each element
print(storage[5]) // 6.0 -- value of the 6th element
Features in this PR
elementSize
size of each elementSubtask of #7
A
SWKStorage
is collection ofFloat
data type. There are also predefined storages for other primitive data types:SWKByteStorage
, corresponding to Swift'sInt8
type;SWKCharStorage
, corresponding to Swift'sCharacter
type;SWKShortStorage
, corresponding to Swift'sInt16
type;SWKIntStorage
, corresponding to Swift'sInt32
type;SWKLongStorage
, corresponding to Swift'sInt64
type;SWKFloatStorage
(same asSWKStorage
), corresponding to Swift'sFloat
type;SWKDoubleStorage
, corresponding to Swift'sDouble
type. You don't usually createSWKStorage
as it's automatically allocated in tensors. In case you still need to create storage yourself, there are two ways how to do it: