This file contains 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
#include <iostream> | |
#include <Eigen/Dense> | |
#include <Eigen/StdVector> | |
using Eigen::MatrixXd; | |
using namespace std; | |
using namespace Eigen; | |
This file contains 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 argparse | |
import numpy as np | |
import mxnet as mx | |
import gluonnlp as nlp | |
import tvm | |
from tvm import relay | |
import tvm.contrib.graph_runtime as runtime | |
def timer(thunk, repeat=1, number=10, dryrun=3, min_repeat_ms=1000): |
This file contains 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
# FP16 TRT command to run : TVM_TENSORRT_USE_FP16=1 python test_trt.py | |
# INT8 TRT command to run : TVM_TENSORRT_USE_INT8=1 TENSORRT_NUM_CALI_INT8=10 python test_trt.py | |
# use tvm branch: https://github.com/tiandiao123/tvm/tree/pr_trt_int8 | |
import tvm | |
from tvm import relay | |
import numpy as np | |
from tvm.contrib.download import download_testdata | |
import os | |
# PyTorch imports |
This file contains 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
# FP16 TRT command to run : TVM_TENSORRT_USE_FP16=1 python test_trt.py | |
# INT8 TRT command to run : TVM_TENSORRT_USE_INT8=1 TENSORRT_NUM_CALI_INT8=10 python test_trt.py | |
# https://github.com/tiandiao123/tvm/tree/pr_trt_int8 (tvm we use) | |
import tvm | |
from tvm import relay | |
from tvm.contrib.download import download_testdata | |
from tvm.relay.op.contrib.tensorrt import partition_for_tensorrt | |
# PyTorch imports |
This file contains 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
# FP16 TRT command to run : TVM_TENSORRT_USE_FP16=1 python test_trt.py | |
# INT8 TRT command to run : TVM_TENSORRT_USE_INT8=1 TENSORRT_NUM_CALI_INT8=10 python test_trt.py | |
# use tvm branch: https://github.com/tiandiao123/tvm/tree/pr_trt_int8 | |
import tvm | |
from tvm import relay | |
import os | |
from tvm import te | |
import tvm.relay as relay | |
from tvm.contrib.download import download_testdata |
This file contains 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 mxnet | |
from mxnet.gluon.model_zoo.vision import get_model | |
import tvm | |
from tvm import relay | |
import tvm.contrib.graph_runtime as runtime | |
import numpy as np | |
dtype = "float32" | |
input_shape = (1, 3, 224, 224) | |
block = get_model('resnet18_v1', pretrained=True) |
This file contains 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
### here is a demo how to convert your tf2 model into tvm relay | |
import tensorflow as tf | |
from tensorflow.python.tools import saved_model_utils | |
from tensorflow import keras | |
from tensorflow.python.framework.convert_to_constants import convert_variables_to_constants_v2 | |
from tvm import relay | |
from tvm.relay.frontend.tensorflow2 import from_tensorflow | |
dtype_dict = { | |
"tf.float32": "float32", |
This file contains 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 tvm | |
from tvm import relay | |
from tvm.relay.op.contrib.tensorrt import partition_for_tensorrt | |
from tvm.contrib import graph_executor | |
import numpy as np | |
# 改成你自己的tvm .so 存储路径 | |
my_lib_saved_path = "/data00/cuiqing.li/xperf_workplace/xperf_tools/xperf_tools/xperf_pipeline/bytetuner/rh2_tvm_lab.vulgar.pipeline_1.4/deploy_batch_id_32.so" | |
lib = tvm.runtime.load_module(my_lib_saved_path) |
This file contains 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 tvm | |
from tvm import relay | |
import tvm.contrib.graph_runtime as runtime | |
import numpy as np | |
from tvm.contrib.download import download_testdata | |
from tvm.relay.op.contrib.tensorrt import partition_for_tensorrt | |
# PyTorch imports | |
import torch | |
import torchvision |
This file contains 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 torch | |
import torchvision | |
from torch.utils.mobile_optimizer import optimize_for_mobile | |
from caffe2.torch.fb.mobile.model_exporter.mobile_model_exporter import ( | |
export_torch_mobile_model, | |
BundledInput, | |
MobileModelInfo, | |
ModelType, | |
OptimizationPassInput | |
) |
OlderNewer