1 |
|
|
/*************************************** |
2 |
|
|
Auteur : Pierre Aubert |
3 |
|
|
Mail : pierre.aubert@lapp.in2p3.fr |
4 |
|
|
Licence : CeCILL-C |
5 |
|
|
****************************************/ |
6 |
|
|
|
7 |
|
|
#include "PTensor.h" |
8 |
|
|
|
9 |
|
|
using namespace std; |
10 |
|
|
|
11 |
|
|
///Test the PTensor |
12 |
|
1 |
void testPTensorCopyPointer(){ |
13 |
✓ |
2 |
PTensor<float> tensor; |
14 |
✓ |
1 |
tensor.resize(AllocMode::NONE, 4lu, 5lu); |
15 |
|
1 |
tensor.fill(1.0f); |
16 |
✓✓ |
1 |
cout << tensor << endl; |
17 |
|
|
|
18 |
✓ |
2 |
PTensor<float> tensorCopy; |
19 |
✓ |
1 |
tensorCopy.copyPointer(tensor.getData(), (size_t *)tensor.getShape(), tensor.getNbDim(), tensor.isAligned(), tensor.getPadding()); |
20 |
✓✓ |
1 |
cout << tensorCopy << endl; |
21 |
|
|
|
22 |
✓ |
2 |
PTensor<float> alignedTensor; |
23 |
✓ |
1 |
alignedTensor.resize(AllocMode::ALIGNED, 4lu, 5lu); |
24 |
|
1 |
alignedTensor.fill(1.0f); |
25 |
✓✓ |
1 |
cout << alignedTensor << endl; |
26 |
|
|
|
27 |
✓ |
2 |
PTensor<float> tensorCopyAligned; |
28 |
✓ |
1 |
tensorCopyAligned.copyPointer(alignedTensor.getData(), (size_t *)alignedTensor.getShape(), alignedTensor.getNbDim(), alignedTensor.isAligned(), alignedTensor.getPadding()); |
29 |
✓✓ |
1 |
cout << tensorCopyAligned << endl; |
30 |
|
|
|
31 |
✓ |
2 |
PTensor<float> paddedTensor; |
32 |
✓ |
1 |
paddedTensor.resize(AllocMode::PADDING, 4lu, 5lu); |
33 |
|
1 |
paddedTensor.fill(1.0f); |
34 |
|
1 |
paddedTensor.setPaddingValue(42.f); |
35 |
✓✓ |
1 |
cout << paddedTensor << endl; |
36 |
|
|
|
37 |
✓ |
2 |
PTensor<float> tensorCopyPadded; |
38 |
✓ |
1 |
tensorCopyPadded.copyPointer(paddedTensor.getData(), (size_t *)paddedTensor.getShape(), paddedTensor.getNbDim(), paddedTensor.isAligned(), paddedTensor.getPadding()); |
39 |
✓✓ |
1 |
cout << tensorCopyPadded << endl; |
40 |
|
1 |
} |
41 |
|
|
|
42 |
|
1 |
int main(int argc, char** argv){ |
43 |
|
1 |
testPTensorCopyPointer(); |
44 |
|
1 |
return 0; |
45 |
|
|
} |
46 |
|
|
|
47 |
|
|
|