Skip to content

Instantly share code, notes, and snippets.

import tvm
from tvm import tir
from tvm.script import ty
@tvm.script.tir
def foo(a: ty.handle, b: ty.handle, c: ty.handle) -> None:
A = tir.match_buffer(a, (128,), "float32")
B = tir.match_buffer(b, (128,), "int32")
C = tir.match_buffer(c, (128,), "float32")
reducer = tir.comm_reducer(lambda x, y: (x + y), tir.float32(0))
import tvm
import tvm.relay as relay
x = relay.var("x", shape=(16,), dtype='float32')
y = relay.var("y", shape=(16,), dtype='float32')
c = relay.Let(x, y, x)
f = relay.Function([y], relay.expr.Tuple([c, c]))
mod = relay.Module.from_expr(f)
mod = relay.transform.PartialEvaluate()(mod)
import numpy as np
import argparse
import tvm
import tvm.relay as relay
import tvm.relay.testing
from tvm.relay.testing import layers
import mxnet as mx
from mxnet import gluon
from mxnet.gluon.model_zoo import vision
import numpy as np
import logging
import argparse
import os
import mxnet as mx
from mxnet import gluon
from mxnet.gluon.model_zoo import vision
import tvm
import tvm.relay as relay
import tvm.relay.expr as _expr
import tvm
import tvm.relay as relay
import tvm.relay.testing
import numpy as np
x = relay.var("x", shape=(1, 16))
y = relay.var("y", shape=(1, 16))
z = relay.var("z", shape=(1, 16))
cond = relay.var("cond", shape=(), dtype='uint1')
net = relay.If(cond, x, y)
@vinx13
vinx13 / pe.py
Last active June 28, 2019 16:59
import tvm
import tvm.relay as relay
import tvm.relay.testing
import numpy as np
x = relay.var("x", shape=(1, 16))
y = relay.var("y", shape=(1, 16))
z = relay.var("z", shape=(1, 16))
cond = relay.var("cond", shape=(), dtype='uint1')
net = relay.If(cond, x, y)
import tvm
import tvm.relay as relay
'''
fn (%cond: bool) -> float32 {
let %x = fn () -> float32 {
let %x1 = 0f /* ty=float32 */
%x1
}
let %x2 = ref(%x)
let %x3 = if (%cond) {
# ========
# captured on: Mon Apr 1 14:48:04 2019
# os release : 4.15.0-42-generic
# perf version : 4.15.17
# arch : x86_64
# nrcpus online : 8
# nrcpus avail : 8
# cpudesc : Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
# cpuid : GenuineIntel,6,94,3
# total memory : 16341608 kB
@vinx13
vinx13 / TVM_OpenCV
Last active April 1, 2019 07:50
TVM_OpenCV
# ========
# captured on: Mon Apr 1 15:38:30 2019
# os release : 4.15.0-42-generic
# perf version : 4.15.17
# arch : x86_64
# nrcpus online : 8
# nrcpus avail : 8
# cpudesc : Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
# cpuid : GenuineIntel,6,94,3
# total memory : 16341608 kB
import argparse
import json
parser = argparse.ArgumentParser()
parser.add_argument('in_file', type=str)
parser.add_argument('out_file', type=str)
args = parser.parse_args()
def transform(line):