Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a DllImport issue for frameworks that do not add the ".dll" suffix automatically #287

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Microsoft.ML.FastTree/Dataset/DenseIntArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ public override IntArray[] Split(int[][] assignment)
}

#if USE_FASTTREENATIVE
[DllImport("FastTreeNative", CallingConvention = CallingConvention.StdCall)]
[DllImport(NativeDll, CallingConvention = CallingConvention.StdCall)]
private unsafe static extern int C_Sumup_float(
int numBits, byte* pData, int* pIndices, float* pSampleOutputs, double* pSampleOutputWeights,
FloatType* pSumTargetsByBin, double* pSumTargets2ByBin, int* pCountByBin,
int totalCount, double totalSampleOutputs, double totalSampleOutputWeights);

[DllImport("FastTreeNative", CallingConvention = CallingConvention.StdCall)]
[DllImport(NativeDll, CallingConvention = CallingConvention.StdCall)]
private unsafe static extern int C_Sumup_double(
int numBits, byte* pData, int* pIndices, double* pSampleOutputs, double* pSampleOutputWeights,
FloatType* pSumTargetsByBin, double* pSumTargets2ByBin, int* pCountByBin,
Expand Down
6 changes: 6 additions & 0 deletions src/Microsoft.ML.FastTree/Dataset/IntArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public enum IntArrayBits { Bits32 = 32, Bits16 = 16, Bits10 = 10, Bits8 = 8, Bit
/// </summary>
public abstract class IntArray : IEnumerable<int>
{
#if USE_DLL_SUFFIX
public const string NativeDll = "FastTreeNative.dll";
#else
public const string NativeDll = "FastTreeNative";
#endif

// The level of compression to use with features.
// 0x1 - Use 10 bit.
// 0x2 -
Expand Down
14 changes: 7 additions & 7 deletions src/Microsoft.ML.FastTree/Dataset/SegmentIntArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -493,29 +493,29 @@ public unsafe static void SegmentFindOptimalCost31(uint[] array, int len, out lo
}

#pragma warning disable TLC_GeneralName // Externs follow their own rules.
[DllImport("FastTreeNative", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
[DllImport(NativeDll, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
private unsafe static extern void C_SegmentFindOptimalPath21(uint* valv, int valc, long* pBits, int* pTransitions);

[DllImport("FastTreeNative", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
[DllImport(NativeDll, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
private unsafe static extern void C_SegmentFindOptimalPath15(uint* valv, int valc, long* pBits, int* pTransitions);

[DllImport("FastTreeNative", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
[DllImport(NativeDll, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
private unsafe static extern void C_SegmentFindOptimalPath7(uint* valv, int valc, long* pBits, int* pTransitions);

[DllImport("FastTreeNative", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
[DllImport(NativeDll, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
private unsafe static extern void C_SegmentFindOptimalCost15(uint* valv, int valc, long* pBits);

[DllImport("FastTreeNative", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
[DllImport(NativeDll, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
private unsafe static extern void C_SegmentFindOptimalCost31(uint* valv, int valc, long* pBits);

[DllImport("FastTreeNative", CallingConvention = CallingConvention.StdCall)]
[DllImport(NativeDll, CallingConvention = CallingConvention.StdCall)]
private unsafe static extern int C_SumupSegment_float(
uint* pData, byte* pSegType, int* pSegLength, int* pIndices,
float* pSampleOutputs, double* pSampleOutputWeights,
float* pSumTargetsByBin, double* pSumWeightsByBin,
int* pCountByBin, int totalCount, double totalSampleOutputs);

[DllImport("FastTreeNative", CallingConvention = CallingConvention.StdCall)]
[DllImport(NativeDll, CallingConvention = CallingConvention.StdCall)]
private unsafe static extern int C_SumupSegment_double(
uint* pData, byte* pSegType, int* pSegLength, int* pIndices,
double* pSampleOutputs, double* pSampleOutputWeights,
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.ML.FastTree/Dataset/SparseIntArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,12 @@ public override void Sumup(SumupInputData input, FeatureHistogram histogram)
}

#if USE_FASTTREENATIVE
[DllImport("FastTreeNative", CallingConvention = CallingConvention.StdCall)]
[DllImport(NativeDll, CallingConvention = CallingConvention.StdCall)]
private unsafe static extern int C_SumupDeltaSparse_float(int numBits, byte* pValues, byte* pDeltas, int numDeltas, int* pIndices, float* pSampleOutputs, double* pSampleOutputWeights,
float* pSumTargetsByBin, double* pSumTargets2ByBin, int* pCountByBin,
int totalCount, double totalSampleOutputs, double totalSampleOutputWeights);

[DllImport("FastTreeNative", CallingConvention = CallingConvention.StdCall)]
[DllImport(NativeDll, CallingConvention = CallingConvention.StdCall)]
private unsafe static extern int C_SumupDeltaSparse_double(int numBits, byte* pValues, byte* pDeltas, int numDeltas, int* pIndices, double* pSampleOutputs, double* pSampleOutputWeights,
double* pSumTargetsByBin, double* pSumTargets2ByBin, int* pCountByBin,
int totalCount, double totalSampleOutputs, double totalSampleOutputWeights);
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ML.FastTree/FastTreeRanking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ private static void PermutationSort(int[] permutation, double[] scores, short[]
}));
}

[DllImport("FastTreeNative", EntryPoint = "C_GetDerivatives", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
[DllImport(IntArray.NativeDll, EntryPoint = "C_GetDerivatives", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
private unsafe static extern void GetDerivatives(
int numDocuments, int begin, int* pPermutation, short* pLabels,
double* pScores, double* pLambdas, double* pWeights, double* pDiscount,
Expand Down