-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create API for extracting information about the nodes in a TensorFlow…
… model (#862) * Add a method that returns TensorFlow model outputs as an ISchema. * Update after merge with master * Address PR comments. * Add metadata with information about the operation type, and the inputs needed for it. * Add method that returns an enumerable of the information about graph nodes, and a console app that displays it * Add the DnnAnalyzer project files. * Address code review comments * Make needed changes after merge with master * Fix bug when there is a node with 1 dimension that is unknown
- Loading branch information
Showing
8 changed files
with
476 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/Microsoft.ML.DnnAnalyzer/Microsoft.ML.DnnAnalyzer/DnnAnalyzer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Microsoft.ML.Runtime; | ||
using Microsoft.ML.Runtime.Data; | ||
using Microsoft.ML.Runtime.Internal.Utilities; | ||
using Microsoft.ML.Transforms.TensorFlow; | ||
using System; | ||
using System.Linq; | ||
|
||
namespace Microsoft.ML.DnnAnalyzer | ||
{ | ||
public static class DnnAnalyzer | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
if (Utils.Size(args) != 1) | ||
{ | ||
Console.Error.WriteLine("Usage: dotnet DnnAnalyzer.dll <model_location>"); | ||
return; | ||
} | ||
|
||
foreach (var (name, opType, type, inputs) in TensorFlowUtils.GetModelNodes(args[0])) | ||
{ | ||
var inputsString = inputs.Length == 0 ? "" : $", input nodes: {string.Join(", ", inputs)}"; | ||
Console.WriteLine($"Graph node: '{name}', operation type: '{opType}', output type: '{type}'{inputsString}"); | ||
} | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/Microsoft.ML.DnnAnalyzer/Microsoft.ML.DnnAnalyzer/Microsoft.ML.DnnAnalyzer.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp2.1</TargetFramework> | ||
<AssemblyName>DnnAnalyzer</AssemblyName> | ||
<IncludeInPackage>Microsoft.ML.TensorFlow</IncludeInPackage> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Microsoft.ML.Core\Microsoft.ML.Core.csproj" /> | ||
<ProjectReference Include="..\..\Microsoft.ML.TensorFlow\Microsoft.ML.TensorFlow.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<NativeAssemblyReference Include="tensorflow" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.