entry_point
stringlengths
1
65
original_triton_python_code
stringlengths
208
619k
optimised_triton_code
stringlengths
1.15k
275k
repo_name
stringlengths
7
115
module_name
stringlengths
1
65
synthetic
bool
1 class
uuid
int64
0
18.5k
licenses
listlengths
1
6
stars
int64
0
19.8k
sha
stringlengths
40
40
repo_link
stringlengths
72
180
DecoderLayer
import math import torch import torch.nn.functional as F import torch.nn as nn def attention(q, k, v, d_k, mask=None, dropout=None): scores = torch.matmul(q, k.transpose(-2, -1)) / math.sqrt(d_k) if mask is not None: mask = mask.unsqueeze(1) scores = scores.masked_fill(mask == 0, -1000000000.0...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
macg0406/Transformer
DecoderLayer
false
12,763
[ "Apache-2.0" ]
0
8c747a6e9f108c63ecc600bf14cde6827b438172
https://github.com/macg0406/Transformer/tree/8c747a6e9f108c63ecc600bf14cde6827b438172
Invertible1x1Conv
import torch import torch.nn.functional as F from torch.autograd import Variable import torch.utils.data import torch.nn class Invertible1x1Conv(torch.nn.Module): """ The layer outputs both the convolution, and the log determinant of its weight matrix. If reverse=True it does convolution with inverse...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn.functional as F from torch.autograd import Variable import torch...
malithj/TensorRT
Invertible1x1Conv
false
12,764
[ "Apache-2.0" ]
0
48605d4b5673df89110cf41249ad007259d7c34a
https://github.com/malithj/TensorRT/tree/48605d4b5673df89110cf41249ad007259d7c34a
ConcatAttention
import torch import torch.nn as nn from torch.nn.parameter import Parameter class ConcatAttention(nn.Module): """ Concatenate attention layer. """ def __init__(self, input_size_encoder, input_size_decoder, hidden_size, num_labels, **kwargs): """ Args: input_size_e...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as ...
krishnamrith12/DCST
ConcatAttention
false
12,765
[ "MIT" ]
0
7ba956d7e648aaeb25816ccfc709106db9293270
https://github.com/krishnamrith12/DCST/tree/7ba956d7e648aaeb25816ccfc709106db9293270
VectorQuantizer
import torch from torch import Tensor from torch import nn from torch.nn import functional as F class VectorQuantizer(nn.Module): """ Reference: [1] https://github.com/deepmind/sonnet/blob/v2/sonnet/src/nets/vqvae.py """ def __init__(self, num_embeddings: 'int', embedding_dim: 'int', beta: ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch import nn assert_s...
mateoIdemia/PyTorch-VAE
VectorQuantizer
false
12,766
[ "Apache-2.0" ]
0
b485924182e62843aae1955fcaf0886ac8492295
https://github.com/mateoIdemia/PyTorch-VAE/tree/b485924182e62843aae1955fcaf0886ac8492295
folder
import torch from torch import nn import torch.nn.functional as F import torch.nn.parallel class folder(nn.Module): def __init__(self): super().__init__() def forward(self, feature_map): N, _, H, W = feature_map.size() feature_map = F.unfold(feature_map, kernel_size=3, padding=1) ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch import nn import torch.nn.parallel assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C....
memesoo99/AdelaiDet
folder
false
12,767
[ "BSD-2-Clause" ]
0
1e9cdfee3d1c35dcb6b4e04fdcc966115f34c71f
https://github.com/memesoo99/AdelaiDet/tree/1e9cdfee3d1c35dcb6b4e04fdcc966115f34c71f
PredictionConvolutions
import torch from torch import nn from itertools import product as product import torch.optim import torch.utils.data class PredictionConvolutions(nn.Module): """ Convolutions to predict class scores and bounding boxes using lower and higher-level feature maps. The bounding boxes (locations) are predicte...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch import nn from itertools import product as product import torch.optim...
gigajet/ICDAR-2019-SROIE
PredictionConvolutions
false
12,768
[ "MIT" ]
0
62dd3ecc90600c0bdf8ceece796fc4e555d3bd16
https://github.com/gigajet/ICDAR-2019-SROIE/tree/62dd3ecc90600c0bdf8ceece796fc4e555d3bd16
LinearBlock
import torch from torch import nn from scipy.stats import truncnorm def truncated_normal_(tensor, mean=0.0, std=1.0): values = truncnorm.rvs(-2, 2, size=tensor.shape) values = mean + std * values tensor.copy_(torch.from_numpy(values)) return tensor def fc_init_(module): if hasattr(module, 'weigh...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
joemzhao/learn2learn
LinearBlock
false
12,769
[ "MIT" ]
0
e161e0a9e0de513d64315c4ceaf2d8608e4cef4d
https://github.com/joemzhao/learn2learn/tree/e161e0a9e0de513d64315c4ceaf2d8608e4cef4d
DebertaSelfOutput
from _paritybench_helpers import _mock_config import torch from torch import nn import torch.utils.checkpoint def get_mask(input, local_context): if not isinstance(local_context, DropoutContext): dropout = local_context mask = None else: dropout = local_context.dropout dropout ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice from torch import n...
Clemens123/transformers
DebertaSelfOutput
false
12,770
[ "Apache-2.0" ]
0
22abe7bbc587c16ec30f9d1aa549dcbeba6e9e26
https://github.com/Clemens123/transformers/tree/22abe7bbc587c16ec30f9d1aa549dcbeba6e9e26
CNN
import torch import torch.nn as nn import torch.nn.functional as F class CNN(nn.Module): def __init__(self, embed_size, hidden_size): super(CNN, self).__init__() self.hidden_size = hidden_size self.conv2d = nn.Conv2d(embed_size, hidden_size, (1, 5), bias=True) def forward(self, x): ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_...
melaniezhang/cs224n-final-proj
CNN
false
12,771
[ "MIT" ]
0
a012759e8caf4d585421d78c07125fa3696fda4e
https://github.com/melaniezhang/cs224n-final-proj/tree/a012759e8caf4d585421d78c07125fa3696fda4e
MultiHeadSelfAttention
import torch import torch.nn as nn class MultiHeadSelfAttention(nn.Module): def __init__(self, input_size, num_heads, drop_prob=0.1): super(MultiHeadSelfAttention, self).__init__() self.drop_prob = drop_prob self.multihead_attention = nn.MultiheadAttention(input_size, num_heads) def ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
melaniezhang/cs224n-final-proj
MultiHeadSelfAttention
false
12,772
[ "MIT" ]
0
a012759e8caf4d585421d78c07125fa3696fda4e
https://github.com/melaniezhang/cs224n-final-proj/tree/a012759e8caf4d585421d78c07125fa3696fda4e
GAT
import torch import torch.nn as nn import torch.nn.functional as F class GraphAttentionLayer(nn.Module): """ Simple GAT layer, similar to https://arxiv.org/abs/1710.10903 """ def __init__(self, in_features, out_features, dropout, alpha, concat=True): super(GraphAttentionLayer, self).__init__(...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
markheimann/fgc
GAT
false
12,773
[ "MIT" ]
0
909d4f0a84c9b61a8030f9f3f50b17f143576007
https://github.com/markheimann/fgc/tree/909d4f0a84c9b61a8030f9f3f50b17f143576007
MyNeural
import torch import torch.nn import torch.nn.functional as Functional class MyNeural(torch.nn.Module): def __init__(self, columns): super(MyNeural, self).__init__() self.f1 = torch.nn.Linear(columns, 32) self.f2 = torch.nn.Linear(32, 16) self.f3 = torch.nn.Linear(16, 1) def f...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn assert_size_s...
med-boubekri/Covid-Fact-Checker
MyNeural
false
12,774
[ "MIT" ]
0
7869bcd830f33aefe4afeb5b75808f479e8094f2
https://github.com/med-boubekri/Covid-Fact-Checker/tree/7869bcd830f33aefe4afeb5b75808f479e8094f2
BeitSelfAttention
from _paritybench_helpers import _mock_config import math import torch from torch import nn import torch.utils.checkpoint class BeitRelativePositionBias(nn.Module): def __init__(self, config, window_size): super().__init__() self.window_size = window_size self.num_relative_distance = (2 *...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
Clemens123/transformers
BeitSelfAttention
false
12,775
[ "Apache-2.0" ]
0
22abe7bbc587c16ec30f9d1aa549dcbeba6e9e26
https://github.com/Clemens123/transformers/tree/22abe7bbc587c16ec30f9d1aa549dcbeba6e9e26
EncoderLayer
import math import torch from torch import nn import torch.nn.functional as F import torch.utils.data.distributed def matmul(x, y): if x.dim() == y.dim(): return x @ y if x.dim() == y.dim() - 1: return (x.unsqueeze(-2) @ y).squeeze(-2) return (x @ y.unsqueeze(-2)).squeeze(-2) class FeedF...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
matatabinoneko/densecap
EncoderLayer
false
12,776
[ "BSD-3-Clause" ]
0
723d9c2cfd3f16b2eb7584cc7cb0aaef973854dd
https://github.com/matatabinoneko/densecap/tree/723d9c2cfd3f16b2eb7584cc7cb0aaef973854dd
SE
import torch from torch import nn class SE(nn.Module): def __init__(self, channels, se_ratio): super(SE, self).__init__() inter_channels = max(1, int(channels * se_ratio)) self.conv1 = nn.Conv2d(channels, inter_channels, (1, 1)) self.silu = nn.SiLU(inplace=True) self.conv2...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch import nn assert_size_stride = torch._C._dynamo.guards.assert_size_st...
mengzhu0308/EfficientNetV2-PyTorch
SE
false
12,777
[ "Apache-2.0" ]
0
b9946a4372849d9231a044dcbf697ae17008b467
https://github.com/mengzhu0308/EfficientNetV2-PyTorch/tree/b9946a4372849d9231a044dcbf697ae17008b467
Net
import torch import torch.nn as nn class Net(nn.Module): """ Fully-connected classifier for MNIST. """ def __init__(self): super(Net, self).__init__() self.fc1 = nn.Linear(28 * 28, 64) self.fc2 = nn.Linear(64, 64) self.fc3 = nn.Linear(64, 10) def forward(self, x):...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_...
mateuszjurewicz/Copilot
Net
false
12,778
[ "MIT" ]
0
ccb3eb2755c7cbb5bb035567aa7e73c1d767147a
https://github.com/mateuszjurewicz/Copilot/tree/ccb3eb2755c7cbb5bb035567aa7e73c1d767147a
TreeCRF
import torch import numpy as np import torch.nn as nn from torch.nn.parameter import Parameter def logdet(x): """ Args: x: 2D positive semidefinite matrix. Returns: log determinant of x """ None None u_chol = x.potrf() return torch.sum(torch.log(u_chol.diag())) * 2 class B...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn from torch.nn.parameter import Parameter assert_size_strid...
krishnamrith12/DCST
TreeCRF
false
12,779
[ "MIT" ]
0
7ba956d7e648aaeb25816ccfc709106db9293270
https://github.com/krishnamrith12/DCST/tree/7ba956d7e648aaeb25816ccfc709106db9293270
SpatialAttentionModule
import torch import torch.nn as nn import torch.nn.parallel import torch.onnx def conv1x1(in_planes, out_planes, bias=False): """1x1 convolution with padding""" return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=1, padding=0, bias=bias) class SpatialAttentionModule(nn.Module): def __...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
mattrent/AttnGAN
SpatialAttentionModule
false
12,780
[ "MIT" ]
0
913a34d1324508a09c18875d41c76baec47cbc6d
https://github.com/mattrent/AttnGAN/tree/913a34d1324508a09c18875d41c76baec47cbc6d
Swish
import torch import torch.nn as nn class Swish(nn.Module): def forward(self, x): return x.mul_(torch.sigmoid(x)) def get_inputs(): return [torch.rand([4, 4, 4, 4])] def get_init_inputs(): return [[], {}]
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride @triton.jit def triton_poi_fused_mul_sigmoid_0(in_pt...
minhduc0711/labelImg
Swish
false
12,781
[ "MIT" ]
0
5030721bb6a59424bfed1d7c09b56e01d08662a1
https://github.com/minhduc0711/labelImg/tree/5030721bb6a59424bfed1d7c09b56e01d08662a1
Mish
import torch import torch.nn.functional as F import torch.nn as nn class Mish(nn.Module): def forward(self, x): return x.mul_(F.softplus(x).tanh()) def get_inputs(): return [torch.rand([4, 4, 4, 4])] def get_init_inputs(): return [[], {}]
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math import torch.nn as nn assert_size_stride = torch._C._dynamo.gu...
minhduc0711/labelImg
Mish
false
12,782
[ "MIT" ]
0
5030721bb6a59424bfed1d7c09b56e01d08662a1
https://github.com/minhduc0711/labelImg/tree/5030721bb6a59424bfed1d7c09b56e01d08662a1
BertAttention
from _paritybench_helpers import _mock_config import math import torch from torch import nn class BertSelfAttention(nn.Module): def __init__(self, config): super(BertSelfAttention, self).__init__() if config.hidden_size % config.num_attention_heads != 0: raise ValueError( ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
mcao516/SSKD-TinyBERT
BertAttention
false
12,783
[ "Apache-2.0" ]
0
d862002e03df5cb54a80657e41a77f1b6f7732d9
https://github.com/mcao516/SSKD-TinyBERT/tree/d862002e03df5cb54a80657e41a77f1b6f7732d9
ScaledL2Norm
import torch import torch.onnx import torch import torch.nn as nn import torch.nn.functional as F class ScaledL2Norm(nn.Module): def __init__(self, in_channels, initial_scale): super(ScaledL2Norm, self).__init__() self.in_channels = in_channels self.scale = nn.Parameter(torch.Tensor(in_ch...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import libdevice import torch.onnx import tor...
mirecta/pytorch-ssd
ScaledL2Norm
false
12,784
[ "MIT" ]
0
360f31bfff12f2954c9166dc78df038334a01c53
https://github.com/mirecta/pytorch-ssd/tree/360f31bfff12f2954c9166dc78df038334a01c53
NRelu
import torch import torch.utils.data import torch.nn as nn import torch.optim import torch.backends.cudnn import torch.nn.functional as F class NRelu(nn.Module): """ -max(-x,0) Parameters ---------- Input shape: (N, C, W, H) Output shape: (N, C * W * H) """ def __init__(self, inplace)...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.utils.data import torch.nn as nn import torch.optim import torch.backends.cu...
minhtannguyen/pytorch_shake_shake
NRelu
false
12,785
[ "MIT" ]
0
d7f245d8d8b9e81a6020aadb438ffeae6d5593c2
https://github.com/minhtannguyen/pytorch_shake_shake/tree/d7f245d8d8b9e81a6020aadb438ffeae6d5593c2
BiDAFSelfAttention
import torch import torch.nn as nn import torch.nn.functional as F def masked_softmax(logits, mask, dim=-1, log_softmax=False): """Take the softmax of `logits` over given dimension, and set entries to 0 wherever `mask` is 0. Args: logits (torch.Tensor): Inputs to the softmax function. mas...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
melaniezhang/cs224n-final-proj
BiDAFSelfAttention
false
12,786
[ "MIT" ]
0
a012759e8caf4d585421d78c07125fa3696fda4e
https://github.com/melaniezhang/cs224n-final-proj/tree/a012759e8caf4d585421d78c07125fa3696fda4e
MultiHead
import math import torch from torch import nn import torch.nn.functional as F import torch.utils.data.distributed def matmul(x, y): if x.dim() == y.dim(): return x @ y if x.dim() == y.dim() - 1: return (x.unsqueeze(-2) @ y).squeeze(-2) return (x @ y.unsqueeze(-2)).squeeze(-2) class Atten...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
matatabinoneko/densecap
MultiHead
false
12,787
[ "BSD-3-Clause" ]
0
723d9c2cfd3f16b2eb7584cc7cb0aaef973854dd
https://github.com/matatabinoneko/densecap/tree/723d9c2cfd3f16b2eb7584cc7cb0aaef973854dd
Learned_Aggregation_Layer
import torch import torch.nn as nn import torch.utils.checkpoint class Learned_Aggregation_Layer(nn.Module): def __init__(self, dim, num_heads=1, qkv_bias=False, qk_scale=None, attn_drop=0.0, proj_drop=0.0): super().__init__() self.num_heads = num_heads head_dim = dim // num_heads...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
mengxinpku/deit
Learned_Aggregation_Layer
false
12,788
[ "Apache-2.0" ]
0
5b61a1ec0a4e73579f41ebdc3d34f319e5d19d14
https://github.com/mengxinpku/deit/tree/5b61a1ec0a4e73579f41ebdc3d34f319e5d19d14
MCRMSE
import torch from torch import nn class MCRMSE(nn.Module): def __init__(self, num_scored=3, eps=1e-08): super().__init__() self.mse = nn.MSELoss() self.num_scored = num_scored self.eps = eps def forward(self, outputs, targets): score = 0 for idx in range(self....
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice from torch import nn assert_size_stride = torch._C._dynamo.guards.assert_size_s...
mohsinkhn/standford-covid-vaccine-kaggle
MCRMSE
false
12,789
[ "MIT" ]
0
fc1e160a6ee67d1ca21dfec3da4dc4863e6bbdba
https://github.com/mohsinkhn/standford-covid-vaccine-kaggle/tree/fc1e160a6ee67d1ca21dfec3da4dc4863e6bbdba
BiAAttention
import torch import torch.nn as nn from torch.nn.parameter import Parameter class BiAAttention(nn.Module): """ Bi-Affine attention layer. """ def __init__(self, input_size_encoder, input_size_decoder, num_labels, biaffine=True, **kwargs): """ Args: input_size_enco...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn from torch.nn.parameter import Parameter assert_size_strid...
krishnamrith12/DCST
BiAAttention
false
12,790
[ "MIT" ]
0
7ba956d7e648aaeb25816ccfc709106db9293270
https://github.com/krishnamrith12/DCST/tree/7ba956d7e648aaeb25816ccfc709106db9293270
FCMinibatchStd
import math import torch from torch import nn from torch.nn import functional as F def fused_leaky_relu(input, bias, negative_slope=0.2, scale=2 ** 0.5): rest_dim = [1] * (input.ndim - bias.ndim - 1) if input.ndim == 3: return F.leaky_relu(input + bias.view(1, *rest_dim, bias.shape[0]), ne...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import math from to...
mkleshchenok/dlcourse_2021_p1_final_project
FCMinibatchStd
false
12,791
[ "MIT" ]
0
1dd4f2e3dccc4604aa98982bf9377273ab4783c1
https://github.com/mkleshchenok/dlcourse_2021_p1_final_project/tree/1dd4f2e3dccc4604aa98982bf9377273ab4783c1
BertPooler
from _paritybench_helpers import _mock_config import torch from torch import nn class BertPooler(nn.Module): def __init__(self, config, recurs=None): super(BertPooler, self).__init__() self.dense = nn.Linear(config.hidden_size, config.hidden_size) self.activation = nn.Tanh() self....
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice from torch import n...
mcao516/SSKD-TinyBERT
BertPooler
false
12,792
[ "Apache-2.0" ]
0
d862002e03df5cb54a80657e41a77f1b6f7732d9
https://github.com/mcao516/SSKD-TinyBERT/tree/d862002e03df5cb54a80657e41a77f1b6f7732d9
Actor
import torch import numpy as np import torch.nn.functional as F import torch.nn as nn def hidden_init(layer): fan_in = layer.weight.data.size()[0] lim = 1.0 / np.sqrt(fan_in) return -lim, lim class Actor(nn.Module): """Actor (Policy) Model.""" def __init__(self, state_size, action_size, hidden_...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import numpy as np ...
monimoyd/project_deep_reinforcement_learning_collaboration_competition
Actor
false
12,793
[ "MIT" ]
0
3782abb839b671ea53ece1435a4d481d7871cd39
https://github.com/monimoyd/project_deep_reinforcement_learning_collaboration_competition/tree/3782abb839b671ea53ece1435a4d481d7871cd39
Transition
import torch import torch.nn as nn class Transition(nn.Module): def __init__(self, z_dim, hidden_dim): super(Transition, self).__init__() self.z_to_hidden = nn.Linear(z_dim, hidden_dim) self.hidden_to_hidden = nn.Linear(hidden_dim, hidden_dim) self.hidden_to_loc = nn.Linear(hidden...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
morimo27182/DeepKalmanFilter
Transition
false
12,794
[ "MIT" ]
0
5d78d2e700fdc24f2a5cfa2877ecdcfc8218c8b7
https://github.com/morimo27182/DeepKalmanFilter/tree/5d78d2e700fdc24f2a5cfa2877ecdcfc8218c8b7
BinaryNLLEntropy
import torch import torch.nn.functional as F import torch.utils.data import torch.nn.init from torch.nn.modules.loss import _Loss class BinaryNLLEntropy(_Loss): def __init__(self, size_average=True): super(BinaryNLLEntropy, self).__init__() self.size_average = size_average def forward(self, ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math import torc...
msft-shahins/ConvLab-2
BinaryNLLEntropy
false
12,795
[ "Apache-2.0" ]
0
ad74c0e9e021916f9330af11e046ed72914b7740
https://github.com/msft-shahins/ConvLab-2/tree/ad74c0e9e021916f9330af11e046ed72914b7740
Critic
import torch import numpy as np import torch.nn.functional as F import torch.nn as nn def hidden_init(layer): fan_in = layer.weight.data.size()[0] lim = 1.0 / np.sqrt(fan_in) return -lim, lim class Critic(nn.Module): """Critic (Value) Model.""" def __init__(self, full_state_size, full_action_si...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import numpy as np ...
monimoyd/project_deep_reinforcement_learning_collaboration_competition
Critic
false
12,796
[ "MIT" ]
0
3782abb839b671ea53ece1435a4d481d7871cd39
https://github.com/monimoyd/project_deep_reinforcement_learning_collaboration_competition/tree/3782abb839b671ea53ece1435a4d481d7871cd39
InResBlock
import math import torch from torch import nn from torch.nn import functional as F def make_kernel(k): k = torch.tensor(k, dtype=torch.float32) if k.ndim == 1: k = k[None, :] * k[:, None] k /= k.sum() return k def upfirdn2d_native(input, kernel, up_x, up_y, down_x, down_y, pad_x0, pad_x1...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import math from to...
mkleshchenok/dlcourse_2021_p1_final_project
InResBlock
false
12,797
[ "MIT" ]
0
1dd4f2e3dccc4604aa98982bf9377273ab4783c1
https://github.com/mkleshchenok/dlcourse_2021_p1_final_project/tree/1dd4f2e3dccc4604aa98982bf9377273ab4783c1
Generator
import torch import torch.nn as nn class Generator(nn.Module): def __init__(self, input_length: 'int'): super(Generator, self).__init__() self.dense_layer = nn.Linear(int(input_length), int(input_length)) self.activation = nn.Sigmoid() def forward(self, x): return self.activa...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_s...
msank00/ganTutorial
Generator
false
12,798
[ "MIT" ]
0
7657ff8cbb0cd66c98b5fd91bf19677e467aac68
https://github.com/msank00/ganTutorial/tree/7657ff8cbb0cd66c98b5fd91bf19677e467aac68
Posterior
import torch import torch.nn as nn class Posterior(nn.Module): def __init__(self, z_dim, hidden_dim, obs_dim): super(Posterior, self).__init__() self.z_obs_to_hidden = nn.Linear(2 * z_dim + obs_dim, hidden_dim) self.hidden_to_hidden = nn.Linear(hidden_dim, hidden_dim) self.hidden_...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
morimo27182/DeepKalmanFilter
Posterior
false
12,799
[ "MIT" ]
0
5d78d2e700fdc24f2a5cfa2877ecdcfc8218c8b7
https://github.com/morimo27182/DeepKalmanFilter/tree/5d78d2e700fdc24f2a5cfa2877ecdcfc8218c8b7
MultiHeadAttentionLayer
import math import torch import torch.nn.functional as F import torch.nn as nn class Layer(nn.Module): def __init__(self, name): super(Layer, self).__init__() self.name = name class MultiHeadAttentionLayer(Layer): def __init__(self, n_heads, d_src, d_tgt, dropout, name='None'): sup...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
mmwebster/DeepRL-Grounding
MultiHeadAttentionLayer
false
12,800
[ "MIT" ]
0
aa7fa63fbc26e8b0fa3fe289a5fe5a00ef3e6278
https://github.com/mmwebster/DeepRL-Grounding/tree/aa7fa63fbc26e8b0fa3fe289a5fe5a00ef3e6278
BilinearWithBias
from torch.nn import Module import math import torch from torch.nn.parameter import Parameter import torch.nn.functional as F from torch.nn.modules import Module class BilinearWithBias(Module): def __init__(self, in1_features, in2_features, out_features): super(BilinearWithBias, self).__init__() ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch.nn import Module import math from torch.nn.parameter import Parameter...
masashi-y/myccg
BilinearWithBias
false
12,801
[ "MIT" ]
0
263fd0afa7a619626fc2d506016625b6068bb27b
https://github.com/masashi-y/myccg/tree/263fd0afa7a619626fc2d506016625b6068bb27b
Norm
import torch import torch.nn as nn class Norm(nn.Module): def __init__(self, d_model, eps=1e-06): super().__init__() self.size = d_model self.alpha = nn.Parameter(torch.ones(self.size)) self.bias = nn.Parameter(torch.zeros(self.size)) self.eps = eps def forward(self, ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_...
msank00/miniTransformer
Norm
false
12,802
[ "MIT" ]
0
a264f30982d9e2dbf8c796d495f7a237c0dd53ef
https://github.com/msank00/miniTransformer/tree/a264f30982d9e2dbf8c796d495f7a237c0dd53ef
MaxPool
import torch import torch.nn as nn class MaxPool(nn.Module): def __init__(self, kernel_size, stride=1, padding=1, zero_pad=False): super(MaxPool, self).__init__() self.is_zero_padded = zero_pad self.zero_pad = nn.ZeroPad2d((1, 0, 1, 0)) self.pool = nn.MaxPool2d(kernel_size, stride...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride emp...
mruberry/pnas_torch
MaxPool
false
12,803
[ "BSD-3-Clause" ]
0
e6471f900f28698fe0ebca158fec059337acee2c
https://github.com/mruberry/pnas_torch/tree/e6471f900f28698fe0ebca158fec059337acee2c
SelfAttn
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.data import torch.nn.init import torch as th class SelfAttn(nn.Module): def __init__(self, hidden_size): super(SelfAttn, self).__init__() self.query = nn.Linear(hidden_size, 1) def forward(self, keys, value...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
msft-shahins/ConvLab-2
SelfAttn
false
12,804
[ "Apache-2.0" ]
0
ad74c0e9e021916f9330af11e046ed72914b7740
https://github.com/msft-shahins/ConvLab-2/tree/ad74c0e9e021916f9330af11e046ed72914b7740
NormKLLoss
import torch import torch.utils.data import torch.nn.init import torch as th from torch.nn.modules.loss import _Loss class NormKLLoss(_Loss): def __init__(self, unit_average=False): super(NormKLLoss, self).__init__() self.unit_average = unit_average def forward(self, recog_mu, recog_logvar, ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import math as tl_math import torch.utils.data import torch.nn.init from torch.nn.modules.loss i...
msft-shahins/ConvLab-2
NormKLLoss
false
12,805
[ "Apache-2.0" ]
0
ad74c0e9e021916f9330af11e046ed72914b7740
https://github.com/msft-shahins/ConvLab-2/tree/ad74c0e9e021916f9330af11e046ed72914b7740
CharbonnierLoss
import torch import torch.nn as nn class CharbonnierLoss(nn.Module): """Charbonnier Loss (L1)""" def __init__(self, eps=1e-06, mode=None): super(CharbonnierLoss, self).__init__() self.eps = eps self.mode = mode def forward(self, x, y, mask=None): N = x.size(1) dif...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as nn assert...
myeldib/Simple-SR
CharbonnierLoss
false
12,806
[ "MIT" ]
0
583456b1f231574d9e0b45c29266cf41603d161d
https://github.com/myeldib/Simple-SR/tree/583456b1f231574d9e0b45c29266cf41603d161d
AddNorm
import torch import torch.nn as nn class Norm(nn.Module): def __init__(self, d_model, eps=1e-06): super().__init__() self.size = d_model self.alpha = nn.Parameter(torch.ones(self.size)) self.bias = nn.Parameter(torch.zeros(self.size)) self.eps = eps def forward(self, ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_...
msank00/miniTransformer
AddNorm
false
12,807
[ "MIT" ]
0
a264f30982d9e2dbf8c796d495f7a237c0dd53ef
https://github.com/msank00/miniTransformer/tree/a264f30982d9e2dbf8c796d495f7a237c0dd53ef
TVLoss
import torch import torch.nn as nn class TVLoss(nn.Module): def __init__(self, weight=1.0): super(TVLoss, self).__init__() self.weight = weight self.l1 = nn.L1Loss(reduction='mean') def forward(self, out, gt): grad_out_x = out[:, :, :, 1:] - out[:, :, :, :-1] grad_out...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import math as tl_math import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert...
myeldib/Simple-SR
TVLoss
false
12,808
[ "MIT" ]
0
583456b1f231574d9e0b45c29266cf41603d161d
https://github.com/myeldib/Simple-SR/tree/583456b1f231574d9e0b45c29266cf41603d161d
TorchFCNModel
import torch class TorchFCNModel(torch.nn.Module): def __init__(self, inputD, outputD, hiddenC=2, hiddenD=36): super(TorchFCNModel, self).__init__() self.device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu') self.inputD, self.outputD = inputD, outputD ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers assert_size_stride = torch._C...
muratcancicek/pointer_head
TorchFCNModel
false
12,809
[ "MIT" ]
0
b2a357f0183d5ced82b6dc7f6f12e0391bdc7380
https://github.com/muratcancicek/pointer_head/tree/b2a357f0183d5ced82b6dc7f6f12e0391bdc7380
Hidden2Discrete
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.data import torch.nn.init class Hidden2Discrete(nn.Module): def __init__(self, input_size, y_size, k_size, is_lstm=False, has_bias=True ): super(Hidden2Discrete, self).__init__() self.y_size = y_size ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
msft-shahins/ConvLab-2
Hidden2Discrete
false
12,810
[ "Apache-2.0" ]
0
ad74c0e9e021916f9330af11e046ed72914b7740
https://github.com/msft-shahins/ConvLab-2/tree/ad74c0e9e021916f9330af11e046ed72914b7740
StyledResBlock
import math import torch from torch import nn from torch.nn import functional as F def make_kernel(k): k = torch.tensor(k, dtype=torch.float32) if k.ndim == 1: k = k[None, :] * k[:, None] k /= k.sum() return k def upfirdn2d_native(input, kernel, up_x, up_y, down_x, down_y, pad_x0, pad_x1...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import math from to...
mkleshchenok/dlcourse_2021_p1_final_project
StyledResBlock
false
12,811
[ "MIT" ]
0
1dd4f2e3dccc4604aa98982bf9377273ab4783c1
https://github.com/mkleshchenok/dlcourse_2021_p1_final_project/tree/1dd4f2e3dccc4604aa98982bf9377273ab4783c1
DynamicConv2d
import torch import torch.nn as nn import torch.nn.functional as F import torch.nn class DynamicConv2d(nn.Conv2d): def __init__(self, in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True, sr_in_list=(1.0,), sr_out_list=None): self.sr_idx, self.sr_in...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn import torch.nn assert_size_stride = torch._C._dynamo.guar...
naili-xing/singa-easy
DynamicConv2d
false
12,812
[ "Apache-2.0" ]
0
ed94cd8b6b77dc1e86c670000eae06d06f81926b
https://github.com/naili-xing/singa-easy/tree/ed94cd8b6b77dc1e86c670000eae06d06f81926b
MultiAccuracy
import torch class MultiAccuracy(torch.nn.Module): """Calculates accuracy for multiclass inputs (batchsize, feature length) by determining the most likely class using argmax -> (batchsize,) and then comparing with targets which are also (batchsize,) """ def __init__(self): super(MultiAccuracy...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda @triton.j...
namiyousef/ml-utils
MultiAccuracy
false
12,813
[ "MIT" ]
0
b67611e9e112f8bbc004a083ce4c9fcd8c1949fa
https://github.com/namiyousef/ml-utils/tree/b67611e9e112f8bbc004a083ce4c9fcd8c1949fa
Attention
import torch import torch.nn as nn class Attention(nn.Module): def __init__(self, src_size, trg_size): super().__init__() self.W = nn.Bilinear(src_size, trg_size, 1) self.softmax = nn.Softmax(dim=-1) def forward(self, src, trg, attention_mask=None): """ src: [src_size...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import math as tl_math import torch....
myunghakLee/GainParallel
Attention
false
12,814
[ "MIT" ]
0
63112bd996591ad898cbb88fdb839992227a5b74
https://github.com/myunghakLee/GainParallel/tree/63112bd996591ad898cbb88fdb839992227a5b74
MlpLite
import torch from torch import nn class MlpLite(nn.Module): def __init__(self, H, W, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0.0): super().__init__() out_features = out_features or in_features hidden_features = hidden_features or in_features ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice from torch import n...
likelyzhao/dino
MlpLite
false
12,815
[ "Apache-2.0" ]
0
ad019889b0e4c103f0471d085f79bba42c817d1b
https://github.com/likelyzhao/dino/tree/ad019889b0e4c103f0471d085f79bba42c817d1b
BinaryFocalLoss
import torch import torch.nn as nn import torch.nn.functional as F class BinaryFocalLoss(nn.Module): """ This is a implementation of Focal Loss with smooth label cross entropy supported which is proposed in 'Focal Loss for Dense Object Detection. (https://arxiv.org/abs/1708.02002)' Focal_Loss= -1*...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math import torc...
naivepig1998/brain_met_3d_cnn
BinaryFocalLoss
false
12,816
[ "MIT" ]
0
6abd783a6e0185c72d64a89713fdaa3bee68a65f
https://github.com/naivepig1998/brain_met_3d_cnn/tree/6abd783a6e0185c72d64a89713fdaa3bee68a65f
SimpleModel
import torch import torch.cuda class SimpleModel(torch.nn.Module): def __init__(self, hidden_dim, empty_grad=False): super(SimpleModel, self).__init__() self.linear = torch.nn.Linear(hidden_dim, hidden_dim) if empty_grad: self.layers2 = torch.nn.ModuleList([torch.nn.Linear(hid...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
mbeacom/DeepSpeed
SimpleModel
false
12,817
[ "MIT" ]
0
012d91df67a9ddd66df847c7608481af027cace9
https://github.com/mbeacom/DeepSpeed/tree/012d91df67a9ddd66df847c7608481af027cace9
KeyValueAttention
import torch import torch.nn as nn from torch.autograd import Variable import torch.nn.functional as F import torch.utils.data import torch.nn.init class KeyValueAttention(nn.Module): def __init__(self, query_size, key_size, value_size, hid_size, init_range): super(KeyValueAttention, self).__init__() ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
msft-shahins/ConvLab-2
KeyValueAttention
false
12,818
[ "Apache-2.0" ]
0
ad74c0e9e021916f9330af11e046ed72914b7740
https://github.com/msft-shahins/ConvLab-2/tree/ad74c0e9e021916f9330af11e046ed72914b7740
KLLoss
import torch import torch.nn as nn class KLLoss(nn.Module): def forward(self, mu: 'torch.Tensor', sigma: 'torch.Tensor', target_mu: 'torch.Tensor', target_std: 'torch.Tensor'): std1 = target_std std2 = sigma mean1 = target_mu mean2 = mu kl = torch.log(torch.abs(std...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import math as tl_math import torch.nn as nn ...
ncduy0303/wmt21-qe-task
KLLoss
false
12,819
[ "Apache-2.0" ]
0
93082afd0c56fb8d60101457082116c79adeac50
https://github.com/ncduy0303/wmt21-qe-task/tree/93082afd0c56fb8d60101457082116c79adeac50
D_GCN
import math import torch from torch import nn import torch.nn.functional as F class D_GCN(nn.Module): """ Neural network block that applies a diffusion graph convolution to sampled location """ def __init__(self, in_channels, out_channels, orders, activation='relu'): """ :param in_cha...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import math from torch import...
mpourhoma/PWWB-London
D_GCN
false
12,820
[ "MIT" ]
0
cfe7a6e3d92ff6b1f18bb5d5bc6a86334e9509d8
https://github.com/mpourhoma/PWWB-London/tree/cfe7a6e3d92ff6b1f18bb5d5bc6a86334e9509d8
Layer4NN
import torch import torch.nn import torch.cuda class Layer4NN(torch.nn.Module): def __init__(self, inputSize, numClasses, channels=3): super(Layer4NN, self).__init__() self.cnn_layer1 = torch.nn.Conv2d(channels, 32, kernel_size=3, stride=1, padding=1) self.cnn_layer2 = torch.n...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn import torch....
naruarjun/SADAM-reproducibility
Layer4NN
false
12,821
[ "MIT" ]
0
1654804268ae984f49abc3ab2495c350dc09a3e2
https://github.com/naruarjun/SADAM-reproducibility/tree/1654804268ae984f49abc3ab2495c350dc09a3e2
TemporalFusion
import torch import torch.nn as nn class TemporalFusion(nn.Module): def __init__(self, nf, n_frame): super(TemporalFusion, self).__init__() self.n_frame = n_frame self.ref_conv = nn.Conv2d(nf, nf, 3, 1, 1, bias=True) self.nbr_conv = nn.Conv2d(nf, nf, 3, 1, 1, bias=True) se...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_s...
myeldib/Simple-SR
TemporalFusion
false
12,822
[ "MIT" ]
0
583456b1f231574d9e0b45c29266cf41603d161d
https://github.com/myeldib/Simple-SR/tree/583456b1f231574d9e0b45c29266cf41603d161d
SplitAndConcat
import torch import torch.nn as nn import torch.utils.data class SplitAndConcat(nn.Module): """Split the data from split_dim and concatenate in concat_dim. @param split_dim from which axis the data will be chunk @param concat_dim to which axis the data will be concatenated @param chunk size of the da...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn import torch.utils.data assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C....
newstzpz/d2go
SplitAndConcat
false
12,823
[ "Apache-2.0" ]
0
fcd511714ec4e34040d35379cb0382b70fb58c70
https://github.com/newstzpz/d2go/tree/fcd511714ec4e34040d35379cb0382b70fb58c70
VarianceLoss
import torch import torch.nn as nn class VarianceLoss(nn.Module): def forward(self, mu: 'torch.Tensor', std: 'torch.Tensor', target: 'torch.Tensor'): sigma = std ** 2 log1 = 0.5 * torch.neg(torch.log(sigma)).exp() mse = (target - mu) ** 2 log2 = 0.5 * torch.log(sigma) ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import math as tl_math import torch.nn as nn ...
ncduy0303/wmt21-qe-task
VarianceLoss
false
12,824
[ "Apache-2.0" ]
0
93082afd0c56fb8d60101457082116c79adeac50
https://github.com/ncduy0303/wmt21-qe-task/tree/93082afd0c56fb8d60101457082116c79adeac50
T5LayerNorm
import torch import torch.nn as nn import torch.utils.checkpoint class T5LayerNorm(nn.Module): def __init__(self, hidden_size, eps=1e-06): """ Construct a layernorm module in the T5 style No bias and no subtraction of mean. """ super().__init__() self.weight = nn.Parameter...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as nn import torch.utils.checkpoint assert_size_stride = torch....
longquan0609/bert_seq2seq
T5LayerNorm
false
12,825
[ "Apache-2.0" ]
0
3aaeb2ea76cd435d53ebcfedd2a080d0c37c1976
https://github.com/longquan0609/bert_seq2seq/tree/3aaeb2ea76cd435d53ebcfedd2a080d0c37c1976
EncoderLayer
import math import torch import torch.nn as nn import torch.nn.functional as F def attention(q, k, v, d_k, mask=None, dropout=None): scores = torch.matmul(q, k.transpose(-2, -1)) / math.sqrt(d_k) if mask is not None: mask = mask.unsqueeze(1) scores = scores.masked_fill(mask == 0, -1000000000.0...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
msank00/miniTransformer
EncoderLayer
false
12,826
[ "MIT" ]
0
a264f30982d9e2dbf8c796d495f7a237c0dd53ef
https://github.com/msank00/miniTransformer/tree/a264f30982d9e2dbf8c796d495f7a237c0dd53ef
KeypointRCNNPredictorNoUpscale
import torch import torch.nn as nn import torch.utils.data class KeypointRCNNPredictorNoUpscale(nn.Module): def __init__(self, in_channels, num_keypoints): super(KeypointRCNNPredictorNoUpscale, self).__init__() input_features = in_channels deconv_kernel = 4 self.kps_score_lowres =...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn import torch.utils.data assert_size_stride = torch._C._dyn...
newstzpz/d2go
KeypointRCNNPredictorNoUpscale
false
12,827
[ "Apache-2.0" ]
0
fcd511714ec4e34040d35379cb0382b70fb58c70
https://github.com/newstzpz/d2go/tree/fcd511714ec4e34040d35379cb0382b70fb58c70
ResidualBlock_noBN
import torch import torch.nn as nn import torch.nn.functional as F import torch.nn.init as init def initialize_weights(net_l, scale=1): if not isinstance(net_l, list): net_l = [net_l] for net in net_l: for m in net.modules(): if isinstance(m, nn.Conv2d): init.kaimin...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn import ...
myeldib/Simple-SR
ResidualBlock_noBN
false
12,828
[ "MIT" ]
0
583456b1f231574d9e0b45c29266cf41603d161d
https://github.com/myeldib/Simple-SR/tree/583456b1f231574d9e0b45c29266cf41603d161d
DiagLinear
import math import torch from torch import Tensor from torch import nn class DiagLinear(nn.Module): """Applies a diagonal linear transformation to the incoming data: :math:`y = xD^T + b`""" __constants__ = ['features'] def __init__(self, features, bias=True): super(DiagLinear, self).__init__() ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import math from torch import Tensor from torch import nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda...
nihaarshah/behavenet
DiagLinear
false
12,829
[ "MIT" ]
0
35bf5360e136075ca5ec30b3f98a2112a53e992c
https://github.com/nihaarshah/behavenet/tree/35bf5360e136075ca5ec30b3f98a2112a53e992c
conv_head_pooling
import torch import torch.nn as nn import torch.utils.data class conv_head_pooling(nn.Module): def __init__(self, in_feature, out_feature, stride, conv_type, padding_mode='zeros', dilation=1): super(conv_head_pooling, self).__init__() if conv_type == 'depthwise': _groups = in_...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn import torch.utils.data assert_size_stride = torch._C._dyn...
newstzpz/d2go
conv_head_pooling
false
12,830
[ "Apache-2.0" ]
0
fcd511714ec4e34040d35379cb0382b70fb58c70
https://github.com/newstzpz/d2go/tree/fcd511714ec4e34040d35379cb0382b70fb58c70
DecoderLayer
import math import torch import torch.nn as nn import torch.nn.functional as F def attention(q, k, v, d_k, mask=None, dropout=None): scores = torch.matmul(q, k.transpose(-2, -1)) / math.sqrt(d_k) if mask is not None: mask = mask.unsqueeze(1) scores = scores.masked_fill(mask == 0, -1000000000.0...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
msank00/miniTransformer
DecoderLayer
false
12,831
[ "MIT" ]
0
a264f30982d9e2dbf8c796d495f7a237c0dd53ef
https://github.com/msank00/miniTransformer/tree/a264f30982d9e2dbf8c796d495f7a237c0dd53ef
SelfGating
import torch from torch import nn import torch as th import torch.hub import torch.utils.data class SelfGating(nn.Module): def __init__(self, input_dim): super(SelfGating, self).__init__() self.fc = nn.Linear(input_dim, input_dim) def forward(self, input_tensor): """Feature gating as...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch import nn import torch.hub import torch.utils.data assert_size_stride...
nicholasneo78/wav2vec-demo
SelfGating
false
12,832
[ "MIT" ]
0
c37db7b8211458dc810a85d4262ef41e3e3e4f12
https://github.com/nicholasneo78/wav2vec-demo/tree/c37db7b8211458dc810a85d4262ef41e3e3e4f12
SpatialGatingUnit
import torch import torch.nn as nn class SpatialGatingUnit(nn.Module): def __init__(self, dim_seq, dim_ff): super().__init__() self.proj = nn.Linear(dim_seq, dim_seq) nn.init.zeros_(self.proj.weight) nn.init.ones_(self.proj.bias) self.norm = nn.LayerNorm(normalized_shape=d...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as ...
nima1999nikkhah/gMLP
SpatialGatingUnit
false
12,833
[ "MIT" ]
0
6e04a173bdb137680695fe55753d8b2284f03fa4
https://github.com/nima1999nikkhah/gMLP/tree/6e04a173bdb137680695fe55753d8b2284f03fa4
SelfAttentionFuseLayer
import torch from torch import nn class SelfAttentionFuseLayer(nn.Module): def __init__(self, dim): super(SelfAttentionFuseLayer, self).__init__() self.W_7 = nn.Linear(dim, dim) self.w_8 = nn.Linear(dim, 1) self.activation = nn.Tanh() def forward(self, hidden_states): ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
nju-websoft/Jeeves
SelfAttentionFuseLayer
false
12,834
[ "Apache-2.0" ]
0
6c817ed9e9c36a27c1c10a0a3c863ca0e5fdb5c1
https://github.com/nju-websoft/Jeeves/tree/6c817ed9e9c36a27c1c10a0a3c863ca0e5fdb5c1
gMLPBlock
import torch import torch.nn as nn class SpatialGatingUnit(nn.Module): def __init__(self, dim_seq, dim_ff): super().__init__() self.proj = nn.Linear(dim_seq, dim_seq) nn.init.zeros_(self.proj.weight) nn.init.ones_(self.proj.bias) self.norm = nn.LayerNorm(normalized_shape=d...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as ...
nima1999nikkhah/gMLP
gMLPBlock
false
12,835
[ "MIT" ]
0
6e04a173bdb137680695fe55753d8b2284f03fa4
https://github.com/nima1999nikkhah/gMLP/tree/6e04a173bdb137680695fe55753d8b2284f03fa4
Attention
import torch import torch.nn as nn import torch.nn.functional as F class Attention(nn.Module): def __init__(self, nf=64): super(Attention, self).__init__() self.sAtt_1 = nn.Conv2d(nf, nf, 1, 1, bias=True) self.max_pool = nn.MaxPool2d(3, stride=2, padding=1) self.avg_pool = nn.AvgP...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_...
myeldib/Simple-SR
Attention
false
12,836
[ "MIT" ]
0
583456b1f231574d9e0b45c29266cf41603d161d
https://github.com/myeldib/Simple-SR/tree/583456b1f231574d9e0b45c29266cf41603d161d
ExpanderConv2d
import torch import torch.nn as nn class ExpanderConv2d(nn.Module): def __init__(self, indim, outdim, kernel_size, expandSize, stride=1, padding=0, inDil=1, groups=1, mode='random'): super(ExpanderConv2d, self).__init__() self.conStride = stride self.conPad = padding self....
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_s...
noonespecial009/resnet-variations
ExpanderConv2d
false
12,837
[ "MIT" ]
0
11ee33d1855c292b15930a2a2c1d757d1ac85699
https://github.com/noonespecial009/resnet-variations/tree/11ee33d1855c292b15930a2a2c1d757d1ac85699
DPDALayear
import torch from torch import nn class DPDALayear(nn.Module): def __init__(self, dim): super(DPDALayear, self).__init__() self.W_p = nn.Linear(2 * dim, dim) self.W_q = nn.Linear(2 * dim, dim) def forward(self, P, Q, p_mask=None, q_mask=None): P_ori = P Q_ori = Q ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
nju-websoft/Jeeves
DPDALayear
false
12,838
[ "Apache-2.0" ]
0
6c817ed9e9c36a27c1c10a0a3c863ca0e5fdb5c1
https://github.com/nju-websoft/Jeeves/tree/6c817ed9e9c36a27c1c10a0a3c863ca0e5fdb5c1
C3D
import torch import torch.nn as nn class C3D(nn.Module): """ The C3D network. """ def __init__(self, num_classes, pretrained=False): super(C3D, self).__init__() self.conv1 = nn.Conv3d(3, 64, kernel_size=(3, 3, 3), padding=(1, 1, 1)) self.pool1 = nn.MaxPool3d(kernel_size=(1, 2,...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_...
gramuah/gui4lola
C3D
false
12,839
[ "MIT" ]
0
6924d681db3b14f9b10a53b115640a749a33e774
https://github.com/gramuah/gui4lola/tree/6924d681db3b14f9b10a53b115640a749a33e774
WavePool
import torch import numpy as np import torch.nn as nn def get_wav(in_channels, pool=True): """wavelet decomposition using conv2d""" harr_wav_L = 1 / np.sqrt(2) * np.ones((1, 2)) harr_wav_H = 1 / np.sqrt(2) * np.ones((1, 2)) harr_wav_H[0, 0] = -1 * harr_wav_H[0, 0] harr_wav_LL = np.transpose(harr_w...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import numpy as np import torch.nn as nn assert_size_stride = torch._C._dynamo.g...
noapadan/WCT2
WavePool
false
12,840
[ "MIT" ]
0
56c819bebb9f023e9eb8603f1f56a37650231730
https://github.com/noapadan/WCT2/tree/56c819bebb9f023e9eb8603f1f56a37650231730
Network
import torch import torch.nn as nn import torch.nn.functional as F class Network(nn.Module): def __init__(self): super(Network, self).__init__() self.fc1 = nn.Linear(4, 256) self.fc2 = nn.Linear(256, 2) def forward(self, x): x = F.relu(self.fc1(x)) x = self.fc2(x) ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_...
noureldinalaa/monocular_visual_odometry-_DuckieTown
Network
false
12,841
[ "MIT" ]
0
6b65e4fb9918dbf435133a9dd608c58cfb12b44b
https://github.com/noureldinalaa/monocular_visual_odometry-_DuckieTown/tree/6b65e4fb9918dbf435133a9dd608c58cfb12b44b
SoftmaxAttention
import torch import torch.nn as nn def masked_softmax(tensor, mask): """ Apply a masked softmax on the last dimension of a tensor. The input tensor and mask should be of size (batch, *, sequence_length). Args: tensor: The tensor on which the softmax function must be applied along ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
nlpcl-lab/msent-cred-predictor
SoftmaxAttention
false
12,842
[ "Apache-2.0" ]
0
1ac75953583e427dd37717a522a1aaa5b2d1a6a9
https://github.com/nlpcl-lab/msent-cred-predictor/tree/1ac75953583e427dd37717a522a1aaa5b2d1a6a9
MLP
import torch import torch.nn as nn from collections import OrderedDict class MLP(nn.Module): def __init__(self, input_dims, n_hiddens, n_class): super(MLP, self).__init__() assert isinstance(input_dims, int), 'Please provide int for input_dims' self.input_dims = input_dims current...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn from co...
luk1684tw/Precision-Reduction
MLP
false
12,843
[ "MIT" ]
0
c782e9a121ed176b12eb9a081aa1960fabd40019
https://github.com/luk1684tw/Precision-Reduction/tree/c782e9a121ed176b12eb9a081aa1960fabd40019
CRFLayer
import torch import torch.nn.functional as F import torch.nn as nn import torch.utils.checkpoint class CRFLayer(nn.Module): """ """ def __init__(self, output_dim): super(CRFLayer, self).__init__() self.output_dim = output_dim self.trans = nn.Parameter(torch.Tensor(output_dim, outp...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
longquan0609/bert_seq2seq
CRFLayer
false
12,845
[ "Apache-2.0" ]
0
3aaeb2ea76cd435d53ebcfedd2a080d0c37c1976
https://github.com/longquan0609/bert_seq2seq/tree/3aaeb2ea76cd435d53ebcfedd2a080d0c37c1976
SeparableConv1D
from _paritybench_helpers import _mock_config import torch from torch import nn import torch.utils.checkpoint class SeparableConv1D(nn.Module): """This class implements separable convolution, i.e. a depthwise and a pointwise layer""" def __init__(self, config, input_filters, output_filters, kernel_size, ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch import nn import torch.utils.checkpoint assert_size_stride = torch._C...
Clemens123/transformers
SeparableConv1D
false
12,847
[ "Apache-2.0" ]
0
22abe7bbc587c16ec30f9d1aa549dcbeba6e9e26
https://github.com/Clemens123/transformers/tree/22abe7bbc587c16ec30f9d1aa549dcbeba6e9e26
RMSNorm
import torch import torch.nn as nn class RMSNorm(nn.Module): def __init__(self, d): super().__init__() self.dd = d ** (-1.0 / 2) self.weight = nn.Parameter(torch.ones(d)) def forward(self, x): norm_x = x.norm(2, dim=-1, keepdim=True) x_normed = x / (norm_x * self.dd +...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_...
ofooo/AI-Writer
RMSNorm
false
12,849
[ "BSD-3-Clause" ]
0
1ba84894c15c9e5605d3c6cd7521d5c6dab6eb6d
https://github.com/ofooo/AI-Writer/tree/1ba84894c15c9e5605d3c6cd7521d5c6dab6eb6d
BertAttention
from _paritybench_helpers import _mock_config import math import torch from torch import nn class BertLayerNorm(nn.Module): def __init__(self, hidden_size, eps=1e-12): """Construct a layernorm module in the TF style (epsilon inside the square root). """ super(BertLayerNorm, self).__init__...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
noble6emc2/MoCo-SSPT
BertAttention
false
12,850
[ "MIT" ]
0
e6d7cf3f0a3b5a467318dfc32096e4929adbe646
https://github.com/noble6emc2/MoCo-SSPT/tree/e6d7cf3f0a3b5a467318dfc32096e4929adbe646
FocalLoss
import torch import torch.nn as nn class FocalLoss(nn.Module): """ Softmax and sigmoid focal loss https://github.com/lonePatient/TorchBlocks/blob/master/torchblocks/losses/focal_loss.py """ def __init__(self, num_labels, gamma=2.0, alpha=0.25, epsilon=1e-09, reduction='mean', activation_t...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math import torc...
okcd00/CDPrototype
FocalLoss
false
12,851
[ "MIT" ]
0
5a05b144e3e4b341c1a67fe455f94c01899539d8
https://github.com/okcd00/CDPrototype/tree/5a05b144e3e4b341c1a67fe455f94c01899539d8
BertSelfAttention
from _paritybench_helpers import _mock_config import math import torch from torch import nn class BertSelfAttention(nn.Module): def __init__(self, config): super(BertSelfAttention, self).__init__() if config.hidden_size % config.num_attention_heads != 0: raise ValueError( ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
noble6emc2/MoCo-SSPT
BertSelfAttention
false
12,852
[ "MIT" ]
0
e6d7cf3f0a3b5a467318dfc32096e4929adbe646
https://github.com/noble6emc2/MoCo-SSPT/tree/e6d7cf3f0a3b5a467318dfc32096e4929adbe646
RandomShiftsAug
import torch import torch.nn as nn import torch.nn.functional as F class RandomShiftsAug(nn.Module): def __init__(self, pad): super().__init__() self.pad = pad def forward(self, x): n, _c, h, w = x.size() assert h == w padding = tuple([self.pad] * 4) x = F.pad...
import torch from torch import device import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as nn assert_size_stride = torch._C._d...
nsortur/drqv2
RandomShiftsAug
false
12,853
[ "MIT" ]
0
2443f93feeb5cace855d16bfa31152d63a2d66aa
https://github.com/nsortur/drqv2/tree/2443f93feeb5cace855d16bfa31152d63a2d66aa
ConcatELU
import torch import torch.nn as nn import torch.nn.functional as F class ConcatELU(nn.Module): """ Activation function that applies ELU in both direction (inverted and plain). Allows non-linearity while providing strong gradients for any input (important for final convolution) """ def forward(sel...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_...
onlyrico/lightning-tutorials
ConcatELU
false
12,854
[ "Apache-2.0" ]
0
b5d5c4015422f8c70411e57734d73bb6c1472999
https://github.com/onlyrico/lightning-tutorials/tree/b5d5c4015422f8c70411e57734d73bb6c1472999
GCNLayer
import torch import torch.nn as nn class GCNLayer(nn.Module): def __init__(self, c_in, c_out): super().__init__() self.projection = nn.Linear(c_in, c_out) def forward(self, node_feats, adj_matrix): """ Inputs: node_feats - Tensor with node features of shape [batch...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_s...
onlyrico/lightning-tutorials
GCNLayer
false
12,855
[ "Apache-2.0" ]
0
b5d5c4015422f8c70411e57734d73bb6c1472999
https://github.com/onlyrico/lightning-tutorials/tree/b5d5c4015422f8c70411e57734d73bb6c1472999
LayerNormChannels
import torch import torch.nn as nn class LayerNormChannels(nn.Module): def __init__(self, c_in): """ This module applies layer norm across channels in an image. Has been shown to work well with ResNet connections. Inputs: c_in - Number of channels of the input """ ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_...
onlyrico/lightning-tutorials
LayerNormChannels
false
12,856
[ "Apache-2.0" ]
0
b5d5c4015422f8c70411e57734d73bb6c1472999
https://github.com/onlyrico/lightning-tutorials/tree/b5d5c4015422f8c70411e57734d73bb6c1472999
Decoder
import torch import torch.nn.functional as F from torch import nn class Decoder(torch.nn.Module): def __init__(self, Z_dim, h_dim, X_dim): super(Decoder, self).__init__() self.hidden1 = torch.nn.Linear(Z_dim, int(h_dim / 4)) self.hidden2 = torch.nn.Linear(int(h_dim / 4), int(h_dim / 2)) ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice assert_size_stride ...
onimaru/Generative_models
Decoder
false
12,858
[ "Apache-2.0" ]
0
915750066996aa3d4dce6ae605778b4eee3f0f3d
https://github.com/onimaru/Generative_models/tree/915750066996aa3d4dce6ae605778b4eee3f0f3d
UpBlock
import torch import torch.nn as nn class UpBlock(nn.Module): def __init__(self, in_f, out_f, stride=2, add_blur=False): super(UpBlock, self).__init__() self.shuffle = nn.ConvTranspose2d(in_f, out_f, kernel_size=3, stride=stride, padding=0) self.has_blur = add_blur if s...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_s...
parth-shettiwar/Image-Toonification
UpBlock
false
12,859
[ "MIT" ]
0
a24d76fa9737558ac38a2fdf23469376f25c0abd
https://github.com/parth-shettiwar/Image-Toonification/tree/a24d76fa9737558ac38a2fdf23469376f25c0abd
MLP
import random import torch import numpy as np from torch import nn class MLP(nn.Module): def __init__(self, kernels, num_features, num_hiddens, normalize=True, num_updates=3000, batch_size=128, weight_decay=0.0001, soft_preds=False ): super().__init__() self.kernels = kernels ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
openmynet/tract
MLP
false
12,860
[ "ECL-2.0", "Apache-2.0", "MIT-0", "MIT" ]
0
a9aba6edcfeacd34f781f08717ae374bfbaba80e
https://github.com/openmynet/tract/tree/a9aba6edcfeacd34f781f08717ae374bfbaba80e
RWKV_TimeMix
from _paritybench_helpers import _mock_config import torch import torch.nn as nn class RWKV_TimeMix(nn.Module): def __init__(self, config, layer_id): super().__init__() assert config.n_attn % config.n_head == 0 self.layer_id = layer_id self.ctx_len = config.ctx_len self.n_...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
ofooo/AI-Writer
RWKV_TimeMix
false
12,861
[ "BSD-3-Clause" ]
0
1ba84894c15c9e5605d3c6cd7521d5c6dab6eb6d
https://github.com/ofooo/AI-Writer/tree/1ba84894c15c9e5605d3c6cd7521d5c6dab6eb6d
Encoder
import torch import torch.nn.functional as F from torch import nn class Encoder(torch.nn.Module): def __init__(self, X_dim, h_dim, Z_dim): super(Encoder, self).__init__() self.hidden1 = torch.nn.Linear(X_dim, X_dim) self.hidden2 = torch.nn.Linear(X_dim, h_dim) self.hidden3 = torch...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice assert_size_stride ...
onimaru/Generative_models
Encoder
false
12,862
[ "Apache-2.0" ]
0
915750066996aa3d4dce6ae605778b4eee3f0f3d
https://github.com/onimaru/Generative_models/tree/915750066996aa3d4dce6ae605778b4eee3f0f3d
Upconv
import math import torch import torch.nn.functional as F from torch.nn import Conv2d from torch.nn import Upsample class PadSameConv2d(torch.nn.Module): def __init__(self, kernel_size, stride=1): """ Imitates padding_mode="same" from tensorflow. :param kernel_size: Kernelsize of the convo...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import math import torch.nn.functional as F from torch.nn import Conv2d from tor...
pc2005/MonoRec
Upconv
false
12,863
[ "MIT" ]
0
6e1628eeef9987b1acce3e5e8bb6a6a324fc8d2c
https://github.com/pc2005/MonoRec/tree/6e1628eeef9987b1acce3e5e8bb6a6a324fc8d2c
Net
import torch import torch.nn as nn class Net(nn.Module): def __init__(self, r0, c0): super(Net, self).__init__() self.r = nn.Parameter(torch.FloatTensor([r0])) self.c = nn.Parameter(torch.FloatTensor([c0])) def forward(self): cube_r = -3 * self.c * self.c * self.r + self.r * ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_st...
pbloem/python-stuff
Net
false
12,864
[ "MIT" ]
0
db50fc52bcd59245c826013f196eb63319b326bc
https://github.com/pbloem/python-stuff/tree/db50fc52bcd59245c826013f196eb63319b326bc
RGBBlock
import torch from torch import nn import torch.nn.functional as F class Conv2DMod(nn.Module): def __init__(self, in_chan, out_chan, kernel, demod=True, stride=1, dilation=1, **kwargs): super().__init__() self.filters = out_chan self.demod = demod self.kernel = kernel ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch import nn import t...
p0werHu/unet-stylegan2
RGBBlock
false
12,865
[ "MIT" ]
0
9978025e2932d5962fcb724cbd0313b85292f0d3
https://github.com/p0werHu/unet-stylegan2/tree/9978025e2932d5962fcb724cbd0313b85292f0d3
DQN_RAM
import torch import torch.nn as nn import torch.nn.functional as F class DQN_RAM(nn.Module): def __init__(self, in_features=4, num_actions=18): """ Initialize a deep Q-learning network for testing algorithm in_features: number of features of input. num_actions: number of a...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_...
paulesta55/pytorch-dqn
DQN_RAM
false
12,866
[ "MIT" ]
0
0c1345952c8f99b2f74ec357867262fae6d928ec
https://github.com/paulesta55/pytorch-dqn/tree/0c1345952c8f99b2f74ec357867262fae6d928ec