NumSharp icon indicating copy to clipboard operation
NumSharp copied to clipboard

how to change to Microsoft.ML.OnnxRuntime.Tensors.DenseTensor<float>?

Open BingGitCn opened this issue 1 year ago • 0 comments

public static void ExtractPixelsArgb(DenseTensor tensor, Span data, int pixelCount) { Span spanR = tensor.Buffer.Span; Span spanG = spanR[pixelCount..]; Span spanB = spanG[pixelCount..];

 int sidx = 0;
 for (int i = 0; i < pixelCount; i++)
 {
     spanR[i] = data[sidx + 2] * 0.0039215686274509803921568627451f;
     spanG[i] = data[sidx + 1] * 0.0039215686274509803921568627451f;
     spanB[i] = data[sidx] * 0.0039215686274509803921568627451f;
     sidx += 4;
 }

} Is there a faster way than this?

BingGitCn avatar Apr 01 '24 09:04 BingGitCn