Skip to content

Commit b3bb79f

Browse files
committed
Introduce TFShape to replace long[]
1 parent 8168578 commit b3bb79f

4 files changed

Lines changed: 138 additions & 31 deletions

File tree

OpGenerator/OpGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ string CSharpType (string tfType)
4646
case "type":
4747
cstype = "TFDataType"; break;
4848
case "shape":
49-
cstype = "long[]"; break;
49+
cstype = "TFShape"; break;
5050
case "tensor":
5151
cstype = "TFTensor"; break;
5252
case "string":

SampleTest/SampleTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,10 @@ void ExpectMeta (TFOperation op, string name, int expectedListSize, TFAttributeT
220220
public void AttributesTest ()
221221
{
222222
using (var x = new AttributeTest ()) {
223-
var shape1 = new long [] { 1, 3 };
224-
var shape2 = new long [] { 2, 4, 6 };
223+
var shape1 = new TFShape (new long [] { 1, 3 });
224+
var shape2 = new TFShape ( 2, 4, 6 );
225225
var desc = x.Init ("list(shape)");
226-
desc.SetAttrShape ("v", new long [] [] { shape1, shape2 });
226+
desc.SetAttrShape ("v", new TFShape [] { shape1, shape2 });
227227
var op = desc.FinishOperation ();
228228
ExpectMeta (op, "v", 2, TFAttributeType.Shape, 5);
229229
}

TensorFlowSharp/Operations.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4719,7 +4719,7 @@ public TFOutput DiagPart (TFOutput input, string operName = null)
47194719
/// intended as a way to represent a value that will always be fed, and to
47204720
/// provide attrs that enable the fed value to be checked at runtime.
47214721
/// </remarks>
4722-
public TFOutput PlaceholderV2 (TFDataType dtype, long[] shape, string operName = null)
4722+
public TFOutput PlaceholderV2 (TFDataType dtype, TFShape shape, string operName = null)
47234723
{
47244724
var desc = new TFOperationDesc (this, "PlaceholderV2", MakeName ("PlaceholderV2", operName));
47254725
desc.SetAttrType ("dtype", dtype);
@@ -4763,7 +4763,7 @@ public TFOutput Acos (TFOutput x, string operName = null)
47634763
/// intended as a way to represent a value that will always be fed, and to
47644764
/// provide attrs that enable the fed value to be checked at runtime.
47654765
/// </remarks>
4766-
public TFOutput Placeholder (TFDataType dtype, long[] shape = null, string operName = null)
4766+
public TFOutput Placeholder (TFDataType dtype, TFShape shape = null, string operName = null)
47674767
{
47684768
var desc = new TFOperationDesc (this, "Placeholder", MakeName ("Placeholder", operName));
47694769
desc.SetAttrType ("dtype", dtype);
@@ -5388,7 +5388,7 @@ public TFOutput Rank (TFOutput input, string operName = null)
53885388
/// <remarks>
53895389
/// All elements selected by `indices` must have the same shape.
53905390
/// </remarks>
5391-
public TFOutput TensorArrayGatherV3 (TFOutput handle, TFOutput indices, TFOutput flow_in, TFDataType dtype, long[] element_shape = null, string operName = null)
5391+
public TFOutput TensorArrayGatherV3 (TFOutput handle, TFOutput indices, TFOutput flow_in, TFDataType dtype, TFShape element_shape = null, string operName = null)
53925392
{
53935393
var desc = new TFOperationDesc (this, "TensorArrayGatherV3", MakeName ("TensorArrayGatherV3", operName));
53945394
desc.AddInput (handle);
@@ -6135,7 +6135,7 @@ public TFOutput Diag (TFOutput diagonal, string operName = null)
61356135
/// <remarks>
61366136
/// The current implementation memmaps the tensor from a file.
61376137
/// </remarks>
6138-
public TFOutput ImmutableConst (TFDataType dtype, long[] shape, string memory_region_name, string operName = null)
6138+
public TFOutput ImmutableConst (TFDataType dtype, TFShape shape, string memory_region_name, string operName = null)
61396139
{
61406140
var desc = new TFOperationDesc (this, "ImmutableConst", MakeName ("ImmutableConst", operName));
61416141
desc.SetAttrType ("dtype", dtype);
@@ -7366,7 +7366,7 @@ public TFOutput FloorDiv (TFOutput x, TFOutput y, string operName = null)
73667366
/// <remarks>
73677367
/// via Read or Pack.
73687368
/// </remarks>
7369-
public TFOperation TensorArrayV3 (TFOutput size, TFDataType dtype, ref TFOutput handle, ref TFOutput flow, long[] element_shape = null, bool? dynamic_size = null, bool? clear_after_read = null, string tensor_array_name = null, string operName = null)
7369+
public TFOperation TensorArrayV3 (TFOutput size, TFDataType dtype, ref TFOutput handle, ref TFOutput flow, TFShape element_shape = null, bool? dynamic_size = null, bool? clear_after_read = null, string tensor_array_name = null, string operName = null)
73707370
{
73717371
var desc = new TFOperationDesc (this, "TensorArrayV3", MakeName ("TensorArrayV3", operName));
73727372
desc.AddInput (size);
@@ -9318,7 +9318,7 @@ public TFOutput SdcaFprint (TFOutput input, string operName = null)
93189318
/// <returns>
93199319
/// A placeholder tensor that defaults to `input` if it is not fed.
93209320
/// </returns>
9321-
public TFOutput PlaceholderWithDefault (TFOutput input, long[] shape, string operName = null)
9321+
public TFOutput PlaceholderWithDefault (TFOutput input, TFShape shape, string operName = null)
93229322
{
93239323
var desc = new TFOperationDesc (this, "PlaceholderWithDefault", MakeName ("PlaceholderWithDefault", operName));
93249324
desc.AddInput (input);
@@ -9766,7 +9766,7 @@ public TFOutput ParseTensor (TFOutput serialized, TFDataType out_type, string op
97669766
/// <param name="operName">
97679767
/// If specified, the created operation in the graph will be this one, otherwise it will be named 'ParseExample'.
97689768
/// </param>
9769-
public TFOperation ParseExample (TFOutput serialized, TFOutput names, TFOutput[] sparse_keys, TFOutput[] dense_keys, TFOutput[] dense_defaults, TFDataType[] sparse_types, long[][] dense_shapes, ref TFOutput[] sparse_indices, ref TFOutput[] sparse_values, ref TFOutput[] sparse_shapes, ref TFOutput[] dense_values, string operName = null)
9769+
public TFOperation ParseExample (TFOutput serialized, TFOutput names, TFOutput[] sparse_keys, TFOutput[] dense_keys, TFOutput[] dense_defaults, TFDataType[] sparse_types, TFShape[] dense_shapes, ref TFOutput[] sparse_indices, ref TFOutput[] sparse_values, ref TFOutput[] sparse_shapes, ref TFOutput[] dense_values, string operName = null)
97709770
{
97719771
var desc = new TFOperationDesc (this, "ParseExample", MakeName ("ParseExample", operName));
97729772
desc.AddInput (serialized);
@@ -14160,7 +14160,7 @@ public TFOutput AddN (TFOutput[] inputs, string operName = null)
1416014160
/// </param>
1416114161
/// <returns>
1416214162
/// </returns>
14163-
public TFOutput TensorArrayV2 (TFOutput size, TFDataType dtype, long[] element_shape = null, bool? dynamic_size = null, bool? clear_after_read = null, string tensor_array_name = null, string operName = null)
14163+
public TFOutput TensorArrayV2 (TFOutput size, TFDataType dtype, TFShape element_shape = null, bool? dynamic_size = null, bool? clear_after_read = null, string tensor_array_name = null, string operName = null)
1416414164
{
1416514165
var desc = new TFOperationDesc (this, "TensorArrayV2", MakeName ("TensorArrayV2", operName));
1416614166
desc.AddInput (size);
@@ -14457,7 +14457,7 @@ public TFOutput ComplexAbs (TFOutput x, TFDataType? Tout = null, string operName
1445714457
/// <param name="operName">
1445814458
/// If specified, the created operation in the graph will be this one, otherwise it will be named 'TensorArrayConcatV2'.
1445914459
/// </param>
14460-
public TFOperation TensorArrayConcatV2 (TFOutput handle, TFOutput flow_in, TFDataType dtype, ref TFOutput value, ref TFOutput lengths, long[] element_shape_except0 = null, string operName = null)
14460+
public TFOperation TensorArrayConcatV2 (TFOutput handle, TFOutput flow_in, TFDataType dtype, ref TFOutput value, ref TFOutput lengths, TFShape element_shape_except0 = null, string operName = null)
1446114461
{
1446214462
var desc = new TFOperationDesc (this, "TensorArrayConcatV2", MakeName ("TensorArrayConcatV2", operName));
1446314463
desc.AddInput (handle);
@@ -14889,7 +14889,7 @@ public TFOperation MaxPoolWithArgmax (TFOutput input, long[] ksize, long[] strid
1488914889
/// and DequeueMany) on a PriorityQueue will all require (resp. output) one extra
1489014890
/// entry in their input (resp. output) lists.
1489114891
/// </remarks>
14892-
public TFOutput PriorityQueueV2 (long[][] shapes, TFDataType[] component_types = null, long? capacity = null, string container = null, string shared_name = null, string operName = null)
14892+
public TFOutput PriorityQueueV2 (TFShape[] shapes, TFDataType[] component_types = null, long? capacity = null, string container = null, string shared_name = null, string operName = null)
1489314893
{
1489414894
var desc = new TFOperationDesc (this, "PriorityQueueV2", MakeName ("PriorityQueueV2", operName));
1489514895
desc.SetAttrShape ("shapes", shapes);
@@ -15054,7 +15054,7 @@ public TFOutput StringToHashBucketFast (TFOutput input, long num_buckets, string
1505415054
/// </param>
1505515055
/// <returns>
1505615056
/// </returns>
15057-
public TFOutput VarHandleOp (TFDataType dtype, long[] shape, string container = null, string shared_name = null, string operName = null)
15057+
public TFOutput VarHandleOp (TFDataType dtype, TFShape shape, string container = null, string shared_name = null, string operName = null)
1505815058
{
1505915059
var desc = new TFOperationDesc (this, "VarHandleOp", MakeName ("VarHandleOp", operName));
1506015060
desc.SetAttrType ("dtype", dtype);
@@ -15551,7 +15551,7 @@ public TFOutput MatrixDiag (TFOutput diagonal, string operName = null)
1555115551
///
1555215552
/// All elements must have the same shape (excepting the first dimension).
1555315553
/// </remarks>
15554-
public TFOperation TensorArrayConcatV3 (TFOutput handle, TFOutput flow_in, TFDataType dtype, ref TFOutput value, ref TFOutput lengths, long[] element_shape_except0 = null, string operName = null)
15554+
public TFOperation TensorArrayConcatV3 (TFOutput handle, TFOutput flow_in, TFDataType dtype, ref TFOutput value, ref TFOutput lengths, TFShape element_shape_except0 = null, string operName = null)
1555515555
{
1555615556
var desc = new TFOperationDesc (this, "TensorArrayConcatV3", MakeName ("TensorArrayConcatV3", operName));
1555715557
desc.AddInput (handle);
@@ -17482,7 +17482,7 @@ public TFOutput Rint (TFOutput x, string operName = null)
1748217482
/// to 0 in the shape attr. In this case DequeueMany will pad up to the maximum
1748317483
/// size of any given element in the minibatch. See below for details.
1748417484
/// </remarks>
17485-
public TFOutput PaddingFIFOQueueV2 (TFDataType[] component_types, long[][] shapes = null, long? capacity = null, string container = null, string shared_name = null, string operName = null)
17485+
public TFOutput PaddingFIFOQueueV2 (TFDataType[] component_types, TFShape[] shapes = null, long? capacity = null, string container = null, string shared_name = null, string operName = null)
1748617486
{
1748717487
var desc = new TFOperationDesc (this, "PaddingFIFOQueueV2", MakeName ("PaddingFIFOQueueV2", operName));
1748817488
desc.SetAttrType ("component_types", component_types);
@@ -17943,7 +17943,7 @@ public TFOutput Sub (TFOutput x, TFOutput y, string operName = null)
1794317943
/// feature_list_dense_key[j] must always equal
1794417944
/// feature_list_dense_shapes[j].NumEntries().
1794517945
/// </param>
17946-
public TFOperation ParseSingleSequenceExample (TFOutput serialized, TFOutput feature_list_dense_missing_assumed_empty, TFOutput[] context_sparse_keys, TFOutput[] context_dense_keys, TFOutput[] feature_list_sparse_keys, TFOutput[] feature_list_dense_keys, TFOutput[] context_dense_defaults, TFOutput debug_name, ref TFOutput[] context_sparse_indices, ref TFOutput[] context_sparse_values, ref TFOutput[] context_sparse_shapes, ref TFOutput[] context_dense_values, ref TFOutput[] feature_list_sparse_indices, ref TFOutput[] feature_list_sparse_values, ref TFOutput[] feature_list_sparse_shapes, ref TFOutput[] feature_list_dense_values, TFDataType[] context_sparse_types = null, TFDataType[] feature_list_dense_types = null, long[][] context_dense_shapes = null, TFDataType[] feature_list_sparse_types = null, long[][] feature_list_dense_shapes = null, string operName = null)
17946+
public TFOperation ParseSingleSequenceExample (TFOutput serialized, TFOutput feature_list_dense_missing_assumed_empty, TFOutput[] context_sparse_keys, TFOutput[] context_dense_keys, TFOutput[] feature_list_sparse_keys, TFOutput[] feature_list_dense_keys, TFOutput[] context_dense_defaults, TFOutput debug_name, ref TFOutput[] context_sparse_indices, ref TFOutput[] context_sparse_values, ref TFOutput[] context_sparse_shapes, ref TFOutput[] context_dense_values, ref TFOutput[] feature_list_sparse_indices, ref TFOutput[] feature_list_sparse_values, ref TFOutput[] feature_list_sparse_shapes, ref TFOutput[] feature_list_dense_values, TFDataType[] context_sparse_types = null, TFDataType[] feature_list_dense_types = null, TFShape[] context_dense_shapes = null, TFDataType[] feature_list_sparse_types = null, TFShape[] feature_list_dense_shapes = null, string operName = null)
1794717947
{
1794817948
var desc = new TFOperationDesc (this, "ParseSingleSequenceExample", MakeName ("ParseSingleSequenceExample", operName));
1794917949
desc.AddInput (serialized);
@@ -18045,7 +18045,7 @@ public TFOperation ParseSingleSequenceExample (TFOutput serialized, TFOutput fea
1804518045
/// <returns>
1804618046
/// The handle to the queue.
1804718047
/// </returns>
18048-
public TFOutput FIFOQueueV2 (TFDataType[] component_types, long[][] shapes = null, long? capacity = null, string container = null, string shared_name = null, string operName = null)
18048+
public TFOutput FIFOQueueV2 (TFDataType[] component_types, TFShape[] shapes = null, long? capacity = null, string container = null, string shared_name = null, string operName = null)
1804918049
{
1805018050
var desc = new TFOperationDesc (this, "FIFOQueueV2", MakeName ("FIFOQueueV2", operName));
1805118051
desc.SetAttrType ("component_types", component_types);
@@ -18111,7 +18111,7 @@ public TFOutput FIFOQueueV2 (TFDataType[] component_types, long[][] shapes = nul
1811118111
/// <returns>
1811218112
/// The handle to the queue.
1811318113
/// </returns>
18114-
public TFOutput RandomShuffleQueueV2 (TFDataType[] component_types, long[][] shapes = null, long? capacity = null, long? min_after_dequeue = null, long? seed = null, long? seed2 = null, string container = null, string shared_name = null, string operName = null)
18114+
public TFOutput RandomShuffleQueueV2 (TFDataType[] component_types, TFShape[] shapes = null, long? capacity = null, long? min_after_dequeue = null, long? seed = null, long? seed2 = null, string container = null, string shared_name = null, string operName = null)
1811518115
{
1811618116
var desc = new TFOperationDesc (this, "RandomShuffleQueueV2", MakeName ("RandomShuffleQueueV2", operName));
1811718117
desc.SetAttrType ("component_types", component_types);
@@ -19474,7 +19474,7 @@ public TFOutput RandomCrop (TFOutput image, TFOutput size, long? seed = null, lo
1947419474
/// </param>
1947519475
/// <returns>
1947619476
/// </returns>
19477-
public TFOutput TensorArrayGatherV2 (TFOutput handle, TFOutput indices, TFOutput flow_in, TFDataType dtype, long[] element_shape = null, string operName = null)
19477+
public TFOutput TensorArrayGatherV2 (TFOutput handle, TFOutput indices, TFOutput flow_in, TFDataType dtype, TFShape element_shape = null, string operName = null)
1947819478
{
1947919479
var desc = new TFOperationDesc (this, "TensorArrayGatherV2", MakeName ("TensorArrayGatherV2", operName));
1948019480
desc.AddInput (handle);

0 commit comments

Comments
 (0)