/// <inheritdoc/> public void SetDevice(int deviceId) { Session?.Dispose(); options?.Dispose(); options = new SessionOptions { GraphOptimizationLevel = GraphOptimizationLevel.ORT_ENABLE_ALL, ExecutionMode = deviceId < 0 ? ExecutionMode.ORT_PARALLEL : ExecutionMode.ORT_SEQUENTIAL, EnableMemoryPattern = deviceId < 0 }; if (deviceId >= 0) { options.AppendExecutionProvider_DML(deviceId); } Session = new InferenceSession(model, options); }