This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import onnxruntime | |
import numpy as np | |
sess_options = onnxruntime.SessionOptions() | |
session = onnxruntime.InferenceSession(export_model_path, | |
sess_options, | |
providers=['CUDAExecutionProvider']) | |
latency = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
device = torch.device("cuda") | |
# Set model to inference mode, which is required before exporting | |
# the model because some operators behave differently in | |
# inference and training mode. | |
model.eval() | |
model.to(device) | |
total_samples = len(df) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import onnxruntime | |
import numpy as np | |
sess_options = onnxruntime.SessionOptions() | |
session = onnxruntime.InferenceSession(export_model_path, | |
sess_options, | |
providers=['CPUExecutionProvider']) | |
latency = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import pandas as pd | |
import numpy as np | |
from tqdm import tqdm | |
df = pd.read_csv('./imdb_top_1000.csv', usecols=['Overview']) | |
total_samples = len(df) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# # Load pretrained model and tokenizer | |
from transformers import AutoModel, AutoTokenizer | |
model_name = "sentence-transformers/all-MiniLM-L6-v2" | |
tokenizer = AutoTokenizer.from_pretrained(model_name, | |
do_lower_case=True ) | |
model = AutoModel.from_pretrained(model_name ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
import seaborn as sns | |
import matplotlib.pyplot as plt | |
import tensorflow as tf | |
from tensorflow.keras import layers | |
from tensorflow.keras.datasets import mnist | |
from tensorflow.keras.layers import Dense, Flatten, Input, Dropout | |
from tensorflow.keras.layers import Conv2D, MaxPooling2D, BatchNormalization |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
import seaborn as sns | |
import matplotlib.pyplot as plt | |
import tensorflow as tf | |
from tensorflow.keras import layers | |
from tensorflow.keras.datasets import mnist | |
from tensorflow.keras.layers import Dense, Flatten, Input, Dropout | |
from tensorflow.keras.layers import Conv2D, MaxPooling2D, BatchNormalization |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
import seaborn as sns | |
import matplotlib.pyplot as plt | |
import tensorflow as tf | |
from tensorflow.keras import layers | |
from tensorflow.keras.datasets import mnist | |
from tensorflow.keras.layers import Dense, Flatten, Input, Dropout | |
from tensorflow.keras.layers import Conv2D, MaxPooling2D |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import onnx | |
print(onnx.__version__) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Imports | |
import numpy as np | |
import pandas as pd | |
import seaborn as sns | |
import matplotlib.pyplot as plt | |
import keras | |
from keras.datasets import mnist | |
from keras.layers import Dense, Flatten, Input | |
from keras.layers import Conv2D, MaxPooling2D |