| 690 | } |
| 691 | |
| 692 | core::TensorValue graph_zipformer_layer( |
| 693 | core::ModuleBuildContext & ctx, |
| 694 | std::vector<GraphConstant> & constants, |
| 695 | const core::TensorValue & input, |
| 696 | const std::unordered_map<std::string, Param> & params, |
| 697 | const std::string & prefix) { |
| 698 | const auto orig = input; |
| 699 | auto attn = graph_attention_weights(ctx, constants, input, params, prefix); |
| 700 | auto x = graph_add(ctx, input, graph_feed_forward(ctx, input, params, prefix, "feed_forward1", 192)); |
| 701 | x = graph_add(ctx, x, graph_nonlin_attention(ctx, x, attn.front(), params, prefix)); |
| 702 | x = graph_add(ctx, x, graph_self_attention(ctx, x, attn, params, prefix, "self_attn1")); |
| 703 | x = graph_add(ctx, x, graph_conv_module(ctx, x, params, prefix, "conv_module1")); |
| 704 | x = graph_add(ctx, x, graph_feed_forward(ctx, x, params, prefix, "feed_forward2", 256)); |
| 705 | x = graph_bypass(ctx, orig, x, require_param(params, prefix + ".bypass_mid.bypass_scale")); |
| 706 | x = graph_add(ctx, x, graph_self_attention(ctx, x, attn, params, prefix, "self_attn2")); |
| 707 | x = graph_add(ctx, x, graph_conv_module(ctx, x, params, prefix, "conv_module2")); |
| 708 | x = graph_add(ctx, x, graph_feed_forward(ctx, x, params, prefix, "feed_forward3", 320)); |
| 709 | x = graph_bias_norm(ctx, x, params, prefix); |
| 710 | return graph_bypass(ctx, orig, x, require_param(params, prefix + ".bypass.bypass_scale")); |
| 711 | } |
| 712 | |
| 713 | std::vector<float> softmax_values(const Param & bias) { |
| 714 | const float max_value = *std::max_element(bias.values.begin(), bias.values.end()); |
no test coverage detected