diff --git a/src/TensorFlowNET.Core/Eager/EagerRunner.RecordGradient.cs b/src/TensorFlowNET.Core/Eager/EagerRunner.RecordGradient.cs index e5ac056e..0622c68c 100644 --- a/src/TensorFlowNET.Core/Eager/EagerRunner.RecordGradient.cs +++ b/src/TensorFlowNET.Core/Eager/EagerRunner.RecordGradient.cs @@ -43,7 +43,9 @@ namespace Tensorflow.Eager if (!should_record) return should_record; Tensor[] op_outputs; +#pragma warning disable CS0219 // Variable is assigned but its value is never used bool op_outputs_tuple_created = false; +#pragma warning restore CS0219 // Variable is assigned but its value is never used var unused_output_indices = gradient_exclustions.OpGradientUnusedOutputIndices(op_name); if (unused_output_indices != null) { @@ -59,7 +61,9 @@ namespace Tensorflow.Eager op_outputs = results; Tensor[] op_inputs; +#pragma warning disable CS0219 // Variable is assigned but its value is never used bool op_inputs_tuple_created = false; +#pragma warning restore CS0219 // Variable is assigned but its value is never used var unused_input_indices = gradient_exclustions.OpGradientUnusedInputIndices(op_name); if(unused_input_indices != null) { diff --git a/src/TensorFlowNET.Core/Framework/importer.cs b/src/TensorFlowNET.Core/Framework/importer.cs index c28579be..49d4372b 100644 --- a/src/TensorFlowNET.Core/Framework/importer.cs +++ b/src/TensorFlowNET.Core/Framework/importer.cs @@ -83,7 +83,9 @@ namespace Tensorflow var combined_return_elements = new List(); int outputs_idx = 0; +#pragma warning disable CS0219 // Variable is assigned but its value is never used int opers_idx = 0; +#pragma warning restore CS0219 // Variable is assigned but its value is never used foreach(var name in requested_return_elements) { if (name.Contains(":")) diff --git a/src/TensorFlowNET.Core/Gradients/gradients_util.cs b/src/TensorFlowNET.Core/Gradients/gradients_util.cs index c9322105..9082d4e2 100644 --- a/src/TensorFlowNET.Core/Gradients/gradients_util.cs +++ b/src/TensorFlowNET.Core/Gradients/gradients_util.cs @@ -393,7 +393,9 @@ namespace Tensorflow // Aggregate multiple gradients, and convert [] to None. if (out_grad.Count > 0) { +#pragma warning disable CS0219 // Variable is assigned but its value is never used string used = ""; +#pragma warning restore CS0219 // Variable is assigned but its value is never used if (out_grad.Count < 2) { used = "nop"; diff --git a/src/TensorFlowNET.Core/Keras/Utils/base_layer_utils.cs b/src/TensorFlowNET.Core/Keras/Utils/base_layer_utils.cs index ed672912..76a20bcf 100644 --- a/src/TensorFlowNET.Core/Keras/Utils/base_layer_utils.cs +++ b/src/TensorFlowNET.Core/Keras/Utils/base_layer_utils.cs @@ -38,8 +38,10 @@ namespace Tensorflow.Keras.Utils IInitializer initializer = null, bool trainable = true) { +#pragma warning disable CS0219 // Variable is assigned but its value is never used var initializing_from_value = false; bool use_resource = true; +#pragma warning restore CS0219 // Variable is assigned but its value is never used ops.init_scope(); diff --git a/src/TensorFlowNET.Core/Operations/NnOps/_WithSpaceToBatch.cs b/src/TensorFlowNET.Core/Operations/NnOps/_WithSpaceToBatch.cs index 5717a3f1..e9b6126c 100644 --- a/src/TensorFlowNET.Core/Operations/NnOps/_WithSpaceToBatch.cs +++ b/src/TensorFlowNET.Core/Operations/NnOps/_WithSpaceToBatch.cs @@ -34,7 +34,9 @@ namespace Tensorflow.Operations var dilation_rate_tensor = ops.convert_to_tensor(dilation_rate, TF_DataType.TF_INT32, name: "dilation_rate"); var rate_shape = dilation_rate_tensor.TensorShape; var num_spatial_dims = rate_shape.dims[0]; +#pragma warning disable CS0219 // Variable is assigned but its value is never used int starting_spatial_dim = -1; +#pragma warning restore CS0219 // Variable is assigned but its value is never used if (!string.IsNullOrEmpty(data_format) && data_format.StartsWith("NC")) starting_spatial_dim = 2; else diff --git a/src/TensorFlowNET.Core/Operations/gen_control_flow_ops.cs b/src/TensorFlowNET.Core/Operations/gen_control_flow_ops.cs index e9801a12..a860d9dc 100644 --- a/src/TensorFlowNET.Core/Operations/gen_control_flow_ops.cs +++ b/src/TensorFlowNET.Core/Operations/gen_control_flow_ops.cs @@ -152,7 +152,9 @@ namespace Tensorflow { var _op = tf._op_def_lib._apply_op_helper("Switch", name, new { data, pred }); var _inputs_flat = _op.inputs; +#pragma warning disable CS0219 // Variable is assigned but its value is never used var _attrs = ("T", _op.get_attr("T")); +#pragma warning restore CS0219 // Variable is assigned but its value is never used // TODO: missing original code //_execute.record_gradient("Switch", _inputs_flat, _attrs, _result, name); return new []{_op.outputs[0], _op.outputs[1]}; diff --git a/src/TensorFlowNET.Core/Training/Optimizer.cs b/src/TensorFlowNET.Core/Training/Optimizer.cs index 848909b2..1a77858e 100644 --- a/src/TensorFlowNET.Core/Training/Optimizer.cs +++ b/src/TensorFlowNET.Core/Training/Optimizer.cs @@ -374,7 +374,9 @@ namespace Tensorflow { // Scale loss if using a "mean" loss reduction and multiple replicas. loss = _scale_loss(loss); +#pragma warning disable CS0219 // Variable is assigned but its value is never used int num_towers = 1; +#pragma warning restore CS0219 // Variable is assigned but its value is never used if(var_list == null) { diff --git a/src/TensorFlowNET.Core/Training/Trackable.cs b/src/TensorFlowNET.Core/Training/Trackable.cs index 332e1764..49eb4ada 100644 --- a/src/TensorFlowNET.Core/Training/Trackable.cs +++ b/src/TensorFlowNET.Core/Training/Trackable.cs @@ -39,7 +39,9 @@ namespace Tensorflow.Train VariableAggregation aggregation = VariableAggregation.None) { ops.init_scope(); +#pragma warning disable CS0219 // Variable is assigned but its value is never used IInitializer checkpoint_initializer = null; +#pragma warning restore CS0219 // Variable is assigned but its value is never used if (tf.context.executing_eagerly()) ; else diff --git a/test/TensorFlowNET.UnitTest/MultithreadingTests.cs b/test/TensorFlowNET.UnitTest/MultithreadingTests.cs index 76fda561..543248bf 100644 --- a/test/TensorFlowNET.UnitTest/MultithreadingTests.cs +++ b/test/TensorFlowNET.UnitTest/MultithreadingTests.cs @@ -167,7 +167,9 @@ namespace TensorFlowNET.UnitTest { using (var sess = tf.Session()) { +#pragma warning disable CS0219 // Variable is assigned but its value is never used Tensor t = null; +#pragma warning restore CS0219 // Variable is assigned but its value is never used for (int i = 0; i < 100; i++) { var v = (int*) Marshal.AllocHGlobal(sizeof(int));