Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose data_ptr as a public API #1454

Open
LittleLittleCloud opened this issue Mar 7, 2025 · 0 comments
Open

Expose data_ptr as a public API #1454

LittleLittleCloud opened this issue Mar 7, 2025 · 0 comments

Comments

@LittleLittleCloud
Copy link
Contributor

This would be useful for using Torchsharp.Tensor with other cuda libraries, like bitsandbytes.

Code could be

using System;
using System.Runtime.InteropServices;

namespace TorchSharp.BitsAndBytes; 
public static class LibTorchNativeMethod 
{ 
    [DllImport("LibTorchSharp")]
    public static extern IntPtr THSStorage_data_ptr(IntPtr tensor);
}

Usage
https://github.com/LittleLittleCloud/TorchSharp.BitsAndBytes/blob/4167aff6ea4d9f177beb8d5a6a3e3e2c4afc06a9/TorchSharp.BitsAndBytes/BitsAndByteUtils.cs#L81

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

No branches or pull requests

1 participant