ScriptModule from Stream / ByteArray #1094
Unanswered
oliver-bernhardt
asked this question in
Q&A
Replies: 4 comments 12 replies
|
The ScriptModule is loaded by native code, so I don't believe it could be made to work from a .NET stream. Just let me ask you this -- where is the TorchScript module coming from in the first place? How do you get it into a stream without going via a file? |
6 replies
|
Again, one does not need to overcomplicate it. It's completely sufficient also to just pass it as a byte[]. Those should not be an issue to pass between .NET and C++ right?
…-Biognosys Confidential-
________________________________
From: Niklas Gustafsson ***@***.***>
Sent: Friday, September 22, 2023 10:58 PM
To: dotnet/TorchSharp ***@***.***>
Cc: Bernhardt, Oliver ***@***.***>; Author ***@***.***>
Subject: Re: [dotnet/TorchSharp] ScriptModule from Stream / ByteArray (Discussion #1094)
**EXTERNAL EMAIL**
Actually, this works, but supposedly (according to StackOverflow) makes a copy:
std::istringstream stream(std::string(bytes, size));
auto res = torch::jit::load(stream, torch::Device(dev, index));
—
Reply to this email directly, view it on GitHub<#1094 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ANWHQ2BADNWSYWBQFGWL3JLX3X3YRANCNFSM6AAAAAA477F5YY>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
5 replies
|
I can take a look later today or tomorrow. It's diverged enough that the merge will have to be manual, which is okay, it's not a huge edit. |
0 replies
|
This will be in the next release. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hey
I was wondering whether there are any means to allow model loading from Stream (instead of only from file) for ScriptModule.cs?
This would be very important in cases where we have propitiatory model architecture that we do not want to store in a human readable form on the clients hard-drive.
Have a nice day
All reactions