⌂ Modules nupp nupp.gpu nupp.gpu.layout nupp.gpu.layout
Where an element of a tensor actually is.
A layout is a shape, a stride per dimension, and an offset. nupp.gpu uses these to say what a view of a buffer covers without copying it, and the algebra here -- slicing, transposing, reshaping -- returns a new layout over the same storage.
const layout = require ( "nupp.gpu.layout" )
const rows = layout . new ( { 4 , 4 } , { 4 , 1 } )
const column = layout . subview ( rows , { 0 , 2 } , { 4 , 1 } )
print ( column : offset ( ) , column : isDense ( ) )
Every operation is checked, so a layout that would read outside its extent is refused rather than produced. A layout knows whether it is dense and whether its stride structure proves that writes use distinct element offsets. A false injectivity result can also mean the bounded stride proof was inconclusive.
Module contents Types Type Kind Description Layoutrecord
Functions Function Kind Description asStridedfunction broadcastfunction newfunction Checks a shape and its strides, with the element offset of the first element, 0 unless given. subviewfunction transposefunction
Types
Layoutrecord
Members Name Kind Description countfield offsetmethod The element offset of the layout's first element. extentmethod One more than the largest element offset the layout reaches, measured from its first element. dimensionsmethod The logical shape. stridesmethod The element stride of each dimension. isDensemethod Reports whether the elements occupy a dense row-major range. isInjectivemethod Reports whether the layout's strides prove that element offsets are distinct.
offsetmethod
offset : function offset ( borrows self ) : integer
The element offset of the layout's first element.
Arguments Name Type Description borrows selfany
Returns
extentmethod
extent : function extent ( borrows self ) : integer
One more than the largest element offset the layout reaches, measured from its first element.
Arguments Name Type Description borrows selfany
Returns
dimensionsmethod
dimensions : function dimensions ( borrows self ) : { integer }
The logical shape. The returned table is a copy.
Arguments Name Type Description borrows selfany
Returns
stridesmethod
strides : function strides ( borrows self ) : { integer }
The element stride of each dimension. The returned table is a copy.
Arguments Name Type Description borrows selfany
Returns
isDensemethod
isDense : function isDense ( borrows self ) : boolean
Reports whether the elements occupy a dense row-major range.
Arguments Name Type Description borrows selfany
Returns
isInjectivemethod
isInjective : function isInjective ( borrows self ) : boolean
Reports whether the layout's strides prove that element offsets are distinct.
A false result also covers layouts for which the bounded stride proof is inconclusive.
Arguments Name Type Description borrows selfany
Returns
Functions
layout.asStridedfunction
Arguments Name Type Description borrows valuelayout . Layout shape{ integer } strides{ integer } relativeOffsetinteger
Returns
layout.broadcastfunction
Arguments
Returns
layout.newfunction
Checks a shape and its strides, with the element offset of the first element, 0 unless given.
Arguments Name Type Description shape{ integer } strides{ integer } offsetinteger ?
Returns
Raises Type Condition string when the shape, strides or offset do not fit uint32
layout.subviewfunction
Arguments Name Type Description borrows valuelayout . Layout origin{ integer } shape{ integer }
Returns
layout.transposefunction
Arguments
Returns
← Previous nupp.gpu Next → nupp.gpu.spi