10000 Fix LSTM crash in release mode. · SciSharp/TensorFlow.NET@b2fe5ca · GitHub
[go: up one dir, main page]

Skip to content

Commit b2fe5ca

Browse files
committed
Fix LSTM crash in release mode.
1 parent 9cd8681 commit b2fe5ca

19 files changed

+160
-57
lines changed

src/TensorFlowNET.Core/Gradients/nn_grad.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ public static Tensor[] _AvgPoolGrad(Operation op, Tensor[] grads)
377377
grad,
378378
op.get_attr_list<int>("ksize"),
379379
op.get_attr_list<int>("strides"),
380-
op.get_attr("padding").ToString(),
381-
op.get_attr("data_format").ToString())
380+
op.get_attr<string>("padding"),
381+
op.get_attr<string>("data_format"))
382382
};
383383
}
384384

src/TensorFlowNET.Core/Operations/Operation.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,11 @@ internal unsafe TF_DataType _get_attr_type(string name)
206206
return result;
207207
}
208208

209-
internal unsafe int _get_attr_int(string name)
209+
internal unsafe l F438 ong _get_attr_int(string name)
210210
{
211-
Status status = new();
212-
int result;
213-
c_api.TF_OperationGetAttrInt(_handle, name, new IntPtr(&result), status);
214-
status.Check(true);
211+
long result;
212+
c_api.TF_OperationGetAttrInt(_handle, name, new IntPtr(&result), tf.Status);
213+
tf.Status.Check(true);
215214
return result;
216215
}
217216

src/TensorFlowNET.Core/Tensorflow.Binding.csproj

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
55
<AssemblyName>Tensorflow.Binding</AssemblyName>
66
<RootNamespace>Tensorflow</RootNamespace>
7-
<TargetTensorFlow>2.10.0</TargetTensorFlow>
8-
<Version>0.110.1</Version>
7+
<TargetTensorFlow>2.11.0</TargetTensorFlow>
8+
<Version>0.110.2</Version>
99
<LangVersion>10.0</LangVersion>
1010
<Nullable>enable</Nullable>
11-
<Authors>Haiping Chen, Meinrad Recheis, Eli Belash</Authors>
11+
<Authors>Haiping Chen, Eli Belash, Yaohui Liu, Meinrad Recheis</Authors>
1212
<Company>SciSharp STACK</Company>
1313
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
1414
<Copyright>Apache 2.0, Haiping Chen $([System.DateTime]::UtcNow.ToString(yyyy))</Copyright>
@@ -23,7 +23,8 @@ https://tensorflownet.readthedocs.io</Description>
2323
<AssemblyVersion>0.110.1.0</AssemblyVersion>
2424
<PackageReleaseNotes>
2525
tf.net 0.110.x and above are based on tensorflow native 2.11.0
26-
* RNN, LSTM works.
26+
* Support RNN, LSTM model.
27+
* Support Transformer model.
2728

2829
tf.net 0.100.x and above are based on tensorflow native 2.10.0
2930

@@ -42,12 +43,11 @@ https://tensorflownet.readthedocs.io</Description>
4243
tf.net 0.10x.x aligns with TensorFlow v2.10.x native library.
4344
tf.net 0.11x.x aligns with TensorFlow v2.11.x native library.
4445
</PackageReleaseNotes>
45-
<FileVersion>0.110.1.0</FileVersion>
46+
<FileVersion>0.110.2.0</FileVersion>
4647
<PackageLicenseFile>LICENSE</PackageLicenseFile>
4748
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
4849
<PackageOutputPath>packages</PackageOutputPath>
4950
<SignAssembly>true</SignAssembly>
50-
<AssemblyOriginatorKeyFile>Open.snk</AssemblyOriginatorKeyFile>
5151
<Platforms>AnyCPU;x64</Platforms>
5252
<PackageId>TensorFlow.NET</PackageId>
5353
<Configurations>Debug;Release;GPU</Configurations>
@@ -88,6 +88,66 @@ https://tensorflownet.readthedocs.io</Description>
8888
<DefineConstants />
8989
</PropertyGroup>
9090

