Skip to content

Instantly share code, notes, and snippets.

View zhiqiu's full-sized avatar
👋
hi

Leo Chen zhiqiu

👋
hi
View GitHub Profile
import os
def get_candidates(git_command=''):
git_command = 'git log --pretty=format:"%h" --since=2019-10-01'
res = os.popen(git_command).read()
candidates = res.split('\n')
# for line in candidates:
# print(line)
return candidates
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
import torch
import paddle
import paddle.fluid as fluid
import unittest
import numpy as np
def get_paddle_loss(input, label, reduction):
loss = paddle.nn.loss.L1Loss(reduction=reduction)
with fluid.dygraph.guard():
return loss(fluid.dygraph.to_variable(input), fluid.dygraph.to_variable(label))
#pragma once
#include "paddle/fluid/imperative/tracer.h"
namespace py = pybind11;
namespace paddle {
namespace pybind {
std::shared_ptr<imperative::VarBase> imperative_logical_xor(const std::shared_ptr<imperative::VarBase>& X,const std::shared_ptr<imperative::VarBase>& Y, const py::args& args)
{
framework::AttributeMap attrs;
#pragma once
#include "paddle/fluid/imperative/tracer.h"
namespace py = pybind11;
namespace paddle {
namespace pybind {
const std::shared_ptr<imperative::VarBase>& imperative_logical_xor(const std::shared_ptr<imperative::VarBase>& X,const std::shared_ptr<imperative::VarBase>& Y, const py::args& args)
{
framework::AttributeMap attrs;
@zhiqiu
zhiqiu / gist:82ea0d00433d812c24bedeacf809aa82
Created January 3, 2020 04:22
binary_search_first_buggy_commit.py
import os
def compile(commit):
cmake = 'cmake ../.. -DCMAKE_BUILD_TYPE=Release -DWITH_DSO=ON -DWITH_GPU=OFF -DWITH_AMD_GPU=OFF -DWITH_DISTRIBUTE=OFF -DWITH_MKL=ON -DWITH_NGRAPH=OFF -DWITH_AVX=ON -DNOAVX_CORE_FILE= -DWITH_GOLANG=OFF -DCUDA_ARCH_NAME=All -DCUDA_ARCH_BIN= -DWITH_PYTHON=ON -DCUDNN_ROOT=/usr/ -DWITH_TESTING=ON -DWITH_COVERAGE=OFF -DCMAKE_MODULE_PATH=/opt/rocm/hip/cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DWITH_CONTRIB=ON -DWITH_INFERENCE_API_TEST=ON -DWITH_HIGH_LEVEL_API_TEST=OFF -DINFERENCE_DEMO_INSTALL_DIR=/root/.cache/inference_demo -DPY_VERSION=2.7 -DCMAKE_INSTALL_PREFIX=/paddle/build -DWITH_GRPC=OFF'
command = 'git reset --hard %s' % commit
os.system(command)
build = 'work/build_%s' % commit
print(build)
if not os.path.exists(build):
os.system("mkdir %s" % build)
command = 'cd %s && %s && make copy_paddle_pybind -j76' %(build, cmake)
@zhiqiu
zhiqiu / analyze_stats.py
Last active January 21, 2020 11:38
A simple scripts to analyze stats generated by cProfile
# python3
# created by zhiqiu
import sys
import marshal
def read_stats(stats_name):
with open(stats_name, "rb") as f:
d = marshal.load(f)
return d
@zhiqiu
zhiqiu / op_function_impl.h
Last active January 17, 2020 09:03
generated op functions for dygraph.
#pragma once
#include "paddle/fluid/imperative/tracer.h"
namespace py = pybind11;
namespace paddle {
namespace pybind {
inline imperative::NameVarBaseMap imperative_read_from_array(const imperative::NameVarBaseMap& ins, const framework::AttributeMap& attrs,
imperative::NameVarBaseMap outs, const std::map<std::string, size_t>& out_nums)
{