Browse Source

Suppress CS0219 (Variable is assigned but its value is never used)

tags/v0.20
Sam Harwell Haiping 5 years ago
parent
commit
e40b2f7925
9 changed files with 20 additions and 0 deletions
  1. +4
    -0
      src/TensorFlowNET.Core/Eager/EagerRunner.RecordGradient.cs
  2. +2
    -0
      src/TensorFlowNET.Core/Framework/importer.cs
  3. +2
    -0
      src/TensorFlowNET.Core/Gradients/gradients_util.cs
  4. +2
    -0
      src/TensorFlowNET.Core/Keras/Utils/base_layer_utils.cs
  5. +2
    -0
      src/TensorFlowNET.Core/Operations/NnOps/_WithSpaceToBatch.cs
  6. +2
    -0
      src/TensorFlowNET.Core/Operations/gen_control_flow_ops.cs
  7. +2
    -0
      src/TensorFlowNET.Core/Training/Optimizer.cs
  8. +2
    -0
      src/TensorFlowNET.Core/Training/Trackable.cs
  9. +2
    -0
      test/TensorFlowNET.UnitTest/MultithreadingTests.cs

+ 4
- 0
src/TensorFlowNET.Core/Eager/EagerRunner.RecordGradient.cs View File

@@ -43,7 +43,9 @@ namespace Tensorflow.Eager
if (!should_record) return should_record; if (!should_record) return should_record;


Tensor[] op_outputs; Tensor[] op_outputs;
#pragma warning disable CS0219 // Variable is assigned but its value is never used
bool op_outputs_tuple_created = false; 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); var unused_output_indices = gradient_exclustions.OpGradientUnusedOutputIndices(op_name);
if (unused_output_indices != null) if (unused_output_indices != null)
{ {
@@ -59,7 +61,9 @@ namespace Tensorflow.Eager
op_outputs = results; op_outputs = results;


Tensor[] op_inputs; Tensor[] op_inputs;
#pragma warning disable CS0219 // Variable is assigned but its value is never used
bool op_inputs_tuple_created = false; 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); var unused_input_indices = gradient_exclustions.OpGradientUnusedInputIndices(op_name);
if(unused_input_indices != null) if(unused_input_indices != null)
{ {


+ 2
- 0
src/TensorFlowNET.Core/Framework/importer.cs View File

@@ -83,7 +83,9 @@ namespace Tensorflow


var combined_return_elements = new List<ITensorOrOperation>(); var combined_return_elements = new List<ITensorOrOperation>();
int outputs_idx = 0; int outputs_idx = 0;
#pragma warning disable CS0219 // Variable is assigned but its value is never used
int opers_idx = 0; int opers_idx = 0;
#pragma warning restore CS0219 // Variable is assigned but its value is never used
foreach(var name in requested_return_elements) foreach(var name in requested_return_elements)
{ {
if (name.Contains(":")) if (name.Contains(":"))


+ 2
- 0
src/TensorFlowNET.Core/Gradients/gradients_util.cs View File

@@ -393,7 +393,9 @@ namespace Tensorflow
// Aggregate multiple gradients, and convert [] to None. // Aggregate multiple gradients, and convert [] to None.
if (out_grad.Count > 0) if (out_grad.Count > 0)
{ {
#pragma warning disable CS0219 // Variable is assigned but its value is never used
string used = ""; string used = "";
#pragma warning restore CS0219 // Variable is assigned but its value is never used
if (out_grad.Count < 2) if (out_grad.Count < 2)
{ {
used = "nop"; used = "nop";


+ 2
- 0
src/TensorFlowNET.Core/Keras/Utils/base_layer_utils.cs View File

@@ -38,8 +38,10 @@ namespace Tensorflow.Keras.Utils
IInitializer initializer = null, IInitializer initializer = null,
bool trainable = true) bool trainable = true)
{ {
#pragma warning disable CS0219 // Variable is assigned but its value is never used
var initializing_from_value = false; var initializing_from_value = false;
bool use_resource = true; bool use_resource = true;
#pragma warning restore CS0219 // Variable is assigned but its value is never used


ops.init_scope(); ops.init_scope();




+ 2
- 0
src/TensorFlowNET.Core/Operations/NnOps/_WithSpaceToBatch.cs View File

@@ -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 dilation_rate_tensor = ops.convert_to_tensor(dilation_rate, TF_DataType.TF_INT32, name: "dilation_rate");
var rate_shape = dilation_rate_tensor.TensorShape; var rate_shape = dilation_rate_tensor.TensorShape;
var num_spatial_dims = rate_shape.dims[0]; 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; 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")) if (!string.IsNullOrEmpty(data_format) && data_format.StartsWith("NC"))
starting_spatial_dim = 2; starting_spatial_dim = 2;
else else


+ 2
- 0
src/TensorFlowNET.Core/Operations/gen_control_flow_ops.cs View File

@@ -152,7 +152,9 @@ namespace Tensorflow
{ {
var _op = tf._op_def_lib._apply_op_helper("Switch", name, new { data, pred }); var _op = tf._op_def_lib._apply_op_helper("Switch", name, new { data, pred });
var _inputs_flat = _op.inputs; 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")); var _attrs = ("T", _op.get_attr("T"));
#pragma warning restore CS0219 // Variable is assigned but its value is never used
// TODO: missing original code // TODO: missing original code
//_execute.record_gradient("Switch", _inputs_flat, _attrs, _result, name); //_execute.record_gradient("Switch", _inputs_flat, _attrs, _result, name);
return new []{_op.outputs[0], _op.outputs[1]}; return new []{_op.outputs[0], _op.outputs[1]};


+ 2
- 0
src/TensorFlowNET.Core/Training/Optimizer.cs View File

@@ -374,7 +374,9 @@ namespace Tensorflow
{ {
// Scale loss if using a "mean" loss reduction and multiple replicas. // Scale loss if using a "mean" loss reduction and multiple replicas.
loss = _scale_loss(loss); loss = _scale_loss(loss);
#pragma warning disable CS0219 // Variable is assigned but its value is never used
int num_towers = 1; int num_towers = 1;
#pragma warning restore CS0219 // Variable is assigned but its value is never used


if(var_list == null) if(var_list == null)
{ {


+ 2
- 0
src/TensorFlowNET.Core/Training/Trackable.cs View File

@@ -39,7 +39,9 @@ namespace Tensorflow.Train
VariableAggregation aggregation = VariableAggregation.None) VariableAggregation aggregation = VariableAggregation.None)
{ {
ops.init_scope(); ops.init_scope();
#pragma warning disable CS0219 // Variable is assigned but its value is never used
IInitializer checkpoint_initializer = null; IInitializer checkpoint_initializer = null;
#pragma warning restore CS0219 // Variable is assigned but its value is never used
if (tf.context.executing_eagerly()) if (tf.context.executing_eagerly())
; ;
else else


+ 2
- 0
test/TensorFlowNET.UnitTest/MultithreadingTests.cs View File

@@ -167,7 +167,9 @@ namespace TensorFlowNET.UnitTest
{ {
using (var sess = tf.Session()) using (var sess = tf.Session())
{ {
#pragma warning disable CS0219 // Variable is assigned but its value is never used
Tensor t = null; Tensor t = null;
#pragma warning restore CS0219 // Variable is assigned but its value is never used
for (int i = 0; i < 100; i++) for (int i = 0; i < 100; i++)
{ {
var v = (int*) Marshal.AllocHGlobal(sizeof(int)); var v = (int*) Marshal.AllocHGlobal(sizeof(int));


Loading…
Cancel
Save