| 123 | config_.dilation, |
| 124 | config_.use_bias, |
| 125 | }).build(ctx, input_4d, {weight_4d, weights.bias}); |
| 126 | return core::reshape_tensor( |
| 127 | ctx, |
| 128 | output_4d, |
| 129 | core::TensorShape::from_dims({ |
| 130 | input.shape.dims[0], |
| 131 | config_.channels, |
| 132 | depthwise_conv1d_output_frames(config_, input.shape.dims[2]), |
| 133 | })); |
| 134 | } |
| 135 | |
| 136 | PointwiseConv1dModule::PointwiseConv1dModule(PointwiseConv1dConfig config) : config_(config) {} |
| 137 | |
| 138 | core::TensorValue PointwiseConv1dModule::build( |
| 139 | core::ModuleBuildContext & ctx, |
| 140 | const core::TensorValue & input, |
| 141 | const PointwiseConv1dWeights & weights) const { |
| 142 | if (config_.quant) { |
| 143 | core::validate_rank_between(input, 3, 3, "input"); |
| 144 | core::validate_shape( |
| 145 | input, |
| 146 | core::TensorShape::from_dims({input.shape.dims[0], config_.in_channels, input.shape.dims[2]}), |
| 147 | "input"); |
| 148 | core::TensorValue weight = weights.weight; |
| 149 | if (weight.shape.rank == 3) { |
| 150 | core::validate_shape( |
| 151 | weight, |
| 152 | core::TensorShape::from_dims({config_.out_channels, config_.in_channels, 1}), |
| 153 | "weight"); |
| 154 | weight = core::reshape_tensor( |
| 155 | ctx, |
| 156 | weight, |
| 157 | core::TensorShape::from_dims({config_.out_channels, config_.in_channels})); |
| 158 | } else { |
| 159 | core::validate_shape( |
| 160 | weight, |
| 161 | core::TensorShape::from_dims({config_.out_channels, config_.in_channels}), |
| 162 | "weight"); |
| 163 | } |
| 164 | auto x = TransposeModule({{0, 2, 1, 3}, 3}).build(ctx, input); |
| 165 | x = LinearModule({config_.in_channels, config_.out_channels, config_.use_bias}).build(ctx, x, {weight, weights.bias}); |
| 166 | return TransposeModule({{0, 2, 1, 3}, 3}).build(ctx, x); |
no test coverage detected