r"""3D convolution operation. Refer to :class:`~.Conv3d` for more information. Args: inp: feature map of the convolution operation. weight: convolution kernel. bias: bias added to the result of convolution (if given). stride: stride of the 3D convolution ope
(
inp: Tensor,
weight: Tensor,
bias: Optional[Tensor] = None,
stride: Union[int, Tuple[int, int, int]] = 1,
padding: Union[int, Tuple[int, int, int]] = 0,
dilation: Union[int, Tuple[int, int, int]] = 1,
groups: int = 1,
conv_mode: str = "cross_correlation",
)
| 290 | |
| 291 | |
| 292 | def conv3d( |
| 293 | inp: Tensor, |
| 294 | weight: Tensor, |
| 295 | bias: Optional[Tensor] = None, |
| 296 | stride: Union[int, Tuple[int, int, int]] = 1, |
| 297 | padding: Union[int, Tuple[int, int, int]] = 0, |
| 298 | dilation: Union[int, Tuple[int, int, int]] = 1, |
| 299 | groups: int = 1, |
| 300 | conv_mode: str = "cross_correlation", |
| 301 | ) -> Tensor: |
| 302 | r"""3D convolution operation. |
| 303 | |
| 304 | Refer to :class:`~.Conv3d` for more information. |
| 305 | |
| 306 | Args: |
| 307 | inp: feature map of the convolution operation. |
| 308 | weight: convolution kernel. |
| 309 | bias: bias added to the result of convolution (if given). |
| 310 | stride: stride of the 3D convolution operation. Default: 1 |
| 311 | padding: size of the paddings added to the input on both sides of its |
| 312 | spatial dimensions. Only zero-padding is supported. Default: 0 |
| 313 | dilation: dilation of the 3D convolution operation. Default: 1 |
| 314 | groups: number of groups into which the input and output channels are divided, |
| 315 | so as to perform a ``grouped convolution``. When ``groups`` is not 1, |
| 316 | ``in_channels`` and ``out_channels`` must be divisible by ``groups``, |
| 317 | and the shape of weight should be ``(groups, out_channel // groups, |
| 318 | in_channels // groups, depth, height, width)``. Default: 1 |
| 319 | conv_mode: supports "cross_correlation". Default: "cross_correlation" |
| 320 | |
| 321 | Returns: |
| 322 | output tensor. |
| 323 | """ |
| 324 | assert conv_mode.lower() == "cross_correlation" |
| 325 | |
| 326 | D, H, W = 0, 1, 2 |
| 327 | |
| 328 | pad = expand_dhw(padding) |
| 329 | stride = expand_dhw(stride) |
| 330 | dilate = expand_dhw(dilation) |
| 331 | |
| 332 | sparse_type = "dense" if groups == 1 else "group" |
| 333 | op = builtin.Convolution3D( |
| 334 | pad_d=pad[D], |
| 335 | pad_h=pad[H], |
| 336 | pad_w=pad[W], |
| 337 | stride_d=stride[D], |
| 338 | stride_h=stride[H], |
| 339 | stride_w=stride[W], |
| 340 | dilate_d=dilate[D], |
| 341 | dilate_h=dilate[H], |
| 342 | dilate_w=dilate[W], |
| 343 | strategy=get_execution_strategy(), |
| 344 | mode=conv_mode, |
| 345 | sparse=sparse_type, |
| 346 | ) |
| 347 | (output,) = apply(op, inp, weight) |
| 348 | if bias is not None: |
| 349 | output += bias |
no test coverage detected