Browse Source

Clean code.

tags/v0.20
Oceania2018 5 years ago
parent
commit
d76eebfdc7
8 changed files with 3 additions and 184 deletions
  1. +1
    -1
      src/TensorFlowNET.Core/APIs/c_api.cs
  2. +1
    -1
      src/TensorFlowNET.Core/Assembly/Properties.cs
  3. +0
    -49
      src/TensorFlowNET.Core/Eager/c_api.eager.cs
  4. +0
    -3
      src/TensorFlowNET.Core/Operations/gen_array_ops.cs
  5. +0
    -50
      src/TensorFlowNET.Core/Util/BindingArray.cs
  6. +0
    -50
      src/TensorFlowNET.Core/Util/BindingTensorArray.cs
  7. +0
    -30
      src/TensorFlowNET.Core/Util/PointerInputs.cs
  8. +1
    -0
      test/TensorFlowNET.UnitTest/ImageTest.cs

+ 1
- 1
src/TensorFlowNET.Core/APIs/c_api.cs View File

@@ -72,6 +72,6 @@ namespace Tensorflow
} }


[DllImport(TensorFlowLibName)] [DllImport(TensorFlowLibName)]
public static extern IntPtr TF_Version();
internal static extern IntPtr TF_Version();
} }
} }

+ 1
- 1
src/TensorFlowNET.Core/Assembly/Properties.cs View File

@@ -1,4 +1,4 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
#if DEBUG #if DEBUG
[assembly: InternalsVisibleTo("TensorFlowNET.UnitTest, PublicKey=00240000048000009400000006020000002400005253413100040000010001004b86c4cb78549b34bab61a3b1800e23bfeb5b3ec390074041536a7e3cbd97f5f04cf0f857155a8928eaa29ebfd11cfbbad3ba70efea7bda3226c6a8d370a4cd303f714486b6ebc225985a638471e6ef571cc92a4613c00b8fa65d61ccee0cbe5f36330c9a01f4183559f1bef24cc2917c6d913e3a541333a1d05d9bed22b38cb")]
[assembly: InternalsVisibleTo("Tensorflow.UnitTest, PublicKey=00240000048000009400000006020000002400005253413100040000010001004b86c4cb78549b34bab61a3b1800e23bfeb5b3ec390074041536a7e3cbd97f5f04cf0f857155a8928eaa29ebfd11cfbbad3ba70efea7bda3226c6a8d370a4cd303f714486b6ebc225985a638471e6ef571cc92a4613c00b8fa65d61ccee0cbe5f36330c9a01f4183559f1bef24cc2917c6d913e3a541333a1d05d9bed22b38cb")]
#endif #endif

+ 0
- 49
src/TensorFlowNET.Core/Eager/c_api.eager.cs View File

@@ -8,46 +8,6 @@ namespace Tensorflow
{ {
public partial class c_api public partial class c_api
{ {
[DllImport(TensorFlowLibName)]
public static extern void TFE_RegisterGradientFunction(gradient_function_callback gradientFunctionCallback,
delete_backward_function_callback deleteBackwardFunctionCallback);

/// <summary>
///
/// </summary>
/// <param name="op_name"></param>
/// <param name="op_inputs"></param>
/// <param name="op_outputs"></param>
/// <param name="attrs_string"></param>
/// <param name="output_grads">previous node ouput</param>
/// <param name="skip_input_indices"></param>
/// <returns></returns>
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate IntPtr gradient_function_callback(string op_name,
IntPtr op_inputs,
IntPtr op_outputs,
string attrs_string,
IntPtr output_grads,
IntPtr skip_input_indices);

[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void delete_backward_function_callback(string op_name,
IntPtr op_inputs,
IntPtr op_outputs);

[DllImport(TensorFlowLibName)]
public static extern IntPtr TFE_WrapGradientResult(IntPtr[] gradients, int num_gradients);

[DllImport(TensorFlowLibName)]
public static extern IntPtr VSpace_Handle(VSpace_callback_Ones ones, VSpace_callback_AggregateGrads aggregate_grads);
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate IntPtr VSpace_callback_Ones(long[] shape, int dims, TF_DataType dtype);
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate IntPtr VSpace_callback_AggregateGrads(TF_BindingArray gradients);

[DllImport(TensorFlowLibName)]
public static extern void TFE_RegisterVSpace(IntPtr vspace);
/// <summary> /// <summary>
/// Return a new options object. /// Return a new options object.
/// </summary> /// </summary>
@@ -239,15 +199,6 @@ namespace Tensorflow
[DllImport(TensorFlowLibName)] [DllImport(TensorFlowLibName)]
public static extern IntPtr TFE_EagerTensorHandle(IntPtr t); public static extern IntPtr TFE_EagerTensorHandle(IntPtr t);


[DllImport(TensorFlowLibName)]
public static extern int TFE_EagerTensorId(IntPtr t);

[DllImport(TensorFlowLibName)]
public static extern IntPtr TFE_NewEagerTensor();

[DllImport(TensorFlowLibName)]
public static extern void TFE_SetEagerTensorHandle(IntPtr tensor, IntPtr handle);

/// <summary> /// <summary>
/// Sets the default execution mode (sync/async). Note that this can be /// Sets the default execution mode (sync/async). Note that this can be
/// overridden per thread using TFE_ContextSetExecutorForThread. /// overridden per thread using TFE_ContextSetExecutorForThread.


+ 0
- 3
src/TensorFlowNET.Core/Operations/gen_array_ops.cs View File

@@ -19,9 +19,6 @@ using System.Collections.Generic;
using static Tensorflow.Binding; using static Tensorflow.Binding;
using Tensorflow.Eager; using Tensorflow.Eager;
using System.Linq; using System.Linq;
#pragma warning disable CS0105 // Using directive appeared previously in this namespace
using static Tensorflow.Binding;
#pragma warning restore CS0105 // Using directive appeared previously in this namespace


namespace Tensorflow namespace Tensorflow
{ {


+ 0
- 50
src/TensorFlowNET.Core/Util/BindingArray.cs View File

@@ -1,50 +0,0 @@
/*****************************************************************************
Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************/

using System;
using System.Runtime.InteropServices;

namespace Tensorflow
{
public class BindingArray : DisposableObject
{
TF_BindingArray data;
public IntPtr Address => data.array;
public int Length => data.length;

public BindingArray(IntPtr handle) : base(handle)
{
if (_handle != IntPtr.Zero)
data = Marshal.PtrToStructure<TF_BindingArray>(_handle);
else
data = default;
}

public static implicit operator BindingArray(IntPtr handle)
=> new BindingArray(handle);

public unsafe IntPtr this[int index]
=> data[index];

public unsafe IntPtr[] Data
=> data.Data;

protected override void DisposeUnmanagedResources(IntPtr handle)
{
c_api.TF_DeleteBindingArray(_handle);
}
}
}

+ 0
- 50
src/TensorFlowNET.Core/Util/BindingTensorArray.cs View File

@@ -1,50 +0,0 @@
/*****************************************************************************
Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************/

using System;
using System.Runtime.InteropServices;

namespace Tensorflow
{
public class BindingTensorArray : DisposableObject
{
TF_BindingArray data;
public IntPtr Address => data.array;
public int Length => data.length;

public BindingTensorArray(IntPtr handle) : base(handle)
{
if (_handle != IntPtr.Zero)
data = Marshal.PtrToStructure<TF_BindingArray>(_handle);
else
data = default;
}

public static implicit operator BindingTensorArray(IntPtr handle)
=> new BindingTensorArray(handle);

public unsafe IntPtr this[int index]
=> data[index];

public unsafe IntPtr[] Data
=> data.Data;

protected override void DisposeUnmanagedResources(IntPtr handle)
{
c_api.TFE_DeleteBindingTensorArray(_handle);
}
}
}

+ 0
- 30
src/TensorFlowNET.Core/Util/PointerInputs.cs View File

@@ -1,30 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace Tensorflow
{
public abstract class PointerInputs<T>
where T : IPointerInputs, new()
{
protected T[] data;
public int Length
=> data.Length;

public IntPtr[] Points
=> data.Select(x => x.ToPointer()).ToArray();

public PointerInputs(params T[] data)
=> this.data = data;

public T this[int idx]
=> data[idx];

public T[] Items
=> data;

public static implicit operator IntPtr[](PointerInputs<T> inputs)
=> inputs.data.Select(x => x.ToPointer()).ToArray();
}
}

+ 1
- 0
test/TensorFlowNET.UnitTest/ImageTest.cs View File

@@ -26,6 +26,7 @@ namespace TensorFlowNET.UnitTest.Basics
contents = tf.io.read_file(imgPath); contents = tf.io.read_file(imgPath);
} }


[Ignore]
[TestMethod] [TestMethod]
public void decode_image() public void decode_image()
{ {


Loading…
Cancel
Save