Browse Source

Import Google Protocol Buffers #3

tags/v0.1.0-Tensor
haiping008 6 years ago
parent
commit
5a58965e91
13 changed files with 3040 additions and 41 deletions
  1. +2
    -0
      src/TensorFlowNET.Core/Graph.cs
  2. +0
    -38
      src/TensorFlowNET.Core/TF_DataType.cs
  3. +4
    -0
      src/TensorFlowNET.Core/TensorFlowNET.Core.csproj
  4. +2
    -1
      src/TensorFlowNET.Core/Tensorflow.cs
  5. +1027
    -0
      src/TensorFlowNET.Core/Tensorflow/AttrValue.cs
  6. +326
    -0
      src/TensorFlowNET.Core/Tensorflow/NodeDef.cs
  7. +12
    -0
      src/TensorFlowNET.Core/Tensorflow/README.md
  8. +311
    -0
      src/TensorFlowNET.Core/Tensorflow/ResourceHandle.cs
  9. +801
    -0
      src/TensorFlowNET.Core/Tensorflow/Tensor.cs
  10. +397
    -0
      src/TensorFlowNET.Core/Tensorflow/TensorShape.cs
  11. +153
    -0
      src/TensorFlowNET.Core/Tensorflow/Types.cs
  12. +2
    -0
      src/TensorFlowNET.Core/c_api.cs
  13. +3
    -2
      src/TensorFlowNET.Core/ops.cs

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

@@ -4,6 +4,8 @@ using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

using TF_DataType = Tensorflow.DataType;

