Skip to content

Instantly share code, notes, and snippets.

View ganler's full-sized avatar
🚀

Jiawei Liu ganler

🚀
View GitHub Profile
#include <opencv2/opencv.hpp>
std::vector<float> images2nchw(std::vector<cv::Mat> images, cv::Size size, double factor=1.0, bool flip_rb = true) {
std::vector<float> data;
data.reserve(size.area() * 3 * images.size());
size_t base = 0;
for(auto&& image : images)
{
assert(image.type() == CV_8UC3);
cv::resize(image, image, size);
#include <string>
#include <iostream>
#include <unordered_map>
class CmdLineParser {
public:
CmdLineParser(int args, char** argv) {
try {
for(size_t i = 1; i < args; ++i) {
enum class State {
/*
-------------------------------------------------------------------------------
Best matrial(I think) currently:
https://luncliff.github.io/coroutine/ppt/%5BEng%5DExploringTheCppCoroutine.pdf
= [Donald Knuth] Coroutines are functions that can suspend and resume their \
execution while keeping their state.
= The coroutine in C++ 20 standard are stackless.
-------------------------------------------------------------------------------
= Key concepts:
>>> [Routine]: An ordered group of instrutions. [instr0 -> instr1 -> ...]
#include <type_traits>
#include <utility>
#include <iostream>
#include <tuple>
#include <array>
using kDHCandidates = std::index_sequence<1, 2, 3>;
using kKWCandidates = std::index_sequence<1, 3, 5, 7>;
// 把REPLACE_ME删掉换成你的deep_conv即可
// Getting start with LLVM
// https://www.youtube.com/watch?v=3QQuhL-dSys
/*
* LLVM Primer
* Transformation Examples
* Middle-End Pass & Backend Pass
*/
/*
@ganler
ganler / tvm_mcov_bitmap.patch
Created October 6, 2022 20:16
Memcov Bitmap Compilation Extension to TVM
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e961c6d2d..45c496c17 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -511,6 +511,9 @@ include(cmake/modules/Git.cmake)
include(cmake/modules/LibInfo.cmake)
include(cmake/modules/RustExt.cmake)
+tvm_option(USE_MEMCOV "Build with ganler/memcov" ON)
+include(cmake/modules/contrib/Memcov.cmake)
@ganler
ganler / nnsmith-fix-grad.patch
Created October 14, 2022 20:46
Quickly fix grad experiment bugs in NNSmith artifact version.
diff --git a/experiments/input_search.py b/experiments/input_search.py
index 3a2eec0..f82f55e 100644
--- a/experiments/input_search.py
+++ b/experiments/input_search.py
@@ -50,7 +50,7 @@ def mknets(args, exp_seed):
os.makedirs(model_path)
__DIFF_CACHE__ = 'config/diff.pkl'
differentiable_ops = rewrite_op_dtype(
- ALL_OP_TYPES, factory=None, diff=True, verbose=True, cache=__DIFF_CACHE__)
+ ALL_OP_TYPES, factory=None, diff=True, verbose=False, cache=__DIFF_CACHE__)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 784b5284170..186a4771648 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -972,8 +972,7 @@ if(USE_CPP_CODE_COVERAGE)
string(APPEND CMAKE_C_FLAGS " --coverage -fprofile-abs-path")
string(APPEND CMAKE_CXX_FLAGS " --coverage -fprofile-abs-path")
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
- string(APPEND CMAKE_C_FLAGS " -fprofile-instr-generate -fcoverage-mapping")
- string(APPEND CMAKE_CXX_FLAGS " -fprofile-instr-generate -fcoverage-mapping")