Skip to content

Commit dda1180

Browse files
MaggieQicheqi
andauthored
Fix python version (#333)
* update python to python3 * use dynamic linking * enable ANNIndexTestTool code compiling * add python version in wheel package * update nuspec * enable to set different maxcheck and hashexponent * change to configure python version * trigger azurepipeline * trigger * fix python version * fix python version * fix python version in windows * fix cosine kmeans * clean avx/see header files * fix nuspec Co-authored-by: cheqi <cheqi@SRGSSD-07>
1 parent 2d2cfb3 commit dda1180

25 files changed

+144
-117
lines changed

AnnService.users.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010

1111
<PropertyGroup Label="UserMacros">
1212
<OutAppDir>$(SolutionDir)\$(Platform)\$(Configuration)\</OutAppDir>
13-
<OutLibDir>$(SolutionDir)\$(Platform)\$(Configuration)\</OutLibDir>
13+
<OutLibDir>$(SolutionDir)\$(Platform)\$(Configuration)\</OutLibDir>
1414
<JavaIncDir></JavaIncDir>
1515
<JavaLib></JavaLib>
16+
<PYTHON_VERSION>3.9</PYTHON_VERSION>
1617
</PropertyGroup>
1718
</Project>
1819

AnnService/CoreLibrary.vcxproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@
128128
<PreprocessorDefinitions>_MBCS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
129129
<AdditionalOptions>/Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
130130
<LanguageStandard>stdcpp17</LanguageStandard>
131+
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
132+
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
133+
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
134+
<OmitFramePointers>true</OmitFramePointers>
135+
<FloatingPointModel>Fast</FloatingPointModel>
131136
</ClCompile>
132137
<Link>
133138
<EnableCOMDATFolding>true</EnableCOMDATFolding>

AnnService/CoreLibrary.vcxproj.filters

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,15 +282,18 @@
282282
<ClCompile Include="src\Core\Common\CommonUtils.cpp">
283283
<Filter>Source Files\Core\Common</Filter>
284284
</ClCompile>
285+
<ClCompile Include="src\Core\Common\SIMDUtils.cpp">
286+
<Filter>Source Files\Core\Common</Filter>
287+
</ClCompile>
288+
<ClCompile Include="src\Core\Common\TruthSet.cpp">
289+
<Filter>Source Files\Core\Common</Filter>
290+
</ClCompile>
285291
<ClCompile Include="src\Core\SPANN\SPANNIndex.cpp">
286292
<Filter>Source Files\Core\SPANN</Filter>
287293
</ClCompile>
288294
<ClCompile Include="src\Helper\AsyncFileReader.cpp">
289295
<Filter>Source Files\Helper</Filter>
290296
</ClCompile>
291-
<ClCompile Include="src\Core\Common\SIMDUtils.cpp">
292-
<Filter>Source Files\Core\Common</Filter>
293-
</ClCompile>
294297
</ItemGroup>
295298
<ItemGroup>
296299
<None Include="packages.config" />

AnnService/SSDServing.vcxproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<ItemGroup Label="ProjectConfigurations">
44
<ProjectConfiguration Include="Debug|Win32">
@@ -161,6 +161,12 @@
161161
<OpenMPSupport>true</OpenMPSupport>
162162
<AdditionalOptions>/Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
163163
<LanguageStandard>stdcpp17</LanguageStandard>
164+
<ProgramDataBaseFileName>$(IntDir)$(ProjectName).pdb</ProgramDataBaseFileName>
165+
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
166+
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
167+
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
168+
<OmitFramePointers>true</OmitFramePointers>
169+
<FloatingPointModel>Fast</FloatingPointModel>
164170
</ClCompile>
165171
<Link>
166172
<SubSystem>Console</SubSystem>

AnnService/inc/Core/Common.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ inline bool fileexists(const TCHAR* path) {
8181
return (dwAttr != INVALID_FILE_ATTRIBUTES) && (dwAttr & FILE_ATTRIBUTE_DIRECTORY) == 0;
8282
}
8383
#define mkdir(a) CreateDirectory(a, NULL)
84+
85+
#ifndef max
86+
#define max(a,b) (((a) > (b)) ? (a) : (b))
87+
#endif
88+
89+
#ifndef min
90+
#define min(a,b) (((a) < (b)) ? (a) : (b))
91+
#endif
92+
8493
#endif
8594

8695
namespace SPTAG

AnnService/inc/Core/Common/BKTree.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ namespace SPTAG
5757
_RD = m_pQuantizer->ReconstructDim();
5858
fComputeDistance = m_pQuantizer->DistanceCalcSelector<T>(distMethod);
5959
}
60-
else if (distMethod == DistCalcMethod::L2 || distMethod == DistCalcMethod::Cosine)
61-
{
62-
fComputeDistance = COMMON::DistanceCalcSelector<T>(DistCalcMethod::L2);
63-
}
6460
else {
6561
fComputeDistance = COMMON::DistanceCalcSelector<T>(distMethod);
6662
}
@@ -182,20 +178,20 @@ namespace SPTAG
182178
for (DimensionType j = 0; j < args._RD; j++) {
183179
currCenters[j] /= args.counts[k];
184180
}
185-
/*
181+
186182
if (args._M == DistCalcMethod::Cosine) {
187183
COMMON::Utils::Normalize(currCenters, args._RD, COMMON::Utils::GetBase<T>());
188184
}
189-
*/
185+
190186
if (args.m_pQuantizer) {
191187
for (DimensionType j = 0; j < args._RD; j++) reconstructVector[j] = (R)(currCenters[j]);
192188
args.m_pQuantizer->QuantizeVector(reconstructVector.data(), (uint8_t*)TCenter);
193189
}
194190
else {
195-
for (DimensionType j = 0; j < args._RD; j++) TCenter[j] = (T)(currCenters[j]);
191+
for (DimensionType j = 0; j < args._D; j++) TCenter[j] = (T)(currCenters[j]);
196192
}
197193
}
198-
diff += args.fComputeDistance(args.centers + k*args._D, TCenter, args._D);
194+
diff += DistanceUtils::ComputeDistance(TCenter, args.centers + k * args._D, args._D, DistCalcMethod::L2);
199195
}
200196
return diff;
201197
}

AnnService/inc/Core/Common/DistanceUtils.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#ifndef _SPTAG_COMMON_DISTANCEUTILS_H_
55
#define _SPTAG_COMMON_DISTANCEUTILS_H_
66

7-
#include <xmmintrin.h>
87
#include <functional>
98
#include <iostream>
109

AnnService/inc/Core/Common/InstructionUtils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
#ifndef _MSC_VER
1010
#include <cpuid.h>
11+
#include <xmmintrin.h>
12+
#include <immintrin.h>
13+
1114
void cpuid(int info[4], int InfoType);
1215

1316
#else

AnnService/inc/Core/Common/PQQuantizer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ namespace SPTAG
173173
subcodebooks += m_DimPerSubvector;
174174
}
175175
assert(bestIndex != -1);
176-
vecout[i] = bestIndex;
176+
vecout[i] = (std::uint8_t)bestIndex;
177177
subvec += m_DimPerSubvector;
178178
}
179179
}

AnnService/inc/Core/Common/RelativeNeighborhoodGraph.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#ifndef _SPTAG_COMMON_RNG_H_
55
#define _SPTAG_COMMON_RNG_H_
66

7-
#include <xmmintrin.h>
87
#include "NeighborhoodGraph.h"
98

109
namespace SPTAG

0 commit comments

Comments
 (0)