toGPUVector

Convert a vector to a torch tensor on the active backend

Description

As toGPUMatrix, for a numeric vector; optionally broadcasts a length-1 vec to length n.

Usage

toGPUVector(vec, n = NULL, backend = c("auto", "cpu", "gpu"))

Arguments

vec a numeric vector (or an existing torch tensor, returned as-is).
n if supplied, the target length; a length-1 vec is broadcast to length n.
backend one of “auto” (default), “cpu” or “gpu”.

Value

a torch tensor, or vec unchanged.

Examples

library("SpaNorm")

toGPUVector(1:4, backend = "cpu")
[1] 1 2 3 4