Repository navigation
Expand file tree
/
Copy pathIStorage.cs
More file actions
141 lines (140 loc) · 5.84 KB
/
Copy pathIStorage.cs
File metadata and controls
141 lines (140 loc) · 5.84 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
using NumSharp;
using System;
namespace NumSharp.Core.Interfaces
{
/// <summary>
/// An abstract interface as design basis for the true Storage
///
/// Responsible for :
///
/// - store data type, elements, Shape
/// - offers methods for accessing elements depending on shape
/// - offers methods for casting elements
/// - offers methods for change tensor order
/// - GetData always return reference object to the true storage
/// - GetData<T> and SetData<T> change dtype and cast storage
/// - CloneData always create a clone of storage and return this as reference object
/// - CloneData<T> clone storage and cast this clone
///
/// </summary>
public interface IStorage : ICloneable
{
/// <summary>
/// Data Type of stored elements
/// </summary>
/// <value>numpys equal dtype</value>
Type DType {get;}
/// <summary>
/// storage shape for outside representation
/// </summary>
/// <value>numpys equal shape</value>
Shape Shape {get;}
/// <summary>
/// column wise or row wise order
/// </summary>
/// <value>0 row wise, 1 column wise</value>
int TensorLayout {get;}
/// <summary>
/// Allocate memory by dtype, shape, tensororder (default column wise)
/// </summary>
/// <param name="dtype">storage data type</param>
/// <param name="shape">storage data shape</param>
/// <param name="tensorOrder">row or column wise</param>
void Allocate(Type dtype, Shape shape, int tensorOrder = 1);
/// <summary>
/// Allocate memory by Array and tensororder and deduce shape and dtype (default column wise)
/// </summary>
/// <param name="values">elements to store</param>
/// <param name="tensorOrder">row or column wise</param>
void Allocate(Array values, int tensorOrder = 1);
/// <summary>
/// Get Back Storage with Columnwise tensor Layout
/// By this method the layout is changed if layout is not columnwise
/// </summary>
/// <returns>reference to storage (transformed or not)</returns>
//IStorage GetColumWiseStorage();
/// <summary>
/// Get Back Storage with row wise tensor Layout
/// By this method the layout is changed if layout is not row wise
/// </summary>
/// <returns>reference to storage (transformed or not)</returns>
//IStorage GetRowWiseStorage();
/// <summary>
/// Get reference to internal data storage
/// </summary>
/// <returns>reference to internal storage as System.Array</returns>
Array GetData();
/// <summary>
/// Clone internal storage and get reference to it
/// </summary>
/// <returns>reference to cloned storage as System.Array</returns>
Array CloneData();
/// <summary>
/// Get reference to internal data storage and cast elements to new dtype
/// </summary>
/// <param name="dtype">new storage data type</param>
/// <returns>reference to internal (casted) storage as System.Array </returns>
Array GetData(Type dtype);
/// <summary>
/// Clone internal storage and cast elements to new dtype
/// </summary>
/// <param name="dtype">cloned storage data type</param>
/// <returns>reference to cloned storage as System.Array</returns>
Array CloneData(Type dtype);
/// <summary>
/// Get reference to internal data storage and cast elements to new dtype
/// </summary>
/// <typeparam name="T">new storage data type</typeparam>
/// <returns>reference to internal (casted) storage as T[]</returns>
T[] GetData<T>();
/// <summary>
/// Get all elements from cloned storage as T[] and cast dtype
/// </summary>
/// <typeparam name="T">cloned storgae dtype</typeparam>
/// <returns>reference to cloned storage as T[]</returns>
T[] CloneData<T>();
/// <summary>
/// Get single value from internal storage and do not cast dtype
/// </summary>
/// <param name="indexes">indexes</param>
/// <returns>element from internal storage</returns>
object GetData(params int[] indexes);
/// <summary>
/// Get single value from internal storage as type T and cast dtype to T
/// </summary>
/// <param name="indexes">indexes</param>
/// <typeparam name="T">new storage data type</typeparam>
/// <returns>element from internal storage</returns>
T GetData<T>(params int[] indexes);
/// <summary>
/// Set an array to internal storage and keep dtype
/// </summary>
/// <param name="values"></param>
void SetData(Array values);
/// <summary>
/// Set 1 single value to internal storage and keep dtype
/// </summary>
/// <param name="value"></param>
/// <param name="indexes"></param>
void SetData(object value, params int[] indexes);
/// <summary>
/// Set an Array to internal storage, cast it to new dtype and change dtype
/// </summary>
/// <param name="values"></param>
/// <param name="dtype"></param>
void SetData(Array values, Type dtype);
/// <summary>
/// Change dtype of elements
/// </summary>
/// <param name="dtype">new storage data type</param>
/// <returns>sucess or not</returns>
void ChangeDataType(Type dtype);
/// <summary>
/// Cange layout to 0 row wise or 1 colum wise
/// </summary>
/// <param name="order">0 or 1</param>
/// <returns>success or not</returns>
void ChangeTensorLayout(int order);
void Reshape(params int[] dimensions);
}
}