91+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard2.0|AnyCPU'">
92+
<WarningLevel>1</WarningLevel>
93+
<NoWarn>$(NoWarn),1570,1573,1591,1712,8603,8604,8625,CS0612</NoWarn>
94+
</PropertyGroup>
95+
96+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard2.0|x64'">
97+
<WarningLevel>1</WarningLevel>
98+
<NoWarn>$(NoWarn),1570,1573,1591,1712,8603,8604,8625,CS0612</NoWarn>
99+
</PropertyGroup>
100+
101+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.0|AnyCPU'">
102+
<WarningLevel>1</WarningLevel>
103+
<NoWarn>$(NoWarn),1570,1573,1591,1712,8603,8604,8625,CS0612</NoWarn>
104+
</PropertyGroup>
105+
106+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.0|x64'">
107+
<WarningLevel>1</WarningLevel>
108+
<NoWarn>$(NoWarn),1570,1573,1591,1712,8603,8604,8625,CS0612</NoWarn>
109+
</PropertyGroup>
110+
111+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='GPU|netstandard2.0|AnyCPU'">
112+
<WarningLevel>1</WarningLevel>
113+
<NoWarn>$(NoWarn),1570,1573,1591,1712,8603,8604,8625,CS0612</NoWarn>
114+
</PropertyGroup>
115+
116+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='GPU|netstandard2.0|x64'">
117+
<WarningLevel>1</WarningLevel>
118+
<NoWarn>$(NoWarn),1570,1573,1591,1712,8603,8604,8625,CS0612</NoWarn>
119+
</PropertyGroup>
120+
121+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0|AnyCPU'">
122+
<WarningLevel>1</WarningLevel>
123+
<NoWarn>$(NoWarn),1570,1573,1591,1712,8603,8604,8625,CS0612</NoWarn>
124+
</PropertyGroup>
125+
126+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0|x64'">
127+
<WarningLevel>1</WarningLevel>
128+
<NoWarn>$(NoWarn),1570,1573,1591,1712,8603,8604,8625,CS0612</NoWarn>
129+
</PropertyGroup>
130+
131+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0|AnyCPU'">
132+
<WarningLevel>1</WarningLevel>
133+
<NoWarn>$(NoWarn),1570,1573,1591,1712,8603,8604,8625,CS0612</NoWarn>
134+
</PropertyGroup>
135+
136+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0|x64'">
137+
<WarningLevel>1</WarningLevel>
138+
<NoWarn>$(NoWarn),1570,1573,1591,1712,8603,8604,8625,CS0612</NoWarn>
139+
</PropertyGroup>
140+
141+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='GPU|net6.0|AnyCPU'">
142+
<WarningLevel>1</WarningLevel>
143+
<NoWarn>$(NoWarn),1570,1573,1591,1712,8603,8604,8625,CS0612</NoWarn>
144+
</PropertyGroup>
145+
146+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='GPU|net6.0|x64'">
147+
<WarningLevel>1</WarningLevel>
148+
<NoWarn>$(NoWarn),1570,1573,1591,1712,8603,8604,8625,CS0612</NoWarn>
149+
</PropertyGroup>
150+
91151
<ItemGroup>
92152
<Compile Remove="Distribute\**" />
93153
<Compile Remove="Models\**" />

src/TensorFlowNET.Core/Tensors/Tensor.Index.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ public Tensor slice(int start)
180180
array_ops.stack(end.ToArray()),
181181
array_ops.stack(strides.ToArray()));
182182

