microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
14.33k stars 2.87k forks source link

Tensor manipulations in C# #6168

Open solarflarefx opened 3 years ago

solarflarefx commented 3 years ago

Is there a way to perform operations such as transpose and reshape on C# tensors similar to how these operations can be done to numpy arrays or tensors in python?

hariharans29 commented 3 years ago

I don’t think any of ORT’s own APIs expose stand-alone tensor manipulation interfaces for onnx operations outside the model/graph (perhaps you may find reshape because it is fairy light-weight update to a tensor’s metadata).

In Python, you maybe able to do it via Numpy (not ORT’s API). The C# DenseTensor class in ORT is a spin-off from System.Numerics.Tensors. Please check the functionalities exposed in that package and see if it meets your needs.

TechnikEmpire commented 1 year ago

It would be extremely helpful if they were exposed. Not all neural networks are trivial. What brought me to this issue is that I am using this runtime to execute a network that requires significant postprocessing of the output doing several common transforms and I'm forced to deep copy data out of the tensor to do this. My 2 cents.