ScriptModule from Stream / ByteArray #1094
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? |
Beta Was this translation helpful? Give feedback.
-
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: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
This will be in the next release. |
Beta Was this translation helpful? Give feedback.
-
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
Beta Was this translation helpful? Give feedback.
All reactions