Example #1
0
        public static void SdcaL1UpdateSparse(float primalUpdate, int count, ReadOnlySpan <float> source, ReadOnlySpan <int> indices, float threshold, Span <float> v, Span <float> w)
        {
            Contracts.AssertNonEmpty(source);
            Contracts.AssertNonEmpty(indices);
            Contracts.AssertNonEmpty(v);
            Contracts.AssertNonEmpty(w);
            Contracts.Assert(count > 0);
            Contracts.Assert(count <= source.Length);
            Contracts.Assert(count <= indices.Length);
            Contracts.Assert(count <= v.Length);
            Contracts.Assert(count <= w.Length);

            if (Avx.IsSupported)
            {
                AvxIntrinsics.SdcaL1UpdateSU(primalUpdate, count, source, indices, threshold, v, w);
            }
            else if (Sse.IsSupported)
            {
                SseIntrinsics.SdcaL1UpdateSU(primalUpdate, count, source, indices, threshold, v, w);
            }
            else
            {
                for (int i = 0; i < count; i++)
                {
                    int index = indices[i];
                    v[index] += source[i] * primalUpdate;
                    float value = v[index];
                    w[index] = Math.Abs(value) > threshold ? (value > 0 ? value - threshold : value + threshold) : 0;
                }
            }
        }
Example #2
0
 private static void SdcaL1UpdateSparse(float primalUpdate, Span <float> src, Span <int> indices, float threshold, Span <float> v, Span <float> w)
 {
     if (Avx.IsSupported)
     {
         AvxIntrinsics.SdcaL1UpdateSU(primalUpdate, src, indices, threshold, v, w);
     }
     else if (Sse.IsSupported)
     {
         SseIntrinsics.SdcaL1UpdateSU(primalUpdate, src, indices, threshold, v, w);
     }
     else
     {
         for (int i = 0; i < indices.Length; i++)
         {
             int index = indices[i];
             v[index] += src[i] * primalUpdate;
             float value = v[index];
             w[index] = Math.Abs(value) > threshold ? (value > 0 ? value - threshold : value + threshold) : 0;
         }
     }
 }
Example #3
0
 public void ManagedSdcaL1UpdateSUPerf()
 {
     AvxIntrinsics.SdcaL1UpdateSU(DEFAULT_SCALE, new Span <float>(src, 0, IDXLEN), new Span <int>(idx, 0, IDXLEN), DEFAULT_SCALE, new Span <float>(dst), new Span <float>(result));
 }
 public void SdcaL1UpdateSU()
 => AvxIntrinsics.SdcaL1UpdateSU(DefaultScale, IndexLength, src, idx, DefaultScale, dst, result);
Example #5
0
 public void SdcaL1UpdateSU()
 => AvxIntrinsics.SdcaL1UpdateSU(DefaultScale, new Span <float>(src, 0, IndexLength), new Span <int>(idx, 0, IndexLength), DefaultScale, new Span <float>(dst), new Span <float>(result));