@@ -92,36 +92,34 @@ void llm_graph_input_pos_bucket_kv::set_input(const llama_ubatch * ubatch) {
9292}
9393
9494void llm_graph_input_out_ids::set_input (const llama_ubatch * ubatch) {
95- if (hparams.causal_attn || cparams.pooling_type == LLAMA_POOLING_TYPE_NONE) {
96- // GGML_ASSERT(out_ids && "every model that can must skip unused outputs");
95+ GGML_ASSERT (out_ids);
9796
98- if (!out_ids) {
99- LLAMA_LOG_WARN (" %s: 'out_ids' is not created\n " , __func__);
100- } else {
101- const int64_t n_tokens = ubatch->n_tokens ;
97+ if (!out_ids) {
98+ LLAMA_LOG_WARN (" %s: 'out_ids' is not created\n " , __func__);
99+ } else {
100+ const int64_t n_tokens = ubatch->n_tokens ;
102101
103- GGML_ASSERT (ggml_backend_buffer_is_host (out_ids->buffer ));
104- int32_t * data = (int32_t *) out_ids->data ;
102+ GGML_ASSERT (ggml_backend_buffer_is_host (out_ids->buffer ));
103+ int32_t * data = (int32_t *) out_ids->data ;
105104
106- if (n_outputs == n_tokens) {
107- for (int i = 0 ; i < n_tokens; ++i) {
108- data[i] = i;
109- }
110- } else if (ubatch->output ) {
111- int32_t n_outputs = 0 ;
112- for (int i = 0 ; i < n_tokens; ++i) {
113- if (ubatch->output [i]) {
114- data[n_outputs++] = i;
115- }
105+ if (n_outputs == n_tokens) {
106+ for (int i = 0 ; i < n_tokens; ++i) {
107+ data[i] = i;
108+ }
109+ } else if (ubatch->output ) {
110+ int32_t n_outputs = 0 ;
111+ for (int i = 0 ; i < n_tokens; ++i) {
112+ if (ubatch->output [i]) {
113+ data[n_outputs++] = i;
116114 }
117- // the graph needs to have been passed the correct number of outputs
118- GGML_ASSERT (n_outputs == n_outputs);
119- } else if (n_outputs == 1 ) {
120- // only keep last output
121- data[0 ] = n_tokens - 1 ;
122- } else {
123- GGML_ASSERT (n_outputs == 0 );
124115 }
116+ // the graph needs to have been passed the correct number of outputs
117+ GGML_ASSERT (n_outputs == n_outputs);
118+ } else if (n_outputs == 1 ) {
119+ // only keep last output
120+ data[0 ] = n_tokens - 1 ;
121+ } else {
122+ GGML_ASSERT (n_outputs == 0 );
125123 }
126124 }
127125}
0 commit comments