public void Train(SamplerDelegate sampler, ref DictionaryTrainingParameters parameters) { var samplesBuffer = GatherSamples(sampler, out var samplesSizes); Size = Native.ZDict.Train( Data, samplesBuffer, (ReadOnlySpan <UIntPtr>)samplesSizes, ref parameters ) .EnsureZDictSuccess(); }
public void Train(SamplerDelegate sampler, ref DictionaryTrainingParameters parameters, int compressionLevel = default, uint nbThreads = 1, uint tuningSteps = 0) { var samplesBuffer = GatherSamples(sampler, out var samplesSizes); Size = Native.ZDict.Train( Data, samplesBuffer, (ReadOnlySpan <UIntPtr>)samplesSizes, ref parameters ) .EnsureZDictSuccess(); }
public unsafe void Train(AsyncSamplerDelegate sampler, ref DictionaryTrainingParameters parameters, int compressionLevel = default, uint nbThreads = 1, uint tuningSteps = 0) { var data = Data; fixed(DictionaryTrainingParameters *pParameters = ¶meters) { Size = GatherSamples(sampler) .ContinueWith((samplesTask, state) => { // ReSharper disable once PossibleNullReferenceException // ReSharper disable once VariableHidesOuterVariable var pParameters = (DictionaryTrainingParameters *)(IntPtr)state; var(samplesBuffer, samplesSizes) = samplesTask.GetAwaiter().GetResult(); return(Native.ZDict.Train( data, samplesBuffer, (ReadOnlySpan <UIntPtr>)samplesSizes, ref Unsafe.AsRef <DictionaryTrainingParameters>(pParameters) )); }, (IntPtr)pParameters) .GetAwaiter().GetResult() .EnsureZDictSuccess(); } }
public static UIntPtr Train(Span <byte> dictionary, ReadOnlySpan <byte> samples, ReadOnlySpan <UIntPtr> samplesSizes, ref DictionaryTrainingParameters parameters) { fixed(byte *pDictBuffer = dictionary) fixed(byte *pSamplesBuffer = samples) fixed(UIntPtr * pSamplesSizes = samplesSizes) fixed(DictionaryTrainingParameters * pParameters = ¶meters) return(Train(pDictBuffer, (UIntPtr)dictionary.Length, pSamplesBuffer, pSamplesSizes, (uint)samplesSizes.Length, pParameters)); }