namespace TensorFlowNET.Core
{
/// <summary>


+ 0
- 38
src/TensorFlowNET.Core/TF_DataType.cs View File

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

namespace TensorFlowNET.Core
{
/// <summary>
/// TF_DataType holds the type for a scalar value. E.g., one slot in a tensor.
/// The enum values here are identical to corresponding values in types.proto.
/// </summary>
public enum TF_DataType
{
TF_FLOAT = 1,
TF_DOUBLE = 2,
TF_INT32 = 3, // Int32 tensors are always in 'host' memory.
TF_UINT8 = 4,
TF_INT16 = 5,
TF_INT8 = 6,
TF_STRING = 7,
TF_COMPLEX64 = 8, // Single-precision complex
TF_COMPLEX = 8, // Old identifier kept for API backwards compatibility
TF_INT64 = 9,
TF_BOOL = 10,
TF_QINT8 = 11, // Quantized int8
TF_QUINT8 = 12, // Quantized uint8
TF_QINT32 = 13, // Quantized int32
TF_BFLOAT16 = 14, // Float32 truncated to 16 bits. Only for cast ops.
TF_QINT16 = 15, // Quantized int16
TF_QUINT16 = 16, // Quantized uint16
TF_UINT16 = 17,
TF_COMPLEX128 = 18, // Double-precision complex
TF_HALF = 19,
TF_RESOURCE = 20,
TF_VARIANT = 21,
TF_UINT32 = 22,
TF_UINT64 = 23,
}
}

+ 4
- 0
src/TensorFlowNET.Core/TensorFlowNET.Core.csproj View File

@@ -9,6 +9,10 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.6.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\NumSharp\src\NumSharp.Core\NumSharp.Core.csproj" />
</ItemGroup>


+ 2
- 1
src/TensorFlowNET.Core/Tensorflow.cs View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using TF_DataType = Tensorflow.DataType;

namespace TensorFlowNET.Core
{
@@ -12,7 +13,7 @@ namespace TensorFlowNET.Core
public static unsafe Tensor constant(object value)
{
var g = ops.get_default_graph();
g.create_op("Const", value, new TF_DataType[] { TF_DataType.TF_DOUBLE });
g.create_op("Const", value, new TF_DataType[] { TF_DataType.DtDouble });

return new Tensor();
}


+ 1027
- 0
src/TensorFlowNET.Core/Tensorflow/AttrValue.cs
File diff suppressed because it is too large
View File


+ 326
- 0
src/TensorFlowNET.Core/Tensorflow/NodeDef.cs View File

@@ -0,0 +1,326 @@
// <auto-generated>
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: node_def.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021
#region Designer generated code

using pb = global::Google.Protobuf;
using pbc = global::Google.Protobuf.Collections;
using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic;
namespace Tensorflow {

/// <summary>Holder for reflection information generated from node_def.proto</summary>
public static partial class NodeDefReflection {

#region Descriptor
/// <summary>File descriptor for node_def.proto</summary>
public static pbr::FileDescriptor Descriptor {
get { return descriptor; }
}
private static pbr::FileDescriptor descriptor;

static NodeDefReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"Cg5ub2RlX2RlZi5wcm90bxIKdGVuc29yZmxvdxoQYXR0cl92YWx1ZS5wcm90",
"byKzAQoHTm9kZURlZhIMCgRuYW1lGAEgASgJEgoKAm9wGAIgASgJEg0KBWlu",
"cHV0GAMgAygJEg4KBmRldmljZRgEIAEoCRIrCgRhdHRyGAUgAygLMh0udGVu",
"c29yZmxvdy5Ob2RlRGVmLkF0dHJFbnRyeRpCCglBdHRyRW50cnkSCwoDa2V5",
"GAEgASgJEiQKBXZhbHVlGAIgASgLMhUudGVuc29yZmxvdy5BdHRyVmFsdWU6",
"AjgBQmkKGG9yZy50ZW5zb3JmbG93LmZyYW1ld29ya0IJTm9kZVByb3RvUAFa",
"PWdpdGh1Yi5jb20vdGVuc29yZmxvdy90ZW5zb3JmbG93L3RlbnNvcmZsb3cv",
"Z28vY29yZS9mcmFtZXdvcmv4AQFiBnByb3RvMw=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Tensorflow.AttrValueReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
new pbr::GeneratedClrTypeInfo(typeof(global::Tensorflow.NodeDef), global::Tensorflow.NodeDef.Parser, new[]{ "Name", "Op", "Input", "Device", "Attr" }, null, null, new pbr::GeneratedClrTypeInfo[] { null, })
}));
}
#endregion

}
#region Messages
public sealed partial class NodeDef : pb::IMessage<NodeDef> {
private static readonly pb::MessageParser<NodeDef> _parser = new pb::MessageParser<NodeDef>(() => new NodeDef());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<NodeDef> Parser { get { return _parser; } }

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor {
get { return global::Tensorflow.NodeDefReflection.Descriptor.MessageTypes[0]; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
pbr::MessageDescriptor pb::IMessage.Descriptor {
get { return Descriptor; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public NodeDef() {
OnConstruction();
}

partial void OnConstruction();

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public NodeDef(NodeDef other) : this() {
name_ = other.name_;
op_ = other.op_;
input_ = other.input_.Clone();
device_ = other.device_;
attr_ = other.attr_.Clone();
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public NodeDef Clone() {
return new NodeDef(this);
}

/// <summary>Field number for the "name" field.</summary>
public const int NameFieldNumber = 1;
private string name_ = "";
/// <summary>
/// The name given to this operator. Used for naming inputs,
/// logging, visualization, etc. Unique within a single GraphDef.
/// Must match the regexp "[A-Za-z0-9.][A-Za-z0-9_./]*".
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Name {
get { return name_; }
set {
name_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}

/// <summary>Field number for the "op" field.</summary>
public const int OpFieldNumber = 2;
private string op_ = "";
/// <summary>
/// The operation name. There may be custom parameters in attrs.
/// Op names starting with an underscore are reserved for internal use.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Op {
get { return op_; }
set {
op_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}

/// <summary>Field number for the "input" field.</summary>
public const int InputFieldNumber = 3;
private static readonly pb::FieldCodec<string> _repeated_input_codec
= pb::FieldCodec.ForString(26);
private readonly pbc::RepeatedField<string> input_ = new pbc::RepeatedField<string>();
/// <summary>
/// Each input is "node:src_output" with "node" being a string name and
/// "src_output" indicating which output tensor to use from "node". If
/// "src_output" is 0 the ":0" suffix can be omitted. Regular inputs
/// may optionally be followed by control inputs that have the format
/// "^node".
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<string> Input {
get { return input_; }
}

/// <summary>Field number for the "device" field.</summary>
public const int DeviceFieldNumber = 4;
private string device_ = "";
/// <summary>
/// A (possibly partial) specification for the device on which this
/// node should be placed.
/// The expected syntax for this string is as follows:
///
/// DEVICE_SPEC ::= PARTIAL_SPEC
///
/// PARTIAL_SPEC ::= ("/" CONSTRAINT) *
/// CONSTRAINT ::= ("job:" JOB_NAME)
/// | ("replica:" [1-9][0-9]*)
/// | ("task:" [1-9][0-9]*)
/// | ("device:" [A-Za-z]* ":" ([1-9][0-9]* | "*") )
///
/// Valid values for this string include:
/// * "/job:worker/replica:0/task:1/device:GPU:3" (full specification)
/// * "/job:worker/device:GPU:3" (partial specification)
/// * "" (no specification)
///
/// If the constraints do not resolve to a single device (or if this
/// field is empty or not present), the runtime will attempt to
/// choose a device automatically.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Device {
get { return device_; }
set {
device_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}

/// <summary>Field number for the "attr" field.</summary>
public const int AttrFieldNumber = 5;
private static readonly pbc::MapField<string, global::Tensorflow.AttrValue>.Codec _map_attr_codec
= new pbc::MapField<string, global::Tensorflow.AttrValue>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForMessage(18, global::Tensorflow.AttrValue.Parser), 42);
private readonly pbc::MapField<string, global::Tensorflow.AttrValue> attr_ = new pbc::MapField<string, global::Tensorflow.AttrValue>();
/// <summary>
/// Operation-specific graph-construction-time configuration.
/// Note that this should include all attrs defined in the
/// corresponding OpDef, including those with a value matching
/// the default -- this allows the default to change and makes
/// NodeDefs easier to interpret on their own. However, if
/// an attr with a default is not specified in this list, the
/// default will be used.
/// The "names" (keys) must match the regexp "[a-z][a-z0-9_]+" (and
/// one of the names from the corresponding OpDef's attr field).
/// The values must have a type matching the corresponding OpDef
/// attr's type field.
/// TODO(josh11b): Add some examples here showing best practices.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::MapField<string, global::Tensorflow.AttrValue> Attr {
get { return attr_; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) {
return Equals(other as NodeDef);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Equals(NodeDef other) {
if (ReferenceEquals(other, null)) {
return false;
}
if (ReferenceEquals(other, this)) {
return true;
}
if (Name != other.Name) return false;
if (Op != other.Op) return false;
if(!input_.Equals(other.input_)) return false;
if (Device != other.Device) return false;
if (!Attr.Equals(other.Attr)) return false;
return Equals(_unknownFields, other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() {
int hash = 1;
if (Name.Length != 0) hash ^= Name.GetHashCode();
if (Op.Length != 0) hash ^= Op.GetHashCode();
hash ^= input_.GetHashCode();
if (Device.Length != 0) hash ^= Device.GetHashCode();
hash ^= Attr.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override string ToString() {
return pb::JsonFormatter.ToDiagnosticString(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void WriteTo(pb::CodedOutputStream output) {
if (Name.Length != 0) {
output.WriteRawTag(10);
output.WriteString(Name);
}
if (Op.Length != 0) {
output.WriteRawTag(18);
output.WriteString(Op);
}
input_.WriteTo(output, _repeated_input_codec);
if (Device.Length != 0) {
output.WriteRawTag(34);
output.WriteString(Device);
}
attr_.WriteTo(output, _map_attr_codec);
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() {
int size = 0;
if (Name.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
}
if (Op.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(Op);
}
size += input_.CalculateSize(_repeated_input_codec);
if (Device.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(Device);
}
size += attr_.CalculateSize(_map_attr_codec);
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(NodeDef other) {
if (other == null) {
return;
}
if (other.Name.Length != 0) {
Name = other.Name;
}
if (other.Op.Length != 0) {
Op = other.Op;
}
input_.Add(other.input_);
if (other.Device.Length != 0) {
Device = other.Device;
}
attr_.Add(other.attr_);
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(pb::CodedInputStream input) {
uint tag;
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Name = input.ReadString();
break;
}
case 18: {
Op = input.ReadString();
break;
}
case 26: {
input_.AddEntriesFrom(input, _repeated_input_codec);
break;
}
case 34: {
Device = input.ReadString();
break;
}
case 42: {
attr_.AddEntriesFrom(input, _map_attr_codec);
break;
}
}
}
}

}

#endregion

}

#endregion Designer generated code

+ 12
- 0
src/TensorFlowNET.Core/Tensorflow/README.md View File

@@ -0,0 +1,12 @@
### Download compiler from https://github.com/protocolbuffers/protobuf/releases
```shell
set SRC_DIR=D:\Projects\tensorflow\tensorflow\core\framework
set DST_DIR=D:\Projects\TensorFlow.NET\src\TensorFlowNET.Core\Tensorflow

.\protoc -I=%SRC_DIR% --csharp_out=%DST_DIR% resource_handle.proto
.\protoc -I=%SRC_DIR% --csharp_out=%DST_DIR% tensor_shape.proto
.\protoc -I=%SRC_DIR% --csharp_out=%DST_DIR% types.proto
.\protoc -I=%SRC_DIR% --csharp_out=%DST_DIR% tensor.proto
.\protoc -I=%SRC_DIR% --csharp_out=%DST_DIR% attr_value.proto
.\protoc -I=%SRC_DIR% --csharp_out=%DST_DIR% node_def.proto
```

+ 311
- 0
src/TensorFlowNET.Core/Tensorflow/ResourceHandle.cs View File

@@ -0,0 +1,311 @@
// <auto-generated>
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: resource_handle.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021
#region Designer generated code

using pb = global::Google.Protobuf;
using pbc = global::Google.Protobuf.Collections;
using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic;
namespace Tensorflow {

/// <summary>Holder for reflection information generated from resource_handle.proto</summary>
public static partial class ResourceHandleReflection {

#region Descriptor
/// <summary>File descriptor for resource_handle.proto</summary>
public static pbr::FileDescriptor Descriptor {
get { return descriptor; }
}
private static pbr::FileDescriptor descriptor;

static ResourceHandleReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"ChVyZXNvdXJjZV9oYW5kbGUucHJvdG8SCnRlbnNvcmZsb3cicgoTUmVzb3Vy",
"Y2VIYW5kbGVQcm90bxIOCgZkZXZpY2UYASABKAkSEQoJY29udGFpbmVyGAIg",
"ASgJEgwKBG5hbWUYAyABKAkSEQoJaGFzaF9jb2RlGAQgASgEEhcKD21heWJl",
"X3R5cGVfbmFtZRgFIAEoCUJuChhvcmcudGVuc29yZmxvdy5mcmFtZXdvcmtC",
"DlJlc291cmNlSGFuZGxlUAFaPWdpdGh1Yi5jb20vdGVuc29yZmxvdy90ZW5z",
"b3JmbG93L3RlbnNvcmZsb3cvZ28vY29yZS9mcmFtZXdvcmv4AQFiBnByb3Rv",
"Mw=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
new pbr::GeneratedClrTypeInfo(typeof(global::Tensorflow.ResourceHandleProto), global::Tensorflow.ResourceHandleProto.Parser, new[]{ "Device", "Container", "Name", "HashCode", "MaybeTypeName" }, null, null, null)
}));
}
#endregion

}
#region Messages
/// <summary>
/// Protocol buffer representing a handle to a tensorflow resource. Handles are
/// not valid across executions, but can be serialized back and forth from within
/// a single run.
/// </summary>
public sealed partial class ResourceHandleProto : pb::IMessage<ResourceHandleProto> {
private static readonly pb::MessageParser<ResourceHandleProto> _parser = new pb::MessageParser<ResourceHandleProto>(() => new ResourceHandleProto());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<ResourceHandleProto> Parser { get { return _parser; } }

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor {
get { return global::Tensorflow.ResourceHandleReflection.Descriptor.MessageTypes[0]; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
pbr::MessageDescriptor pb::IMessage.Descriptor {
get { return Descriptor; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public ResourceHandleProto() {
OnConstruction();
}

partial void OnConstruction();

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public ResourceHandleProto(ResourceHandleProto other) : this() {
device_ = other.device_;
container_ = other.container_;
name_ = other.name_;
hashCode_ = other.hashCode_;
maybeTypeName_ = other.maybeTypeName_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public ResourceHandleProto Clone() {
return new ResourceHandleProto(this);
}

/// <summary>Field number for the "device" field.</summary>
public const int DeviceFieldNumber = 1;
private string device_ = "";
/// <summary>
/// Unique name for the device containing the resource.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Device {
get { return device_; }
set {
device_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}

/// <summary>Field number for the "container" field.</summary>
public const int ContainerFieldNumber = 2;
private string container_ = "";
/// <summary>
/// Container in which this resource is placed.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Container {
get { return container_; }
set {
container_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}

/// <summary>Field number for the "name" field.</summary>
public const int NameFieldNumber = 3;
private string name_ = "";
/// <summary>
/// Unique name of this resource.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Name {
get { return name_; }
set {
name_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}

/// <summary>Field number for the "hash_code" field.</summary>
public const int HashCodeFieldNumber = 4;
private ulong hashCode_;
/// <summary>
/// Hash code for the type of the resource. Is only valid in the same device
/// and in the same execution.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public ulong HashCode {
get { return hashCode_; }
set {
hashCode_ = value;
}
}

/// <summary>Field number for the "maybe_type_name" field.</summary>
public const int MaybeTypeNameFieldNumber = 5;
private string maybeTypeName_ = "";
/// <summary>
/// For debug-only, the name of the type pointed to by this handle, if
/// available.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string MaybeTypeName {
get { return maybeTypeName_; }
set {
maybeTypeName_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) {
return Equals(other as ResourceHandleProto);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Equals(ResourceHandleProto other) {
if (ReferenceEquals(other, null)) {
return false;
}
if (ReferenceEquals(other, this)) {
return true;
}
if (Device != other.Device) return false;
if (Container != other.Container) return false;
if (Name != other.Name) return false;
if (HashCode != other.HashCode) return false;
if (MaybeTypeName != other.MaybeTypeName) return false;
return Equals(_unknownFields, other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() {
int hash = 1;
if (Device.Length != 0) hash ^= Device.GetHashCode();
if (Container.Length != 0) hash ^= Container.GetHashCode();
if (Name.Length != 0) hash ^= Name.GetHashCode();
if (HashCode != 0UL) hash ^= HashCode.GetHashCode();
if (MaybeTypeName.Length != 0) hash ^= MaybeTypeName.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override string ToString() {
return pb::JsonFormatter.ToDiagnosticString(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void WriteTo(pb::CodedOutputStream output) {
if (Device.Length != 0) {
output.WriteRawTag(10);
output.WriteString(Device);
}
if (Container.Length != 0) {
output.WriteRawTag(18);
output.WriteString(Container);
}
if (Name.Length != 0) {
output.WriteRawTag(26);
output.WriteString(Name);
}
if (HashCode != 0UL) {
output.WriteRawTag(32);
output.WriteUInt64(HashCode);
}
if (MaybeTypeName.Length != 0) {
output.WriteRawTag(42);
output.WriteString(MaybeTypeName);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() {
int size = 0;
if (Device.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(Device);
}
if (Container.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(Container);
}
if (Name.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
}
if (HashCode != 0UL) {
size += 1 + pb::CodedOutputStream.ComputeUInt64Size(HashCode);
}
if (MaybeTypeName.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(MaybeTypeName);
}
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(ResourceHandleProto other) {
if (other == null) {
return;
}
if (other.Device.Length != 0) {
Device = other.Device;
}
if (other.Container.Length != 0) {
Container = other.Container;
}
if (other.Name.Length != 0) {
Name = other.Name;
}
if (other.HashCode != 0UL) {
HashCode = other.HashCode;
}
if (other.MaybeTypeName.Length != 0) {
MaybeTypeName = other.MaybeTypeName;
}
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(pb::CodedInputStream input) {
uint tag;
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Device = input.ReadString();
break;
}
case 18: {
Container = input.ReadString();
break;
}
case 26: {
Name = input.ReadString();
break;
}
case 32: {
HashCode = input.ReadUInt64();
break;
}
case 42: {
MaybeTypeName = input.ReadString();
break;
}
}
}
}

}

#endregion

}

#endregion Designer generated code

+ 801
- 0
src/TensorFlowNET.Core/Tensorflow/Tensor.cs View File

@@ -0,0 +1,801 @@
// <auto-generated>
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: tensor.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021
#region Designer generated code

using pb = global::Google.Protobuf;
using pbc = global::Google.Protobuf.Collections;
using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic;
namespace Tensorflow {

/// <summary>Holder for reflection information generated from tensor.proto</summary>
public static partial class TensorReflection {

#region Descriptor
/// <summary>File descriptor for tensor.proto</summary>
public static pbr::FileDescriptor Descriptor {
get { return descriptor; }
}
private static pbr::FileDescriptor descriptor;

static TensorReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"Cgx0ZW5zb3IucHJvdG8SCnRlbnNvcmZsb3caFXJlc291cmNlX2hhbmRsZS5w",
"cm90bxoSdGVuc29yX3NoYXBlLnByb3RvGgt0eXBlcy5wcm90byKMBAoLVGVu",
"c29yUHJvdG8SIwoFZHR5cGUYASABKA4yFC50ZW5zb3JmbG93LkRhdGFUeXBl",
"EjIKDHRlbnNvcl9zaGFwZRgCIAEoCzIcLnRlbnNvcmZsb3cuVGVuc29yU2hh",
"cGVQcm90bxIWCg52ZXJzaW9uX251bWJlchgDIAEoBRIWCg50ZW5zb3JfY29u",
"dGVudBgEIAEoDBIUCghoYWxmX3ZhbBgNIAMoBUICEAESFQoJZmxvYXRfdmFs",
"GAUgAygCQgIQARIWCgpkb3VibGVfdmFsGAYgAygBQgIQARITCgdpbnRfdmFs",
"GAcgAygFQgIQARISCgpzdHJpbmdfdmFsGAggAygMEhgKDHNjb21wbGV4X3Zh",
"bBgJIAMoAkICEAESFQoJaW50NjRfdmFsGAogAygDQgIQARIUCghib29sX3Zh",
"bBgLIAMoCEICEAESGAoMZGNvbXBsZXhfdmFsGAwgAygBQgIQARI8ChNyZXNv",
"dXJjZV9oYW5kbGVfdmFsGA4gAygLMh8udGVuc29yZmxvdy5SZXNvdXJjZUhh",
"bmRsZVByb3RvEjcKC3ZhcmlhbnRfdmFsGA8gAygLMiIudGVuc29yZmxvdy5W",
"YXJpYW50VGVuc29yRGF0YVByb3RvEhYKCnVpbnQzMl92YWwYECADKA1CAhAB",
"EhYKCnVpbnQ2NF92YWwYESADKARCAhABImcKFlZhcmlhbnRUZW5zb3JEYXRh",
"UHJvdG8SEQoJdHlwZV9uYW1lGAEgASgJEhAKCG1ldGFkYXRhGAIgASgMEigK",
"B3RlbnNvcnMYAyADKAsyFy50ZW5zb3JmbG93LlRlbnNvclByb3RvQmwKGG9y",
"Zy50ZW5zb3JmbG93LmZyYW1ld29ya0IMVGVuc29yUHJvdG9zUAFaPWdpdGh1",
"Yi5jb20vdGVuc29yZmxvdy90ZW5zb3JmbG93L3RlbnNvcmZsb3cvZ28vY29y",
"ZS9mcmFtZXdvcmv4AQFiBnByb3RvMw=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Tensorflow.ResourceHandleReflection.Descriptor, global::Tensorflow.TensorShapeReflection.Descriptor, global::Tensorflow.TypesReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
new pbr::GeneratedClrTypeInfo(typeof(global::Tensorflow.TensorProto), global::Tensorflow.TensorProto.Parser, new[]{ "Dtype", "TensorShape", "VersionNumber", "TensorContent", "HalfVal", "FloatVal", "DoubleVal", "IntVal", "StringVal", "ScomplexVal", "Int64Val", "BoolVal", "DcomplexVal", "ResourceHandleVal", "VariantVal", "Uint32Val", "Uint64Val" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Tensorflow.VariantTensorDataProto), global::Tensorflow.VariantTensorDataProto.Parser, new[]{ "TypeName", "Metadata", "Tensors" }, null, null, null)
}));
}
#endregion

}
#region Messages
/// <summary>
/// Protocol buffer representing a tensor.
/// </summary>
public sealed partial class TensorProto : pb::IMessage<TensorProto> {
private static readonly pb::MessageParser<TensorProto> _parser = new pb::MessageParser<TensorProto>(() => new TensorProto());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<TensorProto> Parser { get { return _parser; } }

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor {
get { return global::Tensorflow.TensorReflection.Descriptor.MessageTypes[0]; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
pbr::MessageDescriptor pb::IMessage.Descriptor {
get { return Descriptor; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public TensorProto() {
OnConstruction();
}

partial void OnConstruction();

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public TensorProto(TensorProto other) : this() {
dtype_ = other.dtype_;
tensorShape_ = other.tensorShape_ != null ? other.tensorShape_.Clone() : null;
versionNumber_ = other.versionNumber_;
tensorContent_ = other.tensorContent_;
halfVal_ = other.halfVal_.Clone();
floatVal_ = other.floatVal_.Clone();
doubleVal_ = other.doubleVal_.Clone();
intVal_ = other.intVal_.Clone();
stringVal_ = other.stringVal_.Clone();
scomplexVal_ = other.scomplexVal_.Clone();
int64Val_ = other.int64Val_.Clone();
boolVal_ = other.boolVal_.Clone();
dcomplexVal_ = other.dcomplexVal_.Clone();
resourceHandleVal_ = other.resourceHandleVal_.Clone();
variantVal_ = other.variantVal_.Clone();
uint32Val_ = other.uint32Val_.Clone();
uint64Val_ = other.uint64Val_.Clone();
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public TensorProto Clone() {
return new TensorProto(this);
}

/// <summary>Field number for the "dtype" field.</summary>
public const int DtypeFieldNumber = 1;
private global::Tensorflow.DataType dtype_ = 0;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Tensorflow.DataType Dtype {
get { return dtype_; }
set {
dtype_ = value;
}
}

/// <summary>Field number for the "tensor_shape" field.</summary>
public const int TensorShapeFieldNumber = 2;
private global::Tensorflow.TensorShapeProto tensorShape_;
/// <summary>
/// Shape of the tensor. TODO(touts): sort out the 0-rank issues.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Tensorflow.TensorShapeProto TensorShape {
get { return tensorShape_; }
set {
tensorShape_ = value;
}
}

/// <summary>Field number for the "version_number" field.</summary>
public const int VersionNumberFieldNumber = 3;
private int versionNumber_;
/// <summary>
/// Version number.
///
/// In version 0, if the "repeated xxx" representations contain only one
/// element, that element is repeated to fill the shape. This makes it easy
/// to represent a constant Tensor with a single value.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int VersionNumber {
get { return versionNumber_; }
set {
versionNumber_ = value;
}
}

/// <summary>Field number for the "tensor_content" field.</summary>
public const int TensorContentFieldNumber = 4;
private pb::ByteString tensorContent_ = pb::ByteString.Empty;
/// <summary>
/// Serialized raw tensor content from either Tensor::AsProtoTensorContent or
/// memcpy in tensorflow::grpc::EncodeTensorToByteBuffer. This representation
/// can be used for all tensor types. The purpose of this representation is to
/// reduce serialization overhead during RPC call by avoiding serialization of
/// many repeated small items.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pb::ByteString TensorContent {
get { return tensorContent_; }
set {
tensorContent_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}

/// <summary>Field number for the "half_val" field.</summary>
public const int HalfValFieldNumber = 13;
private static readonly pb::FieldCodec<int> _repeated_halfVal_codec
= pb::FieldCodec.ForInt32(106);
private readonly pbc::RepeatedField<int> halfVal_ = new pbc::RepeatedField<int>();
/// <summary>
/// DT_HALF, DT_BFLOAT16. Note that since protobuf has no int16 type, we'll
/// have some pointless zero padding for each value here.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<int> HalfVal {
get { return halfVal_; }
}

/// <summary>Field number for the "float_val" field.</summary>
public const int FloatValFieldNumber = 5;
private static readonly pb::FieldCodec<float> _repeated_floatVal_codec
= pb::FieldCodec.ForFloat(42);
private readonly pbc::RepeatedField<float> floatVal_ = new pbc::RepeatedField<float>();
/// <summary>
/// DT_FLOAT.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<float> FloatVal {
get { return floatVal_; }
}

/// <summary>Field number for the "double_val" field.</summary>
public const int DoubleValFieldNumber = 6;
private static readonly pb::FieldCodec<double> _repeated_doubleVal_codec
= pb::FieldCodec.ForDouble(50);
private readonly pbc::RepeatedField<double> doubleVal_ = new pbc::RepeatedField<double>();
/// <summary>
/// DT_DOUBLE.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<double> DoubleVal {
get { return doubleVal_; }
}

/// <summary>Field number for the "int_val" field.</summary>
public const int IntValFieldNumber = 7;
private static readonly pb::FieldCodec<int> _repeated_intVal_codec
= pb::FieldCodec.ForInt32(58);
private readonly pbc::RepeatedField<int> intVal_ = new pbc::RepeatedField<int>();
/// <summary>
/// DT_INT32, DT_INT16, DT_INT8, DT_UINT8.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<int> IntVal {
get { return intVal_; }
}

/// <summary>Field number for the "string_val" field.</summary>
public const int StringValFieldNumber = 8;
private static readonly pb::FieldCodec<pb::ByteString> _repeated_stringVal_codec
= pb::FieldCodec.ForBytes(66);
private readonly pbc::RepeatedField<pb::ByteString> stringVal_ = new pbc::RepeatedField<pb::ByteString>();
/// <summary>
/// DT_STRING
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<pb::ByteString> StringVal {
get { return stringVal_; }
}

/// <summary>Field number for the "scomplex_val" field.</summary>
public const int ScomplexValFieldNumber = 9;
private static readonly pb::FieldCodec<float> _repeated_scomplexVal_codec
= pb::FieldCodec.ForFloat(74);
private readonly pbc::RepeatedField<float> scomplexVal_ = new pbc::RepeatedField<float>();
/// <summary>
/// DT_COMPLEX64. scomplex_val(2*i) and scomplex_val(2*i+1) are real
/// and imaginary parts of i-th single precision complex.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<float> ScomplexVal {
get { return scomplexVal_; }
}

/// <summary>Field number for the "int64_val" field.</summary>
public const int Int64ValFieldNumber = 10;
private static readonly pb::FieldCodec<long> _repeated_int64Val_codec
= pb::FieldCodec.ForInt64(82);
private readonly pbc::RepeatedField<long> int64Val_ = new pbc::RepeatedField<long>();
/// <summary>
/// DT_INT64
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<long> Int64Val {
get { return int64Val_; }
}

/// <summary>Field number for the "bool_val" field.</summary>
public const int BoolValFieldNumber = 11;
private static readonly pb::FieldCodec<bool> _repeated_boolVal_codec
= pb::FieldCodec.ForBool(90);
private readonly pbc::RepeatedField<bool> boolVal_ = new pbc::RepeatedField<bool>();
/// <summary>
/// DT_BOOL
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<bool> BoolVal {
get { return boolVal_; }
}

/// <summary>Field number for the "dcomplex_val" field.</summary>
public const int DcomplexValFieldNumber = 12;
private static readonly pb::FieldCodec<double> _repeated_dcomplexVal_codec
= pb::FieldCodec.ForDouble(98);
private readonly pbc::RepeatedField<double> dcomplexVal_ = new pbc::RepeatedField<double>();
/// <summary>
/// DT_COMPLEX128. dcomplex_val(2*i) and dcomplex_val(2*i+1) are real
/// and imaginary parts of i-th double precision complex.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<double> DcomplexVal {
get { return dcomplexVal_; }
}

/// <summary>Field number for the "resource_handle_val" field.</summary>
public const int ResourceHandleValFieldNumber = 14;
private static readonly pb::FieldCodec<global::Tensorflow.ResourceHandleProto> _repeated_resourceHandleVal_codec
= pb::FieldCodec.ForMessage(114, global::Tensorflow.ResourceHandleProto.Parser);
private readonly pbc::RepeatedField<global::Tensorflow.ResourceHandleProto> resourceHandleVal_ = new pbc::RepeatedField<global::Tensorflow.ResourceHandleProto>();
/// <summary>
/// DT_RESOURCE
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Tensorflow.ResourceHandleProto> ResourceHandleVal {
get { return resourceHandleVal_; }
}

/// <summary>Field number for the "variant_val" field.</summary>
public const int VariantValFieldNumber = 15;
private static readonly pb::FieldCodec<global::Tensorflow.VariantTensorDataProto> _repeated_variantVal_codec
= pb::FieldCodec.ForMessage(122, global::Tensorflow.VariantTensorDataProto.Parser);
private readonly pbc::RepeatedField<global::Tensorflow.VariantTensorDataProto> variantVal_ = new pbc::RepeatedField<global::Tensorflow.VariantTensorDataProto>();
/// <summary>
/// DT_VARIANT
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Tensorflow.VariantTensorDataProto> VariantVal {
get { return variantVal_; }
}

/// <summary>Field number for the "uint32_val" field.</summary>
public const int Uint32ValFieldNumber = 16;
private static readonly pb::FieldCodec<uint> _repeated_uint32Val_codec
= pb::FieldCodec.ForUInt32(130);
private readonly pbc::RepeatedField<uint> uint32Val_ = new pbc::RepeatedField<uint>();
/// <summary>
/// DT_UINT32
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<uint> Uint32Val {
get { return uint32Val_; }
}

/// <summary>Field number for the "uint64_val" field.</summary>
public const int Uint64ValFieldNumber = 17;
private static readonly pb::FieldCodec<ulong> _repeated_uint64Val_codec
= pb::FieldCodec.ForUInt64(138);
private readonly pbc::RepeatedField<ulong> uint64Val_ = new pbc::RepeatedField<ulong>();
/// <summary>
/// DT_UINT64
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<ulong> Uint64Val {
get { return uint64Val_; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) {
return Equals(other as TensorProto);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Equals(TensorProto other) {
if (ReferenceEquals(other, null)) {
return false;
}
if (ReferenceEquals(other, this)) {
return true;
}
if (Dtype != other.Dtype) return false;
if (!object.Equals(TensorShape, other.TensorShape)) return false;
if (VersionNumber != other.VersionNumber) return false;
if (TensorContent != other.TensorContent) return false;
if(!halfVal_.Equals(other.halfVal_)) return false;
if(!floatVal_.Equals(other.floatVal_)) return false;
if(!doubleVal_.Equals(other.doubleVal_)) return false;
if(!intVal_.Equals(other.intVal_)) return false;
if(!stringVal_.Equals(other.stringVal_)) return false;
if(!scomplexVal_.Equals(other.scomplexVal_)) return false;
if(!int64Val_.Equals(other.int64Val_)) return false;
if(!boolVal_.Equals(other.boolVal_)) return false;
if(!dcomplexVal_.Equals(other.dcomplexVal_)) return false;
if(!resourceHandleVal_.Equals(other.resourceHandleVal_)) return false;
if(!variantVal_.Equals(other.variantVal_)) return false;
if(!uint32Val_.Equals(other.uint32Val_)) return false;
if(!uint64Val_.Equals(other.uint64Val_)) return false;
return Equals(_unknownFields, other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() {
int hash = 1;
if (Dtype != 0) hash ^= Dtype.GetHashCode();
if (tensorShape_ != null) hash ^= TensorShape.GetHashCode();
if (VersionNumber != 0) hash ^= VersionNumber.GetHashCode();
if (TensorContent.Length != 0) hash ^= TensorContent.GetHashCode();
hash ^= halfVal_.GetHashCode();
hash ^= floatVal_.GetHashCode();
hash ^= doubleVal_.GetHashCode();
hash ^= intVal_.GetHashCode();
hash ^= stringVal_.GetHashCode();
hash ^= scomplexVal_.GetHashCode();
hash ^= int64Val_.GetHashCode();
hash ^= boolVal_.GetHashCode();
hash ^= dcomplexVal_.GetHashCode();
hash ^= resourceHandleVal_.GetHashCode();
hash ^= variantVal_.GetHashCode();
hash ^= uint32Val_.GetHashCode();
hash ^= uint64Val_.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override string ToString() {
return pb::JsonFormatter.ToDiagnosticString(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void WriteTo(pb::CodedOutputStream output) {
if (Dtype != 0) {
output.WriteRawTag(8);
output.WriteEnum((int) Dtype);
}
if (tensorShape_ != null) {
output.WriteRawTag(18);
output.WriteMessage(TensorShape);
}
if (VersionNumber != 0) {
output.WriteRawTag(24);
output.WriteInt32(VersionNumber);
}
if (TensorContent.Length != 0) {
output.WriteRawTag(34);
output.WriteBytes(TensorContent);
}
floatVal_.WriteTo(output, _repeated_floatVal_codec);
doubleVal_.WriteTo(output, _repeated_doubleVal_codec);
intVal_.WriteTo(output, _repeated_intVal_codec);
stringVal_.WriteTo(output, _repeated_stringVal_codec);
scomplexVal_.WriteTo(output, _repeated_scomplexVal_codec);
int64Val_.WriteTo(output, _repeated_int64Val_codec);
boolVal_.WriteTo(output, _repeated_boolVal_codec);
dcomplexVal_.WriteTo(output, _repeated_dcomplexVal_codec);
halfVal_.WriteTo(output, _repeated_halfVal_codec);
resourceHandleVal_.WriteTo(output, _repeated_resourceHandleVal_codec);
variantVal_.WriteTo(output, _repeated_variantVal_codec);
uint32Val_.WriteTo(output, _repeated_uint32Val_codec);
uint64Val_.WriteTo(output, _repeated_uint64Val_codec);
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() {
int size = 0;
if (Dtype != 0) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Dtype);
}
if (tensorShape_ != null) {
size += 1 + pb::CodedOutputStream.ComputeMessageSize(TensorShape);
}
if (VersionNumber != 0) {
size += 1 + pb::CodedOutputStream.ComputeInt32Size(VersionNumber);
}
if (TensorContent.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeBytesSize(TensorContent);
}
size += halfVal_.CalculateSize(_repeated_halfVal_codec);
size += floatVal_.CalculateSize(_repeated_floatVal_codec);
size += doubleVal_.CalculateSize(_repeated_doubleVal_codec);
size += intVal_.CalculateSize(_repeated_intVal_codec);
size += stringVal_.CalculateSize(_repeated_stringVal_codec);
size += scomplexVal_.CalculateSize(_repeated_scomplexVal_codec);
size += int64Val_.CalculateSize(_repeated_int64Val_codec);
size += boolVal_.CalculateSize(_repeated_boolVal_codec);
size += dcomplexVal_.CalculateSize(_repeated_dcomplexVal_codec);
size += resourceHandleVal_.CalculateSize(_repeated_resourceHandleVal_codec);
size += variantVal_.CalculateSize(_repeated_variantVal_codec);
size += uint32Val_.CalculateSize(_repeated_uint32Val_codec);
size += uint64Val_.CalculateSize(_repeated_uint64Val_codec);
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(TensorProto other) {
if (other == null) {
return;
}
if (other.Dtype != 0) {
Dtype = other.Dtype;
}
if (other.tensorShape_ != null) {
if (tensorShape_ == null) {
tensorShape_ = new global::Tensorflow.TensorShapeProto();
}
TensorShape.MergeFrom(other.TensorShape);
}
if (other.VersionNumber != 0) {
VersionNumber = other.VersionNumber;
}
if (other.TensorContent.Length != 0) {
TensorContent = other.TensorContent;
}
halfVal_.Add(other.halfVal_);
floatVal_.Add(other.floatVal_);
doubleVal_.Add(other.doubleVal_);
intVal_.Add(other.intVal_);
stringVal_.Add(other.stringVal_);
scomplexVal_.Add(other.scomplexVal_);
int64Val_.Add(other.int64Val_);
boolVal_.Add(other.boolVal_);
dcomplexVal_.Add(other.dcomplexVal_);
resourceHandleVal_.Add(other.resourceHandleVal_);
variantVal_.Add(other.variantVal_);
uint32Val_.Add(other.uint32Val_);
uint64Val_.Add(other.uint64Val_);
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(pb::CodedInputStream input) {
uint tag;
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
dtype_ = (global::Tensorflow.DataType) input.ReadEnum();
break;
}
case 18: {
if (tensorShape_ == null) {
tensorShape_ = new global::Tensorflow.TensorShapeProto();
}
input.ReadMessage(tensorShape_);
break;
}
case 24: {
VersionNumber = input.ReadInt32();
break;
}
case 34: {
TensorContent = input.ReadBytes();
break;
}
case 42:
case 45: {
floatVal_.AddEntriesFrom(input, _repeated_floatVal_codec);
break;
}
case 50:
case 49: {
doubleVal_.AddEntriesFrom(input, _repeated_doubleVal_codec);
break;
}
case 58:
case 56: {
intVal_.AddEntriesFrom(input, _repeated_intVal_codec);
break;
}
case 66: {
stringVal_.AddEntriesFrom(input, _repeated_stringVal_codec);
break;
}
case 74:
case 77: {
scomplexVal_.AddEntriesFrom(input, _repeated_scomplexVal_codec);
break;
}
case 82:
case 80: {
int64Val_.AddEntriesFrom(input, _repeated_int64Val_codec);
break;
}
case 90:
case 88: {
boolVal_.AddEntriesFrom(input, _repeated_boolVal_codec);
break;
}
case 98:
case 97: {
dcomplexVal_.AddEntriesFrom(input, _repeated_dcomplexVal_codec);
break;
}
case 106:
case 104: {
halfVal_.AddEntriesFrom(input, _repeated_halfVal_codec);
break;
}
case 114: {
resourceHandleVal_.AddEntriesFrom(input, _repeated_resourceHandleVal_codec);
break;
}
case 122: {
variantVal_.AddEntriesFrom(input, _repeated_variantVal_codec);
break;
}
case 130:
case 128: {
uint32Val_.AddEntriesFrom(input, _repeated_uint32Val_codec);
break;
}
case 138:
case 136: {
uint64Val_.AddEntriesFrom(input, _repeated_uint64Val_codec);
break;
}
}
}
}

}

/// <summary>
/// Protocol buffer representing the serialization format of DT_VARIANT tensors.
/// </summary>
public sealed partial class VariantTensorDataProto : pb::IMessage<VariantTensorDataProto> {
private static readonly pb::MessageParser<VariantTensorDataProto> _parser = new pb::MessageParser<VariantTensorDataProto>(() => new VariantTensorDataProto());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<VariantTensorDataProto> Parser { get { return _parser; } }

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor {
get { return global::Tensorflow.TensorReflection.Descriptor.MessageTypes[1]; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
pbr::MessageDescriptor pb::IMessage.Descriptor {
get { return Descriptor; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public VariantTensorDataProto() {
OnConstruction();
}

partial void OnConstruction();

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public VariantTensorDataProto(VariantTensorDataProto other) : this() {
typeName_ = other.typeName_;
metadata_ = other.metadata_;
tensors_ = other.tensors_.Clone();
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public VariantTensorDataProto Clone() {
return new VariantTensorDataProto(this);
}

/// <summary>Field number for the "type_name" field.</summary>
public const int TypeNameFieldNumber = 1;
private string typeName_ = "";
/// <summary>
/// Name of the type of objects being serialized.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string TypeName {
get { return typeName_; }
set {
typeName_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}

/// <summary>Field number for the "metadata" field.</summary>
public const int MetadataFieldNumber = 2;
private pb::ByteString metadata_ = pb::ByteString.Empty;
/// <summary>
/// Portions of the object that are not Tensors.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pb::ByteString Metadata {
get { return metadata_; }
set {
metadata_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}

/// <summary>Field number for the "tensors" field.</summary>
public const int TensorsFieldNumber = 3;
private static readonly pb::FieldCodec<global::Tensorflow.TensorProto> _repeated_tensors_codec
= pb::FieldCodec.ForMessage(26, global::Tensorflow.TensorProto.Parser);
private readonly pbc::RepeatedField<global::Tensorflow.TensorProto> tensors_ = new pbc::RepeatedField<global::Tensorflow.TensorProto>();
/// <summary>
/// Tensors contained within objects being serialized.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Tensorflow.TensorProto> Tensors {
get { return tensors_; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) {
return Equals(other as VariantTensorDataProto);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Equals(VariantTensorDataProto other) {
if (ReferenceEquals(other, null)) {
return false;
}
if (ReferenceEquals(other, this)) {
return true;
}
if (TypeName != other.TypeName) return false;
if (Metadata != other.Metadata) return false;
if(!tensors_.Equals(other.tensors_)) return false;
return Equals(_unknownFields, other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() {
int hash = 1;
if (TypeName.Length != 0) hash ^= TypeName.GetHashCode();
if (Metadata.Length != 0) hash ^= Metadata.GetHashCode();
hash ^= tensors_.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override string ToString() {
return pb::JsonFormatter.ToDiagnosticString(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void WriteTo(pb::CodedOutputStream output) {
if (TypeName.Length != 0) {
output.WriteRawTag(10);
output.WriteString(TypeName);
}
if (Metadata.Length != 0) {
output.WriteRawTag(18);
output.WriteBytes(Metadata);
}
tensors_.WriteTo(output, _repeated_tensors_codec);
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() {
int size = 0;
if (TypeName.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(TypeName);
}
if (Metadata.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeBytesSize(Metadata);
}
size += tensors_.CalculateSize(_repeated_tensors_codec);
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(VariantTensorDataProto other) {
if (other == null) {
return;
}
if (other.TypeName.Length != 0) {
TypeName = other.TypeName;
}
if (other.Metadata.Length != 0) {
Metadata = other.Metadata;
}
tensors_.Add(other.tensors_);
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(pb::CodedInputStream input) {
uint tag;
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
TypeName = input.ReadString();
break;
}
case 18: {
Metadata = input.ReadBytes();
break;
}
case 26: {
tensors_.AddEntriesFrom(input, _repeated_tensors_codec);
break;
}
}
}
}

}

#endregion

}

#endregion Designer generated code

+ 397
- 0
src/TensorFlowNET.Core/Tensorflow/TensorShape.cs View File

@@ -0,0 +1,397 @@
// <auto-generated>
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: tensor_shape.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021
#region Designer generated code

using pb = global::Google.Protobuf;
using pbc = global::Google.Protobuf.Collections;
using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic;
namespace Tensorflow {

/// <summary>Holder for reflection information generated from tensor_shape.proto</summary>
public static partial class TensorShapeReflection {

#region Descriptor
/// <summary>File descriptor for tensor_shape.proto</summary>
public static pbr::FileDescriptor Descriptor {
get { return descriptor; }
}
private static pbr::FileDescriptor descriptor;

static TensorShapeReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"ChJ0ZW5zb3Jfc2hhcGUucHJvdG8SCnRlbnNvcmZsb3ciegoQVGVuc29yU2hh",
"cGVQcm90bxItCgNkaW0YAiADKAsyIC50ZW5zb3JmbG93LlRlbnNvclNoYXBl",
"UHJvdG8uRGltEhQKDHVua25vd25fcmFuaxgDIAEoCBohCgNEaW0SDAoEc2l6",
"ZRgBIAEoAxIMCgRuYW1lGAIgASgJQnEKGG9yZy50ZW5zb3JmbG93LmZyYW1l",
"d29ya0IRVGVuc29yU2hhcGVQcm90b3NQAVo9Z2l0aHViLmNvbS90ZW5zb3Jm",
"bG93L3RlbnNvcmZsb3cvdGVuc29yZmxvdy9nby9jb3JlL2ZyYW1ld29ya/gB",
"AWIGcHJvdG8z"));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
new pbr::GeneratedClrTypeInfo(typeof(global::Tensorflow.TensorShapeProto), global::Tensorflow.TensorShapeProto.Parser, new[]{ "Dim", "UnknownRank" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Tensorflow.TensorShapeProto.Types.Dim), global::Tensorflow.TensorShapeProto.Types.Dim.Parser, new[]{ "Size", "Name" }, null, null, null)})
}));
}
#endregion

}
#region Messages
/// <summary>
/// Dimensions of a tensor.
/// </summary>
public sealed partial class TensorShapeProto : pb::IMessage<TensorShapeProto> {
private static readonly pb::MessageParser<TensorShapeProto> _parser = new pb::MessageParser<TensorShapeProto>(() => new TensorShapeProto());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<TensorShapeProto> Parser { get { return _parser; } }

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor {
get { return global::Tensorflow.TensorShapeReflection.Descriptor.MessageTypes[0]; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
pbr::MessageDescriptor pb::IMessage.Descriptor {
get { return Descriptor; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public TensorShapeProto() {
OnConstruction();
}

partial void OnConstruction();

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public TensorShapeProto(TensorShapeProto other) : this() {
dim_ = other.dim_.Clone();
unknownRank_ = other.unknownRank_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public TensorShapeProto Clone() {
return new TensorShapeProto(this);
}

/// <summary>Field number for the "dim" field.</summary>
public const int DimFieldNumber = 2;
private static readonly pb::FieldCodec<global::Tensorflow.TensorShapeProto.Types.Dim> _repeated_dim_codec
= pb::FieldCodec.ForMessage(18, global::Tensorflow.TensorShapeProto.Types.Dim.Parser);
private readonly pbc::RepeatedField<global::Tensorflow.TensorShapeProto.Types.Dim> dim_ = new pbc::RepeatedField<global::Tensorflow.TensorShapeProto.Types.Dim>();
/// <summary>
/// Dimensions of the tensor, such as {"input", 30}, {"output", 40}
/// for a 30 x 40 2D tensor. If an entry has size -1, this
/// corresponds to a dimension of unknown size. The names are
/// optional.
///
/// The order of entries in "dim" matters: It indicates the layout of the
/// values in the tensor in-memory representation.
///
/// The first entry in "dim" is the outermost dimension used to layout the
/// values, the last entry is the innermost dimension. This matches the
/// in-memory layout of RowMajor Eigen tensors.
///
/// If "dim.size()" > 0, "unknown_rank" must be false.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Tensorflow.TensorShapeProto.Types.Dim> Dim {
get { return dim_; }
}

/// <summary>Field number for the "unknown_rank" field.</summary>
public const int UnknownRankFieldNumber = 3;
private bool unknownRank_;
/// <summary>
/// If true, the number of dimensions in the shape is unknown.
///
/// If true, "dim.size()" must be 0.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool UnknownRank {
get { return unknownRank_; }
set {
unknownRank_ = value;
}
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) {
return Equals(other as TensorShapeProto);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Equals(TensorShapeProto other) {
if (ReferenceEquals(other, null)) {
return false;
}
if (ReferenceEquals(other, this)) {
return true;
}
if(!dim_.Equals(other.dim_)) return false;
if (UnknownRank != other.UnknownRank) return false;
return Equals(_unknownFields, other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() {
int hash = 1;
hash ^= dim_.GetHashCode();
if (UnknownRank != false) hash ^= UnknownRank.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override string ToString() {
return pb::JsonFormatter.ToDiagnosticString(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void WriteTo(pb::CodedOutputStream output) {
dim_.WriteTo(output, _repeated_dim_codec);
if (UnknownRank != false) {
output.WriteRawTag(24);
output.WriteBool(UnknownRank);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() {
int size = 0;
size += dim_.CalculateSize(_repeated_dim_codec);
if (UnknownRank != false) {
size += 1 + 1;
}
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(TensorShapeProto other) {
if (other == null) {
return;
}
dim_.Add(other.dim_);
if (other.UnknownRank != false) {
UnknownRank = other.UnknownRank;
}
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(pb::CodedInputStream input) {
uint tag;
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 18: {
dim_.AddEntriesFrom(input, _repeated_dim_codec);
break;
}
case 24: {
UnknownRank = input.ReadBool();
break;
}
}
}
}

#region Nested types
/// <summary>Container for nested types declared in the TensorShapeProto message type.</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static partial class Types {
/// <summary>
/// One dimension of the tensor.
/// </summary>
public sealed partial class Dim : pb::IMessage<Dim> {
private static readonly pb::MessageParser<Dim> _parser = new pb::MessageParser<Dim>(() => new Dim());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<Dim> Parser { get { return _parser; } }

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor {
get { return global::Tensorflow.TensorShapeProto.Descriptor.NestedTypes[0]; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
pbr::MessageDescriptor pb::IMessage.Descriptor {
get { return Descriptor; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public Dim() {
OnConstruction();
}

partial void OnConstruction();

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public Dim(Dim other) : this() {
size_ = other.size_;
name_ = other.name_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public Dim Clone() {
return new Dim(this);
}

/// <summary>Field number for the "size" field.</summary>
public const int SizeFieldNumber = 1;
private long size_;
/// <summary>
/// Size of the tensor in that dimension.
/// This value must be >= -1, but values of -1 are reserved for "unknown"
/// shapes (values of -1 mean "unknown" dimension). Certain wrappers
/// that work with TensorShapeProto may fail at runtime when deserializing
/// a TensorShapeProto containing a dim value of -1.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public long Size {
get { return size_; }
set {
size_ = value;
}
}

/// <summary>Field number for the "name" field.</summary>
public const int NameFieldNumber = 2;
private string name_ = "";
/// <summary>
/// Optional name of the tensor dimension.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Name {
get { return name_; }
set {
name_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) {
return Equals(other as Dim);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Equals(Dim other) {
if (ReferenceEquals(other, null)) {
return false;
}
if (ReferenceEquals(other, this)) {
return true;
}
if (Size != other.Size) return false;
if (Name != other.Name) return false;
return Equals(_unknownFields, other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() {
int hash = 1;
if (Size != 0L) hash ^= Size.GetHashCode();
if (Name.Length != 0) hash ^= Name.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override string ToString() {
return pb::JsonFormatter.ToDiagnosticString(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void WriteTo(pb::CodedOutputStream output) {
if (Size != 0L) {
output.WriteRawTag(8);
output.WriteInt64(Size);
}
if (Name.Length != 0) {
output.WriteRawTag(18);
output.WriteString(Name);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() {
int size = 0;
if (Size != 0L) {
size += 1 + pb::CodedOutputStream.ComputeInt64Size(Size);
}
if (Name.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
}
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(Dim other) {
if (other == null) {
return;
}
if (other.Size != 0L) {
Size = other.Size;
}
if (other.Name.Length != 0) {
Name = other.Name;
}
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(pb::CodedInputStream input) {
uint tag;
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Size = input.ReadInt64();
break;
}
case 18: {
Name = input.ReadString();
break;
}
}
}
}

}

}
#endregion

}

#endregion

}

#endregion Designer generated code

+ 153
- 0
src/TensorFlowNET.Core/Tensorflow/Types.cs View File

@@ -0,0 +1,153 @@
// <auto-generated>
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: types.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021
#region Designer generated code

using pb = global::Google.Protobuf;
using pbc = global::Google.Protobuf.Collections;
using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic;
namespace Tensorflow {

/// <summary>Holder for reflection information generated from types.proto</summary>
public static partial class TypesReflection {

#region Descriptor
/// <summary>File descriptor for types.proto</summary>
public static pbr::FileDescriptor Descriptor {
get { return descriptor; }
}
private static pbr::FileDescriptor descriptor;

static TypesReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"Cgt0eXBlcy5wcm90bxIKdGVuc29yZmxvdyqqBgoIRGF0YVR5cGUSDgoKRFRf",
"SU5WQUxJRBAAEgwKCERUX0ZMT0FUEAESDQoJRFRfRE9VQkxFEAISDAoIRFRf",
"SU5UMzIQAxIMCghEVF9VSU5UOBAEEgwKCERUX0lOVDE2EAUSCwoHRFRfSU5U",
"OBAGEg0KCURUX1NUUklORxAHEhAKDERUX0NPTVBMRVg2NBAIEgwKCERUX0lO",
"VDY0EAkSCwoHRFRfQk9PTBAKEgwKCERUX1FJTlQ4EAsSDQoJRFRfUVVJTlQ4",
"EAwSDQoJRFRfUUlOVDMyEA0SDwoLRFRfQkZMT0FUMTYQDhINCglEVF9RSU5U",
"MTYQDxIOCgpEVF9RVUlOVDE2EBASDQoJRFRfVUlOVDE2EBESEQoNRFRfQ09N",
"UExFWDEyOBASEgsKB0RUX0hBTEYQExIPCgtEVF9SRVNPVVJDRRAUEg4KCkRU",
"X1ZBUklBTlQQFRINCglEVF9VSU5UMzIQFhINCglEVF9VSU5UNjQQFxIQCgxE",
"VF9GTE9BVF9SRUYQZRIRCg1EVF9ET1VCTEVfUkVGEGYSEAoMRFRfSU5UMzJf",
"UkVGEGcSEAoMRFRfVUlOVDhfUkVGEGgSEAoMRFRfSU5UMTZfUkVGEGkSDwoL",
"RFRfSU5UOF9SRUYQahIRCg1EVF9TVFJJTkdfUkVGEGsSFAoQRFRfQ09NUExF",
"WDY0X1JFRhBsEhAKDERUX0lOVDY0X1JFRhBtEg8KC0RUX0JPT0xfUkVGEG4S",
"EAoMRFRfUUlOVDhfUkVGEG8SEQoNRFRfUVVJTlQ4X1JFRhBwEhEKDURUX1FJ",
"TlQzMl9SRUYQcRITCg9EVF9CRkxPQVQxNl9SRUYQchIRCg1EVF9RSU5UMTZf",
"UkVGEHMSEgoORFRfUVVJTlQxNl9SRUYQdBIRCg1EVF9VSU5UMTZfUkVGEHUS",
"FQoRRFRfQ09NUExFWDEyOF9SRUYQdhIPCgtEVF9IQUxGX1JFRhB3EhMKD0RU",
"X1JFU09VUkNFX1JFRhB4EhIKDkRUX1ZBUklBTlRfUkVGEHkSEQoNRFRfVUlO",
"VDMyX1JFRhB6EhEKDURUX1VJTlQ2NF9SRUYQe0JrChhvcmcudGVuc29yZmxv",
"dy5mcmFtZXdvcmtCC1R5cGVzUHJvdG9zUAFaPWdpdGh1Yi5jb20vdGVuc29y",
"Zmxvdy90ZW5zb3JmbG93L3RlbnNvcmZsb3cvZ28vY29yZS9mcmFtZXdvcmv4",
"AQFiBnByb3RvMw=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Tensorflow.DataType), }, null));
}
#endregion

}
#region Enums
/// <summary>
/// LINT.IfChange
/// </summary>
public enum DataType {
/// <summary>
/// Not a legal value for DataType. Used to indicate a DataType field
/// has not been set.
/// </summary>
[pbr::OriginalName("DT_INVALID")] DtInvalid = 0,
/// <summary>
/// Data types that all computation devices are expected to be
/// capable to support.
/// </summary>
[pbr::OriginalName("DT_FLOAT")] DtFloat = 1,
[pbr::OriginalName("DT_DOUBLE")] DtDouble = 2,
[pbr::OriginalName("DT_INT32")] DtInt32 = 3,
[pbr::OriginalName("DT_UINT8")] DtUint8 = 4,
[pbr::OriginalName("DT_INT16")] DtInt16 = 5,
[pbr::OriginalName("DT_INT8")] DtInt8 = 6,
[pbr::OriginalName("DT_STRING")] DtString = 7,
/// <summary>
/// Single-precision complex
/// </summary>
[pbr::OriginalName("DT_COMPLEX64")] DtComplex64 = 8,
[pbr::OriginalName("DT_INT64")] DtInt64 = 9,
[pbr::OriginalName("DT_BOOL")] DtBool = 10,
/// <summary>
/// Quantized int8
/// </summary>
[pbr::OriginalName("DT_QINT8")] DtQint8 = 11,
/// <summary>
/// Quantized uint8
/// </summary>
[pbr::OriginalName("DT_QUINT8")] DtQuint8 = 12,
/// <summary>
/// Quantized int32
/// </summary>
[pbr::OriginalName("DT_QINT32")] DtQint32 = 13,
/// <summary>
/// Float32 truncated to 16 bits. Only for cast ops.
/// </summary>
[pbr::OriginalName("DT_BFLOAT16")] DtBfloat16 = 14,
/// <summary>
/// Quantized int16
/// </summary>
[pbr::OriginalName("DT_QINT16")] DtQint16 = 15,
/// <summary>
/// Quantized uint16
/// </summary>
[pbr::OriginalName("DT_QUINT16")] DtQuint16 = 16,
[pbr::OriginalName("DT_UINT16")] DtUint16 = 17,
/// <summary>
/// Double-precision complex
/// </summary>
[pbr::OriginalName("DT_COMPLEX128")] DtComplex128 = 18,
[pbr::OriginalName("DT_HALF")] DtHalf = 19,
[pbr::OriginalName("DT_RESOURCE")] DtResource = 20,
/// <summary>
/// Arbitrary C++ data types
/// </summary>
[pbr::OriginalName("DT_VARIANT")] DtVariant = 21,
[pbr::OriginalName("DT_UINT32")] DtUint32 = 22,
[pbr::OriginalName("DT_UINT64")] DtUint64 = 23,
/// <summary>
/// Do not use! These are only for parameters. Every enum above
/// should have a corresponding value below (verified by types_test).
/// </summary>
[pbr::OriginalName("DT_FLOAT_REF")] DtFloatRef = 101,
[pbr::OriginalName("DT_DOUBLE_REF")] DtDoubleRef = 102,
[pbr::OriginalName("DT_INT32_REF")] DtInt32Ref = 103,
[pbr::OriginalName("DT_UINT8_REF")] DtUint8Ref = 104,
[pbr::OriginalName("DT_INT16_REF")] DtInt16Ref = 105,
[pbr::OriginalName("DT_INT8_REF")] DtInt8Ref = 106,
[pbr::OriginalName("DT_STRING_REF")] DtStringRef = 107,
[pbr::OriginalName("DT_COMPLEX64_REF")] DtComplex64Ref = 108,
[pbr::OriginalName("DT_INT64_REF")] DtInt64Ref = 109,
[pbr::OriginalName("DT_BOOL_REF")] DtBoolRef = 110,
[pbr::OriginalName("DT_QINT8_REF")] DtQint8Ref = 111,
[pbr::OriginalName("DT_QUINT8_REF")] DtQuint8Ref = 112,
[pbr::OriginalName("DT_QINT32_REF")] DtQint32Ref = 113,
[pbr::OriginalName("DT_BFLOAT16_REF")] DtBfloat16Ref = 114,
[pbr::OriginalName("DT_QINT16_REF")] DtQint16Ref = 115,
[pbr::OriginalName("DT_QUINT16_REF")] DtQuint16Ref = 116,
[pbr::OriginalName("DT_UINT16_REF")] DtUint16Ref = 117,
[pbr::OriginalName("DT_COMPLEX128_REF")] DtComplex128Ref = 118,
[pbr::OriginalName("DT_HALF_REF")] DtHalfRef = 119,
[pbr::OriginalName("DT_RESOURCE_REF")] DtResourceRef = 120,
[pbr::OriginalName("DT_VARIANT_REF")] DtVariantRef = 121,
[pbr::OriginalName("DT_UINT32_REF")] DtUint32Ref = 122,
[pbr::OriginalName("DT_UINT64_REF")] DtUint64Ref = 123,
}

#endregion

}

#endregion Designer generated code

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

@@ -10,6 +10,8 @@ using TF_Operation = System.IntPtr;
using TF_Status = System.IntPtr;
using TF_Tensor = System.IntPtr;

using TF_DataType = Tensorflow.DataType;

using static TensorFlowNET.Core.Tensorflow;

namespace TensorFlowNET.Core


+ 3
- 2
src/TensorFlowNET.Core/ops.cs View File

@@ -4,6 +4,7 @@ using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using tf = TensorFlowNET.Core.Tensorflow;
using TF_DataType = Tensorflow.DataType;

namespace TensorFlowNET.Core
{
@@ -26,8 +27,8 @@ namespace TensorFlowNET.Core
case double value:
var v = (double*)Marshal.AllocHGlobal(sizeof(double));
*v = value;
tensor = c_api.TF_NewTensor(TF_DataType.TF_DOUBLE, 0, 0, data: (IntPtr)v, len: (UIntPtr)sizeof(double), deallocator: Tensorflow.FreeTensorDataDelegate, deallocator_arg: IntPtr.Zero);
c_api.TF_SetAttrType(op_desc, "dtype", TF_DataType.TF_DOUBLE);
tensor = c_api.TF_NewTensor(TF_DataType.DtDouble, 0, 0, data: (IntPtr)v, len: (UIntPtr)sizeof(double), deallocator: Tensorflow.FreeTensorDataDelegate, deallocator_arg: IntPtr.Zero);
c_api.TF_SetAttrType(op_desc, "dtype", TF_DataType.DtDouble);
break;
}



Loading…
Cancel
Save