Skip to content

Instantly share code, notes, and snippets.

jbai-mbp:/tmp/onnx-benchmark[1][2]$ python bench_caffe2.py --model_name resnet18 --batch_sizes 1 2 8 16 --runs 10
WARNING:root:This caffe2 python run does not have GPU support. Will run in CPU only mode.
WARNING:root:Debug message: No module named caffe2_pybind11_state_gpu
Batch Size=1
WARNING: Logging before InitGoogleLogging() is written to STDERR
I0925 20:12:10.023396 2958132160 net_simple.cc:81] Starting benchmark.
I0925 20:12:10.023424 2958132160 net_simple.cc:82] Running warmup runs.
I0925 20:12:10.221287 2958132160 net_simple.cc:92] Main runs.
I0925 20:12:11.880851 2958132160 net_simple.cc:103] Main run finished. Milliseconds per iter: 165.951. Iters per second: 6.02589
I0925 20:12:13.568706 2958132160 net_simple.cc:152] Operator #0 (105, Conv) 11.2651 ms/iter
from argparse import ArgumentParser
import os
from timeit import Timer
import numpy as np
from caffe2.python import workspace
import onnx
from onnx.numpy_helper import to_array
import onnx_caffe2.backend
import torch
---------- onnx coverage: ----------
Operators (passed/loaded/total): 21/21/70
------------------------------------
╒════════════════════╤════════════════════╕
│ Operator │ Attributes │
│ │ (name: #values) │
╞════════════════════╪════════════════════╡
│ Slice │ axes: 2 │
│ │ ends: 3 │
│ │ starts: 3 │
# /opt/rocm/bin/hcc -DNDEBUG -Dcaffe2_hip_EXPORTS -I/code/build -I/code -isystem /code/build/third_party/gloo -isystem /code/third_party/gloo -I/code/third_party/protobuf/src -I/code/third_party/googletest/googletest/include -I/code/third_party/benchmark/include -I/usr/include/opencv -I/code/third_party/eigen -I/usr/include/python3.6m -I/usr/local/lib/python3.6/dist-packages/numpy/core/include -I/code/third_party/pybind11/include -I/data/Thrust -I/data/Thrust/thrust/system/cuda/detail/cub-hip -I/code/third_party/onnx -I/code/build/third_party/onnx -isystem /opt/rocm/hip/include -isystem /opt/rocm/rocrand/include -isystem /opt/rocm/hiprand/include -I/opt/rocm/miopen/include -I/code/caffe2/core/nomnigraph/include -isystem /opt/rocm/hsa/include -isystem /opt/rocm/hcc/include -isystem /opt/rocm/include -fvisibility-inlines-hidden -DONNX_NAMESPACE=onnx_c2 -O2 -fPIC -Wno-narrowing -Wno-invalid-partial-specialization -O3 -DNDEBUG -fPIC -D__HIP_PLATFORM_HCC__=1 -std=c++11 -hc -fPIC -std=gnu++11 -o CMakeFiles/caf
#include <benchmark/benchmark.h>
#include <torch/torch.h>
template <int size>
class Contiguous : public benchmark::Fixture {
void SetUp(const ::benchmark::State& state) {
input = torch::randn({size, size}).to(at::kFloat);
indexes = torch::randint(0, size, {size / 4}).to(at::kLong);
}
#include <benchmark/benchmark.h>
#include <torch/torch.h>
namespace {
template <int row, int col>
class Contiguous : public benchmark::Fixture {
void SetUp(const ::benchmark::State& /* unused */) override {
input = torch::randn({row, col}).to(at::kFloat);
indexes = torch::randint(0, row, {row / 4}).to(at::kLong);
}
#include <benchmark/benchmark.h>
#include <torch/torch.h>
namespace {
template <int row, int col>
class Contiguous : public benchmark::Fixture {
void SetUp(const ::benchmark::State& /* unused */) override {
input = torch::randn({row, col}).to(at::kFloat);
indexes = torch::randint(0, row, {row / 4}).to(at::kLong);
}
@bddppq
bddppq / run.py
Last active February 2, 2023 10:58
import time
from timeit import default_timer as timer
class DelayedValue:
def __init__(self, done, thunk):
self.done = done
self.thunk = thunk
self.val = None
@bddppq
bddppq / pygmalion-13b.py
Last active September 16, 2023 05:22
pygmalion-13b
import openai
openai.api_base = "https://pygmalion-13b.lepton.run/api/v1"
openai.api_key = "YOUR_API_KEY"
prompt = '''
Assistant's Persona: Assistant is a highly intelligent language model trained to comply with user requests.
<START>
Assistant: Hello! How may I help you today?
You: What is Zork?
@bddppq
bddppq / pygmalion-2-13b.py
Last active September 19, 2023 01:03
pygmalion-2-13b
import openai
openai.api_base = "https://pygmalion-2-13b.lepton.run/api/v1"
openai.api_key = "YOUR_API_KEY"
prompt = '''
<|system|>Enter RP mode. Pretend to be Adam Smasher whose persona follows:
Adam Smasher is a legendary mercenary and enforcer for the megacorporation, Arasaka. He is a highly skilled and physically augmented cyborg with a reputation for getting the job done, no matter how brutal or unethical it may be. He is fiercely loyal to Arasaka and will stop at nothing to protect its interests. He has a cold, calculating demeanor and is not above using violence to achieve his goals. Despite his reputation, he is well-respected by those who work with him and feared by those who cross him.
<|user|>What are you up to these days?<|model|>'''