-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmodified_permutohedral.h
44 lines (38 loc) · 1.31 KB
/
modified_permutohedral.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef MXNET_MODIFIED_PERMUTOHEDRAL_H_
#define MXNET_MODIFIED_PERMUTOHEDRAL_H_
#include <cstdlib>
#include <vector>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cmath>
/************************************************/
/*** ModifiedPermutohedral Lattice ***/
/************************************************/
namespace mxnet {
namespace op {
namespace permutohedral {
class ModifiedPermutohedral
{
protected:
struct Neighbors{
int n1, n2;
Neighbors( int n1=0, int n2=0 ):n1(n1),n2(n2){
}
};
std::vector<int> offset_, rank_;
std::vector<float> barycentric_;
std::vector<Neighbors> blur_neighbors_;
// Number of elements, size of sparse discretized space, dimension of features
int N_, M_, d_;
void sseCompute(float* out, const float* in, int value_size, bool reverse = false, bool add = false) const;
void seqCompute(float* out, const float* in, int value_size, bool reverse = false, bool add = false) const;
public:
ModifiedPermutohedral();
void init (const float* features, int num_dimensions, int num_points);
void compute(float* out, const float* in, int value_size, bool reverse = false, bool add = false) const;
};
} // namespace permutohedral
} // namespace op
} // namespace mxnet
#endif //MXNET_MODIFIED_PERMUTOHEDRAL_H_