(input: Tensor,
weight: Tensor,
bias: Optional[Tensor] = None,
stride: int = 1,
padding: int = 0,
dilation: int = 1,
groups: int = 1)
| 3544 | |
| 3545 | |
| 3546 | def conv1d(input: Tensor, |
| 3547 | weight: Tensor, |
| 3548 | bias: Optional[Tensor] = None, |
| 3549 | stride: int = 1, |
| 3550 | padding: int = 0, |
| 3551 | dilation: int = 1, |
| 3552 | groups: int = 1) -> Tensor: |
| 3553 | |
| 3554 | noutput = weight.size()[0] |
| 3555 | kernel_size = weight.size()[-2] |
| 3556 | is_weight_constant = (weight.producer is not None |
| 3557 | and weight.producer.type == trt.LayerType.CONSTANT) |
| 3558 | weight = weight.producer.weights if is_weight_constant else trt.Weights() |
| 3559 | |
| 3560 | if bias is not None: |
| 3561 | is_bias_constant = (bias.producer is not None |
| 3562 | and bias.producer.type == trt.LayerType.CONSTANT) |
| 3563 | bias = bias.producer.weights if is_bias_constant else trt.Weights() |
| 3564 | |
| 3565 | input_shuffled = stack([input], dim=input.ndim()) |
| 3566 | kernel_size = trt.Dims([kernel_size, 1]) |
| 3567 | |
| 3568 | layer = default_trtnet().add_convolution_nd(input_shuffled.trt_tensor, |
| 3569 | noutput, kernel_size, weight, |
| 3570 | bias) |
| 3571 | layer.stride_nd = (stride, 2) |
| 3572 | layer.padding_nd = (padding, 0) |
| 3573 | layer.dilation_nd = (dilation, 2) |
| 3574 | layer.num_groups = groups |
| 3575 | |
| 3576 | if not is_weight_constant: |
| 3577 | layer.set_input(1, weight.trt_tensor) |
| 3578 | if bias is not None and not is_bias_constant: |
| 3579 | layer.set_input(2, bias.trt_tensor) |
| 3580 | |
| 3581 | output_2d = _create_tensor(layer.get_output(0), layer) |
| 3582 | output_1d = squeeze(output_2d, dim=-1) |
| 3583 | return output_1d |
| 3584 | |
| 3585 | |
| 3586 | def conv2d(input: Tensor, |
no test coverage detected