Skip to content

Instantly share code, notes, and snippets.

import os
import nnvm
import nnvm.testing
import nnvm.compiler
from nnvm import sym
import tvm
from tvm import autotvm
from tvm.autotvm.tuner import XGBTuner, GATuner, RandomTuner, GridSearchTuner
from tvm.contrib.util import tempdir
import sys
import logging
import tvm
from tvm import autotvm
import topi
import numpy as np
from topi.testing import conv2d_nchw_python
import functools
import operator
"""
Writing tunable template and Using auto-tuner
=============================================
**Author**: `Lianmin Zheng <https://https://github.com/merrymercy>`_
This is an introduction tutorial to the auto-tuning module in tvm.
There are two steps in auto-tuning.
The first step is defining a search space.
The second step is running a search algorithm to explore through this space.
import tvm
def main(n):
a = tvm.placeholder((n,), dtype='int8')
c = tvm.compute((n,), lambda i: a[i])
s = tvm.create_schedule(c.op)
bx, tx = s[c].split(s[c].op.axis[0], factor=4)

Enforce constness of SGMatrix / SGVector

Currently, one can always mutate const matrix and vector by creating shadow copy, which breaks the semantic of const reference. We can make copy ctors return deep copy and add move ctors. The move constructor should obtain the ownership of underlying memory, and leave the original one uninitialized.

For example

SGMatrix::SGMatrix(const SGMatrix &orig); // deep copy
SGMatrix& SGMatrix::operator=(const SGMatrix<T>&); // deep copy
SGMatrix(SGMatrix &&); // move ctor