Commit graph

20 commits

Author SHA1 Message Date
Xavier Dupré
a805a49363
Move OrtValueVector from onnxruntime-training to onnxruntime (#11176)
* Move OrtValueVector from onnxruntime-training to onnxruntime

* disable dlpack on onnxruntime

* disable dlpack

* dlpack

* opaque inlcuded in any cc file of the python binding

* fix type issue

* fix incomplete name

* remove len()

* remove unused parameter

* black

* black

* black

* remove unused import

* add unit test to check the output type

* black

* lint

* lint

* lint

* fix method name

* Update onnxruntime/python/onnxruntime_pybind_ortvalue.cc

Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com>

* Update onnxruntime/python/onnxruntime_pybind_ortvalue.cc

Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com>

* Update onnxruntime/python/onnxruntime_pybind_ortvalue.cc

Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com>

* Update onnxruntime/python/onnxruntime_pybind_ortvalue.cc

Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com>

* Update onnxruntime/python/onnxruntime_pybind_ortvalue.cc

Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com>

* Update onnxruntime/test/python/onnxruntime_test_python_sparse_matmul.py

Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com>

* Update onnxruntime/test/python/onnxruntime_test_python_sparse_matmul.py

Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com>

* check return type of C API

* lint

* lint

* fix missing ;

* fix type issue

* fix merge issue

Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com>
2022-06-15 09:36:28 +02:00
Xavier Dupré
3f42665a40
Improve transfered time from ort to torch (#9610)
* Improve transfered time from ort to torch
* Use static_cast
* fix call to Python API for python <= 3.8
* investigation
* fix ref counts
* disable import if no training
* one function to convert multiple ortvalues
* add proto_type
* enforce dlpack->deleter to be not null
* fix _ortvalues_to_torch_tensor for eager mode
* rename proto_type into element_type in the Python API
* conversion from ort to torch 2x times faster
* fix conversion of list of OrtValue
* replace has_bool_tensor by bool_tensor_indices
* introduce _ortvalues_to_torch_tensor_list
* use _ortvalues_to_torch_tensor_list for cache
* fix ambiguity between c and python classes

Co-authored-by: xavier dupré <xavier.dupre@gmail.com>
Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com>
2022-04-06 09:12:58 +02:00
Xavier Dupré
b88fb68fac
Adds missing numpy type when looking for the ort correspondance (#10943) 2022-03-22 14:44:48 -07:00
Changming Sun
4e9e01cb3c
Fix SDL warnings in CPU EP (#9975) 2021-12-19 20:54:29 -08:00
Scott McKay
1aa21df149
Fix issue with debug VS2022 build when python bindings are enabled (#9794)
* Add intermediate header between the ORT code and pybind11 to workaround an issue with VS2022 debug builds by making sure corecrt.h is included first.

This avoids the _STL_ASSERT macro being defined in an incompatible way for a debug build by pybind including the python headers with _DEBUG temporarily undefined .

See #9735 for details.
2021-11-18 16:58:02 +10:00
Changming Sun
436ac6dd5f
Rename ml_value.h to ort_value.h (#8726) 2021-08-13 07:04:56 -07:00
Dmitri Smirnov
950fe5e28b
Implement SparseTensor and infrastructure suppport and advance ONNX commit (#8038)
SparseTensor support
  Implement Builder pattern
  Fix support for 1-D and 2-D COO indices
  Implement and test CSR support.
  Handle shape inference for SparseTensors
  Implement conversion for COO, CSR and tests.
  Address the case where constant sparse initializer is the output.
  Implement test infra for SparseTensors
  Implement SparseDenseMatMul for Csr and COO and tested it.
  Add hash for SparseToDenseMatMul
  Finish shared provider refactor
  Refactor GetOrCreate to Create
  Working on py interface
  Expose OrtDevice and use it in allocate_numpy
	Adjust Sparse interfaces, add support for string SparseTensor. Add tests.
	Add and test to_cuda()
	Add accessors to format specific indices
	Test values and indices views, read-only flag, after GC access
	Add sparse related methods to OrtValue
	Re-work SparseTensor wrapper, add OrtValue methods
	Rework numpy_array_to_cuda/to_cpu
	Add run_with_ort_values
	Add models and test sparse_mat_mul with run_with_ort_values
	Refactor sparse tensor to use a single buffer
        Ifdef x86 Eigen CSR sparse matmul implementation
        Exclude broken test, check for string type when copying cross device
       Split pybind schema, regenerate docs, add exclusion
       Conditionally exclude schema module
       Update docs fix cuda build
       Add test to a filter and renerate JS docs
      Add conversion and test string support for sparse tensors
      Exclude conversion utils from minimal build
      Add CUDA Memcpy and adjust provider interfaces
2021-07-22 15:24:36 -07:00
Dmitri Smirnov
d1f0251e39
Python bindings fix ups in preparation to Sparse Tensor introduction (#7817)
* Fix up constness in pybindings
  Fix up return argument treatments.
  Specifically, for all functions that return pointers or references
  to the members of other pybind registered classes, we want not to copy
  them, but internally bump up a reference to the hosting class so they do not
  disappear before the reference to the returned members is re-claimed.
  This policy is applied by default to def_property and def_readwrite but not to def_readonly
  and other def methods.
  See https://pybind11-jagerman.readthedocs.io/en/stable/advanced.html#return-value-policies
  https://pybind11.readthedocs.io/en/stable/advanced/functions.html#return-value-policies
  Move OrtValue binding to a separate file
  Move IOBinding into separate file.
2021-05-26 09:47:41 -07:00
Hariharan Seshadri
b9f90e297e
Support sharing of initializers between session via the Python API (#5407) 2020-10-09 20:26:28 -07:00
Hariharan Seshadri
6f54113a1b
Support OrtValue binding in Python to enable interesting IOBinding scenarios in Python (#5248) 2020-10-06 21:14:41 -07:00
liqunfu
c3c4ce5ceb
refactor prototypes into headers (#4337)
* refactor prototypes into headers
2020-06-26 12:02:14 -07:00
Du Li
645a988c04
Support binding input only for IOBinding in python api. (#4079)
* Support binding input only in python api.

* Addressing PR comments.

* fixing build issues
2020-06-25 12:20:02 -07:00
Dmitri Smirnov
4e1dac67cd
Address memory leak and improve memory handling (#4124)
Fix memory leak when a Python list passed as a feed.
  Create a custom allocator that can take ownership of python
  arrays that are created inside pybind.
  Allow direct memory use if continuous array is a copy because
  we now can take ownership of it by the allocator.
2020-06-08 09:29:46 -07:00
Edward Chen
e542cfd0e0 Introduce training changes. 2020-03-11 14:39:03 -07:00
Pranav Sharma
2d4d0abd36
Add support for output seq(tensor) in python binding and test framework. Implement SequenceConstruct, SequenceEmpty, SequenceInsert and SequenceErase ops. (#2040)
Add support for output seq(tensor) in python binding and test framework. Implement SequenceConstruct, SequenceEmpty, SequenceInsert and SequenceErase ops. (#2040)
2019-10-10 15:58:49 -07:00
jywu-msft
686bd36210
Remove ml_status.h, add StatusCode to pybind exception mappings (#1889)
* initial checkin.

* add onnxruntime status code to ort pybind exception mapping.

* address review feedback.
2019-09-24 11:13:14 -07:00
Ke Zhang
13d8558404
move environment.h/cc from framework to session project/folder. (#1241) 2019-06-17 18:01:21 -07:00
Changming Sun
2663b9c443
Remove unnecessary casts from OrtValue to MLValue(#1051) 2019-05-17 07:52:59 -07:00
Changming Sun
afd831ae9e Remove unnecessary const 2018-12-13 21:51:28 -08:00
Pranav Sharma
89618e8f1e Initial bootstrap commit. 2018-11-19 16:48:22 -08:00