pdist2 - bottleneck is in argument parsing

2 visualizaciones (últimos 30 días)
Nicholas Bauer
Nicholas Bauer el 11 de Jul. de 2018
Respondida: OCDER el 11 de Jul. de 2018
I'm profiling some code to see where the bottlenecks are, and I saw the bottleneck was in pdist2--expected.
What was unexpected is that the profiler is showing that there are two hot spots: 17% in pdist2mex and 37% in internal.stats.parseArgs(!). It's spending twice as much time parsing arguments as calculating distances.
How can I eliminate this overhead?
  1 comentario
dpb
dpb el 11 de Jul. de 2018
For a specific case you could probably decipher the arguments and call pdist2mex directly if your data are suitably arranged.
I've not looked at the details recently so don't recall just what is done up front otomh.

Iniciar sesión para comentar.

Respuestas (1)

OCDER
OCDER el 11 de Jul. de 2018
To bypass the overhead, you could make your own MEX file for pdist2. Or, use pdist2mex directly, but then you'll have to find this mex file and pull it out of the private folder into your own folder in the matlab path.
EXAMPLE
X = randn(100, 5);
Y = randn(25, 5);
dist = 'euc';
additionalArg = [];
smallestLargestFlag = [];
radius = [];
D = pdist2mex(X',Y',dist,additionalArg,smallestLargestFlag,radius); %Same as pdist2(X, Y, dist)

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by