Skip to content

Instantly share code, notes, and snippets.

@BeMg
BeMg / main.c
Created March 27, 2020 05:40
common base address example
/*
* SPDX-License-Identifier: MIT
* MIT License
*
* Copyright (c) 2019 Western Digital Corporation or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
def schedule_conv2d_2(_,outs,target):
"""Create schedule for tensors"""
s = tvm.create_schedule([x.op for x in outs])
scheduled_ops = []
def traverse(op):
"""Traverse operators from computation graph"""
# inline all one-to-one-mapping operators except the last stage (output)
if 'broadcast' in op.tag:
if op not in s.outputs:
@BeMg
BeMg / download_from_UU.py
Created December 11, 2019 05:29
download all text from UU
import requests
from bs4 import BeautifulSoup
import sys
from opencc import OpenCC
def s2t(text):
cc = OpenCC('s2t')
converted = cc.convert(text)
return converted
@BeMg
BeMg / mxnet_model.py
Created October 30, 2019 13:07
rearrange imagenet dataset
import mxnet as mx
import numpy as np
from mxnet import gluon, nd
from mxnet import autograd as ag
from mxnet.gluon import nn
from mxnet.gluon.model_zoo import vision as models
from mxnet.gluon.data import vision
from mxnet.gluon.data.vision import transforms
import shutil
@BeMg
BeMg / main.py
Created October 7, 2019 07:23
Loop Partition example
import tvm
import numpy
import timeit
n = 225
A = tvm.placeholder((n, n), name='Input')
B = tvm.placeholder((7, 7), name='Filter')
di = tvm.reduce_axis((0, 7), name='di')
dj = tvm.reduce_axis((0, 7), name='dj')
C = tvm.compute(
@BeMg
BeMg / config.cmake
Last active September 17, 2019 05:23
aaaa
#--------------------------------------------------------------------
# Template custom cmake configuration for compiling
#
# This file is used to override the build options in build.
# If you want to change the configuration, please use the following
# steps. Assume you are on the root directory. First copy the this
# file so that any local changes will be ignored by git
#
# $ mkdir build
# $ cp cmake/config.cmake build
@BeMg
BeMg / test.ipynb
Created September 11, 2019 09:18
aaaa
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@BeMg
BeMg / V64_2.s
Last active August 21, 2019 06:55
.text
.file "fuse_reshape"
.globl fuse_reshape # -- Begin function fuse_reshape
.p2align 2
.type fuse_reshape,@function
fuse_reshape: # @fuse_reshape
.cfi_startproc
# %bb.0: # %entry
addi sp, sp, -16
.cfi_def_cfa_offset 16
@BeMg
BeMg / dockerfile
Created August 17, 2019 17:24
dockerfile for riscv_toolchain
FROM ubuntu:18.04
MAINTAINER BeMg
RUN apt-get update && apt-get install -y git autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev libusb-1.0-0-dev gawk \
build-essential bison flex device-tree-compiler texinfo gperf libtool patchutils bc zlib1g-dev device-tree-compiler pkg-config libexpat-dev && mkdir risc-v
ENV RISCV /risc-v
RUN cd ~ && git clone -b rvv-0.7.x --recursive https://github.com/riscv/riscv-gnu-toolchain && \
cd riscv-gnu-toolchain && ./configure --prefix=$RISCV --with-arch=rv64gcv --with-abi=lp64 && make -j4
ENV PATH="/risc-v/bin:${PATH}"
RUN cd ~ && git clone https://github.com/riscv/riscv-pk.git && \
Chain INPUT (policy ACCEPT)
target prot opt source destination
ufw-before-logging-input all -- 0.0.0.0/0 0.0.0.0/0
ufw-before-input all -- 0.0.0.0/0 0.0.0.0/0
ufw-after-input all -- 0.0.0.0/0 0.0.0.0/0
ufw-after-logging-input all -- 0.0.0.0/0 0.0.0.0/0
ufw-reject-input all -- 0.0.0.0/0 0.0.0.0/0
ufw-track-input all -- 0.0.0.0/0 0.0.0.0/0
Chain FORWARD (policy ACCEPT)