183-
return gen_array_ops.strided_slice(
184-
this,
183+
return array_ops.strided_slice(this,
185184
packed_begin,
186185
packed_end,
187186
packed_strides,

src/TensorFlowNET.Keras/Activations.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public class Activations: IActivationsApi
4444
/// <summary>
4545
/// Register the name-activation mapping in this static class.
4646
/// </summary>
47< B41A code class="diff-text syntax-highlighted-line deletion">-
/// <param name="name"></param>
4847
/// <param name="activation"></param>
4948
private static void RegisterActivation(Activation activation)
5049
{

src/TensorFlowNET.Keras/Callbacks/Earlystopping.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ namespace Tensorflow.Keras.Callbacks;
55
/// <summary>
66
/// Stop training when a monitored metric has stopped improving.
77
/// </summary>
8-
/// <param name="parameters"></param>
9-
/// <param name="monitor"></param>
10-
118
public class EarlyStopping: ICallback
129
{
1310
int _paitence;

src/TensorFlowNET.Keras/Engine/DataAdapters/TensorLikeDataAdapter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Tensors permutation(Tensors tensor)
5252
/// <summary>
5353
/// Convert a Tensor of indices into a dataset of batched indices.
5454
/// </summary>
55-
/// <param name="tensor"></param>
55+
/// <param name="indices"></param>
5656
/// <returns></returns>
5757
IDatasetV2 slice_batch_indices(Tensor indices)
5858
{

src/TensorFlowNET.Keras/Engine/Layer.Apply.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public partial class Layer
1010
/// Wraps `call`, applying pre- and post-processing steps.
1111
/// </summary>
1212
/// <param name="inputs"></param>
13-
/// <param name="state"></param>
13+
/// <param name="states"></param>
1414
/// <param name="training"></param>
1515
/// <returns></returns>
1616
public virtual Tensors Apply(Tensors inputs, Tensors states = null, bool? training = false, IOptionalArgs? optional_args = null)

src/TensorFlowNET.Keras/Engine/Layer.FunctionalConstructionCall.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
11
using System;
22
using Tensorflow.Keras.Utils;
3-
using static Tensorflow.Binding;
4-
using static Tensorflow.KerasApi;
53

64
namespace Tensorflow.Keras.Engine
75
{
86
public partial class Layer
97
{
108
Tensors FunctionalConstructionCall(Tensors inputs)
119
{
12-
bool mask_arg_passed_by_framework = false;
13-
bool training_arg_passed_by_framework = false;
14-
Tensor training_value = null;
15-
if (training_value == null)
16-
{
17-
training_arg_passed_by_framework = true;
18-
}
19-
2010
if (base_layer_utils.needs_keras_history(inputs))
2111
base_layer_utils.create_keras_history(inputs);
2212

src/TensorFlowNET.Keras/Engine/Model.Evaluate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Tensorflow.Keras.Engine
1515
public partial class Model
1616
{
1717
/// <summary>
18-
/// Returns the loss value & metrics values for the model in test mode.
18+
/// Returns the loss value and metrics values for the model in test mode.
1919
/// </summary>
2020
/// <param name="x"></param>
2121
/// <param name="y"></param>

src/TensorFlowNET.Keras/Engine/Model.Train.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ Dictionary<string, float> train_step_multi_inputs_function(DataHandler data_hand
2929
/// <summary>
3030
/// The logic for one training step.
3131
/// </summary>
32-
/// <param name="data"></param>
32+
/// <param name="data_handler"></param>
33+
/// <param name="x"></param>
34+
/// <param name="y"></param>
3335
/// <returns></returns>
3436
Dictionary<string, float> train_step(DataHandler data_handler, Tensors x, Tensors y)
3537
{

src/TensorFlowNET.Keras/KerasInterface.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public Sequential Sequential(params ILayer[] layers)
7272
/// <summary>
7373
/// `Model` groups layers into an object with training and inference features.
7474
/// </summary>
75-
/// <param name="input"></param>
76-
/// <param name="output"></param>
75+
/// <param name="inputs"></param>
76+
/// <param name="outputs"></param>
7777
/// <returns></returns>
7878
public IModel Model(Tensors inputs, Tensors outputs, string name = null)
7979
=> new Functional(inputs, outputs, name: name);

src/TensorFlowNET.Keras/Layers/Attention/BaseDenseAttention.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
using Tensorflow.Keras.Engine;
22
using Tensorflow.Keras.ArgsDefinition;
3-
using static Tensorflow.Binding;
4-
using static Tensorflow.KerasApi;
53
using System;
64
using System.Collections.Generic;
75
using System.Linq;
86
using Tensorflow.Keras.Saving;
97
using Tensorflow.Common.Types;
108

11-
/// <summary>
12-
/// Base class for attention layers that can be used in sequence DNN/CNN models.
13-
///This file follows the terminology of https://arxiv.org/abs/1706.03762 Figure 2.
14-
///Attention is formed by three tensors: Query, Key and Value.
15-
/// </summary>
16-
179
namespace Tensorflow.Keras.Layers
1810
{
1911

2012
/// <summary>
2113
/// Base Attention class for Dense networks.
14+
/// This file follows the terminology of https://arxiv.org/abs/1706.03762 Figure 2.
15+
/// Attention is formed by three tensors: Query, Key and Value.
2216
/// This class is suitable for Dense or CNN networks, and not for RNN networks.
2317
/// Implementations of attention mechanisms should inherit from this class, and
2418
/// reuse the `apply_attention_scores()` method.

src/TensorFlowNET.Keras/Layers/LayersApi.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,6 @@ public ILayer Conv2D(int filters,
183183
/// <param name="use_bias">Boolean, whether the layer uses a bias vector.</param>
184184
/// <param name="kernel_initializer">The name of the initializer for the kernel weights matrix (see keras.initializers).</param>
185185
/// <param name="bias_initializer">The name of the initializer for the bias vector (see keras.initializers).</param>
186-
/// <param name="kernel_regularizer">The name of the regularizer function applied to the kernel weights matrix (see keras.regularizers).</param>
187-
/// <param name="bias_regularizer">The name of the regularizer function applied to the bias vector (see keras.regularizers).</param>
188-
/// <param name="activity_regularizer">The name of the regularizer function applied to the output of the layer (its "activation") (see keras.regularizers).</param>
189186
/// <returns>A tensor of rank 4+ representing activation(conv2d(inputs, kernel) + bias).</returns>
190187
public ILayer Conv2D(int filters,
191188
Shape k 10000 ernel_size = null,

src/TensorFlowNET.Keras/Layers/Reshaping/Cropping1D.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using Tensorflow.Keras.Engine;
33
using Tensorflow.Keras.Saving;
44
using Tensorflow.Common.Types;
5-
using Tensorflow.Common.Types;
65

76
namespace Tensorflow.Keras.Layers.Reshaping
87
{

src/TensorFlowNET.Keras/Layers/Rnn/RNN.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,9 @@ object get_state_spec(Shape shape)
242242
///
243243
/// </summary>
244244
/// <param name="inputs"></param>
245-
/// <param name="mask">Binary tensor of shape [batch_size, timesteps] indicating whether a given timestep should be masked</param>
246-
/// <param name="training"></param>
247245
/// <param name="initial_state">List of initial state tensors to be passed to the first call of the cell</param>
248-
/// <param name="constants">List of constant tensors to be passed to the cell at each timestep</param>
246+
/// <param name="training"></param>
247+
/// <param name="optional_args"></param>
249248
/// <returns></returns>
250249
/// <exception cref="ValueError"></exception>
251250
/// <exception cref="NotImplementedException"></exception>

src/TensorFlowNET.Keras/Preprocessings/DatasetUtils.get_training_or_validation_split.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Tensorflow.Keras.Preprocessings
66
public partial class DatasetUtils
77
{
88
/// <summary>
9-
/// Potentially restict samples & labels to a training or validation split.
9+
/// Potentially restict samples and labels to a training or validation split.
1010
/// </summary>
1111
/// <param name="samples"></param>
1212
/// <param name="labels"></param>

src/TensorFlowNET.Keras/Saving/KerasObjectLoader.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,6 @@ private bool _try_build_layer(Layer obj, int node_id, KerasShapesWrapper build_i
693693
/// Infers input shape of layer from SavedModel functions.
694694
/// </summary>
695695
/// <param name="layer_node_id"></param>
696-
/// <param name="convert_to_shapes"></param>
697696
/// <returns></returns>
698697
private TensorSpec _infer_inputs(int layer_node_id)
699698
{

0 commit comments

Comments
 (0)
0