-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
IReadOnlyTensor.cs
46 lines (38 loc) · 1.78 KB
/
IReadOnlyTensor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Buffers;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace System.Numerics.Tensors
{
public interface IReadOnlyTensor<TSelf, T> : IEnumerable<T>
where TSelf : IReadOnlyTensor<TSelf, T>
{
static abstract TSelf? Empty { get; }
bool IsEmpty { get; }
bool IsPinned { get; }
nint FlattenedLength { get; }
int Rank { get; }
T this[params ReadOnlySpan<nint> indexes] { get; }
T this[params ReadOnlySpan<NIndex> indexes] { get; }
TSelf this[params scoped ReadOnlySpan<NRange> ranges] { get; }
ReadOnlyTensorSpan<T> AsReadOnlyTensorSpan();
ReadOnlyTensorSpan<T> AsReadOnlyTensorSpan(params scoped ReadOnlySpan<nint> start);
ReadOnlyTensorSpan<T> AsReadOnlyTensorSpan(params scoped ReadOnlySpan<NIndex> startIndex);
ReadOnlyTensorSpan<T> AsReadOnlyTensorSpan(params scoped ReadOnlySpan<NRange> range);
void CopyTo(scoped TensorSpan<T> destination);
void FlattenTo(scoped Span<T> destination);
// These are not properties so that structs can implement the interface without allocating:
void GetLengths(scoped Span<nint> destination);
void GetStrides(scoped Span<nint> destination);
ref readonly T GetPinnableReference();
TSelf Slice(params scoped ReadOnlySpan<nint> start);
TSelf Slice(params scoped ReadOnlySpan<NIndex> startIndex);
TSelf Slice(params scoped ReadOnlySpan<NRange> range);
bool TryCopyTo(scoped TensorSpan<T> destination);
bool TryFlattenTo(scoped Span<T> destination);
}
}