hasktorch-indef- Core Hasktorch abstractions wrapping FFI bindings

Copyright(c) Sam Stites 2017
Safe HaskellNone



Redundant version of Torch.Indef.{Dynamic/Static}.Tensor for Index tensors.

FIXME: in the future, there could be a smaller subset of Torch which could be compiled to to keep the code dry. Alternatively, if backpack one day supports recursive indefinites, we could use this feature to possibly remove this package and Mask.



esingleton :: Enum i => i -> IndexTensor '[1] Source #

newIx :: forall d. Dimensions d => IndexTensor d Source #

build a new static index tensor

FIXME: This can abstracted away with backpack, but I'm not sure if it can do it atm.

newIxDyn :: Integral i => [i] -> IndexDynamic Source #

build a new 1-dimensional, dynamically-typed index tensor of lenght i

zeroIxNd :: Dimensions d => IndexTensor d Source #

build a new, empty, static index tensor with no term-level dimensions -- but allow the type-level dimensions to vary.

FIXME: this is a bad function and should be replaced with a new function.

index :: forall n. KnownDim n => [Integer] -> Maybe (IndexTensor '[n]) Source #

purely make a 1d static index tensor from a list of integers. Returns Nothing if the list does not match the expected size of the tensor.

should be depreciated in favor of index1d

index1d :: KnownDim n => [Integer] -> Maybe (IndexTensor '[n]) Source #

alias to index and should subsume it when this package no longer assumes that index tensors are 1d.

indexNd :: forall d. KnownDim (Product d) => [Integer] -> Maybe (IndexTensor d) Source #

n-dimensional version of index1d.

FIXME: this relies on indexDyn which only makes 1d tensors.

indexDyn :: [Integer] -> IndexDynamic Source #

Make a dynamic, 1d index tensor from a list.

FIXME construct this with TH, not with the setting, which might be doing a second linear pass

mkCPUIx :: Ptr C'THLongTensor -> IO LongDynamic Source #

make a dynamic CPU tensor from a raw torch ctensor

withCPUIxStorage :: LongStorage -> (Ptr C'THLongStorage -> IO x) -> IO x Source #

run a function with access to a raw CPU-bound Long tensor storage.

withIxStorage :: IndexStorage -> (Ptr CLongStorage -> IO x) -> IO x Source #

run a function with access to a dynamic index storage's raw internal state and c-pointer.

withDynamicState :: IndexDynamic -> (Ptr CState -> Ptr CLongTensor -> IO x) -> IO x Source #

run a function with access to a dynamic index tensor's raw internal state and c-pointer.

mkCPUIxStorage :: Ptr C'THLongStorage -> IO LongStorage Source #

make a dynamic CPU tensor's storage from a raw torch LongStorage

ixShape :: IndexTensor d -> [Word] Source #

get the shape of a static index tensor from the term-level

ixCPUStorage :: [Integer] -> IO LongStorage Source #

Convenience method for newWithData specific to longs for making CPU Long storage.

showIx :: IndexTensor d -> [Char] Source #

show an index.

FIXME: because we are using backpack, we can't declare a show instance on the IndexTensor both here and in the signatures. /if we want this functionality we must operate on raw code and write the show instance in hasktorch-types/.