| 558 | } |
| 559 | |
| 560 | void compute_softmax_node(GraphNode& node, const std::vector<std::unique_ptr<GraphNode>>& nodes, const std::unordered_map<size_t, size_t>& node_index_map) { |
| 561 | const auto& input_buffer = get_input(node, 0, nodes, node_index_map); |
| 562 | const auto& shape = input_buffer.shape; |
| 563 | |
| 564 | if (shape.size() < 2) { |
| 565 | throw std::runtime_error("Softmax operation requires at least 2D tensor, got " + |
| 566 | std::to_string(shape.size()) + "D tensor"); |
| 567 | } |
| 568 | |
| 569 | if (input_buffer.precision != Precision::FP16) { |
| 570 | throw std::runtime_error("Softmax operation only supports FP16 precision"); |
| 571 | } |
| 572 | |
| 573 | size_t batch_size = 1; |
| 574 | for (size_t i = 0; i < shape.size() - 1; i++) { |
| 575 | batch_size *= shape[i]; |
| 576 | } |
| 577 | size_t vocab_size = shape[shape.size() - 1]; |
| 578 | |
| 579 | cactus_softmax_f16(input_buffer.data_as<__fp16>(), node.output_buffer.data_as<__fp16>(), |
| 580 | batch_size, 1, vocab_size); |
| 581 | } |
| 582 | |
| 583 | void compute_rel_pos_bias_node(GraphNode& node, const std::vector<std::unique_ptr<GraphNode>>& nodes, |
| 584 | const std::unordered_map<size_t, size_t>& node_index_map) { |
nothing calls this directly
no test coverage detected