Skip to content

Instantly share code, notes, and snippets.

View yzhliu's full-sized avatar

Yizhi Liu yzhliu

  • Boson AI
  • Bay Area, the United States
View GitHub Profile
import os
import numpy as np
import nnvm.testing
import nnvm.compiler
import tvm
from tvm import autotvm
from tvm.autotvm.tuner import XGBTuner, GATuner, RandomTuner, GridSearchTuner
from tvm.contrib.util import tempdir
diff --git a/nnvm/src/top/nn/nn.cc b/nnvm/src/top/nn/nn.cc
index 322d77b6..12146cca 100644
--- a/nnvm/src/top/nn/nn.cc
+++ b/nnvm/src/top/nn/nn.cc
@@ -641,6 +641,31 @@ inline bool LayoutTransformInferShape(const NodeAttrs& attrs,
return true;
}
+inline Array<Expr> layout_transform_func(const std::string& src, const std::string& dst, const Array<Var>& dst_indices) {
+ Layout src_layout(src);
This file has been truncated, but you can view the full file.
208 [main] INFO MXNetJVM - Try loading mxnet-scala from native path.
209 [main] INFO MXNetJVM - Try loading mxnet-scala-osx-x86_64-gpu from native path.
209 [main] INFO MXNetJVM - Try loading mxnet-scala-osx-x86_64-cpu from native path.
210 [main] WARN MXNetJVM - MXNet Scala native library not found in path. Copying native library from the archive. Consider installing the library somewhere in the path (for Windows: PATH, for Linux: LD_LIBRARY_PATH), or specifying by Java cmd option -Djava.library.path=[lib path].
224 [main] INFO org.apache.mxnet.util.NativeLibraryLoader - Replaced .dylib with .jnilib
228 [main] INFO org.apache.mxnet.util.NativeLibraryLoader - Loading libmxnet-scala.jnilib from /lib/native/ copying to mxnet-scala
661 [main] INFO org.apache.mxnet.WarnIfNotDisposed - Leaked object tracing is enabled (property mxnet.traceLeakedObjects is set)
[22:30:36] src/io/iter_mnist.cc:110: MNISTIter: load 60000 images, shuffle=1, shape=(128,784)
[22:30:37] src/io/iter_mnist.cc:110: MNISTIter: load 10000 ima
import tvm
def compute_conv2d(A, W, stride, padding):
batch_size, in_channel, height, width = A.shape
out_channel, _ = W.shape
kh = 1
kw = 1
out_height = (height + 2 * padding - kh) // stride + 1
@yzhliu
yzhliu / conv2d_nchw_rasp.py
Created January 5, 2018 19:31
Rasp version to do conv2d-nchw
import numpy as np
import tvm
import topi
from tvm.contrib.pickle_memoize import memoize
from topi.util import get_const_tuple
from topi.nn.conv2d import SpatialPack, Im2ColPack, _WORKLOADS
from topi.nn.conv2d import _get_workload
from topi.nn.util import infer_pad, infer_stride
from topi import tag
from topi.nn import pad
@yzhliu
yzhliu / conv2d_nchw_simple.py
Created January 5, 2018 18:46
The simplest version to do conv2d on skylake
import numpy as np
import tvm
import topi
from tvm.contrib.pickle_memoize import memoize
from topi.util import get_const_tuple
from topi import tag
def schedule_conv2d(outs):
print('Run in x86 sch ...')
"""Create schedule for tensors"""
// attr [data_vec] storage_scope = "global"
allocate data_vec[float32 * 1 * 56 * 8 * 64 * 3 * 9]
// attr [kernel_vec] storage_scope = "global"
allocate kernel_vec[float32 * 16 * 64 * 3 * 3 * 4]
produce data_vec {
// attr [iter_var(h.outer, )] pragma_scope = "parallel_launch_point"
// attr [iter_var(h.outer, )] pragma_scope = "parallel_barrier_when_finish"
for (h.outer, 0, 28) {
// attr [iter_var(h.inner, )] pragma_scope = "parallel_stride_pattern"
parallel (h.inner, 0, 2) {
import tvm
import numpy
import time
# The size of the square matrix
N = 100000000
# The default tensor type in tvm
dtype = "float32"
target = "llvm"
#target = "llvm -mcpu=skylake-avx512"
@generic.schedule_conv2d_nchw.register(["cpu"])
def schedule_conv2d(outs):
print('Run in x86 sch ...')
"""Create schedule for tensors"""
s = tvm.create_schedule([x.op for x in outs])
def traverse(op):
"""Traverse operators from computation graph"""
# inline all one-to-one-mapping operators except the last stage (output)
if tag.is_broadcast(op.tag):
@yzhliu
yzhliu / conv2d-x86-1.py
Created January 3, 2018 01:56
conv2d x86 bench with tvm sch-1
@generic.schedule_conv2d_nchw.register(["cpu"])
def schedule_conv2d(outs):
print('Run in x86 sch ...')
"""Create schedule for tensors"""
s = tvm.create_schedule([x.op for x in outs])
def traverse(op):
"""Traverse operators from computation graph"""
# inline all one-to-one-mapping operators except the last stage (output)
if tag.is_broadcast(op.tag):