dthuerck / mapmap_cpu

A high-performance general-purpose MRF MAP solver, heavily exploiting SIMD instructions.
BSD 3-Clause "New" or "Revised" License
102 stars 51 forks source link

Customizing pairwise costs #24

Open blurgyy opened 3 years ago

blurgyy commented 3 years ago

Hello, thank you for the great library!

I want to implement a custom pairwise cost functor, which takes labels and maps the labels to something else to calculate the costs. For example, if the labels are indices of some set of n-dimensional points, I want to define the pairwise costs as the distance between the points which the labels point to. Is this possible?

I have tried implementing a class derived from mapmap::PairwiseCosts, and override the get_pairwise_costs method. When I try to output the labels vector in get_pairwise_costs, sometimes it outputs undefined values (i.e. not labels). Could you please give some instructions on how to define custom pairwise costs? I would be very appreciated.

dthuerck commented 3 years ago

Hi @blurgyy ,

sorry for the late answer! Can you, by any chance, post your code here? A good starting point would be pairwise_table.impl.h.

Did you use a SIMD width larger than 1? If so, my first guess is always an alignment issue...

Feel free to also e-mail me directly (see my personal webpage).