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
depthwise_clipseg_conv
import torch import torch.nn as nn import torch.utils.data class depthwise_clipseg_conv(nn.Module): def __init__(self): super(depthwise_clipseg_conv, self).__init__() self.depthwise = nn.Conv2d(1, 1, kernel_size=3, padding=1) def depthwise_clipseg(self, x, channels): x = torch.cat([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 import torch.utils.data assert_size_stride = torch._C._dyn...
whiteking64/lang-seg
depthwise_clipseg_conv
false
16,707
[ "MIT" ]
202
9d063b126f1b64e38ddb20cc75fc74435bfdcbd3
https://github.com/whiteking64/lang-seg/tree/9d063b126f1b64e38ddb20cc75fc74435bfdcbd3
SAModule
import torch import torch.nn as nn class SAModule(nn.Module): """Spatial Attention Module""" def __init__(self): super(SAModule, self).__init__() self.conv = nn.Conv2d(2, 1, kernel_size=3, padding=1, bias=False) self.sigmoid = nn.Sigmoid() def forward(self, x): input = 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_...
whkwls2653/Pytorch_Face_Recognition-
SAModule
false
16,708
[ "MIT" ]
62
60f3849def589957d9080457a1a9833112a71f6c
https://github.com/whkwls2653/Pytorch_Face_Recognition-/tree/60f3849def589957d9080457a1a9833112a71f6c
BoundaryDecoderAttention
import torch def masked_softmax(x, m=None, axis=-1): """ Softmax with mask (optional) """ x = torch.clamp(x, min=-15.0, max=15.0) if m is not None: m = m.float() x = x * m e_x = torch.exp(x - torch.max(x, dim=axis, keepdim=True)[0]) if m is not None: e_x = e_x * 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 from torch._inductor.runtime....
watchernyu/MatchLSTM-Analyze-Adversarial-Training
BoundaryDecoderAttention
false
16,709
[ "MIT" ]
50
00bd33d3dd22d5291dc2c1ec5feef5eb93b59b3a
https://github.com/watchernyu/MatchLSTM-Analyze-Adversarial-Training/tree/00bd33d3dd22d5291dc2c1ec5feef5eb93b59b3a
VertexConv
import torch from torch import nn class Transform(nn.Module): """ A Vertex Transformation module Permutation invariant transformation: (N, k, d) -> (N, k, d) """ def __init__(self, dim_in, k): """ :param dim_in: input feature dimension :param k: k neighbors """ ...
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....
weiyx15/DHGNN
VertexConv
false
16,710
[ "MIT" ]
124
870a1763c34af6ee9a7a3207fed4a5e6bdb95d23
https://github.com/weiyx15/DHGNN/tree/870a1763c34af6ee9a7a3207fed4a5e6bdb95d23
Transform
import torch from torch import nn class Transform(nn.Module): """ A Vertex Transformation module Permutation invariant transformation: (N, k, d) -> (N, k, d) """ def __init__(self, dim_in, k): """ :param dim_in: input feature dimension :param k: k neighbors """ ...
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....
weiyx15/DHGNN
Transform
false
16,711
[ "MIT" ]
124
870a1763c34af6ee9a7a3207fed4a5e6bdb95d23
https://github.com/weiyx15/DHGNN/tree/870a1763c34af6ee9a7a3207fed4a5e6bdb95d23
ScaledDotProductAttention
import torch def masked_softmax(x, m=None, dim=-1): """ Softmax with mask (optional) """ x = torch.clamp(x, min=-15.0, max=15.0) if m is not None: m = m.float() x = x * m e_x = torch.exp(x - torch.max(x, dim=dim, keepdim=True)[0]) if m is not None: e_x = e_x * 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 from torch._inductor.runtime....
wjurayj/commonsense-rl
ScaledDotProductAttention
false
16,712
[ "Apache-2.0" ]
55
fbbe4fa4a21865095783845fce2f0c4f4346e40f
https://github.com/wjurayj/commonsense-rl/tree/fbbe4fa4a21865095783845fce2f0c4f4346e40f
Attention
import torch import torch.nn as nn class Attention(nn.Module): """ Applies attention mechanism on the `context` using the `query`. **Thank you** to IBM for their initial implementation of :class:`Attention`. Here is their `License <https://github.com/IBM/pytorch-seq2seq/blob/master/LICENSE>`__. ...
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....
wjurayj/commonsense-rl
Attention
false
16,713
[ "Apache-2.0" ]
55
fbbe4fa4a21865095783845fce2f0c4f4346e40f
https://github.com/wjurayj/commonsense-rl/tree/fbbe4fa4a21865095783845fce2f0c4f4346e40f
bottleneck_block
import torch import torch.nn as nn import torch.utils.data class depthwise_conv(nn.Module): def __init__(self, kernel_size=3, stride=1, padding=1): super(depthwise_conv, self).__init__() self.depthwise = nn.Conv2d(1, 1, kernel_size=kernel_size, stride= stride, padding=padding) de...
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 ...
whiteking64/lang-seg
bottleneck_block
false
16,714
[ "MIT" ]
202
9d063b126f1b64e38ddb20cc75fc74435bfdcbd3
https://github.com/whiteking64/lang-seg/tree/9d063b126f1b64e38ddb20cc75fc74435bfdcbd3
depthwise_conv
import torch import torch.nn as nn import torch.utils.data class depthwise_conv(nn.Module): def __init__(self, kernel_size=3, stride=1, padding=1): super(depthwise_conv, self).__init__() self.depthwise = nn.Conv2d(1, 1, kernel_size=kernel_size, stride= stride, padding=padding) de...
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...
whiteking64/lang-seg
depthwise_conv
false
16,715
[ "MIT" ]
202
9d063b126f1b64e38ddb20cc75fc74435bfdcbd3
https://github.com/whiteking64/lang-seg/tree/9d063b126f1b64e38ddb20cc75fc74435bfdcbd3
MNACLayer
import collections import math import torch import torch.utils.data def sparsity_error(W): W_error = torch.min(torch.abs(W), torch.abs(1 - torch.abs(W))) return torch.max(W_error) def mnac(x, W, mode='prod'): out_size, in_size = W.size() x = x.view(x.size()[0], in_size, 1) W = W.t().view(1, in_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 collections import math import torch.utils.data assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = ...
wlm2019/Neural-Arithmetic-Units
MNACLayer
false
16,716
[ "MIT" ]
147
f9de9d004bb2dc2ee28577cd1760d0a00c185836
https://github.com/wlm2019/Neural-Arithmetic-Units/tree/f9de9d004bb2dc2ee28577cd1760d0a00c185836
GaussLinearStandardized
from torch.nn import Module import math import torch from torch.nn.modules import Module from torch.nn.parameter import Parameter import torch.nn.functional as F class GaussLinearStandardized(Module): def __init__(self, in_features, out_features, bias=True, raw_weight_variance=1.0, raw_bias_variance=1.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.nn import Module from torch.nn.modules import Module from torch.nn.pa...
widedeepnetworks/widedeepnetworks
GaussLinearStandardized
false
16,717
[ "Apache-2.0" ]
50
81a8629d62d31643f3d598992ac6376a8fc5c48a
https://github.com/widedeepnetworks/widedeepnetworks/tree/81a8629d62d31643f3d598992ac6376a8fc5c48a
PosNACLayer
import collections import torch import torch.utils.data def sparsity_error(W): W_error = torch.min(torch.abs(W), torch.abs(1 - torch.abs(W))) return torch.max(W_error) class SummaryWriterNamespaceNoLoggingScope: def __init__(self, writer): self._writer = writer def __enter__(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 collections import torch.utils.data assert_size_stride = torch._C._dynamo...
wlm2019/Neural-Arithmetic-Units
PosNACLayer
false
16,718
[ "MIT" ]
147
f9de9d004bb2dc2ee28577cd1760d0a00c185836
https://github.com/wlm2019/Neural-Arithmetic-Units/tree/f9de9d004bb2dc2ee28577cd1760d0a00c185836
GumbelMNACLayer
import collections import torch import torch.utils.data def mnac(x, W, mode='prod'): out_size, in_size = W.size() x = x.view(x.size()[0], in_size, 1) W = W.t().view(1, in_size, out_size) if mode == 'prod': return torch.prod(x * W + 1 - W, -2) elif mode == 'exp-log': return torch.ex...
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 math as tl_math import collections import torch.utils.data asser...
wlm2019/Neural-Arithmetic-Units
GumbelMNACLayer
false
16,719
[ "MIT" ]
147
f9de9d004bb2dc2ee28577cd1760d0a00c185836
https://github.com/wlm2019/Neural-Arithmetic-Units/tree/f9de9d004bb2dc2ee28577cd1760d0a00c185836
ReRegualizedLinearMNACLayer
import collections import math import torch import torch.utils.data def sparsity_error(W): W_error = torch.min(torch.abs(W), torch.abs(1 - torch.abs(W))) return torch.max(W_error) def mnac(x, W, mode='prod'): out_size, in_size = W.size() x = x.view(x.size()[0], in_size, 1) W = W.t().view(1, in_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 import triton_helpers import collections import math import torch.utils.data assert_size_stride = torch._C._dyn...
wlm2019/Neural-Arithmetic-Units
ReRegualizedLinearMNACLayer
false
16,720
[ "MIT" ]
147
f9de9d004bb2dc2ee28577cd1760d0a00c185836
https://github.com/wlm2019/Neural-Arithmetic-Units/tree/f9de9d004bb2dc2ee28577cd1760d0a00c185836
Gain
import random import torch from torchaudio.transforms import Vol class Gain(torch.nn.Module): def __init__(self, min_gain: 'float'=-20.0, max_gain: 'float'=-1): super().__init__() self.min_gain = min_gain self.max_gain = max_gain def forward(self, audio: 'torch.Tensor') ->torch.Tenso...
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 assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torc...
wesbz/torchaudio-augmentations
Gain
false
16,721
[ "MIT" ]
112
e7b379be60376bb4a44f72a6840358871b3ff06d
https://github.com/wesbz/torchaudio-augmentations/tree/e7b379be60376bb4a44f72a6840358871b3ff06d
VisionLanguageFusionModule
import torch from torch import Tensor import torch.utils.data import torch from torch import nn from typing import Optional class VisionLanguageFusionModule(nn.Module): def __init__(self, d_model, nhead, dropout=0.0): super().__init__() self.multihead_attn = nn.MultiheadAttention(d_model, nhead, ...
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....
wjn922/ReferFormer
VisionLanguageFusionModule
false
16,722
[ "Apache-2.0" ]
125
17ca2d8024116068ecae66d0e7155e1d4429b204
https://github.com/wjn922/ReferFormer/tree/17ca2d8024116068ecae66d0e7155e1d4429b204
Task
import torch import torch.nn import torch.utils.data.distributed import torch.nn as nn import torch.nn.parallel import torch.optim import torch.utils.data class Task(nn.Module): def __init__(self): super().__init__() self.p = nn.Parameter(torch.ones(2, 2)) def forward(self, x): retur...
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.distributed import torch.nn as nn import torch.nn.parallel import torch.optim import torch.utils.dat...
woqidaideshi/bagua
Task
false
16,723
[ "MIT" ]
635
0ee96da598685748519d58d24ce983499cb36721
https://github.com/woqidaideshi/bagua/tree/0ee96da598685748519d58d24ce983499cb36721
ModuleForDdpCommHook
import torch import torch.nn import torch.utils.data.distributed import torch.nn as nn import torch.nn.parallel import torch.optim import torch.utils.data class Task(nn.Module): def __init__(self): super().__init__() self.p = nn.Parameter(torch.ones(2, 2)) def forward(self, x): retur...
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.distributed import torch.nn as nn import torch.nn.parallel import torch.optim import torch.utils.dat...
woqidaideshi/bagua
ModuleForDdpCommHook
false
16,724
[ "MIT" ]
635
0ee96da598685748519d58d24ce983499cb36721
https://github.com/woqidaideshi/bagua/tree/0ee96da598685748519d58d24ce983499cb36721
ReRegualizedLinearPosNACLayer
import collections import math import torch import torch.utils.data def sparsity_error(W): W_error = torch.min(torch.abs(W), torch.abs(1 - torch.abs(W))) return torch.max(W_error) class SummaryWriterNamespaceNoLoggingScope: def __init__(self, writer): self._writer = writer def __enter__(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 from torch._inductor.runtime import triton_helpers import collections import mat...
wlm2019/Neural-Arithmetic-Units
ReRegualizedLinearPosNACLayer
false
16,725
[ "MIT" ]
147
f9de9d004bb2dc2ee28577cd1760d0a00c185836
https://github.com/wlm2019/Neural-Arithmetic-Units/tree/f9de9d004bb2dc2ee28577cd1760d0a00c185836
ReRegualizedLinearNACLayer
import collections import math import torch import torch.utils.data def sparsity_error(W): W_error = torch.min(torch.abs(W), torch.abs(1 - torch.abs(W))) return torch.max(W_error) class SummaryWriterNamespaceNoLoggingScope: def __init__(self, writer): self._writer = writer def __enter__(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 from torch._inductor.runtime import triton_helpers import collections import mat...
wlm2019/Neural-Arithmetic-Units
ReRegualizedLinearNACLayer
false
16,726
[ "MIT" ]
147
f9de9d004bb2dc2ee28577cd1760d0a00c185836
https://github.com/wlm2019/Neural-Arithmetic-Units/tree/f9de9d004bb2dc2ee28577cd1760d0a00c185836
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....
wjurayj/commonsense-rl
GAT
false
16,727
[ "Apache-2.0" ]
55
fbbe4fa4a21865095783845fce2f0c4f4346e40f
https://github.com/wjurayj/commonsense-rl/tree/fbbe4fa4a21865095783845fce2f0c4f4346e40f
GL
import torch import torch.nn as nn class GL(nn.Module): def __init__(self, dim): super().__init__() self.gl_conv = nn.Conv2d(dim, dim, kernel_size=3, padding=1, groups=dim ) def forward(self, x): return x + self.gl_conv(x) def get_inputs(): return [torch.rand([4, 4,...
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...
wofmanaf/ResT
GL
false
16,728
[ "Apache-2.0" ]
178
508e30b28036e2cb882a03d24268dc70eb0c82a3
https://github.com/wofmanaf/ResT/tree/508e30b28036e2cb882a03d24268dc70eb0c82a3
HighWay
import torch import torch.nn as nn from torch.nn import Parameter class HighWay(torch.nn.Module): def __init__(self, f_in, f_out, bias=True): super(HighWay, self).__init__() self.w = Parameter(torch.Tensor(f_in, f_out)) nn.init.xavier_uniform_(self.w) if bias: self.bia...
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 import Parameter assert_size_stride = torch....
weihangzhang/EAkit
HighWay
false
16,729
[ "MIT" ]
102
dde8e914480cd1a3585271f70db11d567d9c2a04
https://github.com/weihangzhang/EAkit/tree/dde8e914480cd1a3585271f70db11d567d9c2a04
SobelConv2d
import torch import torch.nn as nn import torch.nn.functional as F class SobelConv2d(nn.Module): def __init__(self, in_channels, out_channels, kernel_size=3, stride=1, padding=0, dilation=1, groups=1, bias=True, requires_grad=True): assert kernel_size % 2 == 1, "SobelConv2d's kernel_size must be ...
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...
workingcoder/EDCNN
SobelConv2d
false
16,730
[ "Apache-2.0" ]
117
68305f465d2b731b60ce78bd0c95c7742d9f52d1
https://github.com/workingcoder/EDCNN/tree/68305f465d2b731b60ce78bd0c95c7742d9f52d1
ContrastiveLoss
import torch import torch.nn.functional as F import torch.utils.data import torch.nn.parallel import torch.optim class ContrastiveLoss(torch.nn.Module): def __init__(self, margin=2.0): super(ContrastiveLoss, self).__init__() self.margin = margin def forward(self, output1, output2, label): ...
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.utils.data impo...
wenqingchu/Semantic-CariGANs
ContrastiveLoss
false
16,731
[ "BSD-3-Clause" ]
50
d6c2fc2046ee62b42dd70fa8892775e33337bbdf
https://github.com/wenqingchu/Semantic-CariGANs/tree/d6c2fc2046ee62b42dd70fa8892775e33337bbdf
My_loss
import torch from torch import nn as nn import torch.nn.parallel import torch.optim from torch.autograd import Variable as Variable import torch.utils.data import torch._utils class My_loss(torch.nn.Module): def __init__(self): super().__init__() def forward(self, x, y): vx = x - torch.mean(...
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 from torch import nn as nn i...
wtomin/MIMA-Net
My_loss
false
16,732
[ "MIT" ]
58
c0330777313ac04b25e53b137dbecd78b5c8dde6
https://github.com/wtomin/MIMA-Net/tree/c0330777313ac04b25e53b137dbecd78b5c8dde6
FusionMax
import torch import torch.nn as nn class Fusion(nn.Module): """ Base Fusion Class""" def __init__(self, input_dim=3): super().__init__() self.input_dim = input_dim def tile_x2(self, x1, x2, x2_proj=None): if x2_proj: x2 = x2_proj(x2) x2 = x2.unsqueeze(-1).unsq...
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...
wx-b/cliport
FusionMax
false
16,733
[ "Apache-2.0" ]
110
c29b0c4b6b1c4e4da5bda6c7f8c718e36f28a6e8
https://github.com/wx-b/cliport/tree/c29b0c4b6b1c4e4da5bda6c7f8c718e36f28a6e8
LossBasic
import torch import torch.nn as nn import torch.nn.functional as F class TensorGradient(nn.Module): """ the gradient of tensor """ def __init__(self, L1=True): super(TensorGradient, self).__init__() self.L1 = L1 def forward(self, img): w, h = img.size(-2), img.size(-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 math as tl_math import torch.nn as nn ...
xenbaloch/efficientderain
LossBasic
false
16,734
[ "MIT" ]
109
d5646815fd14a5a03c859102ecd2f298db7e53be
https://github.com/xenbaloch/efficientderain/tree/d5646815fd14a5a03c859102ecd2f298db7e53be
Attention
import math import torch import torch.nn as nn class Attention(nn.Module): def __init__(self, hidden_size): super(Attention, self).__init__() self.hidden_size = hidden_size self.attn = nn.Linear(hidden_size * 2, hidden_size) self.v = nn.Parameter(torch.rand(hidden_size), requires_...
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....
wptoux/attention-ocr
Attention
false
16,735
[ "MIT" ]
57
ed08719db86a2aaf7e0cbae6169d9919835879d7
https://github.com/wptoux/attention-ocr/tree/ed08719db86a2aaf7e0cbae6169d9919835879d7
ConvNet
import torch import torch.nn import torch.utils.data.distributed import torch.nn as nn import torch.nn.parallel import torch.optim import torch.utils.data class ConvNet(nn.Module): def __init__(self, gpus, layouts, dtypes): super(ConvNet, self).__init__() self.dtypes = dtypes if isinstanc...
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 import torch.utils.data.distributed import torch.nn as nn import...
woqidaideshi/bagua
ConvNet
false
16,737
[ "MIT" ]
635
0ee96da598685748519d58d24ce983499cb36721
https://github.com/woqidaideshi/bagua/tree/0ee96da598685748519d58d24ce983499cb36721
TripletLoss
import torch from torch import nn import torch.nn.functional as F from torch.optim.lr_scheduler import * def _batch_hard(mat_distance, mat_similarity, indice=False): sorted_mat_distance, positive_indices = torch.sort(mat_distance + - 9999999.0 * (1 - mat_similarity), dim=1, descending=True) hard_p = 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 import triton_helpers from torch._inductor.runtime....
xmy0916/IDM
TripletLoss
false
16,738
[ "MIT" ]
68
ab29fbd6d3d8c4650f3dbe41a7d21f745d6167ee
https://github.com/xmy0916/IDM/tree/ab29fbd6d3d8c4650f3dbe41a7d21f745d6167ee
Net
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.data.distributed class Net(nn.Module): def __init__(self): super(Net, self).__init__() self.conv1 = nn.Conv2d(3, 32, (3, 3)) self.pool1 = nn.MaxPool2d((2, 2)) self.conv2 = nn.Conv2d(32, 32, (3, 3...
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 ...
wikfeldt/intro-to-dl
Net
false
16,739
[ "MIT" ]
59
7fb1fb6c520941143000c5e1b46c48c95db17ed6
https://github.com/wikfeldt/intro-to-dl/tree/7fb1fb6c520941143000c5e1b46c48c95db17ed6
Attention_Decoder
import torch import torch.nn as nn import torch._utils class Attention_Decoder(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 self.scal...
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....
xieenze/Trans2Seg
Attention_Decoder
false
16,740
[ "Apache-2.0" ]
149
3972916bba7f985ca1aabc047fea56bdec9e9e5d
https://github.com/xieenze/Trans2Seg/tree/3972916bba7f985ca1aabc047fea56bdec9e9e5d
_Enc
import torch import torch.nn.parallel import torch.optim import torch.utils.data import torch.utils.data.distributed class _NestedEnc(torch.nn.Module): def __init__(self, f): super().__init__() self.f = f def forward(self, x): return self.f(x) class _Enc(torch.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 import torch.nn.parallel import torch.optim import torch.utils.data import torch...
xuanyuzhou98/higher
_Enc
false
16,741
[ "Apache-2.0" ]
1,401
a28b488d8d4c80b38d3a2d322258233d74a89656
https://github.com/xuanyuzhou98/higher/tree/a28b488d8d4c80b38d3a2d322258233d74a89656
MyConv3d
import torch import torch.nn as nn import torch.nn.functional as F class MyConv3d(nn.Module): def __init__(self, in_channels, out_channels, kernel_size, stride=1, bias=True): super(MyConv3d, self).__init__() self.kernel_size = kernel_size self.conv = nn.Conv3d(in_channels=in_chann...
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...
xinxindefeiyu/S2VD-master_RESID
MyConv3d
false
16,742
[ "MIT" ]
48
b075d6873842d70f1d8d3215daf0565f8c0ffe9a
https://github.com/xinxindefeiyu/S2VD-master_RESID/tree/b075d6873842d70f1d8d3215daf0565f8c0ffe9a
LossFunc
import torch import torch.nn as nn import torch.nn.functional as F class TensorGradient(nn.Module): """ the gradient of tensor """ def __init__(self, L1=True): super(TensorGradient, self).__init__() self.L1 = L1 def forward(self, img): w, h = img.size(-2), img.size(-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...
xenbaloch/efficientderain
LossFunc
false
16,743
[ "MIT" ]
109
d5646815fd14a5a03c859102ecd2f298db7e53be
https://github.com/xenbaloch/efficientderain/tree/d5646815fd14a5a03c859102ecd2f298db7e53be
SuperpointDescriptor
import torch import torch.nn as nn class SuperpointDescriptor(nn.Module): """ Descriptor decoder based on the SuperPoint arcihtecture. """ def __init__(self, input_feat_dim=128): super(SuperpointDescriptor, self).__init__() self.relu = torch.nn.ReLU(inplace=True) self.convPa = 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 as nn assert_...
wx-b/SOLD2
SuperpointDescriptor
false
16,744
[ "MIT" ]
347
71c3243f9d3a695788d0a6bfd134b9849425900a
https://github.com/wx-b/SOLD2/tree/71c3243f9d3a695788d0a6bfd134b9849425900a
LossAnneal
import torch import torch.nn as nn import torch.nn.functional as F class TensorGradient(nn.Module): """ the gradient of tensor """ def __init__(self, L1=True): super(TensorGradient, self).__init__() self.L1 = L1 def forward(self, img): w, h = img.size(-2), img.size(-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...
xenbaloch/efficientderain
LossAnneal
false
16,745
[ "MIT" ]
109
d5646815fd14a5a03c859102ecd2f298db7e53be
https://github.com/xenbaloch/efficientderain/tree/d5646815fd14a5a03c859102ecd2f298db7e53be
SuperpointDecoder
import torch import torch.nn as nn class SuperpointDecoder(nn.Module): """ Junction decoder based on the SuperPoint architecture. """ def __init__(self, input_feat_dim=128, backbone_name='lcnn'): super(SuperpointDecoder, self).__init__() self.relu = torch.nn.ReLU(inplace=True) if back...
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_...
wx-b/SOLD2
SuperpointDecoder
false
16,746
[ "MIT" ]
347
71c3243f9d3a695788d0a6bfd134b9849425900a
https://github.com/wx-b/SOLD2/tree/71c3243f9d3a695788d0a6bfd134b9849425900a
WingLoss
import math import torch import torch.onnx from torch.nn.modules.loss import _Loss class WingLoss(_Loss): def __init__(self, width=10, curvature=2.0, reduction='mean'): super(WingLoss, self).__init__(reduction=reduction) self.width = width self.curvature = curvature 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 math as tl_math import math import torch.onnx from torch.nn.modules.loss import _Loss ass...
xuguozhi/Peppa-Facial-Landmark-PyTorch
WingLoss
false
16,747
[ "Apache-2.0" ]
163
238063317fd31c4c21c5c43692e6a5d769970370
https://github.com/xuguozhi/Peppa-Facial-Landmark-PyTorch/tree/238063317fd31c4c21c5c43692e6a5d769970370
FC_Q
import torch import torch.nn as nn import torch.nn.functional as F class FC_Q(nn.Module): def __init__(self, state_dim, num_actions): super(FC_Q, self).__init__() self.q1 = nn.Linear(state_dim, 256) self.q2 = nn.Linear(256, 256) self.q3 = nn.Linear(256, num_actions) self.i...
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....
xtwentian3/BCQ
FC_Q
false
16,748
[ "MIT" ]
402
e114f8c474c57a36d9af78c42a06f612831afda2
https://github.com/xtwentian3/BCQ/tree/e114f8c474c57a36d9af78c42a06f612831afda2
EDCNN
import torch import torch.nn as nn import torch.nn.functional as F class SobelConv2d(nn.Module): def __init__(self, in_channels, out_channels, kernel_size=3, stride=1, padding=0, dilation=1, groups=1, bias=True, requires_grad=True): assert kernel_size % 2 == 1, "SobelConv2d's kernel_size must be ...
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...
workingcoder/EDCNN
EDCNN
false
16,749
[ "Apache-2.0" ]
117
68305f465d2b731b60ce78bd0c95c7742d9f52d1
https://github.com/workingcoder/EDCNN/tree/68305f465d2b731b60ce78bd0c95c7742d9f52d1
Whitening2d
import torch import torch.nn as nn from torch.cuda.amp import custom_fwd from torch.nn.functional import conv2d class Whitening2d(nn.Module): def __init__(self, output_dim: 'int', eps: 'float'=0.0): """Layer that computes hard whitening for W-MSE using the Cholesky decomposition. Args: ...
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...
xwyzsn/solo-learn
Whitening2d
false
16,750
[ "MIT" ]
693
16d021d8053439a3de205337ab2a11d191500b09
https://github.com/xwyzsn/solo-learn/tree/16d021d8053439a3de205337ab2a11d191500b09
SkipConnection
import torch import torch.utils.data import torch.nn as nn def _init_weights(layer): """ Init weights of the layer :param layer: :return: """ nn.init.xavier_uniform_(layer.weight) if layer.bias is not None: nn.init.zeros_(layer.bias) class SkipConnection(nn.Module): """ C...
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.utils.data import torch.nn as nn assert_size_stride = torch._C._dyn...
xyc1207/benchmarking-gnns
SkipConnection
false
16,751
[ "MIT" ]
1,809
9ba25a2825e8c155a93730d6e8f8752090292942
https://github.com/xyc1207/benchmarking-gnns/tree/9ba25a2825e8c155a93730d6e8f8752090292942
SuperpointBackbone
import torch import torch.nn as nn class SuperpointBackbone(nn.Module): """ SuperPoint backbone. """ def __init__(self): super(SuperpointBackbone, self).__init__() self.relu = torch.nn.ReLU(inplace=True) self.pool = torch.nn.MaxPool2d(kernel_size=2, stride=2) c1, c2, c3, c4 = ...
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_...
wx-b/SOLD2
SuperpointBackbone
false
16,752
[ "MIT" ]
347
71c3243f9d3a695788d0a6bfd134b9849425900a
https://github.com/wx-b/SOLD2/tree/71c3243f9d3a695788d0a6bfd134b9849425900a
GateLayer
import torch import torch.nn as nn import torch.nn.functional as F from torch.optim.lr_scheduler import * class GateLayer(nn.Module): def __init__(self, dim, target_dim=None, dropout=None): super(GateLayer, self).__init__() if target_dim is None: target_dim = dim self.line...
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.optim.lr_scheduler import * assert_size_stride ...
xycforgithub/MultiTask-MRC
GateLayer
false
16,753
[ "BSD-3-Clause" ]
105
6e5fe8b3cbc40058784cecad73219390e3c2a922
https://github.com/xycforgithub/MultiTask-MRC/tree/6e5fe8b3cbc40058784cecad73219390e3c2a922
C3D_td5
import torch import torch.nn as nn class Path(object): @staticmethod def db_dir(database): if database == 'ucf101': root_dir = ( '/Users/pingaowang/Google Drive/study/video_classification_research/datasets/UCF-101' ) output_dir = DATA_PATH ...
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_...
pingaowang/pytorch-video-recognition
C3D_td5
false
16,754
[ "MIT" ]
946
096267f88d96a77a74ff743fb0115d997e2cdafd
https://github.com/pingaowang/pytorch-video-recognition/tree/096267f88d96a77a74ff743fb0115d997e2cdafd
LayerNorm
import torch import torch.utils.data import torch.nn as nn class LayerNorm(nn.Module): def __init__(self, d): super().__init__() self.a = nn.Parameter(torch.ones(d).unsqueeze(0).unsqueeze(0)) self.b = nn.Parameter(torch.zeros(d).unsqueeze(0).unsqueeze(0)) def forward(self, 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.triton_helpers import libdevice import torch.utils.data import torch.nn as nn assert_size_stride = torch._C._dy...
xyc1207/benchmarking-gnns
LayerNorm
false
16,755
[ "MIT" ]
1,809
9ba25a2825e8c155a93730d6e8f8752090292942
https://github.com/xyc1207/benchmarking-gnns/tree/9ba25a2825e8c155a93730d6e8f8752090292942
PSA_p
import torch import torch.nn as nn import torch._utils def kaiming_init(module, a=0, mode='fan_out', nonlinearity='relu', bias=0, distribution='normal'): assert distribution in ['uniform', 'normal'] if distribution == 'uniform': nn.init.kaiming_uniform_(module.weight, a=a, mode=mode, 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....
xuewengeophysics/PSA
PSA_p
false
16,756
[ "Apache-2.0" ]
175
06ee556de4e88ecc2a162bd89f9dd494407e3051
https://github.com/xuewengeophysics/PSA/tree/06ee556de4e88ecc2a162bd89f9dd494407e3051
ZeroConv2d
import torch import torch.nn as nn import torch.utils.data from torch.nn import init class ZeroConv2d(nn.Module): def __init__(self, in_channel, out_channel): super().__init__() self.conv = nn.Conv2d(in_channel, out_channel, 1, padding=0) init.uniform_(self.conv.weight, -0.001, 0.001) ...
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....
yhgon/NanoFlow
ZeroConv2d
false
16,757
[ "BSD-3-Clause" ]
62
73b24dfd4d607e73d6167897b83e9f61fcaaca3b
https://github.com/yhgon/NanoFlow/tree/73b24dfd4d607e73d6167897b83e9f61fcaaca3b
ManifoldPropagation
import torch import torch.nn as nn import torch.nn.functional as F def shift(x, direction, amount): if direction == 'left': ret = F.pad(x, (amount, 0, 0, 0, 0, 0, 0, 0))[:, :, :, :-amount] elif direction == 'right': ret = F.pad(x, (0, amount, 0, 0, 0, 0, 0, 0))[:, :, :, amount:] elif direc...
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....
wonkyunglee/MPNet
ManifoldPropagation
false
16,758
[ "MIT" ]
1,280
3a6821a88a5e3db5bd97121761dbb361d9518bc2
https://github.com/wonkyunglee/MPNet/tree/3a6821a88a5e3db5bd97121761dbb361d9518bc2
Model
import torch import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self, num_inputs, num_outputs): super(Model, self).__init__() h_size_1 = 100 h_size_2 = 100 self.p_fc1 = nn.Linear(num_inputs, h_size_1) self.p_fc2 = nn.Linear(h_size_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.triton_helpers import libdevice, math as tl_math im...
yanjiajia-september/Pytorch-DPPO
Model
false
16,759
[ "MIT" ]
179
5e1a75b6dfc6a170270253a35d10109718240e97
https://github.com/yanjiajia-september/Pytorch-DPPO/tree/5e1a75b6dfc6a170270253a35d10109718240e97
PoolFormerBlock
import math import torch import warnings import torch.nn as nn def _no_grad_trunc_normal_(tensor, mean, std, a, b): """Copy & paste from PyTorch official master until it's in a few official releases - RW Method based on https://people.sc.fsu.edu/~jburkardt/presentations/truncated_normal.pdf """ def 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.triton_helpers import libdevice import math import ...
xwyzsn/solo-learn
PoolFormerBlock
false
16,760
[ "MIT" ]
693
16d021d8053439a3de205337ab2a11d191500b09
https://github.com/xwyzsn/solo-learn/tree/16d021d8053439a3de205337ab2a11d191500b09
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...
yoona-ai/stylegan2-pytorch
EqualLinear
false
16,761
[ "MIT" ]
2,954
eceb8aacb669f19b79cc74c7160a85252b1086d6
https://github.com/yoona-ai/stylegan2-pytorch/tree/eceb8aacb669f19b79cc74c7160a85252b1086d6
KeypointsMSESmoothLoss
import torch import torch.utils.data import torch import torch.nn as nn class KeypointsMSESmoothLoss(nn.Module): def __init__(self, threshold=400): super().__init__() self.threshold = threshold def forward(self, output, target, target_weight): batch_size = output.size(0) num_...
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 import torch import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cud...
yihui-he2020/epipolar-transformers
KeypointsMSESmoothLoss
false
16,762
[ "MIT" ]
360
6824f4345b2998500fbacd0f4e30f67f8e3da7b8
https://github.com/yihui-he2020/epipolar-transformers/tree/6824f4345b2998500fbacd0f4e30f67f8e3da7b8
Conv2D
import torch import torch.nn as nn import torch.utils.data class Conv2D(nn.Module): def __init__(self, in_channels, out_channels, kernel_size=3, dilation_h =1, dilation_w=1, causal=True, use_wn_bias=True): super(Conv2D, self).__init__() self.causal = causal self.use_wn_bias = use_...
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 ...
yhgon/NanoFlow
Conv2D
false
16,763
[ "BSD-3-Clause" ]
62
73b24dfd4d607e73d6167897b83e9f61fcaaca3b
https://github.com/yhgon/NanoFlow/tree/73b24dfd4d607e73d6167897b83e9f61fcaaca3b
LayerNorm
import torch import torch.nn as nn import torch.utils.data class LayerNorm(nn.Module): """ LayerNorm that supports inputs of size B, C, T """ def __init__(self, num_channels, eps=1e-05, affine=True, device=None, dtype=None): super().__init__() factory_kwargs = {'device': devic...
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.data assert_size_stride = torch._C._dy...
yjh0410/actionformer_release
LayerNorm
false
16,764
[ "MIT" ]
61
7a97422111d3e29c8d2e14088c850c6975855ea7
https://github.com/yjh0410/actionformer_release/tree/7a97422111d3e29c8d2e14088c850c6975855ea7
AffineDropPath
import torch import torch.nn as nn import torch.utils.data def drop_path(x, drop_prob=0.0, training=False): """ Stochastic Depth per sample. """ if drop_prob == 0.0 or not training: return x keep_prob = 1 - drop_prob shape = (x.shape[0],) + (1,) * (x.ndim - 1) mask = keep_prob + to...
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....
yjh0410/actionformer_release
AffineDropPath
false
16,765
[ "MIT" ]
61
7a97422111d3e29c8d2e14088c850c6975855ea7
https://github.com/yjh0410/actionformer_release/tree/7a97422111d3e29c8d2e14088c850c6975855ea7
IA_gate
import torch import torch.nn as nn class IA_gate(nn.Module): def __init__(self, in_dim, out_dim): super(IA_gate, self).__init__() self.IA = nn.Linear(in_dim, out_dim) def forward(self, x, IA_head): a = self.IA(IA_head) a = 1.0 + torch.tanh(a) a = a.unsqueeze(-1).unsqu...
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 ...
yoxu515/CFBI
IA_gate
false
16,766
[ "BSD-3-Clause" ]
312
0bab1e3c9fc3e3ba0629f716d60221e8f8d9d586
https://github.com/yoxu515/CFBI/tree/0bab1e3c9fc3e3ba0629f716d60221e8f8d9d586
FocalLossSigmoid
import torch import torch.nn as nn from math import sqrt as sqrt from itertools import product as product class FocalLossSigmoid(nn.Module): """ sigmoid version focal loss """ def __init__(self, alpha=0.25, gamma=2, size_average=False): super(FocalLossSigmoid, self).__init__() self.al...
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 ...
yqyao/SSD_Pytorch
FocalLossSigmoid
false
16,767
[ "MIT" ]
163
6060bbb650e7a1df7c12d7c9650a38eaba4ab6a8
https://github.com/yqyao/SSD_Pytorch/tree/6060bbb650e7a1df7c12d7c9650a38eaba4ab6a8
WeightMseLoss
import torch import torch.nn as nn class WeightMseLoss(nn.Module): def __init__(self, size_average=True): super(WeightMseLoss, self).__init__() self.size_average = size_average def forward(self, inputs, targets, weights): """ inputs is N * C targets is N * C w...
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...
yqyao/YOLOv3_Pytorch
WeightMseLoss
false
16,768
[ "MIT" ]
55
ea392f7d418be94605f86ba2b5d167ec30611def
https://github.com/yqyao/YOLOv3_Pytorch/tree/ea392f7d418be94605f86ba2b5d167ec30611def
DownsampleA
import torch import torch.nn as nn import torch.nn.parallel import torch.optim import torch.utils.data import torch.utils.data.distributed import torch.nn.init class DownsampleA(nn.Module): def __init__(self, nIn, nOut, stride): super(DownsampleA, self).__init__() self.avg = nn.AvgPool2d(kernel_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 import torch.nn.parallel import torch.optim import torch.utils.data import torch.utils.data.distributed import torch.n...
yuanjef/imagenet-fast
DownsampleA
false
16,769
[ "Apache-2.0" ]
298
4c1cb1ec11c3444982913fc6526720a0d29b97c5
https://github.com/yuanjef/imagenet-fast/tree/4c1cb1ec11c3444982913fc6526720a0d29b97c5
ImgSenRanking
import torch import numpy as np import torch.utils.data def l2norm(input, p=2.0, dim=1, eps=1e-12): """ Compute L2 norm, row-wise """ l2_inp = input / input.norm(p, dim, keepdim=True).clamp(min=eps) return l2_inp.expand_as(input) def xavier_weight(tensor): nin, nout = tensor.size()[0], tenso...
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....
ypxie/HDGan
ImgSenRanking
false
16,770
[ "MIT" ]
160
d98e2a85f7ae6ce7bfacd1c15e519558d97cb931
https://github.com/ypxie/HDGan/tree/d98e2a85f7ae6ce7bfacd1c15e519558d97cb931
Seedloss
import torch import torch.nn as nn from torch.nn import functional as F class Seedloss(nn.Module): def __init__(self, ignore_label=21): super(Seedloss, self).__init__() self.ignore_label = ignore_label self.eps = 1e-05 def my_softmax(self, score, dim=1): probs = torch.clamp(F...
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...
yaoqi-zd/SGAN
Seedloss
false
16,771
[ "MIT" ]
48
43d8a859b03967e2423a73ef1ba332ee71714ba4
https://github.com/yaoqi-zd/SGAN/tree/43d8a859b03967e2423a73ef1ba332ee71714ba4
PrimaryCaps
import torch import torch.nn as nn class PrimaryCaps(nn.Module): """Creates a primary convolutional capsule layer that outputs a pose matrix and an activation. Note that for computation convenience, pose matrix are stored in first part while the activations are stored in the second part. Arg...
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...
yl-1993/Matrix-Capsules-EM-PyTorch
PrimaryCaps
false
16,772
[ "MIT" ]
97
ca4cd7f45a4234ddf49efe9db34c9ff645378437
https://github.com/yl-1993/Matrix-Capsules-EM-PyTorch/tree/ca4cd7f45a4234ddf49efe9db34c9ff645378437
MaskedMHA
import math import torch import torch.nn as nn import torch.utils.data from torch.nn import functional as F class MaskedMHA(nn.Module): """ Multi Head Attention with mask Modified from https://github.com/karpathy/minGPT/blob/master/mingpt/model.py """ def __init__(self, n_embd, n_head, attn_pdro...
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....
yjh0410/actionformer_release
MaskedMHA
false
16,773
[ "MIT" ]
61
7a97422111d3e29c8d2e14088c850c6975855ea7
https://github.com/yjh0410/actionformer_release/tree/7a97422111d3e29c8d2e14088c850c6975855ea7
FocalLoss
import torch import numpy as np import torch.utils.data import torch import torch.nn as nn from torch.nn import functional as F class FocalLoss(nn.Module): def __init__(self, weight=None, gamma=1.0, num_classes=80): super(FocalLoss, self).__init__() assert gamma >= 0 self.gamma = gamma ...
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 numpy as np imp...
yulonghui/yingying_boss
FocalLoss
false
16,774
[ "MIT" ]
306
f9cf956cb6507ef43f8005c61027f6b54f418224
https://github.com/yulonghui/yingying_boss/tree/f9cf956cb6507ef43f8005c61027f6b54f418224
GCT
import torch import torch.nn as nn class GCT(nn.Module): def __init__(self, num_channels, epsilon=1e-05, mode='l2', after_relu=False ): super(GCT, self).__init__() self.alpha = nn.Parameter(torch.ones(1, num_channels, 1, 1)) self.gamma = nn.Parameter(torch.zeros(1, num_channels, 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.triton_helpers import libdevice import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_...
yoxu515/CFBI
GCT
false
16,775
[ "BSD-3-Clause" ]
312
0bab1e3c9fc3e3ba0629f716d60221e8f8d9d586
https://github.com/yoxu515/CFBI/tree/0bab1e3c9fc3e3ba0629f716d60221e8f8d9d586
MyEntLoss
import torch import torch.nn as nn class MyEntLoss(nn.Module): def __init__(self): super().__init__() def forward(self, x): x = torch.nn.Softmax(dim=1)(x) p = x / torch.repeat_interleave(x.sum(dim=1).unsqueeze(-1), repeats =20, dim=1) logp = torch.log2(p) ...
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...
yuantn/MI-AOD
MyEntLoss
false
16,776
[ "Apache-2.0" ]
188
e57114d60f9ce5e43839cdf7068a90ee58092ec8
https://github.com/yuantn/MI-AOD/tree/e57114d60f9ce5e43839cdf7068a90ee58092ec8
ActorNetwork
import torch import torch.nn.functional as func class ActorNetwork(torch.nn.Module): def __init__(self, s_space, a_space): super(ActorNetwork, self).__init__() self.first_dense = torch.nn.Linear(s_space, 50) self.second_dense = torch.nn.Linear(50, a_space) def forward(self, 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 import triton_helpers assert_size_stride = torch._C...
yutiansut/Personae
ActorNetwork
false
16,777
[ "MIT" ]
1,046
e5e89cbaaf2c4708952d25fdb25e99837aecdb4e
https://github.com/yutiansut/Personae/tree/e5e89cbaaf2c4708952d25fdb25e99837aecdb4e
CriticNetwork
import torch import torch.nn.functional as func class CriticNetwork(torch.nn.Module): def __init__(self, s_space, a_space): super(CriticNetwork, self).__init__() self.s_dense = torch.nn.Linear(s_space, 50) self.a_dense = torch.nn.Linear(a_space, 50) self.q_dense = torch.nn.Linear(...
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...
yutiansut/Personae
CriticNetwork
false
16,778
[ "MIT" ]
1,046
e5e89cbaaf2c4708952d25fdb25e99837aecdb4e
https://github.com/yutiansut/Personae/tree/e5e89cbaaf2c4708952d25fdb25e99837aecdb4e
GELU
import torch import numpy as np import torch.nn as nn class GELU(nn.Module): def forward(self, x): cdf = 0.5 * (1.0 + torch.tanh(np.sqrt(2 / np.pi) * (x + 0.044715 * torch.pow(x, 3)))) return x * cdf def get_inputs(): return [torch.rand([4, 4, 4, 4])] def get_init_inputs(): ...
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_...
yyht/Funnel_Transformer
GELU
false
16,779
[ "MIT" ]
193
4b35a794d5e122a8054471863a52d4eac1c39dcd
https://github.com/yyht/Funnel_Transformer/tree/4b35a794d5e122a8054471863a52d4eac1c39dcd
DynamicPreHead
import torch import torch.nn as nn class DynamicPreHead(nn.Module): def __init__(self, in_dim=3, embed_dim=100, kernel_size=1): super(DynamicPreHead, self).__init__() self.conv = nn.Conv2d(in_dim, embed_dim, kernel_size=kernel_size, stride=1, padding=int((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 from torch._inductor.runtime....
yoxu515/CFBI
DynamicPreHead
false
16,780
[ "BSD-3-Clause" ]
312
0bab1e3c9fc3e3ba0629f716d60221e8f8d9d586
https://github.com/yoxu515/CFBI/tree/0bab1e3c9fc3e3ba0629f716d60221e8f8d9d586
Dense
import torch import numpy as np import torch.nn as nn def get_einsum_string(ndims, einsum_symbols=None): if einsum_symbols is None: einsum_symbols = ['u', 'v', 'w', 'x', 'y', 'z'] assert ndims <= len(einsum_symbols) einsum_prefix = '' for i in range(ndims): einsum_prefix += einsum_symb...
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...
yyht/Funnel_Transformer
Dense
false
16,781
[ "MIT" ]
193
4b35a794d5e122a8054471863a52d4eac1c39dcd
https://github.com/yyht/Funnel_Transformer/tree/4b35a794d5e122a8054471863a52d4eac1c39dcd
InteractionLayer
import math import torch import torchvision.transforms.functional as F from torch import nn import torch.nn.functional as F class InteractionLayer(nn.Module): def __init__(self, d_model, d_feature, dropout=0.1): super().__init__() self.d_feature = d_feature self.det_tfm = nn.Linear(d_mode...
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....
yoyomimi/AS-Net
InteractionLayer
false
16,782
[ "MIT" ]
49
85ce753707c6d1838c3983111ccbba4b1861f438
https://github.com/yoyomimi/AS-Net/tree/85ce753707c6d1838c3983111ccbba4b1861f438
Biaffine
import torch import torch.nn as nn class Biaffine(nn.Module): """ Biaffine layer for first-order scoring :cite:`dozat-etal-2017-biaffine`. This function has a tensor of weights :math:`W` and bias terms if needed. The score :math:`s(x, y)` of the vector pair :math:`(x, y)` is computed as :math:`x^T 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 torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_s...
yzhangcs/parser
Biaffine
false
16,783
[ "MIT" ]
439
3abebde1c9fe0bf2e99adce845aaf2a04b194f8a
https://github.com/yzhangcs/parser/tree/3abebde1c9fe0bf2e99adce845aaf2a04b194f8a
SAN
import torch import torch.nn as nn class SAN(nn.Module): def __init__(self, d_model, nhead, dropout=0.1): super(SAN, self).__init__() self.d_model = d_model self.nhead = nhead self.self_attn = nn.MultiheadAttention(d_model, nhead, dropout=dropout) self.dropout = nn.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 import triton_helpers from torch._inductor.runtime....
yuriy-os/russian-reviews-bert-e2e-absa
SAN
false
16,784
[ "Apache-2.0" ]
293
369a6179353e3bf28643e8e9347b624078e38bf4
https://github.com/yuriy-os/russian-reviews-bert-e2e-absa/tree/369a6179353e3bf28643e8e9347b624078e38bf4
Triaffine
import torch import torch.nn as nn class Triaffine(nn.Module): """ Triaffine layer for second-order scoring :cite:`zhang-etal-2020-efficient,wang-etal-2019-second`. This function has a tensor of weights :math:`W` and bias terms if needed. The score :math:`s(x, y, z)` of the vector triple :math:`(x, y...
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...
yzhangcs/parser
Triaffine
false
16,785
[ "MIT" ]
439
3abebde1c9fe0bf2e99adce845aaf2a04b194f8a
https://github.com/yzhangcs/parser/tree/3abebde1c9fe0bf2e99adce845aaf2a04b194f8a
GlobalMaxPooling
import torch import torch.nn as nn class GlobalMaxPooling(nn.Module): def __init__(self): super(GlobalMaxPooling, self).__init__() def forward(self, x): res, _ = torch.max(x, dim=1) return res def get_inputs(): return [torch.rand([4, 4, 4, 4])] def get_init_inputs(): retu...
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...
zake7749/Sequence-to-Sequence-101
GlobalMaxPooling
false
16,786
[ "MIT" ]
64
f9e9a8e836dc1cb3b35d6e148f6378fcd2736951
https://github.com/zake7749/Sequence-to-Sequence-101/tree/f9e9a8e836dc1cb3b35d6e148f6378fcd2736951
PositionalEmbedding
import torch import torch.nn as nn class PositionalEmbedding(nn.Module): def __init__(self, n_model, max_len=1024): super().__init__() self.embed = nn.Embedding(max_len, n_model) self.reset_parameters() @torch.no_grad() def reset_parameters(self): w = self.embed.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 import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_st...
yzhangcs/parser
PositionalEmbedding
false
16,787
[ "MIT" ]
439
3abebde1c9fe0bf2e99adce845aaf2a04b194f8a
https://github.com/yzhangcs/parser/tree/3abebde1c9fe0bf2e99adce845aaf2a04b194f8a
KernelConv
import torch import torch.nn as nn import torch.nn.functional as F class KernelConv(nn.Module): """ the class of computing prediction """ def __init__(self, kernel_size=[5], sep_conv=False, core_bias=False): super(KernelConv, self).__init__() self.kernel_size = sorted(kernel_size) ...
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...
xenbaloch/efficientderain
KernelConv
false
16,788
[ "MIT" ]
109
d5646815fd14a5a03c859102ecd2f298db7e53be
https://github.com/xenbaloch/efficientderain/tree/d5646815fd14a5a03c859102ecd2f298db7e53be
SinusoidPositionalEmbedding
import torch import torch.nn as nn class SinusoidPositionalEmbedding(nn.Module): def forward(self, x): seq_len, n_model = x[0].shape pos = x.new_tensor(range(seq_len)).unsqueeze(-1) / 10000 ** (x. new_tensor(range(n_model)) // 2 * 2 / n_model) pos[:, 0::2], pos[:, 1::2] = pos[...
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...
yzhangcs/parser
SinusoidPositionalEmbedding
false
16,789
[ "MIT" ]
439
3abebde1c9fe0bf2e99adce845aaf2a04b194f8a
https://github.com/yzhangcs/parser/tree/3abebde1c9fe0bf2e99adce845aaf2a04b194f8a
OfflineTripletLoss
import torch import torch.nn.functional as F from torch import nn class OfflineTripletLoss(nn.Module): """ Triplet loss Takes embeddings of an anchor sample, a positive sample and a negative sample """ def __init__(self, margin=0.1): super(OfflineTripletLoss, self).__init__() 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 import nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empt...
zhangxinyu-tj/PAST
OfflineTripletLoss
false
16,790
[ "MIT" ]
112
67f1f7a780e869aa7867167538edb03faa96dec5
https://github.com/zhangxinyu-tj/PAST/tree/67f1f7a780e869aa7867167538edb03faa96dec5
SinusoidRelativePositionalEmbedding
import torch import torch.nn as nn class SinusoidRelativePositionalEmbedding(nn.Module): def forward(self, x): seq_len, n_model = x[0].shape pos = x.new_tensor(range(seq_len)) pos = (pos - pos.unsqueeze(-1)).unsqueeze(-1) / 10000 ** (x. new_tensor(range(n_model)) // 2 * 2 / n_...
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...
yzhangcs/parser
SinusoidRelativePositionalEmbedding
false
16,791
[ "MIT" ]
439
3abebde1c9fe0bf2e99adce845aaf2a04b194f8a
https://github.com/yzhangcs/parser/tree/3abebde1c9fe0bf2e99adce845aaf2a04b194f8a
SoftCrossEntropy
import torch from torch import nn import torch.nn.functional as F class SoftCrossEntropy(nn.Module): def __init__(self): super().__init__() def forward(self, inputs, target): log_likelihood = -F.log_softmax(inputs, dim=1) sample_num, _class_num = target.shape loss = torch.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 from torch._inductor.runtime.triton_helpers import math as tl_math from torch import nn a...
zake7749/WSDM-Cup-2019
SoftCrossEntropy
false
16,792
[ "Apache-2.0" ]
64
5e9c9ae4197a5dedf6dbccc712bb2bbaae99edee
https://github.com/zake7749/WSDM-Cup-2019/tree/5e9c9ae4197a5dedf6dbccc712bb2bbaae99edee
Quantization
import torch import torch.nn as nn class Quant(torch.autograd.Function): @staticmethod def forward(ctx, input): input = torch.clamp(input, 0, 1) output = (input * 255.0).round() / 255.0 return output @staticmethod def backward(ctx, grad_output): return grad_output c...
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...
yzxing87/Invertible-ISP
Quantization
false
16,793
[ "MIT" ]
246
344dd333dd2a075f6a9e4ffc445dc387ca3014c4
https://github.com/yzxing87/Invertible-ISP/tree/344dd333dd2a075f6a9e4ffc445dc387ca3014c4
SoftMarginTriplet
import torch import torch.nn.functional as F from torch.nn.modules.loss import _Loss class SoftMarginTriplet(_Loss): __constants__ = ['reduction'] """ inputs `x1`, `x2`, two 1D mini-batch `Tensor`s, and a label 1D mini-batch tensor `y` with values (`1` or `-1`). If `y == 1` then it assumed the fi...
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.nn.modules.loss import _Loss assert_size_stride = torch._C._dynamo.guards.asse...
zhangxinyu-tj/PAST
SoftMarginTriplet
false
16,794
[ "MIT" ]
112
67f1f7a780e869aa7867167538edb03faa96dec5
https://github.com/zhangxinyu-tj/PAST/tree/67f1f7a780e869aa7867167538edb03faa96dec5
BCELoss
import torch import torch.distributed import torch import torch.nn as nn import torch.nn.functional as F import torch.nn.functional import torch.utils.data import torch.optim import torch.optim.lr_scheduler def bce_loss(pred, target, use_sigmoid=True): """Quality Focal Loss (QFL) is from `Generalized Focal Loss: ...
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...
zhangzhengde0225/SwinTrack
BCELoss
false
16,795
[ "MIT" ]
143
526be17f8ef266cb924c6939bd8dda23e9b73249
https://github.com/zhangzhengde0225/SwinTrack/tree/526be17f8ef266cb924c6939bd8dda23e9b73249
DotAttention
import torch import torch.nn as nn import torch.nn.init as init import torch.nn.functional as F class DotAttention(nn.Module): def __init__(self, hidden_size): super(DotAttention, self).__init__() self.hidden_size = hidden_size self.attn_vector = nn.Parameter(torch.Tensor(1, 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 import triton_helpers from torch._inductor.runtime....
zake7749/DeepToxic
DotAttention
false
16,796
[ "MIT" ]
206
92710446c55fe60526099f808a7e1179402e199f
https://github.com/zake7749/DeepToxic/tree/92710446c55fe60526099f808a7e1179402e199f
IoULoss
import torch import torch.distributed import torch import torch.nn as nn import torch.nn.functional import torch.utils.data import torch.optim import torch.optim.lr_scheduler def fp16_clamp(x, min=None, max=None): if not x.is_cuda and x.dtype == torch.float16: return x.float().clamp(min, max).half() 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 from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import math as tl_math import torch.distribut...
zhangzhengde0225/SwinTrack
IoULoss
false
16,797
[ "MIT" ]
143
526be17f8ef266cb924c6939bd8dda23e9b73249
https://github.com/zhangzhengde0225/SwinTrack/tree/526be17f8ef266cb924c6939bd8dda23e9b73249
DIoULoss
import torch import torch.distributed import torch import torch.nn as nn import torch.nn.functional import torch.utils.data import torch.optim import torch.optim.lr_scheduler def diou(pred, target, eps=1e-07): lt = torch.max(pred[:, :2], target[:, :2]) rb = torch.min(pred[:, 2:], target[:, 2:]) wh = (rb -...
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.distributed import torch import torch.nn as nn import torch.nn.functional im...
zhangzhengde0225/SwinTrack
DIoULoss
false
16,798
[ "MIT" ]
143
526be17f8ef266cb924c6939bd8dda23e9b73249
https://github.com/zhangzhengde0225/SwinTrack/tree/526be17f8ef266cb924c6939bd8dda23e9b73249
VarifocalLoss
import torch import torch.distributed import torch import torch.nn as nn import torch.nn.functional as F import torch.nn.functional import torch.utils.data import torch.optim import torch.optim.lr_scheduler def varifocal_loss(pred, target, alpha=0.75, gamma=2.0, iou_weighted=True, use_sigmoid=True): """`Varif...
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...
zhangzhengde0225/SwinTrack
VarifocalLoss
false
16,799
[ "MIT" ]
143
526be17f8ef266cb924c6939bd8dda23e9b73249
https://github.com/zhangzhengde0225/SwinTrack/tree/526be17f8ef266cb924c6939bd8dda23e9b73249
CXLoss
import torch import torch.nn as nn import torch.nn.functional as F import torch.nn.parallel import torch.utils.data class CXLoss(nn.Module): def __init__(self, sigma=0.1, b=1.0, similarity='consine'): super(CXLoss, self).__init__() self.similarity = similarity self.sigma = sigma 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 import triton_helpers from torch._inductor.runtime....
yizhiwang96/deepvecfont
CXLoss
false
16,800
[ "MIT" ]
68
3ba4adb0406f16a6f387c5e12dd12286c9c341e8
https://github.com/yizhiwang96/deepvecfont/tree/3ba4adb0406f16a6f387c5e12dd12286c9c341e8
MaskedMHCA
import math import torch import torch.nn as nn import torch.utils.data from torch.nn import functional as F class LayerNorm(nn.Module): """ LayerNorm that supports inputs of size B, C, T """ def __init__(self, num_channels, eps=1e-05, affine=True, device=None, dtype=None): super().__i...
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....
yjh0410/actionformer_release
MaskedMHCA
false
16,801
[ "MIT" ]
61
7a97422111d3e29c8d2e14088c850c6975855ea7
https://github.com/yjh0410/actionformer_release/tree/7a97422111d3e29c8d2e14088c850c6975855ea7
Attention
import torch import torch.utils.data import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.utils import weight_norm class FCNet(nn.Module): def __init__(self, in_size, out_size, activate=None, drop=0.0): super(FCNet, self).__init__() self.lin = weight_norm(nn.Linear(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....
zaynmi/semantic-equivalent-da-for-vqa
Attention
false
16,802
[ "MIT" ]
298
f121fb3e8fee8af5f1935a7526f19e0d884bd95b
https://github.com/zaynmi/semantic-equivalent-da-for-vqa/tree/f121fb3e8fee8af5f1935a7526f19e0d884bd95b
EltwiseProdScoring
import torch import torch.nn as nn class EltwiseProdScoring(nn.Module): """ Linearly mapping h and v to the same dimension, and do a elementwise multiplication and a linear scoring """ def __init__(self, h_dim, a_dim, dot_dim=256): """Initialize layer.""" super(EltwiseProdScoring,...
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...
zhangybzbo/speaker_follower
EltwiseProdScoring
false
16,803
[ "BSD-2-Clause", "MIT" ]
117
e4d109ee26b2f57066adc9720443abf842ee9a9d
https://github.com/zhangybzbo/speaker_follower/tree/e4d109ee26b2f57066adc9720443abf842ee9a9d
RelativePositionalEmbedding
import torch import torch.nn as nn class RelativePositionalEmbedding(nn.Module): def __init__(self, n_model, max_len=1024): super().__init__() self.embed = nn.Embedding(max_len, n_model) self.reset_parameters() @torch.no_grad() def reset_parameters(self): w = self.embed.w...
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...
yzhangcs/parser
RelativePositionalEmbedding
false
16,804
[ "MIT" ]
439
3abebde1c9fe0bf2e99adce845aaf2a04b194f8a
https://github.com/yzhangcs/parser/tree/3abebde1c9fe0bf2e99adce845aaf2a04b194f8a
Classifier
import torch import torch.utils.data import torch import torch.nn as nn from torch.nn.utils import weight_norm class FCNet(nn.Module): def __init__(self, in_size, out_size, activate=None, drop=0.0): super(FCNet, self).__init__() self.lin = weight_norm(nn.Linear(in_size, out_size), dim=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 from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
zaynmi/semantic-equivalent-da-for-vqa
Classifier
false
16,805
[ "MIT" ]
298
f121fb3e8fee8af5f1935a7526f19e0d884bd95b
https://github.com/zaynmi/semantic-equivalent-da-for-vqa/tree/f121fb3e8fee8af5f1935a7526f19e0d884bd95b
GumbelSigmoid
import torch import torch.nn as nn class GumbelSigmoid(nn.Module): def __init__(self, max_T, decay_alpha): super(GumbelSigmoid, self).__init__() self.max_T = max_T self.decay_alpha = decay_alpha self.softmax = nn.Softmax(dim=1) self.p_value = 1e-08 self.register_bu...
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 import triton_helpers from torch._inductor.runtime.triton_helpers import math as tl_ma...
zdaxie/SpatiallyAdaptiveInference-Detection
GumbelSigmoid
false
16,806
[ "Apache-2.0" ]
55
323801deac6f0641d00ecb23f6885df8483cc447
https://github.com/zdaxie/SpatiallyAdaptiveInference-Detection/tree/323801deac6f0641d00ecb23f6885df8483cc447
AdaptiveInstanceNorm
import torch import torch.utils.data import torch import torch.nn as nn import torch.sparse class AdaptiveInstanceNorm(nn.Module): def __init__(self, in_channel, style_dim): super().__init__() self.norm = nn.InstanceNorm2d(in_channel) self.linear = nn.Linear(style_dim, in_channel * 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 import torch.utils....
zhengqili/Crowdsampling-the-Plenoptic-Function
AdaptiveInstanceNorm
false
16,807
[ "MIT" ]
70
3164e9f9574d597690f83dfdfb34cc470d2dcb88
https://github.com/zhengqili/Crowdsampling-the-Plenoptic-Function/tree/3164e9f9574d597690f83dfdfb34cc470d2dcb88