Torch-style 1D convolution in NCW layout: x is
[batch, in_channels, width], weight is
[out_channels, in_channels / groups, kW], output is
[batch, out_channels, out_w]. Symmetric zero padding.
Usage
nv_conv1d(
x,
weight,
stride = 1L,
padding = 0L,
dilation = 1L,
groups = 1L,
precision = "highest"
)Arguments
- x
(
arrayish)[N, C_in, W]. Can be any data type;xandweightare promoted to a common data type. An R value assumes the other operand's data type, and materializes at its default data type when that has none either.- weight
(
arrayish)[C_out, C_in / groups, kW]. Promoted together withx– seex.- stride, padding, dilation
(
integer())
Length 1.- groups
(
integer(1))
Grouped/depthwise convolution.- precision
(
character(1))"highest","high"or"default".
Value
(arrayish)
Has the operands' common data type, and shape
[N, C_out, out_W].
Examples
# one batch, one channel, width 5, convolved with a width-3 kernel
x <- nv_array(1:5, shape = c(1, 1, 5), dtype = "f32")
weight <- nv_array(c(1, 0, -1), shape = c(1, 1, 3), dtype = "f32")
nv_conv1d(x, weight)
#> AnvlArray
#> (1,.,.) =
#> -2 -2 -2
#> [ CPUf32{1,1,3} ]
# `padding = 1` keeps the input width, `stride = 2` visits every other
# window position
nv_conv1d(x, weight, padding = 1L)
#> AnvlArray
#> (1,.,.) =
#> -2 -2 -2 -2 4
#> [ CPUf32{1,1,5} ]
nv_conv1d(x, weight, stride = 2L)
#> AnvlArray
#> (1,.,.) =
#> -2 -2
#> [ CPUf32{1,1,2} ]