Skip to content

Conversation

@xhuan8
Copy link
Contributor

@xhuan8 xhuan8 commented Dec 7, 2022

Add nms method from torch vision.
Build torchvision dll from source and rename to "libtorchvision", put it and all dependencies to the same path of exe file.
Tested on windows, the dll uploaded to https://drive.google.com/drive/folders/14R6_HzDEOlespcOd6pAWYgxjoYjD1Xpz?usp=share_link

command to build torch vision:

cmake .. -DWITH_CUDA=on -DCMAKE_PREFIX_PATH="D:\Code\libtorch-cuda-11.7\libtorch;D:\Lib\vcpkg\packages\zlib_x64-windows;D:\Lib\vcpkg\packages\libpng_x64-windows;D:\Lib\libjpeg-turbo64\lib" -G "Visual Studio 16 2019"

return NULL;
}
#else
lib = dlopen((libName + ".so").c_str(), RTLD_LAZY);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work on Mac, I believe. There, it's '.dylib'

/// <param name="input">The first input tensor</param>
/// <param name="other">The second input tensor</param>
public static Tensor maximum(Tensor input, Tensor other) => input.maximum(other);
public static Tensor max(Tensor input, Tensor other) => maximum(input, other);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is an overload at the bottom of the 'max‘ page

torch.max(input, other, *, out=None) → Tensor
See torch.maximum().

/// <param name="input">The first input tensor</param>
/// <param name="other">The second input tensor</param>
public static Tensor minimum(Tensor input, Tensor other) => input.minimum(other);
public static Tensor min(Tensor input, Tensor other) => minimum(input, other);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment on 'max'

/// </summary>
public static class DeconstructExtension
{
public static void Deconstruct<T>(this IEnumerable<T> seq, out T first, out IEnumerable<T> rest)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doc comments on all public APIs, please.

var scores = torch.from_array(new[] { 0.9 });

var nms_boxes = nms(boxes, scores);
var nms_boxes = nms_custom(boxes, scores);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means there's no unit test for 'nms' -- please add one.

@NiklasGustafsson
Copy link
Contributor

@huangyangyu -- can you take a look at this PR? You added the C# implementation of 'nms'

@NiklasGustafsson
Copy link
Contributor

I'm curious about libtorchvision.dll -- you uploaded it to Google drive, but we'll have to come up with a more automated way of building it.

@NiklasGustafsson
Copy link
Contributor

I'm wondering if it wouldn't be more convenient, in the long run to just add torchvision (and audio, and text) as linked projects and build the native code into our native project.

@xhuan8
Copy link
Contributor Author

xhuan8 commented Dec 12, 2022

@NiklasGustafsson it will be great if it's possible to build torchvision automatically, but currently I cannot find a way to do it.

@xhuan8
Copy link
Contributor Author

xhuan8 commented Jan 18, 2023

Currently my branch is a mess, I'll consider create pull request later.

@xhuan8 xhuan8 closed this Jan 18, 2023
xhuan8 added a commit to xhuan8/TorchSharp that referenced this pull request Jan 19, 2023
xhuan8 added a commit to xhuan8/TorchSharp that referenced this pull request Jan 19, 2023
xhuan8 added a commit to xhuan8/TorchSharp that referenced this pull request Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants