Skip to content

Commit 4400665

Browse files
committed
Initial support for References, the switch of Variable to use VariableV2 from VarHandleOp to address migueldeicaza#133 breaks the SampleTest with a type mismatch that I have not trackedn down yet
1 parent 6eb4124 commit 4400665

File tree

9 files changed

+19320
-14342
lines changed

9 files changed

+19320
-14342
lines changed

Examples/FExampleInceptionInference/FSharpExampleInceptionInference.fsproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@
5959
<MonoDevelop>
6060
<Properties>
6161
<Policies>
62-
<TextStylePolicy TabWidth="4" TabsToSpaces="True" IndentWidth="4" RemoveTrailingWhitespace="True" NoTabsAfterNonTabs="False" EolMarker="Native" FileWidth="120" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-fsharp" />
62+
<TextStylePolicy FileWidth="120" TabWidth="4" IndentWidth="4" RemoveTrailingWhitespace="True" NoTabsAfterNonTabs="False" EolMarker="Native" TabsToSpaces="True" scope="text/x-fsharp" />
6363
<FSharpFormattingPolicy scope="text/x-fsharp">
64-
<DefaultFormat IndentOnTryWith="False" ReorderOpenDeclaration="False" SpaceAfterComma="True" SpaceAfterSemicolon="True" SpaceAroundDelimiter="True" SpaceBeforeArgument="True" SpaceBeforeColon="True" />
64+
<DefaultFormat IndentOnTryWith="False" ReorderOpenDeclaration="False" SpaceAfterComma="True" SpaceAfterSemicolon="True" SpaceAroundDelimiter="True" SpaceBeforeArgument="True" SpaceBeforeColon="True" __added="0" />
6565
</FSharpFormattingPolicy>
6666
</Policies>
6767
</Properties>

OpGenerator/OpGenerator.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ void Run ()
411411
continue;
412412
}
413413

