| 54 | }; |
| 55 | |
| 56 | int64_t head_dim(const AceStepTextEncoderConfig & config) { |
| 57 | if (config.num_attention_heads <= 0 || config.num_key_value_heads <= 0 || config.head_dim <= 0) { |
| 58 | throw std::runtime_error("ACE-Step text encoder attention config is invalid"); |
| 59 | } |
| 60 | if (config.num_attention_heads % config.num_key_value_heads != 0) { |
| 61 | throw std::runtime_error("ACE-Step text encoder num_attention_heads must be divisible by num_key_value_heads"); |
| 62 | } |
| 63 | return config.head_dim; |
| 64 | } |
| 65 | |
| 66 | core::TensorValue ensure_contiguous(core::ModuleBuildContext & ctx, const core::TensorValue & input) { |
| 67 | return core::ensure_backend_addressable_layout(ctx, input); |