Skip to content

Commit dd2e1ed

Browse files
committed
fix fsharp
1 parent aedf161 commit dd2e1ed

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/TorchSharp/Dataset.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,23 @@ public static partial class data
1414
/// <summary>
1515
/// Map-style data set
1616
/// </summary>
17-
public abstract class Dataset : Dataset<Dictionary<string, torch.Tensor>>
17+
public abstract class Dataset : Dataset<Dictionary<string, Tensor>>,
18+
IDataset<IReadOnlyDictionary<string, Tensor>>
1819
{
20+
// Due to covariation, it should naturally be IDataset<IReadOnlyDictionary<string, Tensor>>.
21+
// However FSharp.Examples will break down without this.
22+
IReadOnlyDictionary<string, Tensor> IDataset<IReadOnlyDictionary<string, Tensor>>.this[long index] => this[index];
1923
}
2024

2125
/// <summary>
2226
/// Iterable-style data sets
2327
/// </summary>
24-
public abstract class IterableDataset : Dataset<IList<Tensor>>
28+
public abstract class IterableDataset : Dataset<IList<Tensor>>,
29+
IDataset<IEnumerable<Tensor>>
2530
{
31+
// Due to covariation, it should naturally be IDataset<IEnumerable<Tensor>>.
32+
// However FSharp.Examples will break down without this.
33+
IEnumerable<Tensor> IDataset<IEnumerable<Tensor>>.this[long index] => this[index];
2634
}
2735

2836
/// <summary>

0 commit comments

Comments
 (0)