414-
#if true
414+
#if false
415415
// Ignore reference types as well (per go's binding)
416416
if (oper.input_arg.Any (ia => ia.is_ref)) {
417417
var pars = String.Join (", ", oper.input_arg.Where (x => x.is_ref).Select (x => $"{x.type} {x.name}"));
@@ -421,8 +421,9 @@ void Run ()
421421

422422
// Ignore reference types as well (per go's binding)
423423
if (oper.output_arg.Any (ia => ia.is_ref)) {
424-
var pars = String.Join (", ", oper.input_arg.Where (x => x.is_ref).Select (x => $"{x.type} {x.name}"));
425-
Console.WriteLine ($"SkipOutREF: {oper.name} parameters with is_ref: {pars}");
424+
var pars = String.Join (", ", oper.output_arg.Where (x => x.is_ref).Select (x => $"{x.type} {x.name}"));
425+
var all = String.Join (", ", oper.input_arg.Select (x => $"{x.type} {x.name}"));
426+
Console.WriteLine ($"SkipOutREF: {oper.name} parameters with is_ref: {pars} all: {all}");
426427

427428
continue;
428429
}

SampleTest/SampleTest.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,17 +290,20 @@ void LinearRegression ()
290290

291291
var X = g.Placeholder (TFDataType.Float);
292292
var Y = g.Placeholder (TFDataType.Float);
293-
293+
var xx = g.Pow (g.Sub (g.Const ((float)3), Y), g.Const ((float)2));
294294
// For now, use constants which are not as nice as variables, which can retain
295295
// values across invocations to Run().
296296

297-
// var W = g.Variable (g.Const (rng.Next ()), operName: "weight");
298-
// var b = g.Variable (g.Const (rng.Next ()), operName: "bias");
299-
var W = g.Const ((float) rng.Next (), operName: "weight");
300-
var b = g.Const ((float) rng.Next (), operName: "bias");
301-
var pred = g.Add (g.Mul (X, W), b);
297+
var W = g.Variable (g.Const ((float)rng.Next ()), operName: "weight");
298+
var b = g.Variable (g.Const ((float) rng.Next ()), operName: "bias");
299+
//var W = g.Const ((float) rng.Next (), operName: "weight");
300+
//var b = g.Const ((float) rng.Next (), operName: "bias");
301+
var pred = g.Add (g.Mul (X, W, "x*w"), b);
302302

303-
var cost = g.Div (g.ReduceSum (g.Pow (g.Sub (pred, Y), g.Const (2))), g.Mul (g.Const (2), g.Const (n_samples)));
303+
var first = g.Pow (g.Const ((float) 2), g.Const ((float)2));
304+
var second = g.Mul (g.Const (2), g.Const (n_samples), "dbg2*n_samples");
305+
var rs = g.ReduceSum (first);
306+
var cost = g.Div (g.ReduceSum (g.Pow (g.Sub (pred, Y), g.Const ((float)2))), g.Mul (g.Const (2), g.Const (n_samples), "2*n_samples"));
304307

305308
// STuck here: TensorFlow bindings need to surface gradient support
306309
// waiting on Google for this

TensorFlowSharp.sln

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Learn", "Learn\Learn.csproj
1212
EndProject
1313
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExampleInceptionInference", "Examples\ExampleInceptionInference\ExampleInceptionInference.csproj", "{069A6736-7711-4805-8660-A267E713BC54}"
1414
EndProject
15-
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpExampleInceptionInference", "Examples\FExampleInceptionInference\FSharpExampleInceptionInference.fsproj", "{03FB7F3A-6D24-4033-9B04-69AD8A198CCF}"
15+
Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "FSharpExampleInceptionInference", "Examples\FExampleInceptionInference\FSharpExampleInceptionInference.fsproj", "{03FB7F3A-6D24-4033-9B04-69AD8A198CCF}"
1616
EndProject
1717
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{674EC1D7-9649-462E-A7A8-93D0DE84FE64}"
1818
EndProject
19-
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "ImageCompression", "Examples\ImageCompression\ImageCompression.fsproj", "{5A493E1F-407D-4A3B-AF9B-A0F2930C1C18}"
19+
Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "ImageCompression", "Examples\ImageCompression\ImageCompression.fsproj", "{5A493E1F-407D-4A3B-AF9B-A0F2930C1C18}"
2020
EndProject
2121
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{6E72CAD1-7962-4256-AF2A-3B813FFC88EA}"
2222
EndProject
23-
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "TensorFlowSharp.Tests", "tests\TensorFlowSharp.Tests\TensorFlowSharp.Tests.fsproj", "{9EE13143-569F-4F7A-975A-DE7DF5C8FF0B}"
23+
Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "TensorFlowSharp.Tests", "tests\TensorFlowSharp.Tests\TensorFlowSharp.Tests.fsproj", "{9EE13143-569F-4F7A-975A-DE7DF5C8FF0B}"
2424
EndProject
2525
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TensorFlowSharp.Tests.CSharp", "tests\TensorFlowSharp.Tests.CSharp\TensorFlowSharp.Tests.CSharp.csproj", "{6504A704-575C-48D0-A4D2-422A7010936B}"
2626
EndProject
@@ -89,15 +89,30 @@ Global
8989
Policies = $0
9090
$0.DotNetNamingPolicy = $1
9191
$1.DirectoryNamespaceAssociation = PrefixedHierarchical
92-
$1.ResourceNamePolicy = FileFormatDefault
9392
$0.TextStylePolicy = $2
9493
$2.scope = text/x-csharp
95-
$2.inheritsSet = Mono
96-
$2.inheritsScope = text/plain
94+
$2.FileWidth = 80
95+
$2.TabWidth = 8
96+
$2.IndentWidth = 8
9797
$0.CSharpFormattingPolicy = $3
9898
$3.scope = text/x-csharp
99-
$3.inheritsSet = Mono
100-
$3.inheritsScope = text/x-csharp
99+
$3.IndentSwitchSection = False
100+
$3.NewLinesForBracesInProperties = False
101+
$3.NewLinesForBracesInAccessors = False
102+
$3.NewLinesForBracesInAnonymousMethods = False
103+
$3.NewLinesForBracesInControlBlocks = False
104+
$3.NewLinesForBracesInAnonymousTypes = False
105+
$3.NewLinesForBracesInObjectCollectionArrayInitializers = False
106+
$3.NewLinesForBracesInLambdaExpressionBody = False
107+
$3.NewLineForElse = False
108+
$3.NewLineForCatch = False
109+
$3.NewLineForFinally = False
110+
$3.NewLineForMembersInObjectInit = False
111+
$3.NewLineForMembersInAnonymousTypes = False
112+
$3.NewLineForClausesInQuery = False
113+
$3.SpacingAfterMethodDeclarationName = True
114+
$3.SpaceAfterMethodCallName = True
115+
$3.SpaceBeforeOpenSquareBracket = True
101116
version = 0.2
102117
EndGlobalSection
103118
EndGlobal

0 commit comments

Comments
 (0)