Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
305182f
[TVM][.NET] Introduce TVM.NET project
Apr 4, 2020
faa55a3
[1] Binding added
Apr 19, 2020
5eb018e
[2] Module added
Apr 19, 2020
8b552ca
[3] NDArray added
Apr 19, 2020
6f6d5e5
[4] PFManager added
Apr 19, 2020
07f4118
[5] Runtime added
Apr 19, 2020
4665a2c
[6] utils added
Apr 19, 2020
4237110
[7] Module wrapper added
Apr 25, 2020
2fbb539
[8] NDArray wrapper added
Apr 25, 2020
69fbd36
[9] PFManager wrapper added
Apr 25, 2020
2ca31f7
[10] TVMContext added
Apr 25, 2020
c2b10e9
[11] Runtime wrapper added
Apr 25, 2020
8c6ae66
[12] Test folder added
Apr 25, 2020
9b4d23d
[13] Binding updated
Apr 25, 2020
c9fab02
[14] Module updated
Apr 25, 2020
9ad6ac6
[15] NDArray updated
Apr 25, 2020
b21b840
[16] PFManager updated
Apr 25, 2020
7053e07
[17] Runtime updated
Apr 25, 2020
bb90084
[18] Utils updated
Apr 25, 2020
613e3c5
[19] Module Naming convention updated
Apr 25, 2020
52a2c61
[20] Module wrapper Naming convention updated
Apr 25, 2020
1395aae
[21] NDArray Naming convention updated
Apr 25, 2020
d5d61f7
[22] NDArray Wrapper Naming convention updated
Apr 25, 2020
f9f4fe3
[23] PFManager Wrapper Naming convention updated
Apr 25, 2020
1e15bbe
[24] Runtime Naming convention updated
Apr 25, 2020
cdbd817
[25] TVContext Naming convention updated
Apr 25, 2020
42cc3ed
[26] Runtime wrapper Naming convention updated
Apr 25, 2020
925064e
[27] Util Naming convention updated
Apr 25, 2020
42b7284
[28] NDArray build error resolved
Apr 26, 2020
074e98b
[29] Project file updated
Apr 26, 2020
a64440d
[30] NDArray memory corruption handled
Apr 26, 2020
4a5f7c9
[31] Private member name updated as per naming convention
Apr 26, 2020
a59d63c
[32] Test case added for Module
Apr 26, 2020
33ebd1d
[33] Asset added for Module
Apr 26, 2020
e6e0dfe
[34] PFManager generic func added
Apr 27, 2020
0241c94
[35] New test case for Module added
Apr 27, 2020
a9f4cc4
[36] NDArray update with new handle added
Apr 28, 2020
753fa52
[37] Test case added for Runtime
Apr 28, 2020
7e1253f
[38] NDArray float buffer copy support
Apr 29, 2020
e7b9e6c
[39] Few signature changes
Apr 29, 2020
f643da7
[40] Open points handled
May 1, 2020
cece582
[41] New test case added
May 1, 2020
e776c7f
[42] NDArray flat buffer indexing added
May 1, 2020
fb8946a
[43] NDArray indexer test case added
May 1, 2020
3aa8cb0
Review comments handled
May 16, 2020
c91b243
Review comment handled for moving TVM.NET to dotnet
May 17, 2020
f5e3e7d
String marshalling is handled
May 19, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions dotnet/csharp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## How to Link TVM Runtime Lib ##

1:> Set LD_LIBRARY_PATH with the actual path for TVM runtime library. As below:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/incubator-tvm/build/
139 changes: 139 additions & 0 deletions dotnet/csharp/src/Module.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
using System;
using System.IO;
using Native;

namespace TVMRuntime
{
public class Module
{
/// <summary>
/// The module lib path.
/// </summary>
private string _modLibPath = "";

/// <summary>
/// The module lib format.
/// </summary>
private string _modLibFormat = "";

/// <summary>
/// The module handle.
/// </summary>
private IntPtr _moduleHandle = IntPtr.Zero;

/// <summary>
/// Gets the module handle.
/// </summary>
/// <value>The module handle.</value>
public IntPtr ModuleHandle
{ get => _moduleHandle; set
{
// Release previous module if any
DisposeModule();
_moduleHandle = value;
}
}

/// <summary>
/// Initializes a new instance of the <see cref="T:TVMRuntime.Module"/> class.
/// </summary>
/// <param name="moduleHandle">Module handle.</param>
public Module(IntPtr moduleHandle)
{
_moduleHandle = moduleHandle;
}

/// <summary>
/// Initializes a new instance of the <see cref="T:TVMRuntime.Module"/> class.
/// </summary>
/// <param name="other">Other.</param>
public Module(Module other)
{
_moduleHandle = other._moduleHandle;
_modLibPath = other._modLibPath;
_modLibFormat = other._modLibFormat;
}

/// <summary>
/// Initializes a new instance of the <see cref="T:TVMRuntime.Module"/> class.
/// </summary>
/// <param name="path">Path.</param>
/// <param name="format">Format.</param>
public Module(string path, string format)
{
if ((!File.Exists(path)))
{
throw new System.ArgumentException("Please provide valid path for Module!");
}
_modLibPath = path;
_modLibFormat = format;

int result = NativeImport.TVMModLoadFromFile(_modLibPath, _modLibFormat,
ref _moduleHandle);
Utils.CheckSuccess(0, result);

}

/// <summary>
/// Imports the module.
/// </summary>
/// <param name="depMod">Dep mod.</param>
public void ImportModule(IntPtr depMod)
{
int result = NativeImport.TVMModImport(_moduleHandle, depMod);
Utils.CheckSuccess(0, result);
}

/// <summary>
/// Gets the module embeded func.
/// </summary>
/// <param name="funcName">Func name.</param>
/// <param name="queryImports">Query imports.</param>
/// <param name="funcHandle">Func handle.</param>
public void GetModuleEmbededFunc(string funcName,
int queryImports, ref IntPtr funcHandle)
{
int result = NativeImport.TVMModGetFunction(_moduleHandle, funcName, queryImports,
ref funcHandle);
Utils.CheckSuccess(0, result);
}

/// <summary>
/// Loads the module from file.
/// </summary>
/// <param name="fileName">File name.</param>
/// <param name="format">Format.</param>
/// <param name="modHandle">Module handle.</param>
private static void LoadModuleFromFile(string fileName,
string format, ref IntPtr modHandle)
{
int result = NativeImport.TVMModLoadFromFile(fileName, format,
ref modHandle);
Utils.CheckSuccess(0, result);
}

/// <summary>
/// Disposes the module.
/// </summary>
public void DisposeModule()
{
if (!IntPtr.Zero.Equals(_moduleHandle))
{
int result = NativeImport.TVMModFree(_moduleHandle);
Utils.CheckSuccess(0, result);
_modLibPath = "";
_modLibFormat = "";
_moduleHandle = IntPtr.Zero;
}
}

/// <summary>
/// Releases unmanaged resources and performs other cleanup operations before the
/// <see cref="T:TVMRuntime.Module"/> is reclaimed by garbage collection.
/// </summary>
~Module()
{
DisposeModule();
}
}
}
Loading