


"""simple docstring"""



import os
import time

import numpy as np
import onnxruntime as ort


__snake_case       =       """1"""
__snake_case       =       """0"""
__snake_case       =       """1"""

__snake_case       =       ort.SessionOptions()
__snake_case       =       ort.GraphOptimizationLevel.ORT_DISABLE_ALL
print("""Create inference session...""")
__snake_case       =       ["""TensorrtExecutionProvider""", """CUDAExecutionProvider"""]
__snake_case       =       ort.InferenceSession("""model.onnx""", sess_options=sess_opt, providers=execution_provider)
__snake_case       =       ort.RunOptions()

__snake_case       =       128
__snake_case       =       1
__snake_case       =       np.ones((batch, sequence), dtype=np.intaa)
__snake_case       =       np.ones((batch, sequence), dtype=np.intaa)
__snake_case       =       np.ones((batch, sequence), dtype=np.intaa)

print("""Warm up phase...""")
sess.run(
    None,
    {
        sess.get_inputs()[0].name: input_ids,
        sess.get_inputs()[1].name: attention_mask,
        sess.get_inputs()[2].name: token_type_ids,
    },
    run_options=run_opt,
)

print("""Start inference...""")
__snake_case       =       time.time()
__snake_case       =       2000
__snake_case       =       {}
for iter in range(max_iters):
  __snake_case       =       sess.run(
      None,
      {
          sess.get_inputs()[0].name: input_ids,
          sess.get_inputs()[1].name: attention_mask,
          sess.get_inputs()[2].name: token_type_ids,
      },
      run_options=run_opt,
  )
print("""Average Inference Time = {:.3f} ms""".format((time.time() - start_time) * 1000 / max_iters))









"""simple docstring"""



from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


__snake_case       =       {
    """configuration_poolformer""": [
        """POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """PoolFormerConfig""",
        """PoolFormerOnnxConfig""",
    ]
}

try:
  if not is_vision_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __snake_case       =       ["""PoolFormerFeatureExtractor"""]
  __snake_case       =       ["""PoolFormerImageProcessor"""]

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __snake_case       =       [
      """POOLFORMER_PRETRAINED_MODEL_ARCHIVE_LIST""",
      """PoolFormerForImageClassification""",
      """PoolFormerModel""",
      """PoolFormerPreTrainedModel""",
  ]


if TYPE_CHECKING:
  from .configuration_poolformer import (
      POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
      PoolFormerConfig,
      PoolFormerOnnxConfig,
  )

  try:
    if not is_vision_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .feature_extraction_poolformer import PoolFormerFeatureExtractor
    from .image_processing_poolformer import PoolFormerImageProcessor

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_poolformer import (
        POOLFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
        PoolFormerForImageClassification,
        PoolFormerModel,
        PoolFormerPreTrainedModel,
    )


else:
  import sys

  __snake_case       =       _LazyModule(__name__, globals()["""__file__"""], _import_structure)





