This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <chrono> | |
#include <iostream> | |
#include <vector> | |
#include <thread> | |
__global__ void do_nothing(int time_us, int clock_rate) { | |
clock_t start = clock64(); | |
clock_t end; | |
for (;;) { | |
end = clock64(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torch.nn as nn | |
class GroupNorm(nn.Module): | |
def __init__(self, num_groups, num_features, eps=1e-5): | |
super(GroupNorm, self).__init__() | |
self.weight = nn.Parameter(torch.ones(1,num_features,1,1)) | |
self.bias = nn.Parameter(torch.zeros(1,num_features,1,1)) | |
self.num_groups = num_groups |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <thread> | |
#include <chrono> | |
#include <iostream> | |
const int N = 1 << 20; | |
__global__ void kernel(float *x, int n) | |
{ | |
int tid = threadIdx.x + blockIdx.x * blockDim.x; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <pybind11/pybind11.h> | |
int add(int i, int j){ | |
return i+j; | |
} | |
PYBIND11_MODULE(pybind11_example, m) { | |
m.doc() = "pybind11 example to add 2 integers"; | |
m.def("add", &add, "A function to add 2 integers"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torch.nn as nn | |
import time | |
from torch import Tensor | |
class Net(nn.Module): | |
def __init__(self, features): | |
super().__init__() | |
self.fc_layers = [nn.Linear(features, features) for _ in range(100)] | |
self.layers = nn.Sequential(*self.fc_layers) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <thread> | |
#include <pthread.h> | |
#include <iostream> | |
#include <cstring> | |
class thread : public std::thread | |
{ | |
public: | |
static void setScheduling(std::thread &th, int priority) { | |
sched_param sch; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "omp.h" | |
#include <thread> | |
#include <iostream> | |
#include <vector> | |
#include <chrono> | |
void doNothing(){ | |
int count =0; | |
for (int i=0; i<1000; ++i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torch.nn as nn | |
import copy | |
import torchvision.models as models | |
class BN_Folder(): | |
def fold(self, model): | |
mymodel = copy.deepcopy(model) | |
mymodel.eval() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline void gpuAssert(cudaError_t err, const char *file, int line) | |
{ | |
if (err != cudaSuccess){ | |
printf("%s in %s at line %d\n", cudaGetErrorString(err), file, line); | |
exit(EXIT_FAILURE); | |
} | |
} | |
#define gpuErrchk(ans) \ | |
{ \ | |
gpuAssert((ans), __FILE__, __LINE__); \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdio.h> | |
#define BLOCK_SIZE 16 | |
inline void gpuAssert(cudaError_t err, const char *file, int line) | |
{ | |
if (err != cudaSuccess){ | |
printf("%s in %s at line %d\n", cudaGetErrorString(err), file, line); | |
exit(EXIT_FAILURE); |