Skip to content

Commit 22effd6

Browse files
committed
Using Shape instead of TensorShape.
1 parent 8784c31 commit 22effd6

164 files changed

Lines changed: 836 additions & 1134 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/TensorFlowNET.Console/MemoryBasicTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public Action<int, int> Conv2DWithVariable
151151
public Action<int, int> Dataset
152152
=> (epoch, iterate) =>
153153
{
154-
TensorShape shape = (16, 32, 32, 3);
154+
Shape shape = (16, 32, 32, 3);
155155
var images = np.arange(shape.size).astype(np.float32).reshape(shape.dims);
156156
var data_handler = new DataHandler(new DataHandlerArgs
157157
{

src/TensorFlowNET.Console/MemoryFuncGraphTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public Action<int, int> ConcreteFunction
2222

2323
Tensor permutation(Tensor tensor)
2424
{
25-
TensorShape shape = (8, 64, 64, 3);
25+
Shape shape = (8, 64, 64, 3);
2626
var images = np.arange(shape.size).astype(np.float32).reshape(shape.dims);
2727
return tf.constant(images);
2828
}

src/TensorFlowNET.Console/MemoryKerasTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public Action<int, int> Conv2DLayer
1919
public Action<int, int> InputLayer
2020
=> (epoch, iterate) =>
2121
{
22-
TensorShape shape = (32, 256, 256, 3); // 48M
22+
Shape shape = (32, 256, 256, 3); // 48M
2323
var images = np.arange(shape.size).astype(np.float32).reshape(shape.dims);
2424

2525
var inputs = keras.Input((shape.dims[1], shape.dims[2], 3));
@@ -31,7 +31,7 @@ public Action<int, int> InputLayer
3131
public Action<int, int> Prediction
3232
=> (epoch, iterate) =>
3333
{
34-
TensorShape shape = (32, 256, 256, 3); // 48M
34+
Shape shape = (32, 256, 256, 3); // 48M
3535
var images = np.arange(shape.size).astype(np.float32).reshape(shape.dims);
3636

3737
var inputs = keras.Input((shape.dims[1], shape.dims[2], 3));

src/TensorFlowNET.Core/APIs/tf.array.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public Tensor boolean_mask<T1, T2>(T1 tensor, T2 mask, string name = "boolean_ma
6565
/// <param name="shape"></param>
6666
/// <param name="name"></param>
6767
/// <returns></returns>
68-
public Tensor broadcast_to(Tensor input, TensorShape shape, string name = null)
68+
public Tensor broadcast_to(Tensor input, Shape shape, string name = null)
6969
=> gen_array_ops.broadcast_to(input, shape, name: name);
7070

7171
public Tensor check_numerics(Tensor tensor, string message, string name = null)
@@ -85,7 +85,7 @@ public Tensor concat(IEnumerable<Tensor> values, int axis, string name = "concat
8585
return tf_with(ops.name_scope(name), scope =>
8686
{
8787
var tensor = ops.convert_to_tensor(axis, name: "concat_dim", dtype: dtypes.int32);
88-
Debug.Assert(tensor.TensorShape.ndim == 0);
88+
Debug.Assert(tensor.shape.ndim == 0);
8989
return identity(values.First(), name: scope);
9090
});
9191
}
@@ -152,7 +152,7 @@ public Tensor where<Tx, Ty>(Tensor condition, Tx x, Ty y, string name = null)
152152
/// <param name="name"></param>
153153
/// <param name="conjugate"></param>
154154
/// <returns></returns>
155-
public Tensor transpose<T1>(T1 a, TensorShape perm = null, string name = "transpose", bool conjugate = false)
155+
public Tensor transpose<T1>(T1 a, Shape perm = null, string name = "transpose", bool conjugate = false)
156156
=> array_ops.transpose(a, perm, name, conjugate);
157157

158158
/// <summary>
@@ -246,7 +246,7 @@ public Tensor pad(Tensor tensor, Tensor paddings, string mode = "CONSTANT", stri
246246
/// <typeparam name="T"></typeparam>
247247
/// <param name="input">A `Tensor`. The default value to produce when output is not fed.</param>
248248
/// <param name="shape">
249-
/// A `tf.TensorShape` or list of `int`s. The (possibly partial) shape of
249+
/// A `tf.Shape` or list of `int`s. The (possibly partial) shape of
250250
/// the tensor.
251251
/// </param>
252252
/// <param name="name">A name for the operation (optional).</param>

src/TensorFlowNET.Core/APIs/tf.compat.v1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void disable_eager_execution()
2525
=> tf.Context.graph_mode();
2626

2727
public IVariableV1 get_variable(string name,
28-
TensorShape shape = null,
28+
Shape shape = null,
2929
TF_DataType dtype = TF_DataType.DtInvalid,
3030
object initializer = null, // IInitializer or Tensor
3131
bool? trainable = null,

src/TensorFlowNET.Core/APIs/tf.image.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public Tensor resize_images(Tensor images, Tensor size, string method = ResizeMe
5858
string name = null)
5959
=> image_ops_impl.resize_images(images, size, method, preserve_aspect_ratio, antialias, name);
6060

61-
public Tensor resize_images_v2(Tensor images, TensorShape size, string method = ResizeMethod.BILINEAR, bool preserve_aspect_ratio = false, bool antialias = false,
61+
public Tensor resize_images_v2(Tensor images, Shape size, string method = ResizeMethod.BILINEAR, bool preserve_aspect_ratio = false, bool antialias = false,
6262
string name = null)
6363
=> image_ops_impl.resize_images_v2(images, size, method, preserve_aspect_ratio, antialias, name);
6464

src/TensorFlowNET.Core/APIs/tf.init.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public IInitializer random_normal_initializer(float mean = 0.0f,
9696
seed: seed,
9797
dtype: dtype);
9898

99-
public IInitializer zeros_initializer(TensorShape shape = null,
99+
public IInitializer zeros_initializer(Shape shape = null,
100100
TF_DataType dtype = TF_DataType.TF_FLOAT) => new Zeros(shape: shape,
101101
dtype: dtype);
102102
}

src/TensorFlowNET.Core/APIs/tf.linalg.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class LinalgApi
2727

2828
public Tensor eye(int num_rows,
2929
int num_columns = -1,
30-
TensorShape batch_shape = null,
30+
Shape batch_shape = null,
3131
TF_DataType dtype = TF_DataType.TF_DOUBLE,
3232
string name = null)
3333
=> ops.eye(num_rows, num_columns: num_columns, batch_shape: batch_shape, dtype: dtype, name: name);

src/TensorFlowNET.Core/APIs/tf.math.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public Tensor bincount(Tensor arr, Tensor weights = null,
5050
Tensor maxlength = null,
5151
TF_DataType dtype = TF_DataType.TF_INT32,
5252
string name = null,
53-
TensorShape axis = null,
53+
Shape axis = null,
5454
bool binary_output = false)
5555
=> math_ops.bincount(arr, weights: weights, minlength: minlength, maxlength: maxlength,
5656
dtype: dtype, name: name, axis: axis, binary_output: binary_output);
@@ -327,7 +327,7 @@ public Tensor log(Tensor x, string name = null)
327327
=> gen_math_ops.log(x, name);
328328

329329
public Tensor equal(Tensor x, Tensor y, string name = null)
330-
=> gen_math_ops.equal(x, y, name);
330+
=> gen_math_ops.equal(x, y, name: name);
331331

332332
/// <summary>
333333
/// Computes arctangent of `y/x` element-wise, respecting signs of the arguments.
@@ -453,7 +453,7 @@ public Tensor floordiv(Tensor x, Tensor y, string name = null)
453453
public static Tensor truediv(Tensor x, Tensor y, string name = null)
454454
=> math_ops.truediv(x, y, name: name);
455455

456-
public Tensor range(object start, object limit = null, object delta = null, TF_DataType dtype = TF_DataType.DtInvalid, string name = "range")
456+
public Tensor range(object start, object limit = null, object delta = null, TF_DataType? dtype = null, string name = "range")
457457
=> math_ops.range(start, limit: limit, delta: delta, dtype: dtype, name: name);
458458

459459
public Tensor real(Tensor input, string name = null)
@@ -522,7 +522,7 @@ public Tensor reduce_sum(Tensor input, int? axis = null, int? reduction_indices
522522
return math_ops.reduce_sum(input, keepdims: keepdims, name: name);
523523
}
524524

525-
public Tensor reduce_sum(Tensor input, TensorShape axis, int? reduction_indices = null,
525+
public Tensor reduce_sum(Tensor input, Shape axis, int? reduction_indices = null,
526526
bool keepdims = false, string name = null)
527527
=> math_ops.reduce_sum(input, axis, keepdims: keepdims, name: name);
528528

src/TensorFlowNET.Core/APIs/tf.queue.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public partial class tensorflow
3232
/// <returns></returns>
3333
public PaddingFIFOQueue PaddingFIFOQueue(int capacity,
3434
TF_DataType[] dtypes,
35-
TensorShape[] shapes,
35+
Shape[] shapes,
3636
string[] names = null,
3737
string shared_name = null,
3838
string name = "padding_fifo_queue")
@@ -45,7 +45,7 @@ public PaddingFIFOQueue PaddingFIFOQueue(int capacity,
4545

4646
public PaddingFIFOQueue PaddingFIFOQueue(int capacity,
4747
TF_DataType dtype,
48-
TensorShape shape,
48+
Shape shape,
4949
string shared_name = null,
5050
string name = "padding_fifo_queue")
5151
=> new PaddingFIFOQueue(capacity,
@@ -66,7 +66,7 @@ public PaddingFIFOQueue PaddingFIFOQueue(int capacity,
6666
/// <returns></returns>
6767
public FIFOQueue FIFOQueue(int capacity,
6868
TF_DataType[] dtypes,
69-
TensorShape[] shapes = null,
69+
Shape[] shapes = null,
7070
string[] names = null,
7171
string shared_name = null,
7272
string name = "fifo_queue")
@@ -79,12 +79,12 @@ public FIFOQueue FIFOQueue(int capacity,
7979

8080
public FIFOQueue FIFOQueue(int capacity,
8181
TF_DataType dtype,
82-
TensorShape shape = null,
82+
Shape shape = null,
8383
string shared_name = null,
8484
string name = "fifo_queue")
8585
=> new FIFOQueue(capacity,
8686
new[] { dtype },
87-
new[] { shape ?? new TensorShape() },
87+
new[] { shape ?? Shape.Null },
8888
shared_name: shared_name,
8989
name: name);
9090

@@ -99,26 +99,26 @@ public FIFOQueue FIFOQueue(int capacity,
9999
/// <returns></returns>
100100
public PriorityQueue PriorityQueue(int capacity,
101101
TF_DataType dtype,
102-
TensorShape shape = null,
102+
Shape shape = null,
103103
string shared_name = null,
104104
string name = "priority_queue")
105105
=> new PriorityQueue(capacity,
106106
new[] { dtype },
107-
new[] { shape ?? new TensorShape() },
107+
new[] { shape ?? Shape.Null },
108108
shared_name: shared_name,
109109
name: name);
110110

111111
public RandomShuffleQueue RandomShuffleQueue(int capacity,
112112
int min_after_dequeue,
113113
TF_DataType dtype,
114-
TensorShape shape = null,
114+
Shape shape = null,
115115
int? seed = null,
116116
string shared_name = null,
117117
string name = "random_shuffle_queue")
118118
=> new RandomShuffleQueue(capacity,
119119
min_after_dequeue: min_after_dequeue,
120120
new[] { dtype },
121-
new[] { shape ?? new TensorShape() },
121+
new[] { shape ?? Shape.Null },
122122
seed: seed,
123123
shared_name: shared_name,
124124
name: name);

0 commit comments

Comments
 (0)