diff --git a/csharp/src/Microsoft.ML.OnnxRuntime/SessionOptions.cs b/csharp/src/Microsoft.ML.OnnxRuntime/SessionOptions.cs index b4157a616a..6ef6c60345 100644 --- a/csharp/src/Microsoft.ML.OnnxRuntime/SessionOptions.cs +++ b/csharp/src/Microsoft.ML.OnnxRuntime/SessionOptions.cs @@ -55,6 +55,24 @@ namespace Microsoft.ML.OnnxRuntime NativeApiStatus.VerifySuccess(NativeMethods.OrtDisableSequentialExecution(_nativePtr)); } + /// + /// Enable Mem Pattern. By default, it is enabled + /// + /// + public void EnableMemPattern() + { + NativeApiStatus.VerifySuccess(NativeMethods.OrtEnableMemPattern(_nativePtr)); + } + + /// + /// Disable Mem Pattern. + /// + /// + public void DisableMemPattern() + { + NativeApiStatus.VerifySuccess(NativeMethods.OrtDisableMemPattern(_nativePtr)); + } + /// /// Default instance /// diff --git a/onnxruntime/python/onnxruntime_pybind_state.cc b/onnxruntime/python/onnxruntime_pybind_state.cc index d0b91de33f..e29c6cf3f8 100644 --- a/onnxruntime/python/onnxruntime_pybind_state.cc +++ b/onnxruntime/python/onnxruntime_pybind_state.cc @@ -389,6 +389,8 @@ void addObjectMethods(py::module& m) { Set this option to false if you don't want it. Default is True.)pbdoc") .def_readwrite("enable_profiling", &SessionOptions::enable_profiling, R"pbdoc(Enable profiling for this session. Default is false.)pbdoc") + .def_readwrite("enable_mem_pattern", &SessionOptions::enable_mem_pattern, + R"pbdoc(Enable the memory pattern optimization. Default is true.)pbdoc") .def_readwrite("enable_sequential_execution", &SessionOptions::enable_sequential_execution, R"pbdoc(Enables sequential execution, disables parallel execution. Default is true.)pbdoc") .def_readwrite("max_num_graph_transformation_steps", &SessionOptions::max_num_graph_transformation_steps,