| 645 | } |
| 646 | |
| 647 | core::TensorValue graph_conv_module( |
| 648 | core::ModuleBuildContext & ctx, |
| 649 | const core::TensorValue & x, |
| 650 | const std::unordered_map<std::string, Param> & params, |
| 651 | const std::string & prefix, |
| 652 | const std::string & which) { |
| 653 | const std::string base = prefix + "." + which; |
| 654 | auto p = graph_linear(ctx, x, params, base + ".in_proj", 128); |
| 655 | auto lhs = modules::SliceModule({2, 0, kDense}).build(ctx, p); |
| 656 | auto rhs = modules::SliceModule({2, kDense, kDense}).build(ctx, p); |
| 657 | auto gated = graph_mul(ctx, lhs, modules::SigmoidModule().build(ctx, rhs)); |
| 658 | auto channel_first = graph_transpose(ctx, gated, {{1, 2, 0, 3}}, 3); |
| 659 | auto conv = graph_depthwise_conv1d( |
| 660 | ctx, |
| 661 | channel_first, |
| 662 | require_param(params, base + ".depthwise_conv.weight"), |
| 663 | require_param(params, base + ".depthwise_conv.bias"), |
| 664 | base + ".depthwise_conv"); |
| 665 | conv = graph_swoosh_r(ctx, conv); |
| 666 | auto seq_first = graph_transpose(ctx, conv, {{2, 0, 1, 3}}, 3); |
| 667 | return graph_linear(ctx, seq_first, params, base + ".out_proj", kDense); |
| 668 | } |
| 669 | |
| 670 | core::TensorValue graph_bias_norm( |
| 671 | core::ModuleBuildContext & ctx, |
no test coverage detected