Forum

ReadOnlySpan Error

Using vvvv Gamma 2019.2.081

I try to use or create a ReadOnly Span and I hit this error:
ReadOnlySpan Error.log (99.8 KB)

To reproduce, create a ReadOnlySpan from ReadonlyMemory

36

Show stopper at the moment. This error doesn’t occur with VL 2019.1.975

Interesting. Root cause is https://github.com/dotnet/csharplang/issues/1148 combined with how value tracing works in VL. I will need to find a way to disable tracing on such ref structs all together :/ Will report back once this is done.

2 Likes

Thanks, this one’s killing me

It’s a little tricky to do this so can I ask what you need Span for? Or any chance you can outsource that functionality for now to C#?

Thanks for looking. Its part of System.Numerics.Tensors and is needed to create a new tensor. It expects Memory<T>Data, IReadOnlySpan<int>Dimensions , so this merked the WIP Onnx with Gamma 2019.2

When you mentioned that this is tricky to fix I figured I’ll might to break my golden rule.

My wrapper is this so far:

namespace VL.ONNX
{
    public class OnnxTensorsVL<T>
    {
        public static Tensor<T> CreateNewTensor(string Name, Memory<T> InputData, int[] Dimensions)
        {
            var DimSpan = new ReadOnlySpan<int>(Dimensions);
            return new DenseTensor<T>(InputData, DimSpan);
        }
    }
}

@Hadasi:
ReadOnlySpan contains an implicit cast operator from array msdn
passing an array to denstensor didn’t give me any syntaxerror in vs. can you just cast or even just input the array?

Hi @woei, and thanks for having a look,

I’ll check it out. Should make the code a little tidier. VL itself will throw an error on any pin interacting with ReadOnlySpan, so it has to be wrapped away for now.