@@ -596,6 +596,14 @@ void tm_fit_regression(struct TsetlinMachine *tm, unsigned int *X, int *y, int n
596596 }
597597 }
598598
599+ for (int t = 0 ; t < max_threads ; t ++ ) {
600+ free (tm_thread [t ]-> clause_output );
601+ free (tm_thread [t ]-> output_one_patches );
602+ free (tm_thread [t ]-> feedback_to_la );
603+ free (tm_thread [t ]-> feedback_to_clauses );
604+ free (tm_thread [t ]);
605+ }
606+
599607 for (int j = 0 ; j < tm -> number_of_clauses ; ++ j ) {
600608 omp_destroy_lock (& tm -> clause_lock [j ]);
601609 }
@@ -628,19 +636,13 @@ void tm_predict_regression(struct TsetlinMachine *tm, unsigned int *X, int *y, i
628636
629637 int max_threads = omp_get_max_threads ();
630638 struct TsetlinMachine * * tm_thread = (void * )malloc (sizeof (struct TsetlinMachine * ) * max_threads );
631-
632- // tm->clause_lock = (omp_lock_t *)malloc(sizeof(omp_lock_t) * tm->number_of_clauses);
633- // for (int j = 0; j < tm->number_of_clauses; ++j) {
634- // omp_init_lock(&tm->clause_lock[j]);
635- // }
636639
637640 for (int t = 0 ; t < max_threads ; t ++ ) {
638641 tm_thread [t ] = CreateTsetlinMachine (tm -> number_of_clauses , tm -> number_of_features , tm -> number_of_patches , tm -> number_of_ta_chunks , tm -> number_of_state_bits , tm -> T , tm -> s , tm -> s_range , tm -> boost_true_positive_feedback , tm -> weighted_clauses );
639642 free (tm_thread [t ]-> ta_state );
640643 tm_thread [t ]-> ta_state = tm -> ta_state ;
641644 free (tm_thread [t ]-> clause_weights );
642645 tm_thread [t ]-> clause_weights = tm -> clause_weights ;
643- // tm_thread[t]->clause_lock = tm->clause_lock;
644646 }
645647
646648 #pragma omp parallel for
@@ -651,9 +653,13 @@ void tm_predict_regression(struct TsetlinMachine *tm, unsigned int *X, int *y, i
651653 y [l ] = tm_score_regression (tm_thread [thread_id ], & X [pos ]);
652654 }
653655
654- //for (int j = 0; j < tm->number_of_clauses; ++j) {
655- // omp_destroy_lock(&tm->clause_lock[j]);
656- //}
656+ for (int t = 0 ; t < max_threads ; t ++ ) {
657+ free (tm_thread [t ]-> clause_output );
658+ free (tm_thread [t ]-> output_one_patches );
659+ free (tm_thread [t ]-> feedback_to_la );
660+ free (tm_thread [t ]-> feedback_to_clauses );
661+ free (tm_thread [t ]);
662+ }
657663
658664 free (tm_thread );
659665
0 commit comments