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
C3
import torch import torch.nn as nn from collections import OrderedDict class C3(nn.Module): def __init__(self): super(C3, self).__init__() self.c3 = nn.Sequential(OrderedDict([('c3', nn.Conv2d(32, 64, kernel_size=(3, 3), bias=32)), ('relu3', nn.ReLU())])) def forward(self, img): ...
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...
devillove084/DeepSignal
C3
false
12,260
[ "MIT" ]
0
1fe122b32752b11e10ca4bef3d07ddd7de4348b5
https://github.com/devillove084/DeepSignal/tree/1fe122b32752b11e10ca4bef3d07ddd7de4348b5
L2Norm
import torch import torch.nn.functional as F import torch.nn as nn class L2Norm(nn.Module): def __init__(self): super().__init__() def forward(self, x): assert x.dim( ) == 2, 'the input tensor of L2Norm must be the shape of [B, C]' return F.normalize(x, p=2, dim=-1) def...
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...
deokhk/Proxy-Anchor-CVPR2020
L2Norm
false
12,261
[ "MIT" ]
0
acb3a16c3ebc8b8777542898ec83de32aa8ba64e
https://github.com/deokhk/Proxy-Anchor-CVPR2020/tree/acb3a16c3ebc8b8777542898ec83de32aa8ba64e
MaskedMSE
import torch import torch.nn as nn class MaskedMSE(nn.Module): def __init__(self): super(MaskedMSE, self).__init__() self.criterion = nn.MSELoss() def forward(self, input, target, gamma=2.0): mask = gamma * target / (target + 1e-07) self.loss = self.criterion(input * mask, ta...
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...
dhruvramani/MaskedMSE
MaskedMSE
false
12,262
[ "MIT" ]
0
76ff94add5659217a3f4f21e60a4f069defede29
https://github.com/dhruvramani/MaskedMSE/tree/76ff94add5659217a3f4f21e60a4f069defede29
C1
import torch import torch.nn as nn from collections import OrderedDict class C1(nn.Module): def __init__(self) ->None: super(C1, self).__init__() self.c1 = nn.Sequential(OrderedDict([('c1', nn.Conv2d(3, 16, kernel_size=(3, 3), bias=True)), ('relu1', nn.ReLU()), ('s1', nn.M...
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...
devillove084/DeepSignal
C1
false
12,263
[ "MIT" ]
0
1fe122b32752b11e10ca4bef3d07ddd7de4348b5
https://github.com/devillove084/DeepSignal/tree/1fe122b32752b11e10ca4bef3d07ddd7de4348b5
ContractingBlock
import torch from torch import nn class ContractingBlock(nn.Module): def __init__(self, input_channels, use_bn=True, kernel_size=3, activation='relu'): super(ContractingBlock, self).__init__() self.conv1 = nn.Conv2d(input_channels, input_channels * 2, kernel_size=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._inductor.runtime import triton_helpers from torch._inductor.runtime....
diegushko/CycleGAN
ContractingBlock
false
12,264
[ "MIT" ]
0
630d1cd00cef3f09f036d3c734d31c772cc0a786
https://github.com/diegushko/CycleGAN/tree/630d1cd00cef3f09f036d3c734d31c772cc0a786
h_swish
import torch import torch.nn as nn class h_sigmoid(nn.Module): def __init__(self, inplace=True): super(h_sigmoid, self).__init__() self.relu = nn.ReLU6(inplace=inplace) def forward(self, x): return self.relu(x + 3) / 6 class h_swish(nn.Module): def __init__(self, inplace=True)...
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...
dhananjaisharma10/mmdetection
h_swish
false
12,265
[ "Apache-2.0" ]
0
6f6db3211c3760cffe9db2350297c42cc29ce140
https://github.com/dhananjaisharma10/mmdetection/tree/6f6db3211c3760cffe9db2350297c42cc29ce140
Mlp
import math import torch import torch.utils.data import torch import torch.nn as nn def gelu(x): """ Original Implementation of the gelu activation function in Google Bert repo when initialy created. For information: OpenAI GPT's gelu is slightly different (and gives slightly different results): 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.triton_helpers import libdevice import math import ...
denisleonov/pytorch-CycleGAN-and-pix2pix
Mlp
false
12,266
[ "BSD-3-Clause" ]
0
d1a5f0c5911f70ed896f826619b4067ce737a83d
https://github.com/denisleonov/pytorch-CycleGAN-and-pix2pix/tree/d1a5f0c5911f70ed896f826619b4067ce737a83d
FeatureMapBlock
import torch from torch import nn class FeatureMapBlock(nn.Module): def __init__(self, input_channels, output_channels): super(FeatureMapBlock, self).__init__() self.conv = nn.Conv2d(input_channels, output_channels, kernel_size= 7, padding=3, padding_mode='reflect') def forward(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 from torch._inductor.runtime.triton_helpers import math as tl_math from torch im...
diegushko/CycleGAN
FeatureMapBlock
false
12,267
[ "MIT" ]
0
630d1cd00cef3f09f036d3c734d31c772cc0a786
https://github.com/diegushko/CycleGAN/tree/630d1cd00cef3f09f036d3c734d31c772cc0a786
PrecomputedNorm
import torch import torch.nn as nn class PrecomputedNorm(nn.Module): """Normalization using Pre-computed Mean/Std. Args: stats: Precomputed (mean, std). axis: Axis setting used to calculate mean/variance. """ def __init__(self, stats, axis=[1, 2]): super().__init__() s...
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...
czlwang/s3prl
PrecomputedNorm
false
12,268
[ "Apache-2.0" ]
0
81d4bb8d051cee20fa87c083b8478999e1766172
https://github.com/czlwang/s3prl/tree/81d4bb8d051cee20fa87c083b8478999e1766172
AMSoftmaxLoss
import torch import torch.nn as nn import torch.nn.functional as F class AMSoftmaxLoss(nn.Module): def __init__(self, hidden_dim, speaker_num, s=30.0, m=0.4, **kwargs): """ AM Softmax Loss """ super(AMSoftmaxLoss, self).__init__() self.s = s self.m = m 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 import triton_helpers from torch._inductor.runtime....
czlwang/s3prl
AMSoftmaxLoss
false
12,269
[ "Apache-2.0" ]
0
81d4bb8d051cee20fa87c083b8478999e1766172
https://github.com/czlwang/s3prl/tree/81d4bb8d051cee20fa87c083b8478999e1766172
ResidualBlock
import torch from torch import nn class ResidualBlock(nn.Module): def __init__(self, input_channels): super(ResidualBlock, self).__init__() self.conv1 = nn.Conv2d(input_channels, input_channels, kernel_size= 3, padding=1, padding_mode='reflect') self.conv2 = nn.Conv2d(input_ch...
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....
diegushko/CycleGAN
ResidualBlock
false
12,271
[ "MIT" ]
0
630d1cd00cef3f09f036d3c734d31c772cc0a786
https://github.com/diegushko/CycleGAN/tree/630d1cd00cef3f09f036d3c734d31c772cc0a786
SelfAttentionPooling
import torch import torch.nn as nn class SelfAttentionPooling(nn.Module): """ Implementation of SelfAttentionPooling Original Paper: Self-Attention Encoding and Pooling for Speaker Recognition https://arxiv.org/pdf/2008.01077v1.pdf """ def __init__(self, input_dim): super(SelfAttentio...
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....
czlwang/s3prl
SelfAttentionPooling
false
12,272
[ "Apache-2.0" ]
0
81d4bb8d051cee20fa87c083b8478999e1766172
https://github.com/czlwang/s3prl/tree/81d4bb8d051cee20fa87c083b8478999e1766172
AP
import torch import torch.nn as nn class AttentivePooling(nn.Module): """ Implementation of Attentive Pooling """ def __init__(self, input_dim, **kwargs): super(AttentivePooling, self).__init__() self.W_a = nn.Linear(input_dim, input_dim) self.W = nn.Linear(input_dim, 1) ...
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....
czlwang/s3prl
AP
false
12,273
[ "Apache-2.0" ]
0
81d4bb8d051cee20fa87c083b8478999e1766172
https://github.com/czlwang/s3prl/tree/81d4bb8d051cee20fa87c083b8478999e1766172
BertLayer
from _paritybench_helpers import _mock_config import math import torch import torch.nn as nn import torch.nn.functional as F class BertSelfAttention(nn.Module): def __init__(self, config): super().__init__() self.num_attention_heads = config.num_attention_heads self.attention_head_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....
brendon-boldt/minbert-assignment
BertLayer
false
12,274
[ "Apache-2.0" ]
0
0b562d791d34a40fd3c0383a0a32b4eeb2171cb5
https://github.com/brendon-boldt/minbert-assignment/tree/0b562d791d34a40fd3c0383a0a32b4eeb2171cb5
AdMSoftmaxLoss
import torch import torch.nn as nn import torch.nn.functional as F class AdMSoftmaxLoss(nn.Module): def __init__(self, in_features, out_features, s=30.0, m=0.4): """ AM Softmax Loss """ super(AdMSoftmaxLoss, self).__init__() self.s = s self.m = m self.in_fe...
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....
czlwang/s3prl
AdMSoftmaxLoss
false
12,275
[ "Apache-2.0" ]
0
81d4bb8d051cee20fa87c083b8478999e1766172
https://github.com/czlwang/s3prl/tree/81d4bb8d051cee20fa87c083b8478999e1766172
SoftmaxLoss
import torch import torch.nn as nn class SoftmaxLoss(nn.Module): def __init__(self, hidden_dim, speaker_num, **kwargs): """ Softmax Loss """ super(SoftmaxLoss, self).__init__() self.fc = nn.Linear(hidden_dim, speaker_num) self.loss = nn.CrossEntropyLoss() 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....
czlwang/s3prl
SoftmaxLoss
false
12,276
[ "Apache-2.0" ]
0
81d4bb8d051cee20fa87c083b8478999e1766172
https://github.com/czlwang/s3prl/tree/81d4bb8d051cee20fa87c083b8478999e1766172
CMVN
import torch import torch.nn as nn class CMVN(nn.Module): __constants__ = ['mode', 'dim', 'eps'] def __init__(self, mode='global', dim=2, eps=1e-10): super(CMVN, self).__init__() if mode != 'global': raise NotImplementedError( 'Only support global mean variance nor...
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_...
czlwang/s3prl
CMVN
false
12,277
[ "Apache-2.0" ]
0
81d4bb8d051cee20fa87c083b8478999e1766172
https://github.com/czlwang/s3prl/tree/81d4bb8d051cee20fa87c083b8478999e1766172
ASP
import torch import torch.nn as nn class AttentivePooling(nn.Module): """ Implementation of Attentive Pooling """ def __init__(self, input_dim, **kwargs): super(AttentivePooling, self).__init__() self.W_a = nn.Linear(input_dim, input_dim) self.W = nn.Linear(input_dim, 1) ...
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....
czlwang/s3prl
ASP
false
12,278
[ "Apache-2.0" ]
0
81d4bb8d051cee20fa87c083b8478999e1766172
https://github.com/czlwang/s3prl/tree/81d4bb8d051cee20fa87c083b8478999e1766172
ChannelNorm
import torch import torch.nn as nn class ChannelNorm(nn.Module): def __init__(self, numFeatures, epsilon=1e-05, affine=True): super(ChannelNorm, self).__init__() if affine: self.weight = nn.parameter.Parameter(torch.Tensor(1, numFeatures, 1)) self.bias = nn...
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_...
czlwang/s3prl
ChannelNorm
false
12,279
[ "Apache-2.0" ]
0
81d4bb8d051cee20fa87c083b8478999e1766172
https://github.com/czlwang/s3prl/tree/81d4bb8d051cee20fa87c083b8478999e1766172
Block
import math import torch import torch.utils.data import torch import torch.nn as nn def gelu(x): """ Original Implementation of the gelu activation function in Google Bert repo when initialy created. For information: OpenAI GPT's gelu is slightly different (and gives slightly different results): 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....
denisleonov/pytorch-CycleGAN-and-pix2pix
Block
false
12,280
[ "BSD-3-Clause" ]
0
d1a5f0c5911f70ed896f826619b4067ce737a83d
https://github.com/denisleonov/pytorch-CycleGAN-and-pix2pix/tree/d1a5f0c5911f70ed896f826619b4067ce737a83d
AttentivePooling
import torch import torch.nn as nn class AttentivePooling(nn.Module): """ Implementation of Attentive Pooling """ def __init__(self, input_dim, **kwargs): super(AttentivePooling, self).__init__() self.W_a = nn.Linear(input_dim, input_dim) self.W = nn.Linear(input_dim, 1) ...
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....
czlwang/s3prl
AttentivePooling
false
12,281
[ "Apache-2.0" ]
0
81d4bb8d051cee20fa87c083b8478999e1766172
https://github.com/czlwang/s3prl/tree/81d4bb8d051cee20fa87c083b8478999e1766172
Delta
import torch import torch.nn as nn from torchaudio import transforms class Delta(nn.Module): def __init__(self, order=2, **kwargs): super(Delta, self).__init__() self.order = order self.compute_delta = transforms.ComputeDeltas(**kwargs) def forward(self, x): feats = [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 import torch.nn as nn from torchaudio import transforms assert_size_stride = tor...
czlwang/s3prl
Delta
false
12,282
[ "Apache-2.0" ]
0
81d4bb8d051cee20fa87c083b8478999e1766172
https://github.com/czlwang/s3prl/tree/81d4bb8d051cee20fa87c083b8478999e1766172
ExpandingBlock
import torch from torch import nn class ExpandingBlock(nn.Module): def __init__(self, input_channels, use_bn=True): super(ExpandingBlock, self).__init__() self.conv1 = nn.ConvTranspose2d(input_channels, input_channels // 2, kernel_size=3, stride=2, padding=1, output_padding=1) ...
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....
diegushko/CycleGAN
ExpandingBlock
false
12,283
[ "MIT" ]
0
630d1cd00cef3f09f036d3c734d31c772cc0a786
https://github.com/diegushko/CycleGAN/tree/630d1cd00cef3f09f036d3c734d31c772cc0a786
FocalLoss
import torch import torch.nn as nn import torch.nn.parallel import torch.optim import torch.utils.data import torch.nn.functional as F def focal_loss(input_values, gamma): """Computes the focal loss""" p = torch.exp(-input_values) loss = (1 - p) ** gamma * input_values return loss.mean() class Focal...
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 ...
dixit-dude7/LDAM-DRW
FocalLoss
false
12,284
[ "MIT" ]
0
6366f4756d3ac0c6b6db784b7f20e16066967ed4
https://github.com/dixit-dude7/LDAM-DRW/tree/6366f4756d3ac0c6b6db784b7f20e16066967ed4
NormedLinear
import torch import torch.nn as nn import torch.nn.parallel import torch.optim import torch.utils.data import torch.nn.functional as F from torch.nn import Parameter class NormedLinear(nn.Module): def __init__(self, in_features, out_features): super(NormedLinear, self).__init__() self.weight = Pa...
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....
dixit-dude7/LDAM-DRW
NormedLinear
false
12,285
[ "MIT" ]
0
6366f4756d3ac0c6b6db784b7f20e16066967ed4
https://github.com/dixit-dude7/LDAM-DRW/tree/6366f4756d3ac0c6b6db784b7f20e16066967ed4
Warp
import torch from torch import Tensor import torch.nn as nn import torch.nn.functional as F def coords_grid(flow: 'Tensor') ->Tensor: """Generate shifted coordinate grid based based input flow. Args: flow (Tensor): Estimated optical flow. Returns: Tensor: The coordinate that shifted by i...
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 Tensor import torch.nn as nn assert_size_stride = torch._C._d...
dimagrshk/opt_flow_attack
Warp
false
12,286
[ "Apache-2.0" ]
0
6bfad92abcf3eaae1a6ca05b865be072361636ed
https://github.com/dimagrshk/opt_flow_attack/tree/6bfad92abcf3eaae1a6ca05b865be072361636ed
Normalize
import torch from torch import Tensor import torch.nn.parallel import torch.utils.data import torch.nn.functional as F import torch.onnx import torch.optim import torch.utils.data.distributed class Normalize(torch.nn.Module): """Normalize a tensor image with mean and standard deviation. This transform does no...
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.parallel imp...
dineenai/pytorch_untrained_models
Normalize
false
12,287
[ "BSD-3-Clause" ]
0
eb301d3b8e3e87b8a79cd8cb4e1cb8d4e44a273a
https://github.com/dineenai/pytorch_untrained_models/tree/eb301d3b8e3e87b8a79cd8cb4e1cb8d4e44a273a
LowRankResidualDecoderLayer
import torch import torch.nn as nn import torch.utils.checkpoint import torch.nn.functional as F from torch.cuda.amp import autocast class ScaledDotProductAttention(nn.Module): """ Scaled Dot-Product Attention """ def __init__(self, temperature, attn_dropout=0.1): super().__init__() self.temp...
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....
bahducoup/factorized_training
LowRankResidualDecoderLayer
false
12,288
[ "MIT" ]
0
0af38f16338a9bcfcc11091b1a6b75befd67f234
https://github.com/bahducoup/factorized_training/tree/0af38f16338a9bcfcc11091b1a6b75befd67f234
SelfAttention
import torch import torch.nn.functional as F from torch import nn class SelfAttention(nn.Module): def __init__(self, embedding_dimension, num_heads): super().__init__() assert embedding_dimension % num_heads == 0, f'embedding dimension must be divisible by number of heads, got embedding_dimension...
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....
dimitrios-ebi/gene_symbol_classifier
SelfAttention
false
12,289
[ "Apache-2.0" ]
0
fe415f719fda4619041b9fe0639996c92e0f12a8
https://github.com/dimitrios-ebi/gene_symbol_classifier/tree/fe415f719fda4619041b9fe0639996c92e0f12a8
MHAttentionMap
import torch import torch.nn as nn from torch.nn import functional as F import torch._utils class MHAttentionMap(nn.Module): """This is a 2D attention module, which only returns the attention softmax (no multiplication by value)""" def __init__(self, query_dim, hidden_dim, num_heads=1, dropout=0.0, 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 from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
dingmyu/mmclassification
MHAttentionMap
false
12,290
[ "Apache-2.0" ]
0
c600b22907fb9423899f7c308c659168c2d01cd8
https://github.com/dingmyu/mmclassification/tree/c600b22907fb9423899f7c308c659168c2d01cd8
GNNExplainerProbe
import math import torch class AbstractTorchModule(torch.nn.Module): def __init__(self): torch.nn.Module.__init__(self) def save(self, path): None torch.save(self.state_dict(), path) def load(self, path): None self.load_state_dict(torch.load(path, map_location=se...
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 math assert_size_stride = torch._C._dynamo.guards.assert_size_stri...
djz233/GraphMask
GNNExplainerProbe
false
12,291
[ "MIT" ]
0
4b699a1685f0d26973bb90cd75b09d74726cdc2f
https://github.com/djz233/GraphMask/tree/4b699a1685f0d26973bb90cd75b09d74726cdc2f
DenseGCNConv
import math import torch from torch.nn import Parameter import torch.utils.data def glorot(tensor): if tensor is not None: stdv = math.sqrt(6.0 / (tensor.size(-2) + tensor.size(-1))) tensor.data.uniform_(-stdv, stdv) def zeros(tensor): if tensor is not None: tensor.data.fill_(0) cl...
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....
douglasrizzo/pytorch_geometric
DenseGCNConv
false
12,292
[ "MIT" ]
0
effc617c6ad6daad506038bb79e4407082e74740
https://github.com/douglasrizzo/pytorch_geometric/tree/effc617c6ad6daad506038bb79e4407082e74740
LayerNormLSTMCell
import torch import torch.distributed import torch import torch.nn as nn import torch.nn.functional as F class LayerNormLSTMCell(nn.LSTMCell): def __init__(self, input_size, hidden_size, bias=True): super().__init__(input_size, hidden_size, bias) self.ln_ih = nn.LayerNorm(4 * hidden_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 libdevice import torch.distri...
dimoteo333/TL-DR
LayerNormLSTMCell
false
12,293
[ "Apache-2.0" ]
0
b3bebc51e70a48294d7762fa73375cf1bf2ff068
https://github.com/dimoteo333/TL-DR/tree/b3bebc51e70a48294d7762fa73375cf1bf2ff068
Linear
import math import torch from torch import Tensor from torch.nn import Linear from torch.nn import Parameter import torch.utils.data def uniform(size, tensor): bound = 1.0 / math.sqrt(size) if tensor is not None: tensor.data.uniform_(-bound, bound) def kaiming_uniform(tensor, fan, a): if tensor ...
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 from torch import Tensor from torch.nn import Parameter import torch...
douglasrizzo/pytorch_geometric
Linear
false
12,294
[ "MIT" ]
0
effc617c6ad6daad506038bb79e4407082e74740
https://github.com/douglasrizzo/pytorch_geometric/tree/effc617c6ad6daad506038bb79e4407082e74740
DenseSAGEConv
import math import torch import torch.nn.functional as F from torch.nn import Parameter import torch.utils.data def uniform(size, tensor): bound = 1.0 / math.sqrt(size) if tensor is not None: tensor.data.uniform_(-bound, bound) class DenseSAGEConv(torch.nn.Module): """See :class:`torch_geometric...
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.nn imp...
douglasrizzo/pytorch_geometric
DenseSAGEConv
false
12,295
[ "MIT" ]
0
effc617c6ad6daad506038bb79e4407082e74740
https://github.com/douglasrizzo/pytorch_geometric/tree/effc617c6ad6daad506038bb79e4407082e74740
Gate
from _paritybench_helpers import _mock_config import torch import torch.nn as nn import torch.nn.functional as F class Gate(nn.Module): def __init__(self, args): super(Gate, self).__init__() self.d_model = args.d_model self.weight_proj = nn.Linear(2 * self.d_model, 1) self.tanh = ...
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 ...
djz233/GraphMask
Gate
false
12,296
[ "MIT" ]
0
4b699a1685f0d26973bb90cd75b09d74726cdc2f
https://github.com/djz233/GraphMask/tree/4b699a1685f0d26973bb90cd75b09d74726cdc2f
TransformerDecoderLayer
import torch import torch.nn as nn from torch.nn import functional as F import torch._utils def _get_activation_fn(activation): """Return an activation function given a string""" if activation == 'relu': return F.relu if activation == 'gelu': return F.gelu if activation == 'glu': ...
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....
dingmyu/mmclassification
TransformerDecoderLayer
false
12,297
[ "Apache-2.0" ]
0
c600b22907fb9423899f7c308c659168c2d01cd8
https://github.com/dingmyu/mmclassification/tree/c600b22907fb9423899f7c308c659168c2d01cd8
Envelope
import torch import torch.utils.data class Envelope(torch.nn.Module): def __init__(self, exponent): super(Envelope, self).__init__() self.p = exponent self.a = -(self.p + 1) * (self.p + 2) / 2 self.b = self.p * (self.p + 2) self.c = -self.p * (self.p + 1) / 2 def forw...
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.utils.data assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_...
douglasrizzo/pytorch_geometric
Envelope
false
12,298
[ "MIT" ]
0
effc617c6ad6daad506038bb79e4407082e74740
https://github.com/douglasrizzo/pytorch_geometric/tree/effc617c6ad6daad506038bb79e4407082e74740
CategoricalSampler
import torch import torch.nn as nn class Sampler(nn.Module): """ args; logits: (batch, n_nodes) return; next_node: (batch, 1) TopKSampler <=> greedy; sample one with biggest probability CategoricalSampler <=> sampling; randomly sample one from possible distribution based on probability """ def __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 from torch._inductor.runtime.triton_helpers import math as tl_math import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert...
daunfamily/VRP_MHA
CategoricalSampler
false
12,299
[ "MIT" ]
0
9c23d181d11dbbacac01299c6e8931b8e266b9b4
https://github.com/daunfamily/VRP_MHA/tree/9c23d181d11dbbacac01299c6e8931b8e266b9b4
Attention
import math import torch import torch.nn.functional as F import torch.utils.data def restricted_softmax(src, dim=-1, margin=0): src_max = torch.clamp(src.max(dim=dim, keepdim=True)[0], min=0) out = (src - src_max).exp() out = out / (out.sum(dim=dim, keepdim=True) + (margin - src_max).exp()) return out...
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....
douglasrizzo/pytorch_geometric
Attention
false
12,300
[ "MIT" ]
0
effc617c6ad6daad506038bb79e4407082e74740
https://github.com/douglasrizzo/pytorch_geometric/tree/effc617c6ad6daad506038bb79e4407082e74740
Model
import torch from torch import nn class Model(nn.Module): def __init__(self, input_size, dropout=0.5): super(Model, self).__init__() self.dropout = dropout if self.dropout > 0: self.dropout = nn.Dropout(dropout) self.encode_w1 = nn.Linear(input_size, 64) self.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 import triton_helpers from torch import nn assert_s...
dohnlee/qufa2021
Model
false
12,301
[ "MIT" ]
0
5fb42caee09ec228358e49768e32c75e3c0094ce
https://github.com/dohnlee/qufa2021/tree/5fb42caee09ec228358e49768e32c75e3c0094ce
MaxPoolPad
import torch import torch.nn as nn import torch.nn.init class MaxPoolPad(nn.Module): def __init__(self): super(MaxPoolPad, self).__init__() self.pad = nn.ZeroPad2d((1, 0, 1, 0)) self.pool = nn.MaxPool2d(3, stride=2, padding=1) def forward(self, x): x = self.pad(x) x =...
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 import torch.nn.init assert_size_stride = torch._C._dynamo.guards.a...
dowhilefalse/DeOldify
MaxPoolPad
false
12,302
[ "MIT" ]
0
08f012cdbe36e3f8482460f57e1844b361a7fb16
https://github.com/dowhilefalse/DeOldify/tree/08f012cdbe36e3f8482460f57e1844b361a7fb16
DenseGraphConv
import math import torch from torch.nn import Parameter import torch.utils.data def uniform(size, tensor): bound = 1.0 / math.sqrt(size) if tensor is not None: tensor.data.uniform_(-bound, bound) class DenseGraphConv(torch.nn.Module): """See :class:`torch_geometric.nn.conv.GraphConv`. """ ...
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 from torch.nn import Parameter import torch.utils.data assert_size_s...
douglasrizzo/pytorch_geometric
DenseGraphConv
false
12,303
[ "MIT" ]
0
effc617c6ad6daad506038bb79e4407082e74740
https://github.com/douglasrizzo/pytorch_geometric/tree/effc617c6ad6daad506038bb79e4407082e74740
SelfAttentionUnit
import torch from torch import nn class SelfAttentionUnit(nn.Module): def __init__(self, embed_dim, num_heads, max_len, dropout=0.8, bias= False, skip_connection=True): super(SelfAttentionUnit, self).__init__() self.skip_connection = skip_connection self.attn = nn.MultiheadAttenti...
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....
dohnlee/qufa2021
SelfAttentionUnit
false
12,304
[ "MIT" ]
0
5fb42caee09ec228358e49768e32c75e3c0094ce
https://github.com/dohnlee/qufa2021/tree/5fb42caee09ec228358e49768e32c75e3c0094ce
AvgPoolPad
import torch import torch.nn as nn import torch.nn.init class AvgPoolPad(nn.Module): def __init__(self, stride=2, padding=1): super(AvgPoolPad, self).__init__() self.pad = nn.ZeroPad2d((1, 0, 1, 0)) self.pool = nn.AvgPool2d(3, stride=stride, padding=padding, count_include_pad=...
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.nn.init assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dy...
dowhilefalse/DeOldify
AvgPoolPad
false
12,305
[ "MIT" ]
0
08f012cdbe36e3f8482460f57e1844b361a7fb16
https://github.com/dowhilefalse/DeOldify/tree/08f012cdbe36e3f8482460f57e1844b361a7fb16
MultiHead
import math import torch from torch import Tensor from torch.nn import Linear import torch.nn.functional as F from torch.nn import Parameter import torch.utils.data def uniform(size, tensor): bound = 1.0 / math.sqrt(size) if tensor is not None: tensor.data.uniform_(-bound, bound) def kaiming_uniform...
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....
douglasrizzo/pytorch_geometric
MultiHead
false
12,306
[ "MIT" ]
0
effc617c6ad6daad506038bb79e4407082e74740
https://github.com/douglasrizzo/pytorch_geometric/tree/effc617c6ad6daad506038bb79e4407082e74740
ResidualLayer
import math import torch from torch import Tensor from torch.nn import Linear from torch.nn import Parameter import torch.utils.data def uniform(size, tensor): bound = 1.0 / math.sqrt(size) if tensor is not None: tensor.data.uniform_(-bound, bound) def kaiming_uniform(tensor, fan, a): if tensor ...
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 from torch import Tensor from torch.nn import Linear from torch.nn i...
douglasrizzo/pytorch_geometric
ResidualLayer
false
12,307
[ "MIT" ]
0
effc617c6ad6daad506038bb79e4407082e74740
https://github.com/douglasrizzo/pytorch_geometric/tree/effc617c6ad6daad506038bb79e4407082e74740
BPRLoss
import torch import torch.nn as nn class BPRLoss(nn.Module): """ BPRLoss, based on Bayesian Personalized Ranking Args: - gamma(float): Small value to avoid division by zero Shape: - Pos_score: (N) - Neg_score: (N), same shape as the Pos_score - Output: scalar. Exampl...
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 ...
dreaming-qin/RecBole
BPRLoss
false
12,308
[ "MIT" ]
0
d6de39521484ded60c387ca604abaf86310acdbe
https://github.com/dreaming-qin/RecBole/tree/d6de39521484ded60c387ca604abaf86310acdbe
ResNetV2
import torch import torch.nn as nn from collections import OrderedDict import torch.nn.functional as F def conv1x1(cin, cout, stride=1, bias=False): return StdConv2d(cin, cout, kernel_size=1, stride=stride, padding=0, bias=bias) def conv3x3(cin, cout, stride=1, groups=1, bias=False): return StdConv2...
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....
Yifanfanfanfan/ViT-pytorch
ResNetV2
false
12,309
[ "MIT" ]
0
0f975aa7d3fd0aba6f74260c2b5a91786f1211ba
https://github.com/Yifanfanfanfan/ViT-pytorch/tree/0f975aa7d3fd0aba6f74260c2b5a91786f1211ba
NegSamplingLoss
import torch import torch.nn as nn class NegSamplingLoss(nn.Module): def __init__(self): super(NegSamplingLoss, self).__init__() def forward(self, score, sign): return -torch.mean(torch.sigmoid(sign * score)) def get_inputs(): return [torch.rand([4, 4, 4, 4]), torch.rand([4, 4, 4, 4])]...
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...
dreaming-qin/RecBole
NegSamplingLoss
false
12,310
[ "MIT" ]
0
d6de39521484ded60c387ca604abaf86310acdbe
https://github.com/dreaming-qin/RecBole/tree/d6de39521484ded60c387ca604abaf86310acdbe
InnerProductLoss
import torch import torch.nn as nn import torch.nn.functional as F class InnerProductLoss(nn.Module): """This is the inner-product loss used in CFKG for optimization. """ def __init__(self): super(InnerProductLoss, self).__init__() def forward(self, anchor, positive, negative): pos_s...
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...
dreaming-qin/RecBole
InnerProductLoss
false
12,311
[ "MIT" ]
0
d6de39521484ded60c387ca604abaf86310acdbe
https://github.com/dreaming-qin/RecBole/tree/d6de39521484ded60c387ca604abaf86310acdbe
InnerProductLayer
import torch import torch.nn as nn class InnerProductLayer(nn.Module): """InnerProduct Layer used in PNN that compute the element-wise product or inner product between feature vectors. """ def __init__(self, num_feature_field, device): """ Args: num_feature_field(int) :nu...
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...
dreaming-qin/RecBole
InnerProductLayer
false
12,312
[ "MIT" ]
0
d6de39521484ded60c387ca604abaf86310acdbe
https://github.com/dreaming-qin/RecBole/tree/d6de39521484ded60c387ca604abaf86310acdbe
ConvNCFBPRLoss
import torch import torch.nn as nn class ConvNCFBPRLoss(nn.Module): """ ConvNCFBPRLoss, based on Bayesian Personalized Ranking, Shape: - Pos_score: (N) - Neg_score: (N), same shape as the Pos_score - Output: scalar. Examples:: >>> loss = ConvNCFBPRLoss() >>> ...
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 ...
dreaming-qin/RecBole
ConvNCFBPRLoss
false
12,313
[ "MIT" ]
0
d6de39521484ded60c387ca604abaf86310acdbe
https://github.com/dreaming-qin/RecBole/tree/d6de39521484ded60c387ca604abaf86310acdbe
BaseFactorizationMachine
import torch import torch.nn as nn class BaseFactorizationMachine(nn.Module): """Calculate FM result over the embeddings Args: reduce_sum: bool, whether to sum the result, default is True. Input: input_x: tensor, A 3D tensor with shape:``(batch_size,field_size,embed_dim)``. Output ...
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...
dreaming-qin/RecBole
BaseFactorizationMachine
false
12,314
[ "MIT" ]
0
d6de39521484ded60c387ca604abaf86310acdbe
https://github.com/dreaming-qin/RecBole/tree/d6de39521484ded60c387ca604abaf86310acdbe
AGRUCell
import torch import torch.nn as nn import torch.nn.functional as F class AGRUCell(nn.Module): ' Attention based GRU (AGRU). AGRU uses the attention score to replace the update gate of GRU, and changes the\n hidden state directly.\n\n Formally:\n ..math: {h}_{t}^{\\prime}=\\left(1-a_{t}\right) * {h}_{...
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 ...
dreaming-qin/RecBole
AGRUCell
false
12,315
[ "MIT" ]
0
d6de39521484ded60c387ca604abaf86310acdbe
https://github.com/dreaming-qin/RecBole/tree/d6de39521484ded60c387ca604abaf86310acdbe
RegLoss
import torch import torch.nn as nn class RegLoss(nn.Module): """ RegLoss, L2 regularization on model parameters """ def __init__(self): super(RegLoss, self).__init__() def forward(self, parameters): reg_loss = None for W in parameters: if reg_loss is None: ...
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_...
dreaming-qin/RecBole
RegLoss
false
12,316
[ "MIT" ]
0
d6de39521484ded60c387ca604abaf86310acdbe
https://github.com/dreaming-qin/RecBole/tree/d6de39521484ded60c387ca604abaf86310acdbe
AttLayer
import torch import torch.nn as nn import torch.nn.functional as fn class AttLayer(nn.Module): """Calculate the attention signal(weight) according the input tensor. Args: infeatures (torch.FloatTensor): A 3D input tensor with shape of[batch_size, M, embed_dim]. Returns: torch.FloatTensor...
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....
dreaming-qin/RecBole
AttLayer
false
12,317
[ "MIT" ]
0
d6de39521484ded60c387ca604abaf86310acdbe
https://github.com/dreaming-qin/RecBole/tree/d6de39521484ded60c387ca604abaf86310acdbe
Repeat_Explore_Mechanism
import torch import torch.nn as nn class Repeat_Explore_Mechanism(nn.Module): def __init__(self, device, hidden_size, seq_len, dropout_prob): super(Repeat_Explore_Mechanism, self).__init__() self.dropout = nn.Dropout(dropout_prob) self.hidden_size = hidden_size self.device = devic...
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....
dreaming-qin/RecBole
Repeat_Explore_Mechanism
false
12,318
[ "MIT" ]
0
d6de39521484ded60c387ca604abaf86310acdbe
https://github.com/dreaming-qin/RecBole/tree/d6de39521484ded60c387ca604abaf86310acdbe
ItemToInterestAggregation
import torch import torch.nn as nn class ItemToInterestAggregation(nn.Module): def __init__(self, seq_len, hidden_size, k_interests=5): super().__init__() self.k_interests = k_interests self.theta = nn.Parameter(torch.randn([hidden_size, k_interests])) def forward(self, input_tensor)...
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....
dreaming-qin/RecBole
ItemToInterestAggregation
false
12,319
[ "MIT" ]
0
d6de39521484ded60c387ca604abaf86310acdbe
https://github.com/dreaming-qin/RecBole/tree/d6de39521484ded60c387ca604abaf86310acdbe
AUGRUCell
import torch import torch.nn as nn import torch.nn.functional as F class AUGRUCell(nn.Module): ' Effect of GRU with attentional update gate (AUGRU). AUGRU combines attention mechanism and GRU seamlessly.\n\n Formally:\n ..math: \tilde{{u}}_{t}^{\\prime}=a_{t} * {u}_{t}^{\\prime} \\\n {h}_...
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 ...
dreaming-qin/RecBole
AUGRUCell
false
12,320
[ "MIT" ]
0
d6de39521484ded60c387ca604abaf86310acdbe
https://github.com/dreaming-qin/RecBole/tree/d6de39521484ded60c387ca604abaf86310acdbe
ComplexLinear
from torch.nn import Module import torch from torch.nn import Linear class ComplexLinear(Module): def __init__(self, in_features, out_features): super(ComplexLinear, self).__init__() self.fc_r = Linear(in_features, out_features) self.fc_i = Linear(in_features, out_features) def forwa...
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 from torch.nn import Linear assert_size_stride = tor...
drydenwiebe/complexPyTorch
ComplexLinear
false
12,321
[ "MIT" ]
0
cea88ba7ee5692dfa1b40f0ba609ef14160d5073
https://github.com/drydenwiebe/complexPyTorch/tree/cea88ba7ee5692dfa1b40f0ba609ef14160d5073
BinaryClassificationHead
from _paritybench_helpers import _mock_config import torch class BinaryClassificationHead(torch.nn.Module): def __init__(self, config): super().__init__() self.config = config self.dense = torch.nn.Linear(config.hidden_size, config.hidden_size) self.dropout = torch.nn.Dropout(conf...
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 ...
BunnyNoBugs/DeepPavlov
BinaryClassificationHead
false
12,322
[ "Apache-2.0" ]
0
b2213db633a669d27d6f745dd780530574ccf8b5
https://github.com/BunnyNoBugs/DeepPavlov/tree/b2213db633a669d27d6f745dd780530574ccf8b5
ComplexConv2d
from torch.nn import Module import torch from torch.nn import Conv2d class ComplexConv2d(Module): def __init__(self, in_channels, out_channels, kernel_size=3, stride=1, padding=0, dilation=1, groups=1, bias=True): super(ComplexConv2d, self).__init__() self.conv_r = Conv2d(in_channels, out...
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 from torch.nn import Conv2d assert_size_stride = tor...
drydenwiebe/complexPyTorch
ComplexConv2d
false
12,323
[ "MIT" ]
0
cea88ba7ee5692dfa1b40f0ba609ef14160d5073
https://github.com/drydenwiebe/complexPyTorch/tree/cea88ba7ee5692dfa1b40f0ba609ef14160d5073
Transition
import torch import torch.nn as nn import torch.nn.parallel class Transition(nn.Module): def __init__(self, in_features, out_features, act_layer=nn.GELU): super(Transition, self).__init__() self.act = act_layer() self.linear = nn.Linear(in_features, out_features) 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.triton_helpers import libdevice import torch.nn as ...
druzhkov-paul/T2T-ViT
Transition
false
12,324
[ "BSD-3-Clause-Clear" ]
0
819c3ddc4cb6f464d4a9866d8713c7ace42ebf6c
https://github.com/druzhkov-paul/T2T-ViT/tree/819c3ddc4cb6f464d4a9866d8713c7ace42ebf6c
_TestNetStrided
import torch import torch.nn.functional as F import torch.nn import torch.utils.data import torch.utils.tensorboard._pytorch_graph import torch.onnx.symbolic_caffe2 class _TestNetStrided(torch.nn.Module): def __init__(self): super(_TestNetStrided, self).__init__() self.conv1 = torch.nn.Conv2d(1, ...
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....
arjunsuresh/aimet
_TestNetStrided
false
12,325
[ "BSD-3-Clause" ]
0
f6e09cb07a91eed3a5e6b8e19e6b065303af5a39
https://github.com/arjunsuresh/aimet/tree/f6e09cb07a91eed3a5e6b8e19e6b065303af5a39
Concat
import torch import torch.nn import torch.utils.data import torch.utils.tensorboard._pytorch_graph import torch.onnx.symbolic_caffe2 class Concat(torch.nn.Module): """ Concat module for a functional concat""" def __init__(self, axis: 'int'=0): super(Concat, self).__init__() self.axis = axis ...
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 import torch.utils.data import torch.utils.tensorboard._pytorch_graph import torch.onnx.symbolic_caffe2 assert_size_stride =...
arjunsuresh/aimet
Concat
false
12,326
[ "BSD-3-Clause" ]
0
f6e09cb07a91eed3a5e6b8e19e6b065303af5a39
https://github.com/arjunsuresh/aimet/tree/f6e09cb07a91eed3a5e6b8e19e6b065303af5a39
EdgeCaseModel
import torch from typing import Any import torch.nn as nn class LayerWithRidiculouslyLongNameAndDoesntDoAnything(nn.Module): """ Model with a very long name. """ def __init__(self) ->None: super().__init__() self.identity = nn.Identity() def forward(self, x: 'Any') ->Any: return ...
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 typing import Any import torch.nn as nn assert_size_stride = torch._C._dyna...
e-dorigatti/torchinfo
EdgeCaseModel
false
12,327
[ "MIT" ]
0
9fa0e677fb7002e89afd5b1bb372fe8c1dd813d6
https://github.com/e-dorigatti/torchinfo/tree/9fa0e677fb7002e89afd5b1bb372fe8c1dd813d6
ComplexConvTranspose2d
from torch.nn import Module import torch from torch.nn import ConvTranspose2d class ComplexConvTranspose2d(Module): def __init__(self, in_channels, out_channels, kernel_size, stride=1, padding=0, output_padding=0, groups=1, bias=True, dilation=1, padding_mode='zeros'): super(ComplexConvTr...
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 from torch.nn import ConvTranspose2d assert_size_str...
drydenwiebe/complexPyTorch
ComplexConvTranspose2d
false
12,328
[ "MIT" ]
0
cea88ba7ee5692dfa1b40f0ba609ef14160d5073
https://github.com/drydenwiebe/complexPyTorch/tree/cea88ba7ee5692dfa1b40f0ba609ef14160d5073
OuterProductLayer
import torch import torch.nn as nn class OuterProductLayer(nn.Module): """OuterProduct Layer used in PNN. This implementation is adapted from code that the author of the paper published on https://github.com/Atomu2014/product-nets. """ def __init__(self, num_feature_field, embedding_size, device): ...
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...
dreaming-qin/RecBole
OuterProductLayer
false
12,329
[ "MIT" ]
0
d6de39521484ded60c387ca604abaf86310acdbe
https://github.com/dreaming-qin/RecBole/tree/d6de39521484ded60c387ca604abaf86310acdbe
Net
import torch import torch.nn as nn class Net(nn.Module): def __init__(self, input_placeholder, output_size): super(Net, self).__init__() self.fc1 = nn.Linear(input_placeholder, 255) self.relu1 = nn.ReLU() self.fc2 = nn.Linear(255, 255) self.relu2 = nn.ReLU() self.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 as nn assert_...
dylan-albertazzi/Berkely_DeepRL
Net
false
12,330
[ "MIT" ]
0
997d066df7b429f6ad365dca8105490dae8f978e
https://github.com/dylan-albertazzi/Berkely_DeepRL/tree/997d066df7b429f6ad365dca8105490dae8f978e
MPNetAttention
from _paritybench_helpers import _mock_config import math import torch from typing import List from typing import Tuple from torch import nn from typing import Set import torch.utils.checkpoint def find_pruneable_heads_and_indices(heads: 'List[int]', n_heads: 'int', head_size: 'int', already_pruned_heads: 'Set[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 from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
Clemens123/transformers
MPNetAttention
false
12,331
[ "Apache-2.0" ]
0
22abe7bbc587c16ec30f9d1aa549dcbeba6e9e26
https://github.com/Clemens123/transformers/tree/22abe7bbc587c16ec30f9d1aa549dcbeba6e9e26
NoiseLayer
import torch import torch.nn as nn class NoiseLayer(nn.Module): """adds noise. noise is per pixel (constant over channels) with per-channel weight""" def __init__(self, channels): super().__init__() self.weight = nn.Parameter(torch.zeros(channels)) self.noise = None def forward(s...
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 import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C...
eitanrich/ganspace-manifold
NoiseLayer
false
12,332
[ "Apache-2.0" ]
0
148d5d30001c43794a40bbed885601e7816f5d7d
https://github.com/eitanrich/ganspace-manifold/tree/148d5d30001c43794a40bbed885601e7816f5d7d
KnowledgeDistillationLoss
import torch from torch import nn class KnowledgeDistillationLoss(nn.Module): def __init__(self, reduction='mean', alpha=1.0): super().__init__() self.reduction = reduction self.alpha = alpha def forward(self, inputs, targets, mask=None): inputs = inputs.narrow(1, 0, targets....
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 from torch import nn a...
edoardofantolino/MLDLproject4
KnowledgeDistillationLoss
false
12,333
[ "MIT" ]
0
fed0cfd51f5984bbf21205a43ea43dc49f4d289a
https://github.com/edoardofantolino/MLDLproject4/tree/fed0cfd51f5984bbf21205a43ea43dc49f4d289a
SubpixelConvolutionLayer
import torch import torch.nn as nn class SubpixelConvolutionLayer(nn.Module): def __init__(self, channels: 'int'=64) ->None: """ Args: channels (int): Number of channels in the input image. (Default: 64) """ super(SubpixelConvolutionLayer, self).__init__() 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...
duylebkHCM/Anime-Face-Generator-
SubpixelConvolutionLayer
false
12,334
[ "MIT" ]
0
ffcbe22f2073971e81b1bbc61b7ef7970889f8a2
https://github.com/duylebkHCM/Anime-Face-Generator-/tree/ffcbe22f2073971e81b1bbc61b7ef7970889f8a2
RecursiveNet
import torch from typing import Any import torch.nn as nn class RecursiveNet(nn.Module): """ Model that uses a layer recursively in computation. """ def __init__(self) ->None: super().__init__() self.conv1 = nn.Conv2d(64, 64, 3, 1, 1) def forward(self, x: 'torch.Tensor', args1: 'Any'=Non...
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...
e-dorigatti/torchinfo
RecursiveNet
false
12,335
[ "MIT" ]
0
9fa0e677fb7002e89afd5b1bb372fe8c1dd813d6
https://github.com/e-dorigatti/torchinfo/tree/9fa0e677fb7002e89afd5b1bb372fe8c1dd813d6
MyLinear
import torch import torch.nn as nn import torch.nn.functional as F class MyLinear(nn.Module): """Linear layer with equalized learning rate and custom learning rate multiplier.""" def __init__(self, input_size, output_size, gain=2 ** 0.5, use_wscale= False, lrmul=1, bias=True): super().__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 import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_s...
eitanrich/ganspace-manifold
MyLinear
false
12,336
[ "Apache-2.0" ]
0
148d5d30001c43794a40bbed885601e7816f5d7d
https://github.com/eitanrich/ganspace-manifold/tree/148d5d30001c43794a40bbed885601e7816f5d7d
BCELoss2d
import torch import torch.nn.functional as F import torch.nn as nn class BCELoss2d(nn.Module): def __init__(self, weight=None, size_average=True): """ Imlements Binary Cross Entropy loss function. """ super(BCELoss2d, self).__init__() self.bce_loss = nn.BCELoss(weight,...
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...
ekalyashov/segmentation-unet
BCELoss2d
false
12,337
[ "MIT" ]
0
59dc95419481b2535a52332e0be92b15c7450674
https://github.com/ekalyashov/segmentation-unet/tree/59dc95419481b2535a52332e0be92b15c7450674
StyleMod
import torch import torch.nn as nn import torch.nn.functional as F class MyLinear(nn.Module): """Linear layer with equalized learning rate and custom learning rate multiplier.""" def __init__(self, input_size, output_size, gain=2 ** 0.5, use_wscale= False, lrmul=1, bias=True): super().__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 import torch.nn as nn import torch.nn.functional as F assert_size_stride = torch...
eitanrich/ganspace-manifold
StyleMod
false
12,338
[ "Apache-2.0" ]
0
148d5d30001c43794a40bbed885601e7816f5d7d
https://github.com/eitanrich/ganspace-manifold/tree/148d5d30001c43794a40bbed885601e7816f5d7d
ProteinResNetPooler
from _paritybench_helpers import _mock_config import torch import torch.nn as nn class ProteinResNetPooler(nn.Module): def __init__(self, config): super().__init__() self.attention_weights = nn.Linear(config.hidden_size, 1) self.dense = nn.Linear(config.hidden_size, config.hidden_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 libdevice, math as tl_math im...
ekvall93/tape
ProteinResNetPooler
false
12,339
[ "BSD-3-Clause" ]
0
1ca4d5a39c72f806f23a36fb7a7c7325f06096ae
https://github.com/ekvall93/tape/tree/1ca4d5a39c72f806f23a36fb7a7c7325f06096ae
Accuracy
import torch import torch.nn as nn def accuracy(logits, labels, ignore_index: 'int'=-100): with torch.no_grad(): valid_mask = labels != ignore_index predictions = logits.float().argmax(-1) correct = (predictions == labels) * valid_mask return correct.sum().float() / valid_mask.sum(...
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...
ekvall93/tape
Accuracy
false
12,340
[ "BSD-3-Clause" ]
0
1ca4d5a39c72f806f23a36fb7a7c7325f06096ae
https://github.com/ekvall93/tape/tree/1ca4d5a39c72f806f23a36fb7a7c7325f06096ae
DNNModel
import torch from torch import nn class DNNModel(nn.Module): def __init__(self, dropout=0.2): super(DNNModel, self).__init__() self.fc1 = nn.Linear(4, 4) self.relu1 = nn.ReLU() self.dropout1 = nn.Dropout(p=dropout) self.fc2 = nn.Linear(4, 4) self.relu2 = nn.ReLU() ...
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...
ehsangolshani/workload-to-metric-mapper
DNNModel
false
12,341
[ "Apache-2.0" ]
0
4c2825696200748382247909f2f777f49bf62cf0
https://github.com/ehsangolshani/workload-to-metric-mapper/tree/4c2825696200748382247909f2f777f49bf62cf0
SoftDiceLoss
import torch import torch.nn.functional as F import torch.nn as nn class SoftDiceLoss(nn.Module): def __init__(self, weight=None, size_average=True): """ Imlements Dice loss function (using Sørensen–Dice coefficient). """ super(SoftDiceLoss, self).__init__() def forward(s...
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...
ekalyashov/segmentation-unet
SoftDiceLoss
false
12,342
[ "MIT" ]
0
59dc95419481b2535a52332e0be92b15c7450674
https://github.com/ekalyashov/segmentation-unet/tree/59dc95419481b2535a52332e0be92b15c7450674
LeNet_300_100
import torch import torch.nn as nn import torch.nn.functional as F import torch.nn.parallel import torch.optim import torch.utils.data import torch.utils.data.distributed class LeNet_300_100(nn.Module): """Simple NN with hidden layers [300, 100] Based on https://github.com/mi-lad/snip/blob/master/train.py ...
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....
elony314/sparse_learning
LeNet_300_100
false
12,343
[ "MIT" ]
0
fff9ea0267016bda747f2882ef8de508ac1369e7
https://github.com/elony314/sparse_learning/tree/fff9ea0267016bda747f2882ef8de508ac1369e7
Attention
import torch import torch.nn as nn import torch.nn.functional as F class Attention(nn.Module): def __init__(self, device, hidden_size): super(Attention, self).__init__() self.device = device self.hidden_size = hidden_size self.concat_linear = nn.Linear(self.hidden_size * 2, self.h...
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....
ekvall93/tape
Attention
false
12,344
[ "BSD-3-Clause" ]
0
1ca4d5a39c72f806f23a36fb7a7c7325f06096ae
https://github.com/ekvall93/tape/tree/1ca4d5a39c72f806f23a36fb7a7c7325f06096ae
L2Norm
import torch import torch.nn as nn import torch.onnx class L2Norm(nn.Module): """ Scale shall be learnable according to original paper scale: initial scale number chan_num: L2Norm channel number (norm over all channels) """ def __init__(self, scale=20, chan_num=512): super(L2...
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 import...
ephrem-git/inference
L2Norm
false
12,345
[ "Apache-2.0" ]
0
bfbda5fc419364c3f71b5b1640f6c00e7675b212
https://github.com/ephrem-git/inference/tree/bfbda5fc419364c3f71b5b1640f6c00e7675b212
Get_gradient_nopadding
import torch import torch.nn as nn import torch.nn.functional as F class Get_gradient_nopadding(nn.Module): def __init__(self): super(Get_gradient_nopadding, self).__init__() kernel_v = [[0, -1, 0], [0, 0, 0], [0, 1, 0]] kernel_h = [[0, 0, 0], [-1, 0, 1], [0, 0, 0]] kernel_h = tor...
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 ...
eqprog/ESRGAN
Get_gradient_nopadding
false
12,346
[ "Apache-2.0" ]
0
d5eb02531cf0ce4e8df93793f3012486bac8d87a
https://github.com/eqprog/ESRGAN/tree/d5eb02531cf0ce4e8df93793f3012486bac8d87a
MultiheadAttention
import torch import torch.nn.functional as F from torch import nn import torch.utils.data from torch.nn import Parameter import torch.onnx.operators import torch.optim import torch.optim.lr_scheduler class MultiheadAttention(nn.Module): """Multi-headed attention. See "Attention Is All You Need" for more deta...
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....
edbltn/fairseq
MultiheadAttention
false
12,347
[ "BSD-3-Clause" ]
0
e4d25fd96f1e38190400dbbdbc77eeda71ac50a0
https://github.com/edbltn/fairseq/tree/e4d25fd96f1e38190400dbbdbc77eeda71ac50a0
StackTime
import torch import torch.onnx class StackTime(torch.nn.Module): __constants__ = ['factor'] def __init__(self, factor): super().__init__() self.factor = int(factor) def forward(self, x, x_lens): seq = [x] for i in range(1, self.factor): tmp = torch.zeros_like(...
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.onnx assert_size_stride = torch._C._dynamo.guards.assert_size_stri...
ephrem-git/inference
StackTime
false
12,348
[ "Apache-2.0" ]
0
bfbda5fc419364c3f71b5b1640f6c00e7675b212
https://github.com/ephrem-git/inference/tree/bfbda5fc419364c3f71b5b1640f6c00e7675b212
SharpenedCosineSimilarity
import torch import torch.nn as nn import torch.nn.functional as F def unfold2d(x, kernel_size: 'int', stride: 'int', padding: 'int'): x = F.pad(x, [padding] * 4) bs, in_c, h, w = x.size() ks = kernel_size strided_x = x.as_strided((bs, in_c, (h - ks) // stride + 1, (w - ks) // stride + 1, ks, ...
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 import torch.nn.functional as F assert_s...
enzokro/sharpened_cosine_similarity_torch
SharpenedCosineSimilarity
false
12,349
[ "MIT" ]
0
150c84f5cf81721baf097abdc0d4ac772fb39fc4
https://github.com/enzokro/sharpened_cosine_similarity_torch/tree/150c84f5cf81721baf097abdc0d4ac772fb39fc4
PredictionHead
import torch import torch.nn as nn import torch.onnx class PredictionHead(nn.Module): def __init__(self, in_channels, num_classes, num_anchors): super(PredictionHead, self).__init__() self.classification = nn.Conv2d(in_channels, num_classes * num_anchors, kernel_size=1) self.r...
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.onnx assert_size_stride = torch._C._dynamo.gu...
ephrem-git/inference
PredictionHead
false
12,350
[ "Apache-2.0" ]
0
bfbda5fc419364c3f71b5b1640f6c00e7675b212
https://github.com/ephrem-git/inference/tree/bfbda5fc419364c3f71b5b1640f6c00e7675b212
ExtClassifier
import torch import torch.nn as nn import torch.cuda import torch.distributed class ExtClassifier(nn.Module): def __init__(self, hidden_size): super(ExtClassifier, self).__init__() self.linear1 = nn.Linear(hidden_size, 1) self.sigmoid = nn.Sigmoid() def forward(self, x, mask=None): ...
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.cuda import torch.distributed assert_size_str...
eric-zhizu/OpenNMT-kpg-release
ExtClassifier
false
12,351
[ "MIT" ]
0
9f15dea6f663425eef2157845c4c8042ad845c11
https://github.com/eric-zhizu/OpenNMT-kpg-release/tree/9f15dea6f663425eef2157845c4c8042ad845c11
SharpenedCosineSimilarity_ConvImpl
import torch import torch.nn as nn import torch.nn.functional as F class SharpenedCosineSimilarity_ConvImpl(nn.Module): def __init__(self, in_channels=1, out_channels=1, kernel_size=1, stride =1, padding=0, eps=1e-12): super(SharpenedCosineSimilarity_ConvImpl, self).__init__() self.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.triton_helpers import libdevice, math as tl_math im...
enzokro/sharpened_cosine_similarity_torch
SharpenedCosineSimilarity_ConvImpl
false
12,352
[ "MIT" ]
0
150c84f5cf81721baf097abdc0d4ac772fb39fc4
https://github.com/enzokro/sharpened_cosine_similarity_torch/tree/150c84f5cf81721baf097abdc0d4ac772fb39fc4
SharpenedCosineSimilarityAnnotated
import torch import torch.nn as nn import torch.nn.functional as F class SharpenedCosineSimilarityAnnotated(nn.Module): def __init__(self, in_channels=1, out_channels=1, kernel_size=1, stride =1, padding=0, eps=1e-12): super(SharpenedCosineSimilarityAnnotated, self).__init__() self.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.triton_helpers import libdevice, math as tl_math im...
enzokro/sharpened_cosine_similarity_torch
SharpenedCosineSimilarityAnnotated
false
12,353
[ "MIT" ]
0
150c84f5cf81721baf097abdc0d4ac772fb39fc4
https://github.com/enzokro/sharpened_cosine_similarity_torch/tree/150c84f5cf81721baf097abdc0d4ac772fb39fc4
Divide
import torch import torch.nn import torch.utils.data import torch.utils.tensorboard._pytorch_graph import torch.onnx.symbolic_caffe2 class Divide(torch.nn.Module): """ Divide module for a functional divide""" def forward(self, x, y): """ Forward-pass routine for divide op """ ...
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 import torch.utils.data import torch.utils.tensorboard._pytorch_graph import torch.onnx.symbolic_caffe2 assert_size_stride =...
arjunsuresh/aimet
Divide
false
12,354
[ "BSD-3-Clause" ]
0
f6e09cb07a91eed3a5e6b8e19e6b065303af5a39
https://github.com/arjunsuresh/aimet/tree/f6e09cb07a91eed3a5e6b8e19e6b065303af5a39
EqualLinear
import torch import torch.nn.functional as F from torch import nn class EqualLinear(nn.Module): def __init__(self, in_dim, out_dim, lr_mul=1, bias=True): super().__init__() self.weight = nn.Parameter(torch.randn(out_dim, in_dim)) if bias: self.bias = nn.Parameter(torch.zeros(o...
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...
ericguizzo/stylegan2-pytorch
EqualLinear
false
12,355
[ "MIT" ]
0
d6e5cf4e30247e12d330537676f9ba63867cfaa0
https://github.com/ericguizzo/stylegan2-pytorch/tree/d6e5cf4e30247e12d330537676f9ba63867cfaa0
ScaleNorm
import math import torch import torch.nn as nn class ScaleNorm(nn.Module): """ScaleNorm""" """All g’s in SCALE NORM are initialized to sqrt(d)""" def __init__(self, scale, eps=1e-05): super(ScaleNorm, self).__init__() self.scale = nn.Parameter(torch.tensor(math.sqrt(scale))) 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 import math import torch.nn ...
eweiner/MAT_Extension
ScaleNorm
false
12,356
[ "MIT" ]
0
505884a67f97bf54e1198077d15a48531fcac7a5
https://github.com/eweiner/MAT_Extension/tree/505884a67f97bf54e1198077d15a48531fcac7a5
Generator
import math import torch import torch.nn as nn class LayerNorm(nn.Module): """Construct a layernorm module (See citation for details).""" def __init__(self, features, eps=1e-06): super(LayerNorm, self).__init__() self.a_2 = nn.Parameter(torch.ones(features)) self.b_2 = nn.Parameter(to...
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 as nn assert_size_stride = torch._C._dynamo.guards.a...
eweiner/MAT_Extension
Generator
false
12,357
[ "MIT" ]
0
505884a67f97bf54e1198077d15a48531fcac7a5
https://github.com/eweiner/MAT_Extension/tree/505884a67f97bf54e1198077d15a48531fcac7a5
SAB
import math import torch import torch.nn as nn import torch.nn.functional as F class MAB(nn.Module): def __init__(self, dim_Q, dim_K, dim_V, num_heads, ln=False): super(MAB, self).__init__() self.dim_V = dim_V self.num_heads = num_heads self.fc_q = nn.Linear(dim_Q, dim_V) ...
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....
ernoult/set_transformer
SAB
false
12,358
[ "MIT" ]
0
4b380106e1f43b7eb6315624c57d4d1d38737b78
https://github.com/ernoult/set_transformer/tree/4b380106e1f43b7eb6315624c57d4d1d38737b78
MAB
import math import torch import torch.nn as nn import torch.nn.functional as F class MAB(nn.Module): def __init__(self, dim_Q, dim_K, dim_V, num_heads, ln=False): super(MAB, self).__init__() self.dim_V = dim_V self.num_heads = num_heads self.fc_q = nn.Linear(dim_Q, dim_V) ...
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....
ernoult/set_transformer
MAB
false
12,359
[ "MIT" ]
0
4b380106e1f43b7eb6315624c57d4d1d38737b78
https://github.com/ernoult/set_transformer/tree/4b380106e1f43b7eb6315624c57d4d1d38737b78
EdgeFeaturesLayer
import torch import torch.nn as nn class EdgeFeaturesLayer(nn.Module): def __init__(self, d_model, d_edge, h, dropout): super(EdgeFeaturesLayer, self).__init__() assert d_model % h == 0 d_model // h self.linear = nn.Linear(d_edge, 1, bias=False) with torch.no_grad(): ...
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_...
eweiner/MAT_Extension
EdgeFeaturesLayer
false
12,360
[ "MIT" ]
0
505884a67f97bf54e1198077d15a48531fcac7a5
https://github.com/eweiner/MAT_Extension/tree/505884a67f97bf54e1198077d15a48531fcac7a5