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 |
|---|---|---|---|---|---|---|---|---|---|---|
RelativeMargin | import torch
import torch.nn as nn
class RelativeMargin(nn.Module):
def __init__(self):
super(RelativeMargin, self).__init__()
def forward(self, x1, x2, y1, y2, t, reduce=True):
if reduce:
loss = torch.mean(torch.clamp(torch.abs(y1 - y2) - t * (x1 - x2
), 0.0))
... | 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
... | UKPLab/ijcai2019-relis | RelativeMargin | false | 18,025 | [
"MIT"
] | 5 | 8a40762dcfa90c075a4f6591cbdceb468026ef17 | https://github.com/UKPLab/ijcai2019-relis/tree/8a40762dcfa90c075a4f6591cbdceb468026ef17 |
TVLoss | import torch
from torch import nn
class TVLoss(nn.Module):
"""
Total variation loss.
"""
def __init__(self):
super(TVLoss, self).__init__()
def forward(self, yhat, y):
_bsize, _chan, height, width = y.size()
dyh = torch.abs(y[:, :, 1:, :] - y[:, :, :-1, :])
dyhath... | 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
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_... | TiagoCortinhal/SR_GAN | TVLoss | false | 18,026 | [
"MIT"
] | 4 | 9ccceaa25e87e404d20825dbb552fa6a2ef3af47 | https://github.com/TiagoCortinhal/SR_GAN/tree/9ccceaa25e87e404d20825dbb552fa6a2ef3af47 |
SoftDetectionModule | import torch
import torch.nn.functional as F
import torch.nn as nn
class SoftDetectionModule(nn.Module):
def __init__(self, soft_local_max_size=3):
super(SoftDetectionModule, self).__init__()
self.soft_local_max_size = soft_local_max_size
self.pad = self.soft_local_max_size // 2
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 math as tl_math
import torch.nn as nn
... | UditSinghParihar/d2-net | SoftDetectionModule | false | 18,027 | [
"BSD-3-Clause-Clear"
] | 6 | b3592beebe6759cf4cc1acdfd23d603ef059ef30 | https://github.com/UditSinghParihar/d2-net/tree/b3592beebe6759cf4cc1acdfd23d603ef059ef30 |
FRN | import torch
import torch.nn as nn
class FRN(nn.Module):
def __init__(self, num_features, eps=1e-05):
super(FRN, self).__init__()
self.tau = nn.Parameter(torch.zeros(1, num_features, 1, 1))
self.gamma = nn.Parameter(torch.ones(1, num_features, 1, 1))
self.beta = nn.Parameter(torch... | 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... | UdonDa/StarGAN-v2-pytorch-nonofficial | FRN | false | 18,028 | [
"MIT"
] | 9 | 219df6b7fd4bd533686e2093ee914a337914ca9b | https://github.com/UdonDa/StarGAN-v2-pytorch-nonofficial/tree/219df6b7fd4bd533686e2093ee914a337914ca9b |
Discriminator | import torch
import torch.nn as nn
import torch.nn.functional as F
class Discriminator(nn.Module):
def __init__(self, in_dim, hidden_dim=100):
super(Discriminator, self).__init__()
self.fc1 = nn.Linear(in_dim, 256)
nn.init.xavier_normal(self.fc1.weight)
nn.init.constant(self.fc1.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
import torch.nn as nn
assert_... | Vahe1994/ThreeDLAPGAN | Discriminator | false | 18,029 | [
"MIT"
] | 6 | 7e8f20be9216bc741bbe22ed2a13c261f78db521 | https://github.com/Vahe1994/ThreeDLAPGAN/tree/7e8f20be9216bc741bbe22ed2a13c261f78db521 |
FocalLoss | import torch
from torchvision.transforms import functional as F
from torch import nn
import torch.nn.functional as F
class FocalLoss(nn.Module):
def __init__(self, gamma: 'int'=2) ->None:
super().__init__()
self.gamma = gamma
def forward(self, output: 'torch.Tensor', target: 'torch.Tensor'
... | 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
from torch ... | TylerYep/ml-toolkit | FocalLoss | false | 18,030 | [
"MIT"
] | 7 | 095bdce961133acc720f90b6d1bbb0a7becbfc9f | https://github.com/TylerYep/ml-toolkit/tree/095bdce961133acc720f90b6d1bbb0a7becbfc9f |
Block_local | import math
import torch
import numpy as np
from torch import nn
from torch.nn.modules.utils import _pair
from functools import partial
import torch.utils.data
import torch.nn.parallel
from torch import optim as optim
def drop_path(x, drop_prob: 'float'=0.0, training: 'bool'=False):
"""Drop paths (Stochastic Dept... | 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.... | TencentYoutuResearch/BaseArchitecture-EAT | Block_local | false | 18,031 | [
"BSD-3-Clause"
] | 9 | b916738ef9b1314f5fdad780a0839cb4e010a208 | https://github.com/TencentYoutuResearch/BaseArchitecture-EAT/tree/b916738ef9b1314f5fdad780a0839cb4e010a208 |
BatchMLP | import torch
from torch import nn
class NPBlockRelu2d(nn.Module):
"""Block for Neural Processes."""
def __init__(self, in_channels, out_channels, dropout=0, batchnorm=
False, bias=False):
super().__init__()
self.linear = nn.Linear(in_channels, out_channels, bias=bias)
self.act... | 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... | VersElectronics/Neural-Processes | BatchMLP | false | 18,032 | [
"MIT"
] | 5 | 6eb7552a0d1c489189d6dd0f83704dcdbeaed24b | https://github.com/VersElectronics/Neural-Processes/tree/6eb7552a0d1c489189d6dd0f83704dcdbeaed24b |
DropConnect | import torch
class DropConnect(torch.nn.Module):
def __init__(self, p):
super(DropConnect, self).__init__()
self.p = p
def forward(self, inputs):
batch_size = inputs.shape[0]
inputs.shape[2]
inputs.shape[3]
channel_size = inputs.shape[1]
keep_prob = 1 ... | import torch
from torch import device
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
assert_size_stride = torch._C._dynamo.guards.assert_si... | VascoLopes/GEA | DropConnect | false | 18,033 | [
"MIT"
] | 4 | ab80dbb9851dfc215102e5222e8d5f70e855dd15 | https://github.com/VascoLopes/GEA/tree/ab80dbb9851dfc215102e5222e8d5f70e855dd15 |
Block_cls | import torch
from torch import nn
from functools import partial
import torch.utils.data
import torch.nn.parallel
from torch import optim as optim
def drop_path(x, drop_prob: 'float'=0.0, training: 'bool'=False):
"""Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks).
This ... | 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.... | TencentYoutuResearch/BaseArchitecture-EAT | Block_cls | false | 18,034 | [
"BSD-3-Clause"
] | 9 | b916738ef9b1314f5fdad780a0839cb4e010a208 | https://github.com/TencentYoutuResearch/BaseArchitecture-EAT/tree/b916738ef9b1314f5fdad780a0839cb4e010a208 |
Classifier | import torch
import torch.nn as nn
import torch.utils.data
class Classifier(nn.Module):
def __init__(self, feature_dim, classes):
super(Classifier, self).__init__()
self.classifier = nn.Linear(int(feature_dim * 2), classes)
def forward(self, di_z, ds_z):
z = torch.cat((di_z, ds_z), d... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
import torch.utils.data
assert_size_stride = torch._C._dyn... | VinAIResearch/mDSDI | Classifier | false | 18,035 | [
"Apache-2.0"
] | 9 | 8ec49085d8389ab490ec633c3ae4bf66be085366 | https://github.com/VinAIResearch/mDSDI/tree/8ec49085d8389ab490ec633c3ae4bf66be085366 |
AdaFRN | import torch
import torch.nn as nn
class AdaFRN(nn.Module):
def __init__(self, style_dim, num_features, eps=1e-05):
super(AdaFRN, self).__init__()
self.tau = nn.Parameter(torch.zeros(1, num_features, 1, 1))
self.fc = nn.Linear(style_dim, num_features * 2)
self.eps = eps
def f... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | UdonDa/StarGAN-v2-pytorch-nonofficial | AdaFRN | false | 18,036 | [
"MIT"
] | 9 | 219df6b7fd4bd533686e2093ee914a337914ca9b | https://github.com/UdonDa/StarGAN-v2-pytorch-nonofficial/tree/219df6b7fd4bd533686e2093ee914a337914ca9b |
LayerNormalization | import torch
from torch import nn
class LayerNormalization(nn.Module):
def __init__(self, d_hid, eps=0.001):
super(LayerNormalization, self).__init__()
self.gamma = nn.Parameter(torch.ones(d_hid), requires_grad=True)
self.beta = nn.Parameter(torch.zeros(d_hid), requires_grad=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.triton_helpers import libdevice
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | VarnithChordia/Multlingual_Punctuation_restoration | LayerNormalization | false | 18,037 | [
"MIT"
] | 8 | 17c026e8935b9fecae01d446a756926c7733fcd1 | https://github.com/VarnithChordia/Multlingual_Punctuation_restoration/tree/17c026e8935b9fecae01d446a756926c7733fcd1 |
DiceLoss | import torch
from torch import nn
class DiceLoss(nn.Module):
def __init__(self, eps: 'int'=1) ->None:
super().__init__()
self.eps = eps
def forward(self, output: 'torch.Tensor', target: 'torch.Tensor'
) ->torch.Tensor:
batch_size = output.shape[0]
dice_target = target... | 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
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_... | TylerYep/ml-toolkit | DiceLoss | false | 18,038 | [
"MIT"
] | 7 | 095bdce961133acc720f90b6d1bbb0a7becbfc9f | https://github.com/TylerYep/ml-toolkit/tree/095bdce961133acc720f90b6d1bbb0a7becbfc9f |
GAP1d | import torch
from torch import nn
import torch.nn.functional
class Flatten(nn.Module):
def forward(self, x):
return x.view(x.size(0), -1)
class GAP1d(nn.Module):
"""Global Adaptive Pooling + Flatten
"""
def __init__(self, output_size=1):
super(GAP1d, self).__init__()
self.g... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
import torch.nn.functional
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._... | VincentSch4rf/torchtime | GAP1d | false | 18,039 | [
"Apache-2.0"
] | 4 | bebd006cd67b31c342e0658285c9771c27411df0 | https://github.com/VincentSch4rf/torchtime/tree/bebd006cd67b31c342e0658285c9771c27411df0 |
LRN | import torch
import torch.nn as nn
import torch.utils.data
class LRN(nn.Module):
def __init__(self, local_size=1, alpha=1.0, beta=0.75, ACROSS_CHANNELS=True
):
super(LRN, self).__init__()
self.ACROSS_CHANNELS = ACROSS_CHANNELS
if ACROSS_CHANNELS:
self.average = nn.AvgP... | 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... | VisionLearningGroup/CDS | LRN | false | 18,040 | [
"MIT"
] | 7 | 5b3644c286f19f76acdc03c6f6021a6f6e4ec4fc | https://github.com/VisionLearningGroup/CDS/tree/5b3644c286f19f76acdc03c6f6021a6f6e4ec4fc |
BinaryFocalLoss | import torch
import torch.nn as nn
def binary_focal_loss(pred, target, gamma=2.0, alpha=-1, reduction='mean'):
p = torch.sigmoid(pred)
loss_pos = -target * (1.0 - p) ** gamma * torch.log(p + 1e-09)
loss_neg = -(1.0 - target) * p ** gamma * torch.log(1.0 - p + 1e-09)
if alpha >= 0.0 and alpha <= 1.0:
... | 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
... | VisualComputingInstitute/Person_MinkUNet | BinaryFocalLoss | false | 18,041 | [
"MIT"
] | 4 | fa39764245a022740c0a3d8c85026532fff93e74 | https://github.com/VisualComputingInstitute/Person_MinkUNet/tree/fa39764245a022740c0a3d8c85026532fff93e74 |
LayerNorm | import torch
from torch import nn
class LayerNorm(nn.Module):
"""
Simple 1D LayerNorm.
"""
def __init__(self, features, center=True, scale=False, eps=1e-06):
super().__init__()
self.center = center
self.scale = scale
self.eps = eps
if self.scale:
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 libdevice
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | UT-Austin-RPL/maple | LayerNorm | false | 18,042 | [
"MIT"
] | 9 | aef9fe9869945df5bbd1b02fd40813aac135cf5a | https://github.com/UT-Austin-RPL/maple/tree/aef9fe9869945df5bbd1b02fd40813aac135cf5a |
SAM_Module | import torch
import torch.nn as nn
from torchvision.transforms import *
class SAM_Module(nn.Module):
""" Position attention module"""
def __init__(self, channels):
super(SAM_Module, self).__init__()
self.relu = nn.ReLU(inplace=True)
self.conv_after_concat = nn.Conv2d(1, 1, 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
import torch.nn as nn
from torchvision.transforms import *
assert_size_stride = ... | Vill-Lab/IGOAS | SAM_Module | false | 18,043 | [
"MIT"
] | 8 | 42ca1d45e441f993c95b5e8f33c9f97ea3b916f3 | https://github.com/Vill-Lab/IGOAS/tree/42ca1d45e441f993c95b5e8f33c9f97ea3b916f3 |
Normalize | import torch
from torch import Tensor
from typing import Tuple
import torch.nn.functional as F
import torch.nn.functional
class Normalize(torch.nn.Module):
"""Normalize a tensor time series with mean and standard deviation.
Given mean: ``(mean[1],...,mean[n])`` and std: ``(std[1],..,std[n])`` for ``n``
ch... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
from typing import Tuple
imp... | VincentSch4rf/torchtime | Normalize | false | 18,044 | [
"Apache-2.0"
] | 4 | bebd006cd67b31c342e0658285c9771c27411df0 | https://github.com/VincentSch4rf/torchtime/tree/bebd006cd67b31c342e0658285c9771c27411df0 |
LinearAverage | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
class LinearAverage(nn.Module):
def __init__(self, inputSize, outputSize, T=0.05, momentum=0.5):
super(LinearAverage, self).__init__()
self.nLem = outputSize
self.momentum = momentum
self.re... | 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
import torch.utils.data
as... | VisionLearningGroup/CDS | LinearAverage | false | 18,045 | [
"MIT"
] | 7 | 5b3644c286f19f76acdc03c6f6021a6f6e4ec4fc | https://github.com/VisionLearningGroup/CDS/tree/5b3644c286f19f76acdc03c6f6021a6f6e4ec4fc |
L2Norm | import torch
import torch.nn as nn
import torch.utils.data
import torch.nn.init as init
class L2Norm(nn.Module):
def __init__(self, n_channels, scale):
super(L2Norm, self).__init__()
self.n_channels = n_channels
self.gamma = scale or None
self.eps = 1e-10
self.weight = 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
import torch.utils.data
import torch.nn.init as init
asse... | VisionLearningGroup/CDS | L2Norm | false | 18,046 | [
"MIT"
] | 7 | 5b3644c286f19f76acdc03c6f6021a6f6e4ec4fc | https://github.com/VisionLearningGroup/CDS/tree/5b3644c286f19f76acdc03c6f6021a6f6e4ec4fc |
UNetUpsamplingBlock | import torch
import torch.nn as nn
import torch.nn.functional as F
class UNetUpsamplingBlock(nn.Module):
def __init__(self, in_channels, out_channels):
super(UNetUpsamplingBlock, self).__init__()
params = {'kernel_size': 3, 'stride': 1, 'padding': 1, 'bias': True}
self.conv = nn.Conv2d(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.... | TropComplique/bicycle-gan | UNetUpsamplingBlock | false | 18,047 | [
"MIT"
] | 4 | 4bc8f4cdbe138e23c8a02c408cfb8e2ff7dfe6ab | https://github.com/TropComplique/bicycle-gan/tree/4bc8f4cdbe138e23c8a02c408cfb8e2ff7dfe6ab |
_BahdanauAttention | import math
import torch
from torch import nn
from torch.nn import functional
class _BahdanauAttention(nn.Module):
def __init__(self, method, hidden_size):
super(_BahdanauAttention, self).__init__()
self.method = method
self.hidden_size = hidden_size
self.attn = nn.Linear(self.hid... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | VarnithChordia/Multlingual_Punctuation_restoration | _BahdanauAttention | false | 18,048 | [
"MIT"
] | 8 | 17c026e8935b9fecae01d446a756926c7733fcd1 | https://github.com/VarnithChordia/Multlingual_Punctuation_restoration/tree/17c026e8935b9fecae01d446a756926c7733fcd1 |
loss_shape_exp | import torch
import torch.nn as nn
class loss_shape_exp(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x, y, beta=2):
return torch.mean(torch.exp(beta * y) * torch.pow(x - y, 2))
def get_inputs():
return [torch.rand([4, 4, 4, 4]), torch.rand([4, 4, 4, 4])]
def g... | 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
... | Tsinghua-gongjing/StructureImpute | loss_shape_exp | false | 18,049 | [
"MIT"
] | 9 | 59e33e913998a8841c2cb552828f0f0cc19ebc21 | https://github.com/Tsinghua-gongjing/StructureImpute/tree/59e33e913998a8841c2cb552828f0f0cc19ebc21 |
ResBlk | import torch
import torch.nn as nn
import torch.nn.functional as F
class FRN(nn.Module):
def __init__(self, num_features, eps=1e-05):
super(FRN, self).__init__()
self.tau = nn.Parameter(torch.zeros(1, num_features, 1, 1))
self.gamma = nn.Parameter(torch.ones(1, num_features, 1, 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.... | UdonDa/StarGAN-v2-pytorch-nonofficial | ResBlk | false | 18,050 | [
"MIT"
] | 9 | 219df6b7fd4bd533686e2093ee914a337914ca9b | https://github.com/UdonDa/StarGAN-v2-pytorch-nonofficial/tree/219df6b7fd4bd533686e2093ee914a337914ca9b |
TransformerEncoderLayer | import math
import torch
import warnings
from torch import Tensor
import torch.nn as nn
from torch.nn.parameter import Parameter
from torch.nn.init import xavier_uniform_
from torch.nn.init import constant_
import torch.nn.functional as F
from typing import Optional
from typing import Tuple
from typing import List
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
from torch._inductor.runtime.... | Treedy2020/TransNet | TransformerEncoderLayer | false | 18,051 | [
"MIT"
] | 4 | dd0e43e1931153baea4e5fe8cb31dc5ff0cb7b09 | https://github.com/Treedy2020/TransNet/tree/dd0e43e1931153baea4e5fe8cb31dc5ff0cb7b09 |
BertSelfAttention | from _paritybench_helpers import _mock_config
import math
import torch
from torch import nn
class BertSelfAttention(nn.Module):
def __init__(self, config):
super(BertSelfAttention, self).__init__()
if config.hidden_size % config.num_attention_heads != 0:
raise ValueError(
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | Ahren09/FinerFact | BertSelfAttention | false | 18,052 | [
"MIT"
] | 9 | 68df3799fbfadd56fa69b019ca6fba0c482f21d3 | https://github.com/Ahren09/FinerFact/tree/68df3799fbfadd56fa69b019ca6fba0c482f21d3 |
TransformerDecoderLayer | import math
import torch
import warnings
from torch import Tensor
import torch.nn as nn
from torch.nn.parameter import Parameter
from torch.nn.init import xavier_uniform_
from torch.nn.init import constant_
import torch.nn.functional as F
from typing import Optional
from typing import Tuple
from typing import List
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
from torch._inductor.runtime.... | Treedy2020/TransNet | TransformerDecoderLayer | false | 18,053 | [
"MIT"
] | 4 | dd0e43e1931153baea4e5fe8cb31dc5ff0cb7b09 | https://github.com/Treedy2020/TransNet/tree/dd0e43e1931153baea4e5fe8cb31dc5ff0cb7b09 |
distLinear | import torch
import torch.nn as nn
from torch.nn.utils.weight_norm import WeightNorm
import torch.utils.data
class distLinear(nn.Module):
def __init__(self, indim, outdim):
super(distLinear, self).__init__()
self.L = nn.Linear(indim, outdim, bias=False)
self.class_wise_learnable_norm = Fa... | 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 ... | VisionLearningGroup/CDS | distLinear | false | 18,054 | [
"MIT"
] | 7 | 5b3644c286f19f76acdc03c6f6021a6f6e4ec4fc | https://github.com/VisionLearningGroup/CDS/tree/5b3644c286f19f76acdc03c6f6021a6f6e4ec4fc |
BertAttention | from _paritybench_helpers import _mock_config
import math
import torch
import torch.nn as nn
class BertLayerNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-12):
super(BertLayerNorm, self).__init__()
self.weight = nn.Parameter(torch.ones(hidden_size))
self.bias = nn.Parameter(torch... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | Vitvicky/mrc-for-flat-nested-ner | BertAttention | false | 18,055 | [
"Apache-2.0"
] | 9 | 37099625e3002c334884fe982a6476e2c783da63 | https://github.com/Vitvicky/mrc-for-flat-nested-ner/tree/37099625e3002c334884fe982a6476e2c783da63 |
ContrastiveLoss | import torch
import torch.nn.functional as F
class ContrastiveLoss(torch.nn.Module):
def __init__(self, margin=2.0):
super(ContrastiveLoss, self).__init__()
self.margin = margin
def forward(self, output1, output2, label):
euclidean_distance = F.pairwise_distance(output1, output2)
... | 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
assert_size_stride = torch._... | WLYLab/PepFormer | ContrastiveLoss | false | 18,056 | [
"MIT"
] | 6 | 9bac4544dc88bcd66e975a6714a264dcc9c55304 | https://github.com/WLYLab/PepFormer/tree/9bac4544dc88bcd66e975a6714a264dcc9c55304 |
WeightNet | import torch
import torch.nn as nn
class WeightNet(nn.Module):
"""WeightNet in Temporal interlace module.
The WeightNet consists of two parts: one convolution layer
and a sigmoid function. Following the convolution layer, the sigmoid
function and rescale module can scale our output to the range (0, 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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | Viditagarwal7479/Video-Swin-Transformer | WeightNet | false | 18,057 | [
"Apache-2.0"
] | 9 | 37910ef3141c7b2eef76544f9ec8bdf26ec94c7d | https://github.com/Viditagarwal7479/Video-Swin-Transformer/tree/37910ef3141c7b2eef76544f9ec8bdf26ec94c7d |
PatchMerging | import torch
import torch.nn.functional as F
import torch.nn as nn
class PatchMerging(nn.Module):
""" Patch Merging Layer
Args:
dim (int): Number of input channels.
norm_layer (nn.Module, optional): Normalization layer. Default: nn.LayerNorm
"""
def __init__(self, dim, norm_layer=nn.... | 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 ... | Viditagarwal7479/Video-Swin-Transformer | PatchMerging | false | 18,058 | [
"Apache-2.0"
] | 9 | 37910ef3141c7b2eef76544f9ec8bdf26ec94c7d | https://github.com/Viditagarwal7479/Video-Swin-Transformer/tree/37910ef3141c7b2eef76544f9ec8bdf26ec94c7d |
TripletLoss | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import *
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, descend... | 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.... | WangWenhao0716/DomainMix | TripletLoss | false | 18,059 | [
"MIT"
] | 8 | 2d9a20c1536177d1d71fbdc99f714eaf98fdfe92 | https://github.com/WangWenhao0716/DomainMix/tree/2d9a20c1536177d1d71fbdc99f714eaf98fdfe92 |
PatchEmbed3D | import torch
import torch.nn.functional as F
import torch.nn as nn
class PatchEmbed3D(nn.Module):
""" Video to Patch Embedding.
Args:
patch_size (int): Patch token size. Default: (2,4,4).
in_chans (int): Number of input video channels. Default: 3.
embed_dim (int): Number of linear proj... | 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... | Viditagarwal7479/Video-Swin-Transformer | PatchEmbed3D | false | 18,060 | [
"Apache-2.0"
] | 9 | 37910ef3141c7b2eef76544f9ec8bdf26ec94c7d | https://github.com/Viditagarwal7479/Video-Swin-Transformer/tree/37910ef3141c7b2eef76544f9ec8bdf26ec94c7d |
RobertaClassificationHead | from _paritybench_helpers import _mock_config
import torch
import torch.nn as nn
class RobertaClassificationHead(nn.Module):
"""Head for sentence-level classification tasks."""
def __init__(self, config):
super().__init__()
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
import torch.nn as ... | Amber-Chaeeunk/Open-Domain-Question-Answering | RobertaClassificationHead | false | 18,061 | [
"MIT"
] | 5 | 725e369a4409c54bf11bcfb9db53865d8fc1f935 | https://github.com/Amber-Chaeeunk/Open-Domain-Question-Answering/tree/725e369a4409c54bf11bcfb9db53865d8fc1f935 |
TemporallyBatchedAdditiveAttention | import torch
import torch.nn as nn
import torch.nn.functional as F
class AdditiveAttention(nn.Module):
def __init__(self, encoder_hidden_state_dim, decoder_hidden_state_dim,
internal_dim=None):
super(AdditiveAttention, self).__init__()
if internal_dim is None:
internal_dim = 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.... | Vision-CAIR/HalentNet | TemporallyBatchedAdditiveAttention | false | 18,062 | [
"MIT"
] | 4 | dedef73c57c63aa580fc497fa42d512f4241a64b | https://github.com/Vision-CAIR/HalentNet/tree/dedef73c57c63aa580fc497fa42d512f4241a64b |
FocalLoss | import torch
import torch.nn as nn
import torch.nn.functional as F
class FocalLoss(nn.Module):
def __init__(self, alpha: 'float'=0.25, gamma: 'float'=2, reduction:
'str'='none'):
"""
Original implementation from https://github.com/facebookresearch/fvcore/blob/master/fvcore/nn/focal_loss.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... | VisualJoyce/ChengyuBERT | FocalLoss | false | 18,063 | [
"MIT"
] | 8 | 605db3a4b3241dd4d02baa41a68bf23b5b00b36d | https://github.com/VisualJoyce/ChengyuBERT/tree/605db3a4b3241dd4d02baa41a68bf23b5b00b36d |
BMNLoss | import torch
import torch.nn.functional as F
import torch.nn as nn
def binary_logistic_regression_loss(reg_score, label, threshold=0.5,
ratio_range=(1.05, 21), eps=1e-05):
"""Binary Logistic Regression Loss."""
label = label.view(-1)
reg_score = reg_score.contiguous().view(-1)
pmask = (label > thr... | 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... | Viditagarwal7479/Video-Swin-Transformer | BMNLoss | false | 18,064 | [
"Apache-2.0"
] | 9 | 37910ef3141c7b2eef76544f9ec8bdf26ec94c7d | https://github.com/Viditagarwal7479/Video-Swin-Transformer/tree/37910ef3141c7b2eef76544f9ec8bdf26ec94c7d |
LanguageModelCriterion | import torch
import torch.nn as nn
from torch.autograd import *
import torch.nn.init
def to_contiguous(tensor):
if tensor.is_contiguous():
return tensor
else:
return tensor.contiguous()
class LanguageModelCriterion(nn.Module):
def __init__(self):
super(LanguageModelCriterion, 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
import torch.nn as nn
from torch.autograd import *
import torch.nn.init
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empt... | WuJie1010/Fine-Grained-Image-Captioning | LanguageModelCriterion | false | 18,065 | [
"MIT"
] | 9 | 340bc1868634f3bf0fdd62d439fec32ee1b45407 | https://github.com/WuJie1010/Fine-Grained-Image-Captioning/tree/340bc1868634f3bf0fdd62d439fec32ee1b45407 |
ImgAttention | from _paritybench_helpers import _mock_config
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import *
import torch.nn.init
class ImgAttention(nn.Module):
def __init__(self, opt):
super(ImgAttention, self).__init__()
self.rnn_size = opt.rnn_size
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.... | WuJie1010/Fine-Grained-Image-Captioning | ImgAttention | false | 18,066 | [
"MIT"
] | 9 | 340bc1868634f3bf0fdd62d439fec32ee1b45407 | https://github.com/WuJie1010/Fine-Grained-Image-Captioning/tree/340bc1868634f3bf0fdd62d439fec32ee1b45407 |
UNET | import torch
import torch.nn as nn
def concat(c1, c2):
return torch.cat([c1, c2], dim=1)
def conv1x1(in_c, out_c, k, s):
return nn.ConvTranspose2d(in_c, out_c, kernel_size=k, stride=s)
def conv3x3(in_c, out_c, k, s):
return nn.Conv2d(in_c, out_c, kernel_size=k, stride=s)
def cut(c1, c2):
x1, y1 ... | 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_... | TerenceChen95/Retina-Unet-Pytorch | UNET | false | 18,067 | [
"MIT"
] | 5 | fad5a9a0bcab5d81a0f1bb2537b9a2ead87828ca | https://github.com/TerenceChen95/Retina-Unet-Pytorch/tree/fad5a9a0bcab5d81a0f1bb2537b9a2ead87828ca |
MNIST_CNN | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
class MNIST_CNN(nn.Module):
def __init__(self):
super(MNIST_CNN, self).__init__()
self.conv1 = nn.Conv2d(1, 64, 3, 1, padding=1)
self.conv2 = nn.Conv2d(64, 128, 3, stride=2, padding=1)
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.... | VinAIResearch/mDSDI | MNIST_CNN | false | 18,068 | [
"Apache-2.0"
] | 9 | 8ec49085d8389ab490ec633c3ae4bf66be085366 | https://github.com/VinAIResearch/mDSDI/tree/8ec49085d8389ab490ec633c3ae4bf66be085366 |
CNNBlock | import torch
import torch.nn.functional as F
import torch.nn as nn
class CNNLayer(nn.Module):
"""Conv1d layer.
nn.Conv1d layer require the input shape is (batch_size, in_channels, length),
however, our input shape is (batch_size, length, in_channels), so we need to
transpose our input data into (B, 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
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | WiseDoge/Text-Classification-PyTorch | CNNBlock | false | 18,069 | [
"MIT"
] | 6 | 9371eeed6bd7ecf1d529c8f2a6c997fcde67a559 | https://github.com/WiseDoge/Text-Classification-PyTorch/tree/9371eeed6bd7ecf1d529c8f2a6c997fcde67a559 |
AttnLayer | import torch
import torch.nn.functional as F
import torch.nn as nn
class AttnLayer(nn.Module):
"""Attention layer.
w is context vector.
Formula:
$$
v_i=tanh(Wh_i+b)\\
lpha_i = v_i^Tw\\
lpha_i = softmax(lpha_i)\\
Vec = \\sum_0^L lpha_ih_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.... | WiseDoge/Text-Classification-PyTorch | AttnLayer | false | 18,070 | [
"MIT"
] | 6 | 9371eeed6bd7ecf1d529c8f2a6c997fcde67a559 | https://github.com/WiseDoge/Text-Classification-PyTorch/tree/9371eeed6bd7ecf1d529c8f2a6c997fcde67a559 |
knn_ContrastiveLoss | import torch
import torch.nn as nn
from torch.autograd import *
import torch.nn.init
def cosine_sim(im, s):
"""Cosine similarity between all the image and sentence pairs
"""
return im.mm(s.t())
def order_sim(im, s):
"""Order embeddings similarity measure $max(0, s-im)$
"""
YmX = s.unsqueeze(... | 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 to... | WuJie1010/Fine-Grained-Image-Captioning | knn_ContrastiveLoss | false | 18,071 | [
"MIT"
] | 9 | 340bc1868634f3bf0fdd62d439fec32ee1b45407 | https://github.com/WuJie1010/Fine-Grained-Image-Captioning/tree/340bc1868634f3bf0fdd62d439fec32ee1b45407 |
HuberLoss | import torch
from torch import nn
class HuberLoss(nn.Module):
def __init__(self, delta=1):
super().__init__()
self.huber_loss_delta1 = nn.SmoothL1Loss()
self.delta = delta
def forward(self, x, x_hat):
loss = self.huber_loss_delta1(x / self.delta, x_hat / self.delta)
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
from torch import nn
a... | UT-Austin-RPL/maple | HuberLoss | false | 18,072 | [
"MIT"
] | 9 | aef9fe9869945df5bbd1b02fd40813aac135cf5a | https://github.com/UT-Austin-RPL/maple/tree/aef9fe9869945df5bbd1b02fd40813aac135cf5a |
Conv1dSamePadding | import torch
import torch.nn.functional as F
import torch.nn as nn
class Conv1dSamePadding(nn.Conv1d):
"""
1D convolutional layer with "same" padding (no downsampling),
that is also compatible with strides > 1
"""
def __init__(self, *args, **kwargs):
super(Conv1dSamePadding, 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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | Wadaboa/titanet | Conv1dSamePadding | false | 18,073 | [
"MIT"
] | 4 | b07e3074e79ea8c1129fb0adb8315e06bb4943ea | https://github.com/Wadaboa/titanet/tree/b07e3074e79ea8c1129fb0adb8315e06bb4943ea |
Wang | import torch
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
class Wang(nn.Module):
"""Neural network model for linear combination of EDU scores.
"""
def __init__(self, nrels):
"""Class constructor.
Args:
nrels (int): total number of relations
... | 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... | WladimirSidorenko/DASA | Wang | false | 18,074 | [
"MIT"
] | 7 | 618d9060a5fd6f567628c8dec5e26943c8c49ad4 | https://github.com/WladimirSidorenko/DASA/tree/618d9060a5fd6f567628c8dec5e26943c8c49ad4 |
AdditiveAttention | import torch
import torch.nn as nn
import torch.nn.functional as F
class AdditiveAttention(nn.Module):
def __init__(self, encoder_hidden_state_dim, decoder_hidden_state_dim,
internal_dim=None):
super(AdditiveAttention, self).__init__()
if internal_dim is None:
internal_dim = 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.... | Vision-CAIR/HalentNet | AdditiveAttention | false | 18,075 | [
"MIT"
] | 4 | dedef73c57c63aa580fc497fa42d512f4241a64b | https://github.com/Vision-CAIR/HalentNet/tree/dedef73c57c63aa580fc497fa42d512f4241a64b |
SVM | import torch
import torch.nn as nn
class SVM(nn.Module):
def __init__(self, hidden_size):
super(SVM, self).__init__()
self.linear1 = nn.Linear(hidden_size, 1)
self.sigmoid = nn.Sigmoid()
def forward(self, x):
y = self.sigmoid(self.linear1(x))
return y.view(-1)
def g... | 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... | XIAOYEJIAYOU/GSAN | SVM | false | 18,076 | [
"MIT"
] | 6 | 8ca4fdf4c3d615af9cc10e1f9f22ceb7e27fe196 | https://github.com/XIAOYEJIAYOU/GSAN/tree/8ca4fdf4c3d615af9cc10e1f9f22ceb7e27fe196 |
MLP | import torch
import torch.nn as nn
class MLP(nn.Module):
def __init__(self, num_actions):
super(MLP, self).__init__()
self.fc = nn.Linear(4, 128)
self.logits = nn.Linear(128, num_actions)
self.value = nn.Linear(128, 1)
def forward(self, x):
x = torch.relu(self.fc(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_... | XFFXFF/endorphin | MLP | false | 18,077 | [
"Apache-2.0"
] | 5 | a29d6faf76284e5346d900dfd4fdeda82c710744 | https://github.com/XFFXFF/endorphin/tree/a29d6faf76284e5346d900dfd4fdeda82c710744 |
Attention | import torch
import torch.nn as nn
import torch.nn.functional as F
class Attention(nn.Module):
def __init__(self, n_hidden_enc, n_hidden_dec):
super().__init__()
self.h_hidden_enc = n_hidden_enc
self.h_hidden_dec = n_hidden_dec
self.W = nn.Linear(n_hidden_enc + n_hidden_dec, n_hid... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | VisualJoyce/ChengyuBERT | Attention | false | 18,078 | [
"MIT"
] | 8 | 605db3a4b3241dd4d02baa41a68bf23b5b00b36d | https://github.com/VisualJoyce/ChengyuBERT/tree/605db3a4b3241dd4d02baa41a68bf23b5b00b36d |
SEModule | import torch
import torch.nn as nn
class SEModule(nn.Module):
def __init__(self, channels, reduction):
super().__init__()
self.avg_pool = nn.AdaptiveAvgPool3d(1)
self.bottleneck = self._round_width(channels, reduction)
self.fc1 = nn.Conv3d(channels, self.bottleneck, kernel_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 import triton_helpers
import torch.nn as nn
assert_... | Viditagarwal7479/Video-Swin-Transformer | SEModule | false | 18,079 | [
"Apache-2.0"
] | 9 | 37910ef3141c7b2eef76544f9ec8bdf26ec94c7d | https://github.com/Viditagarwal7479/Video-Swin-Transformer/tree/37910ef3141c7b2eef76544f9ec8bdf26ec94c7d |
BertSelfAttention | from _paritybench_helpers import _mock_config
import math
import torch
from torch import nn
class BertSelfAttention(nn.Module):
def __init__(self, config):
super(BertSelfAttention, self).__init__()
if config.hidden_size % config.num_attention_heads != 0:
raise ValueError(
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | MingjieWang0606/2021-Sohu-Text-Matching-TOP2 | BertSelfAttention | false | 18,080 | [
"MIT"
] | 5 | 830a286cc978cb285cb63ae5a457e1d3813fa68a | https://github.com/MingjieWang0606/2021-Sohu-Text-Matching-TOP2/tree/830a286cc978cb285cb63ae5a457e1d3813fa68a |
Color_MNIST_CNN | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
class Color_MNIST_CNN(nn.Module):
def __init__(self):
super(Color_MNIST_CNN, self).__init__()
self.conv1 = nn.Conv2d(3, 64, 3, 1, padding=1)
self.conv2 = nn.Conv2d(64, 128, 3, stride=2, 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.... | VinAIResearch/mDSDI | Color_MNIST_CNN | false | 18,081 | [
"Apache-2.0"
] | 9 | 8ec49085d8389ab490ec633c3ae4bf66be085366 | https://github.com/VinAIResearch/mDSDI/tree/8ec49085d8389ab490ec633c3ae4bf66be085366 |
AngularMarginLoss | import torch
import torch.nn.functional as F
import torch.nn as nn
class MetricLearningLoss(nn.Module):
"""
Generic loss function to be used in a metric learning setting
"""
def __init__(self, embedding_size, n_classes, device='cpu', *args, **kwargs
):
super(MetricLearningLoss, 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.... | Wadaboa/titanet | AngularMarginLoss | false | 18,082 | [
"MIT"
] | 4 | b07e3074e79ea8c1129fb0adb8315e06bb4943ea | https://github.com/Wadaboa/titanet/tree/b07e3074e79ea8c1129fb0adb8315e06bb4943ea |
GatedTanh | import torch
import torch.nn as nn
class GatedTanh(nn.Module):
"""
From: https://arxiv.org/pdf/1707.07998.pdf
nonlinear_layer (f_a) : x\\in R^m => y \\in R^n
ilda{y} = tanh(Wx + b)
g = sigmoid(W'x + b')
y = ilda(y) \\circ g
input: (N, *, in_dim)
output: (N, *, out_dim)
"""
d... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as ... | VisualJoyce/ChengyuBERT | GatedTanh | false | 18,083 | [
"MIT"
] | 8 | 605db3a4b3241dd4d02baa41a68bf23b5b00b36d | https://github.com/VisualJoyce/ChengyuBERT/tree/605db3a4b3241dd4d02baa41a68bf23b5b00b36d |
CELoss | import torch
import torch.nn.functional as F
import torch.nn as nn
class MetricLearningLoss(nn.Module):
"""
Generic loss function to be used in a metric learning setting
"""
def __init__(self, embedding_size, n_classes, device='cpu', *args, **kwargs
):
super(MetricLearningLoss, 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.... | Wadaboa/titanet | CELoss | false | 18,084 | [
"MIT"
] | 4 | b07e3074e79ea8c1129fb0adb8315e06bb4943ea | https://github.com/Wadaboa/titanet/tree/b07e3074e79ea8c1129fb0adb8315e06bb4943ea |
CrossEntropyLoss | import torch
import torch.utils.data
import torch
import torch.nn as nn
class CrossEntropyLoss(nn.Module):
def __init__(self, label_nc):
super(CrossEntropyLoss, self).__init__()
self.softmax = nn.LogSoftmax(dim=1)
self.criterion = nn.NLLLoss2d()
def forward(self, output, 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 math as tl_math
import torch.utils.dat... | WeisiX/ITAS3D | CrossEntropyLoss | false | 18,085 | [
"MIT"
] | 4 | fc861e0cb2d4516905bfadab5e5e880c2b021832 | https://github.com/WeisiX/ITAS3D/tree/fc861e0cb2d4516905bfadab5e5e880c2b021832 |
Mask_BN | import torch
import torch.nn as nn
class Mask_BN(nn.Module):
def __init__(self):
super(Mask_BN, self).__init__()
def forward(self, x):
x_mask = x != 0
x_centralization = x - x_mask * x[:, 0, :, :].unsqueeze(1)
none_zero_n = x_mask.sum(axis=3).sum(axis=2).sum(axis=1).unsqueeze... | 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_... | XIAOYEJIAYOU/GSAN | Mask_BN | false | 18,086 | [
"MIT"
] | 6 | 8ca4fdf4c3d615af9cc10e1f9f22ceb7e27fe196 | https://github.com/XIAOYEJIAYOU/GSAN/tree/8ca4fdf4c3d615af9cc10e1f9f22ceb7e27fe196 |
OffsetNet | import torch
import torch.nn as nn
class OffsetNet(nn.Module):
"""OffsetNet in Temporal interlace module.
The OffsetNet consists of one convolution layer and two fc layers
with a relu activation following with a sigmoid function. Following
the convolution layer, two fc layers and relu are applied 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
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | Viditagarwal7479/Video-Swin-Transformer | OffsetNet | false | 18,087 | [
"Apache-2.0"
] | 9 | 37910ef3141c7b2eef76544f9ec8bdf26ec94c7d | https://github.com/Viditagarwal7479/Video-Swin-Transformer/tree/37910ef3141c7b2eef76544f9ec8bdf26ec94c7d |
BinaryLogisticRegressionLoss | import torch
import torch.nn as nn
def binary_logistic_regression_loss(reg_score, label, threshold=0.5,
ratio_range=(1.05, 21), eps=1e-05):
"""Binary Logistic Regression Loss."""
label = label.view(-1)
reg_score = reg_score.contiguous().view(-1)
pmask = (label > threshold).float()
num_positive... | 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
... | Viditagarwal7479/Video-Swin-Transformer | BinaryLogisticRegressionLoss | false | 18,088 | [
"Apache-2.0"
] | 9 | 37910ef3141c7b2eef76544f9ec8bdf26ec94c7d | https://github.com/Viditagarwal7479/Video-Swin-Transformer/tree/37910ef3141c7b2eef76544f9ec8bdf26ec94c7d |
CharbonnierLoss | import functools
import torch
import torch.utils.data
from torch.utils import data as data
from torch.nn import functional as F
from torch import nn as nn
from torch.nn import init as init
from torchvision.models import vgg as vgg
from torch import autograd as autograd
def reduce_loss(loss, reduction):
"""Reduce ... | 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 functools
import torc... | WoojunePark/BasicSR | CharbonnierLoss | false | 18,089 | [
"Apache-2.0"
] | 9 | e0910b022b924bb913045fc412a5470dc2242cf0 | https://github.com/WoojunePark/BasicSR/tree/e0910b022b924bb913045fc412a5470dc2242cf0 |
Decoder | from _paritybench_helpers import _mock_config
import torch
import torch.nn as nn
class Decoder(nn.Module):
def __init__(self, config):
super(Decoder, self).__init__()
self.linear = nn.Linear(config.hidden_size, 2)
def forward(self, x, encoder_output):
y = self.linear(encoder_output)
... | 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... | XIAOYEJIAYOU/GSAN | Decoder | false | 18,090 | [
"MIT"
] | 6 | 8ca4fdf4c3d615af9cc10e1f9f22ceb7e27fe196 | https://github.com/XIAOYEJIAYOU/GSAN/tree/8ca4fdf4c3d615af9cc10e1f9f22ceb7e27fe196 |
MaxPool1d | import torch
import torch.nn as nn
class MaxPool1d(nn.Module):
def __init__(self, win=2, stride=None, pad=0):
super().__init__()
self.pooling = nn.MaxPool1d(kernel_size=win, stride=stride, padding=pad
)
def forward(self, x):
"""
Args:
x: shape=(batch_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 torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
emp... | WiseDoge/Text-Classification-PyTorch | MaxPool1d | false | 18,091 | [
"MIT"
] | 6 | 9371eeed6bd7ecf1d529c8f2a6c997fcde67a559 | https://github.com/WiseDoge/Text-Classification-PyTorch/tree/9371eeed6bd7ecf1d529c8f2a6c997fcde67a559 |
SelfExpression | import torch
import torch.nn as nn
class SelfExpression(nn.Module):
def __init__(self, n):
super(SelfExpression, self).__init__()
self.Coefficient = nn.Parameter(1e-08 * torch.ones(n, n, dtype=
torch.float32), requires_grad=True)
def forward(self, x):
y = torch.matmul(sel... | 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... | Xanadu12138/DSCN-superpixels | SelfExpression | false | 18,092 | [
"MIT"
] | 4 | babe16edde9c61699ef203effbfc9f03246765f3 | https://github.com/Xanadu12138/DSCN-superpixels/tree/babe16edde9c61699ef203effbfc9f03246765f3 |
ConvAE | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
class Conv2dSamePad(nn.Module):
"""
Implement Tensorflow's 'SAME' padding mode in Conv2d.
When an odd number, say `m`, of pixels are need to pad, Tensorflow will pad one more column at right or one more
row at bottom. But P... | 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
import torch.nn a... | Xanadu12138/DSCN-superpixels | ConvAE | false | 18,093 | [
"MIT"
] | 4 | babe16edde9c61699ef203effbfc9f03246765f3 | https://github.com/Xanadu12138/DSCN-superpixels/tree/babe16edde9c61699ef203effbfc9f03246765f3 |
FeedForward | import torch
import torch.nn as nn
import torch.cuda
class FeedForward(nn.Module):
def __init__(self, hidden_size, inner_size, dropout):
super(FeedForward, self).__init__()
self.linear_in = nn.Linear(hidden_size, inner_size, bias=False)
self.linear_out = nn.Linear(inner_size, 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
import torch.nn as nn
import ... | XL2248/VHM | FeedForward | false | 18,094 | [
"MIT"
] | 8 | d6c21938f7cf095590b35e6ae7e0ef2b27d430f8 | https://github.com/XL2248/VHM/tree/d6c21938f7cf095590b35e6ae7e0ef2b27d430f8 |
CNNLayer | import torch
import torch.nn as nn
class CNNLayer(nn.Module):
"""Conv1d layer.
nn.Conv1d layer require the input shape is (batch_size, in_channels, length),
however, our input shape is (batch_size, length, in_channels), so we need to
transpose our input data into (B, C, L_in) and send it to conv layer... | 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... | WiseDoge/Text-Classification-PyTorch | CNNLayer | false | 18,095 | [
"MIT"
] | 6 | 9371eeed6bd7ecf1d529c8f2a6c997fcde67a559 | https://github.com/WiseDoge/Text-Classification-PyTorch/tree/9371eeed6bd7ecf1d529c8f2a6c997fcde67a559 |
AttentiveStatsPooling | import torch
import torch.nn as nn
class AttentiveStatsPooling(nn.Module):
"""
The attentive statistics pooling layer uses an attention
mechanism to give different weights to different frames and
generates not only weighted means but also weighted variances,
to form utterance-level features from 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
from torch._inductor.runtime.... | Wadaboa/titanet | AttentiveStatsPooling | false | 18,096 | [
"MIT"
] | 4 | b07e3074e79ea8c1129fb0adb8315e06bb4943ea | https://github.com/Wadaboa/titanet/tree/b07e3074e79ea8c1129fb0adb8315e06bb4943ea |
AutoEncoder | import torch
import torch.nn as nn
class AutoEncoder(nn.Module):
def __init__(self, channels):
"""
param:
channels: a list containing all channels in the network.
"""
super(AutoEncoder, self).__init__()
self.encoder = nn.Sequential()
for i in range(len(... | 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_... | Xanadu12138/DSCN-superpixels | AutoEncoder | false | 18,097 | [
"MIT"
] | 4 | babe16edde9c61699ef203effbfc9f03246765f3 | https://github.com/Xanadu12138/DSCN-superpixels/tree/babe16edde9c61699ef203effbfc9f03246765f3 |
SAM_Loss | import torch
import torch.nn as nn
class SAM_Loss(nn.Module):
def __init__(self):
super(SAM_Loss, self).__init__()
def forward(self, output, label):
ratio = torch.sum((output + 1e-08).mul(label + 1e-08), dim=1
) / torch.sqrt(torch.sum((output + 1e-08).mul(output + 1e-08),
... | 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_... | XiuhengWang/Sylvester_TSFN_MDC_HSI_superresolution | SAM_Loss | false | 18,098 | [
"MIT"
] | 5 | f70799c931d44d5d6cac635ef539a38bc573c7d9 | https://github.com/XiuhengWang/Sylvester_TSFN_MDC_HSI_superresolution/tree/f70799c931d44d5d6cac635ef539a38bc573c7d9 |
LinearRegression | import torch
import torch.nn as nn
class LinearRegression(nn.Module):
def __init__(self, hidden_size):
super(LinearRegression, self).__init__()
self.linear1 = nn.Linear(hidden_size, 3)
def forward(self, x, mask):
y = self.linear1(x)
y = y * mask
return y.view(-1, 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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | XIAOYEJIAYOU/GSAN | LinearRegression | false | 18,099 | [
"MIT"
] | 6 | 8ca4fdf4c3d615af9cc10e1f9f22ceb7e27fe196 | https://github.com/XIAOYEJIAYOU/GSAN/tree/8ca4fdf4c3d615af9cc10e1f9f22ceb7e27fe196 |
Q_Critic | import torch
import torch.nn as nn
import torch.nn.functional as F
class Q_Critic(nn.Module):
def __init__(self, state_dim, action_dim, net_width):
super(Q_Critic, self).__init__()
self.l1 = nn.Linear(state_dim + action_dim, net_width)
self.l2 = nn.Linear(net_width, net_width)
sel... | 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 ... | XinJingHao/RL | Q_Critic | false | 18,100 | [
"MIT"
] | 6 | eed54d6602b173e45ede722b0fcf82b5a203f14a | https://github.com/XinJingHao/RL/tree/eed54d6602b173e45ede722b0fcf82b5a203f14a |
Actor | import torch
import torch.nn as nn
class Actor(nn.Module):
def __init__(self, state_dim, action_dim, net_width, maxaction):
super(Actor, self).__init__()
self.l1 = nn.Linear(state_dim, net_width)
self.l2 = nn.Linear(net_width, net_width)
self.l3 = nn.Linear(net_width, action_dim)
... | 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 ... | XinJingHao/RL | Actor | false | 18,101 | [
"MIT"
] | 6 | eed54d6602b173e45ede722b0fcf82b5a203f14a | https://github.com/XinJingHao/RL/tree/eed54d6602b173e45ede722b0fcf82b5a203f14a |
MaxMinGroup | import torch
import torch.nn as nn
import torch.utils.data
def process_maxmin_groupsize(x, group_size, axis=-1):
size = list(x.size())
num_channels = size[axis]
if num_channels % group_size:
raise ValueError(
'number of features({}) is not a multiple of group_size({})'.
for... | 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.utils.data
assert_size_stride = torch._C._dynamo.guard... | XinZhang525/fGAIL | MaxMinGroup | false | 18,102 | [
"MIT"
] | 4 | 682d70286685612558e072d9a1668779b8ae325b | https://github.com/XinZhang525/fGAIL/tree/682d70286685612558e072d9a1668779b8ae325b |
MaskedL1Loss | import torch
import torch.utils.data
import torch
import torch.nn as nn
class MaskedL1Loss(nn.Module):
def __init__(self):
super(MaskedL1Loss, self).__init__()
self.criterion = nn.L1Loss()
def forward(self, input, target, mask):
mask = mask.expand(-1, input.size()[1], -1, -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.utils.dat... | WeisiX/ITAS3D | MaskedL1Loss | false | 18,103 | [
"MIT"
] | 4 | fc861e0cb2d4516905bfadab5e5e880c2b021832 | https://github.com/WeisiX/ITAS3D/tree/fc861e0cb2d4516905bfadab5e5e880c2b021832 |
squeeze | import torch
import torch.nn as nn
import torch.utils.data
class squeeze(nn.Module):
def __init__(self, block_size):
super(squeeze, self).__init__()
self.block_size = block_size
self.block_size_sq = block_size * block_size
def inverse(self, input):
output = input.permute(0, 2... | 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.... | XinZhang525/fGAIL | squeeze | false | 18,104 | [
"MIT"
] | 4 | 682d70286685612558e072d9a1668779b8ae325b | https://github.com/XinZhang525/fGAIL/tree/682d70286685612558e072d9a1668779b8ae325b |
ModulatedConv2d | from torch.autograd import Function
import math
import torch
import torch.utils.data
from torch.utils import data as data
from torch.nn import functional as F
from torch import nn as nn
from torch.nn import init as init
from torchvision.models import vgg as vgg
from torch import autograd as autograd
def make_resample... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
from torch.autograd... | WoojunePark/BasicSR | ModulatedConv2d | false | 18,105 | [
"Apache-2.0"
] | 9 | e0910b022b924bb913045fc412a5470dc2242cf0 | https://github.com/WoojunePark/BasicSR/tree/e0910b022b924bb913045fc412a5470dc2242cf0 |
Split | import torch
import torch.nn as nn
import torch.utils.data
class Split(nn.Module):
def __init__(self):
super(Split, self).__init__()
def forward(self, x):
n = int(x.size(1) / 2)
x1 = x[:, :n, :, :].contiguous()
x2 = x[:, n:, :, :].contiguous()
return x1, x2
def 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
import torch.nn as nn
import torch.utils.data
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C.... | XinZhang525/fGAIL | Split | false | 18,106 | [
"MIT"
] | 4 | 682d70286685612558e072d9a1668779b8ae325b | https://github.com/XinZhang525/fGAIL/tree/682d70286685612558e072d9a1668779b8ae325b |
MaskUpdate | import torch
import torch.nn as nn
import torch.multiprocessing
class MaskUpdate(nn.Module):
def __init__(self, alpha):
super(MaskUpdate, self).__init__()
self.func = nn.ReLU(True)
self.alpha = alpha
def forward(self, input_masks):
return torch.pow(self.func(input_masks), sel... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
import torch.multiprocessing
assert_size_stride = torch._C._dynamo.... | Xiefan-Guo/LBAM | MaskUpdate | false | 18,107 | [
"MIT"
] | 4 | 9795e2af4677a9f5e8e13b5d89fc6d50534c006a | https://github.com/Xiefan-Guo/LBAM/tree/9795e2af4677a9f5e8e13b5d89fc6d50534c006a |
L1 | import torch
import torch.utils.data
import torch
import torch.nn as nn
class L1(nn.Module):
def __init__(self):
super(L1, self).__init__()
def forward(self, output, target):
lossvalue = torch.abs(output - target).mean()
return lossvalue
def get_inputs():
return [torch.rand([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
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.utils.dat... | WeisiX/ITAS3D | L1 | false | 18,108 | [
"MIT"
] | 4 | fc861e0cb2d4516905bfadab5e5e880c2b021832 | https://github.com/WeisiX/ITAS3D/tree/fc861e0cb2d4516905bfadab5e5e880c2b021832 |
GaussianActivation | import torch
import torch.nn as nn
from torch.nn.parameter import Parameter
import torch.multiprocessing
class GaussianActivation(nn.Module):
def __init__(self, a, mu, gamma_l, gamma_r):
super(GaussianActivation, self).__init__()
self.a = Parameter(torch.tensor(a, dtype=torch.float32))
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 import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
... | Xiefan-Guo/LBAM | GaussianActivation | false | 18,109 | [
"MIT"
] | 4 | 9795e2af4677a9f5e8e13b5d89fc6d50534c006a | https://github.com/Xiefan-Guo/LBAM/tree/9795e2af4677a9f5e8e13b5d89fc6d50534c006a |
BertIntermediate | from _paritybench_helpers import _mock_config
import torch
from torch import nn
class BertIntermediate(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.intermediate_size)
self.intermediate_act_fn = nn.functional.gelu
def for... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
from torch import n... | RyanWangZf/SurvTRACE | BertIntermediate | false | 18,110 | [
"MIT"
] | 8 | d55299a28629d233f49ad1feaea7ed00835f0dd0 | https://github.com/RyanWangZf/SurvTRACE/tree/d55299a28629d233f49ad1feaea7ed00835f0dd0 |
L2 | import torch
import torch.utils.data
import torch
import torch.nn as nn
class L2(nn.Module):
def __init__(self):
super(L2, self).__init__()
def forward(self, output, target):
lossvalue = torch.norm(output - target, p=2, dim=1).mean()
return lossvalue
def get_inputs():
return [t... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.utils.data
import torch
import torch.nn as nn
assert_size_stride =... | WeisiX/ITAS3D | L2 | false | 18,111 | [
"MIT"
] | 4 | fc861e0cb2d4516905bfadab5e5e880c2b021832 | https://github.com/WeisiX/ITAS3D/tree/fc861e0cb2d4516905bfadab5e5e880c2b021832 |
Inception_Temporal_Layer | import torch
import torch.nn as nn
class CausalConv1d(nn.Conv1d):
def __init__(self, in_channels, out_channels, kernel_size, stride=1,
dilation=1, groups=1, bias=True):
self.padding = (kernel_size - 1) * dilation
super(CausalConv1d, self).__init__(in_channels, out_channels,
ke... | 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... | WoodSugar/GSTNet | Inception_Temporal_Layer | false | 18,112 | [
"MIT"
] | 8 | 3c21cfc8a873d61336f257030a28fdee12dcee2f | https://github.com/WoodSugar/GSTNet/tree/3c21cfc8a873d61336f257030a28fdee12dcee2f |
EqualLinear | from torch.autograd import Function
import math
import torch
import torch.utils.data
from torch.utils import data as data
from torch.nn import functional as F
from torch import nn as nn
from torch.nn import init as init
from torchvision.models import vgg as vgg
from torch import autograd as autograd
def fused_leaky_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
from torch.autograd import Function
import math
import torch.utils.data
from tor... | WoojunePark/BasicSR | EqualLinear | false | 18,113 | [
"Apache-2.0"
] | 9 | e0910b022b924bb913045fc412a5470dc2242cf0 | https://github.com/WoojunePark/BasicSR/tree/e0910b022b924bb913045fc412a5470dc2242cf0 |
RegLoss | import torch
import torch.nn as nn
from itertools import product as product
from math import sqrt as sqrt
import torch.utils.data
def _reg_loss(regr, gt_regr, mask):
""" L1 regression loss
Arguments:
regr (batch x max_objects x dim)
gt_regr (batch x max_objects x dim)
mask (batch x max_objec... | 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
... | XiangLiK/cv_course | RegLoss | false | 18,114 | [
"MIT"
] | 8 | da7c2318fd4128bbdab96db26ddbb2524f37d0a0 | https://github.com/XiangLiK/cv_course/tree/da7c2318fd4128bbdab96db26ddbb2524f37d0a0 |
RegWeightedL1Loss | import torch
import torch.nn as nn
import torch.nn.functional as F
from itertools import product as product
from math import sqrt as sqrt
import torch.utils.data
def _gather_feat(feat, ind, mask=None):
dim = feat.size(2)
ind = ind.unsqueeze(2).expand(ind.size(0), ind.size(1), dim)
feat = feat.gather(1, in... | 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
... | XiangLiK/cv_course | RegWeightedL1Loss | false | 18,115 | [
"MIT"
] | 8 | da7c2318fd4128bbdab96db26ddbb2524f37d0a0 | https://github.com/XiangLiK/cv_course/tree/da7c2318fd4128bbdab96db26ddbb2524f37d0a0 |
MultiscaleL1Loss | import torch
import torch.utils.data
import torch
import torch.nn as nn
class MultiscaleL1Loss(nn.Module):
def __init__(self, scale=5):
super(MultiscaleL1Loss, self).__init__()
self.criterion = nn.L1Loss()
self.downsample = nn.AvgPool2d(2, stride=2, count_include_pad=False)
self.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
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.utils.dat... | WeisiX/ITAS3D | MultiscaleL1Loss | false | 18,116 | [
"MIT"
] | 4 | fc861e0cb2d4516905bfadab5e5e880c2b021832 | https://github.com/WeisiX/ITAS3D/tree/fc861e0cb2d4516905bfadab5e5e880c2b021832 |
ReverseAttentionLayer | import math
import torch
import torch.nn as nn
from torch.nn.parameter import Parameter
import torch.multiprocessing
def weights_init(init_type='gaussian'):
def init_func(m):
classname = m.__class__.__name__
if (classname.find('Conv') == 0 or classname.find('Linear') == 0
) and hasatt... | 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.... | Xiefan-Guo/LBAM | ReverseAttentionLayer | false | 18,118 | [
"MIT"
] | 4 | 9795e2af4677a9f5e8e13b5d89fc6d50534c006a | https://github.com/Xiefan-Guo/LBAM/tree/9795e2af4677a9f5e8e13b5d89fc6d50534c006a |
patch_extractor | import torch
import torch.nn as nn
class patch_extractor(nn.Module):
"""
Module for creating custom patch extractor
"""
def __init__(self, patch_size, pad=False):
super(patch_extractor, self).__init__()
self.im2pat = nn.Unfold(kernel_size=patch_size)
self.pad = pad
sel... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | Xmaster6y/wgenpatex | patch_extractor | false | 18,119 | [
"MIT"
] | 8 | 08079dc131cc2e9c74ee4f9e16cf9b58667f2b07 | https://github.com/Xmaster6y/wgenpatex/tree/08079dc131cc2e9c74ee4f9e16cf9b58667f2b07 |
gaussian_layer | import math
import torch
import torch.nn as nn
class gaussian_downsample(nn.Module):
"""
Downsampling module with Gaussian filtering
"""
def __init__(self, kernel_size, sigma, stride, pad=False):
super(gaussian_downsample, self).__init__()
self.gauss = nn.Conv2d(3, 3, kernel_size, str... | 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... | Xmaster6y/wgenpatex | gaussian_layer | false | 18,120 | [
"MIT"
] | 8 | 08079dc131cc2e9c74ee4f9e16cf9b58667f2b07 | https://github.com/Xmaster6y/wgenpatex/tree/08079dc131cc2e9c74ee4f9e16cf9b58667f2b07 |
ToRGB | from torch.autograd import Function
import math
import torch
import torch.utils.data
from torch.utils import data as data
from torch.nn import functional as F
from torch import nn as nn
from torch.nn import init as init
from torchvision.models import vgg as vgg
from torch import autograd as autograd
def make_resample... | 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.autograd import Function
import math
import torch.utils.data
from tor... | WoojunePark/BasicSR | ToRGB | false | 18,121 | [
"Apache-2.0"
] | 9 | e0910b022b924bb913045fc412a5470dc2242cf0 | https://github.com/WoojunePark/BasicSR/tree/e0910b022b924bb913045fc412a5470dc2242cf0 |
PairwiseRankingLoss | import torch
import torch.nn as nn
class PairwiseRankingLoss(nn.Module):
"""
Pairwise ranking loss
"""
def __init__(self, margin):
super(PairwiseRankingLoss, self).__init__()
self.margin = margin
def forward(self, anchor1, anchor2, img_sentc, sent_imgc):
cost_sent = torch... | 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... | YJiangcm/DCPCSE | PairwiseRankingLoss | false | 18,122 | [
"MIT"
] | 5 | 698255e2e66b402325ff611e098e01d2f322743e | https://github.com/YJiangcm/DCPCSE/tree/698255e2e66b402325ff611e098e01d2f322743e |
Resv1Block | import torch
import torch.nn as nn
from itertools import product as product
from math import sqrt as sqrt
import torch.utils.data
def conv3x3(in_planes, out_planes, stride=1):
"""3x3 convolution with padding"""
return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride,
padding=1, bias=False... | 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 it... | XiangLiK/cv_course | Resv1Block | false | 18,124 | [
"MIT"
] | 8 | da7c2318fd4128bbdab96db26ddbb2524f37d0a0 | https://github.com/XiangLiK/cv_course/tree/da7c2318fd4128bbdab96db26ddbb2524f37d0a0 |
Similarity | import torch
import torch.nn as nn
class Similarity(nn.Module):
"""
Dot product or cosine similarity
"""
def __init__(self, temp):
super().__init__()
self.temp = temp
self.cos = nn.CosineSimilarity(dim=-1)
def forward(self, x, y):
return self.cos(x, y) / self.temp... | 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... | YJiangcm/DCPCSE | Similarity | false | 18,125 | [
"MIT"
] | 5 | 698255e2e66b402325ff611e098e01d2f322743e | https://github.com/YJiangcm/DCPCSE/tree/698255e2e66b402325ff611e098e01d2f322743e |
ResidualBlockNoBN | import torch
import torch.utils.data
from torch.utils import data as data
from torch import nn as nn
from torch.nn import init as init
from torch.nn.modules.batchnorm import _BatchNorm
from torchvision.models import vgg as vgg
from torch import autograd as autograd
@torch.no_grad()
def default_init_weights(module_lis... | 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.utils.data
from ... | WoojunePark/BasicSR | ResidualBlockNoBN | false | 18,127 | [
"Apache-2.0"
] | 9 | e0910b022b924bb913045fc412a5470dc2242cf0 | https://github.com/WoojunePark/BasicSR/tree/e0910b022b924bb913045fc412a5470dc2242cf0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.