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
AttentionModule
import torch from torch import nn from torch.nn import functional as F class AttentionModule(nn.Module): """ A neural module that takes a feature map and attention, attends to the features, and produces an attention. Extended Summary ---------------- A :class:`AttentionModule` takes input fea...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language 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...
kdexd/probnmn-clevr
AttentionModule
false
15,795
[ "MIT" ]
69
9c1b2286cf30e9fb045370153c9242a39760e02e
https://github.com/kdexd/probnmn-clevr/tree/9c1b2286cf30e9fb045370153c9242a39760e02e
Aggregation
import torch from torch import nn from torch.nn import * class Aggregation(nn.Module): """ Aggregation layer for the Dueling architecture. https://arxiv.org/abs/1511.06581 This layer computes a Q function by combining an estimate of V with an estimate of the advantage. The advantage is normal...
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 from torch.nn import * assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._d...
kcorder/autonomous-learning-library
Aggregation
false
15,796
[ "MIT" ]
584
0266195fa47564e51a32087bc007bff6dda5e263
https://github.com/kcorder/autonomous-learning-library/tree/0266195fa47564e51a32087bc007bff6dda5e263
FeatureCorrelation
import torch import torch.nn as nn class FeatureCorrelation(nn.Module): def __init__(self, scale): super(FeatureCorrelation, self).__init__() self.scale = scale def forward(self, feature_A, feature_B): b, c, h, w = feature_A.size() feature_A = feature_A.transpose(2, 3).contig...
import torch from torch._inductor.select_algorithm import extern_kernels import 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...
kensakurada/SceneChangeDet
FeatureCorrelation
false
15,797
[ "MIT" ]
199
0530e0162863fec0c5296188526f0d27e0109814
https://github.com/kensakurada/SceneChangeDet/tree/0530e0162863fec0c5296188526f0d27e0109814
KLCoefficient
import torch import torch.nn as nn import torch.nn.functional as F class KLCoefficient(nn.Module): def __init__(self): super(KLCoefficient, self).__init__() def forward(self, hist1, hist2): kl = F.kl_div(hist1, hist2) dist = 1.0 / 1 + kl return dist def get_inputs(): re...
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...
kensakurada/SceneChangeDet
KLCoefficient
false
15,798
[ "MIT" ]
199
0530e0162863fec0c5296188526f0d27e0109814
https://github.com/kensakurada/SceneChangeDet/tree/0530e0162863fec0c5296188526f0d27e0109814
RelateModule
import torch from torch import nn from torch.nn import functional as F class RelateModule(nn.Module): """ A neural module that takes as input a feature map and an attention and produces an attention as output. Extended Summary ---------------- A :class:`RelateModule` takes input features and ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language 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...
kdexd/probnmn-clevr
RelateModule
false
15,799
[ "MIT" ]
69
9c1b2286cf30e9fb045370153c9242a39760e02e
https://github.com/kdexd/probnmn-clevr/tree/9c1b2286cf30e9fb045370153c9242a39760e02e
l2normalization
import torch import torch.nn as nn class l2normalization(nn.Module): def __init__(self, scale): super(l2normalization, self).__init__() self.scale = scale def forward(self, x, dim=1): """out = scale * x / sqrt(\\sum x_i^2)""" return self.scale * x * x.pow(2).sum(dim).clamp(mi...
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...
kensakurada/SceneChangeDet
l2normalization
false
15,800
[ "MIT" ]
199
0530e0162863fec0c5296188526f0d27e0109814
https://github.com/kensakurada/SceneChangeDet/tree/0530e0162863fec0c5296188526f0d27e0109814
StatsNet
import torch from torch import nn import torch.utils.data class StatsNet(nn.Module): def __init__(self): super(StatsNet, self).__init__() def forward(self, x): x = x.view(x.data.shape[0], x.data.shape[1], x.data.shape[2] * x. data.shape[3]) mean = torch.mean(x, 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 from torch._inductor.runtime.triton_helpers import libdevice from torch import nn import torch.utils.data assert_size_stride = torch._C._dyn...
kerenalli/Capsule-Forensics-v2
StatsNet
false
15,801
[ "BSD-3-Clause" ]
97
8e60ca0035f8392a543f7fad37ab3704d43021cf
https://github.com/kerenalli/Capsule-Forensics-v2/tree/8e60ca0035f8392a543f7fad37ab3704d43021cf
GaussianKLLoss
import torch import torch.nn as nn class GaussianKLLoss(nn.Module): def __init__(self): super(GaussianKLLoss, self).__init__() def forward(self, mu1, logvar1, mu2, logvar2): numerator = logvar1.exp() + torch.pow(mu1 - mu2, 2) fraction = torch.div(numerator, logvar2.exp()) kl ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import math as tl_math import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert...
kekayan/Info-HCVAE
GaussianKLLoss
false
15,802
[ "Apache-2.0" ]
120
1f4d536523767f439e689d8963c54a55fb75c6f9
https://github.com/kekayan/Info-HCVAE/tree/1f4d536523767f439e689d8963c54a55fb75c6f9
BhattacharyyaDistance
import torch import torch.nn as nn class BhattacharyyaDistance(nn.Module): def __init__(self): super(BhattacharyyaDistance, self).__init__() def forward(self, hist1, hist2): bh_dist = torch.sqrt(hist1 * hist2).sum() return bh_dist def get_inputs(): return [torch.rand([4, 4, 4, ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as nn assert...
kensakurada/SceneChangeDet
BhattacharyyaDistance
false
15,803
[ "MIT" ]
199
0530e0162863fec0c5296188526f0d27e0109814
https://github.com/kensakurada/SceneChangeDet/tree/0530e0162863fec0c5296188526f0d27e0109814
Perplexity
import torch import torch as t import torch.nn as nn import torch.nn.functional as F class Perplexity(nn.Module): def __init__(self): super(Perplexity, self).__init__() def forward(self, logits, target): """ :param logits: tensor with shape of [batch_size, seq_len, input_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 from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import math as tl_math import torch.nn as nn ...
kefirski/contiguous-succotash
Perplexity
false
15,804
[ "MIT" ]
57
7497efd1392693248ed98805dcdbbf5dc125afc2
https://github.com/kefirski/contiguous-succotash/tree/7497efd1392693248ed98805dcdbbf5dc125afc2
StableBCELoss
import torch from torch import nn class StableBCELoss(nn.Module): def __init__(self): super(StableBCELoss, self).__init__() def forward(self, input: 'torch.Tensor', target: 'torch.Tensor'): input = input.float().view(-1) target = target.float().view(-1) neg_abs = -input.abs()...
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...
kevinkwshin/kaggle-pneumothorax
StableBCELoss
false
15,805
[ "MIT" ]
74
24b91a9425097023f0cc7781a9380cb247babe22
https://github.com/kevinkwshin/kaggle-pneumothorax/tree/24b91a9425097023f0cc7781a9380cb247babe22
MultiHeadedAttention
import math import torch import numpy as np from typing import Optional from torch import nn class MultiHeadedAttention(nn.Module): """Multi-Head Attention layer :param int n_head: the number of head s :param int n_feat: the number of features :param float dropout_rate: dropout rate """ def ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
karan-deepsync/FastSpeech2
MultiHeadedAttention
false
15,806
[ "Apache-2.0" ]
148
84ad261db4a865536b2e15dfb8346644c3192704
https://github.com/karan-deepsync/FastSpeech2/tree/84ad261db4a865536b2e15dfb8346644c3192704
Attention
import torch import torch.nn as nn import torch.utils import torch.nn.functional as F import torch.nn.parallel class Attention(nn.Module): def __init__(self, input_dim, source_dim=None, output_dim=None, bias=False ): super(Attention, self).__init__() if source_dim is None: sou...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language 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....
kcyu2014/eval-nas
Attention
false
15,807
[ "MIT" ]
47
385376a3ef96336b54ee7e696af1d02b97aa5c32
https://github.com/kcyu2014/eval-nas/tree/385376a3ef96336b54ee7e696af1d02b97aa5c32
ConstractiveThresholdHingeLoss
import torch import torch.nn as nn import torch.nn.functional as F class ConstractiveThresholdHingeLoss(nn.Module): def __init__(self, hingethresh=0.0, margin=2.0): super(ConstractiveThresholdHingeLoss, self).__init__() self.threshold = hingethresh self.margin = margin def forward(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 libdevice import torch.nn as nn assert...
kensakurada/SceneChangeDet
ConstractiveThresholdHingeLoss
false
15,808
[ "MIT" ]
199
0530e0162863fec0c5296188526f0d27e0109814
https://github.com/kensakurada/SceneChangeDet/tree/0530e0162863fec0c5296188526f0d27e0109814
AdjDecoder
import torch from torch import nn import torch.utils.data class AdjDecoder(nn.Module): u""" Decode an input (parent) feature into a left-child and a right-child feature """ def __init__(self, feature_size, hidden_size): super(AdjDecoder, self).__init__() self.mlp = nn.Linear(feature_size, 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.triton_helpers import libdevice from torch import n...
kevin-kaixu/grass_pytorch
AdjDecoder
false
15,809
[ "Apache-2.0" ]
85
1d8dc6dcc0ab3ca029e449f57c37ba3910a4f90a
https://github.com/kevin-kaixu/grass_pytorch/tree/1d8dc6dcc0ab3ca029e449f57c37ba3910a4f90a
NodeClassifier
import torch from torch import nn import torch.utils.data class NodeClassifier(nn.Module): def __init__(self, feature_size, hidden_size): super(NodeClassifier, self).__init__() self.mlp1 = nn.Linear(feature_size, hidden_size) self.tanh = nn.Tanh() self.mlp2 = nn.Linear(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 from torch import n...
kevin-kaixu/grass_pytorch
NodeClassifier
false
15,810
[ "Apache-2.0" ]
85
1d8dc6dcc0ab3ca029e449f57c37ba3910a4f90a
https://github.com/kevin-kaixu/grass_pytorch/tree/1d8dc6dcc0ab3ca029e449f57c37ba3910a4f90a
CategoricalKLLoss
import torch import torch.nn as nn class CategoricalKLLoss(nn.Module): def __init__(self): super(CategoricalKLLoss, self).__init__() def forward(self, P, Q): log_P = P.log() log_Q = Q.log() kl = (P * (log_P - log_Q)).sum(dim=-1).sum(dim=-1) return kl.mean(dim=0) 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.triton_helpers import math as tl_math import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert...
kekayan/Info-HCVAE
CategoricalKLLoss
false
15,811
[ "Apache-2.0" ]
120
1f4d536523767f439e689d8963c54a55fb75c6f9
https://github.com/kekayan/Info-HCVAE/tree/1f4d536523767f439e689d8963c54a55fb75c6f9
Net
import torch import torch.nn as nn import torch.nn.functional as F class Net(nn.Module): def __init__(self): super(Net, self).__init__() self.conv1_1 = nn.Conv2d(1, 32, kernel_size=5, padding=2) self.prelu1_1 = nn.PReLU() self.conv1_2 = nn.Conv2d(32, 32, kernel_size=5, padding=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....
jxgu1016/MNIST_with_centerloss.pytorch
Net
false
15,812
[ "MIT" ]
346
4e94cc77fe94056a7f1f081fcaf0325781ba0224
https://github.com/jxgu1016/MNIST_with_centerloss.pytorch/tree/4e94cc77fe94056a7f1f081fcaf0325781ba0224
dilated_1D
import torch import torch.utils.data import torch.nn as nn class dilated_1D(nn.Module): def __init__(self, cin, cout, dilation_factor=2): super(dilated_1D, self).__init__() self.tconv = nn.ModuleList() self.kernel_set = [2, 3, 6, 7] self.tconv = nn.Conv2d(cin, cout, (1, 7), dilati...
import torch from torch._inductor.select_algorithm import extern_kernels import 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...
kevin-xuan/Traffic-Benchmark
dilated_1D
false
15,813
[ "MIT" ]
120
b9f8e40b4df9b58f5ad88432dc070cbbbcdc0228
https://github.com/kevin-xuan/Traffic-Benchmark/tree/b9f8e40b4df9b58f5ad88432dc070cbbbcdc0228
SymEncoder
import torch from torch import nn import torch.utils.data class SymEncoder(nn.Module): def __init__(self, feature_size, symmetry_size, hidden_size): super(SymEncoder, self).__init__() self.left = nn.Linear(feature_size, hidden_size) self.right = nn.Linear(symmetry_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.triton_helpers import libdevice from torch import n...
kevin-kaixu/grass_pytorch
SymEncoder
false
15,814
[ "Apache-2.0" ]
85
1d8dc6dcc0ab3ca029e449f57c37ba3910a4f90a
https://github.com/kevin-kaixu/grass_pytorch/tree/1d8dc6dcc0ab3ca029e449f57c37ba3910a4f90a
gconv_RNN
import torch import torch.utils.data import torch.nn as nn class gconv_RNN(nn.Module): def __init__(self): super(gconv_RNN, self).__init__() def forward(self, x, A): x = torch.einsum('nvc,nvw->nwc', (x, A)) return x.contiguous() def get_inputs(): return [torch.rand([4, 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.utils.data import torch.nn as nn assert_size_stride = torch._C._dyn...
kevin-xuan/Traffic-Benchmark
gconv_RNN
false
15,815
[ "MIT" ]
120
b9f8e40b4df9b58f5ad88432dc070cbbbcdc0228
https://github.com/kevin-xuan/Traffic-Benchmark/tree/b9f8e40b4df9b58f5ad88432dc070cbbbcdc0228
AdjEncoder
import torch from torch import nn import torch.utils.data class AdjEncoder(nn.Module): def __init__(self, feature_size, hidden_size): super(AdjEncoder, self).__init__() self.left = nn.Linear(feature_size, hidden_size) self.right = nn.Linear(feature_size, hidden_size, bias=False) s...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice from torch import n...
kevin-kaixu/grass_pytorch
AdjEncoder
false
15,816
[ "Apache-2.0" ]
85
1d8dc6dcc0ab3ca029e449f57c37ba3910a4f90a
https://github.com/kevin-kaixu/grass_pytorch/tree/1d8dc6dcc0ab3ca029e449f57c37ba3910a4f90a
SymDecoder
import torch from torch import nn import torch.utils.data class SymDecoder(nn.Module): def __init__(self, feature_size, symmetry_size, hidden_size): super(SymDecoder, self).__init__() self.mlp = nn.Linear(feature_size, hidden_size) self.tanh = nn.Tanh() self.mlp_sg = nn.Linear(hid...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice from torch import n...
kevin-kaixu/grass_pytorch
SymDecoder
false
15,817
[ "Apache-2.0" ]
85
1d8dc6dcc0ab3ca029e449f57c37ba3910a4f90a
https://github.com/kevin-kaixu/grass_pytorch/tree/1d8dc6dcc0ab3ca029e449f57c37ba3910a4f90a
FocalLoss2d
import torch from torch import nn class FocalLoss2d(nn.Module): def __init__(self, gamma=2, ignore_index=255): super().__init__() self.gamma = gamma self.ignore_index = ignore_index def forward(self, outputs: 'torch.Tensor', targets: 'torch.Tensor'): outputs = outputs.contigu...
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 assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_str...
kevinkwshin/kaggle-pneumothorax
FocalLoss2d
false
15,818
[ "MIT" ]
74
24b91a9425097023f0cc7781a9380cb247babe22
https://github.com/kevinkwshin/kaggle-pneumothorax/tree/24b91a9425097023f0cc7781a9380cb247babe22
AdaptiveAvgPool3dOutSize1
import torch from typing import Tuple import torch.nn as nn from abc import abstractmethod import torch.utils.data import torch.nn class EfficientBlockBase(nn.Module): """ PyTorchVideo/accelerator provides a set of efficient blocks that have optimal efficiency for each target hardware device. Each ef...
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 typing import Tuple import torch.nn as nn from abc import abstractmethod import torch.utils.data import torch.nn assert_size_stride = t...
kevinmtian/pytorchvideo
AdaptiveAvgPool3dOutSize1
false
15,819
[ "Apache-2.0" ]
2,391
168e16859a6029ef8ebeb476f9163bebb6c6b87d
https://github.com/kevinmtian/pytorchvideo/tree/168e16859a6029ef8ebeb476f9163bebb6c6b87d
JaccardLoss
import torch from torch import nn def jaccard(outputs, targets, per_image=False, non_empty=False, min_pixels=5): batch_size = outputs.size()[0] eps = 0.001 if not per_image: batch_size = 1 dice_target = targets.contiguous().view(batch_size, -1).float() dice_output = outputs.contiguous().vi...
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...
kevinkwshin/kaggle-pneumothorax
JaccardLoss
false
15,820
[ "MIT" ]
74
24b91a9425097023f0cc7781a9380cb247babe22
https://github.com/kevinkwshin/kaggle-pneumothorax/tree/24b91a9425097023f0cc7781a9380cb247babe22
DiceLoss
import torch from torch import nn def soft_dice_loss(outputs, targets, per_image=False): batch_size = outputs.size()[0] eps = 1e-05 if not per_image: batch_size = 1 dice_target = targets.contiguous().view(batch_size, -1).float() dice_output = outputs.contiguous().view(batch_size, -1) i...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch import nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empt...
kevinkwshin/kaggle-pneumothorax
DiceLoss
false
15,821
[ "MIT" ]
74
24b91a9425097023f0cc7781a9380cb247babe22
https://github.com/kevinkwshin/kaggle-pneumothorax/tree/24b91a9425097023f0cc7781a9380cb247babe22
MaskedTemporalPooling
import torch from typing import Optional import torch.utils.data import torch.nn class MaskedTemporalPooling(torch.nn.Module): """ Applies temporal pooling operations on masked inputs. For each pooling operation all masked values are ignored. """ def __init__(self, method: 'str'): """ ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.utils.data import torch.nn assert_size_stride = torch._C._dynamo.guards.asse...
kevinmtian/pytorchvideo
MaskedTemporalPooling
false
15,822
[ "Apache-2.0" ]
2,391
168e16859a6029ef8ebeb476f9163bebb6c6b87d
https://github.com/kevinmtian/pytorchvideo/tree/168e16859a6029ef8ebeb476f9163bebb6c6b87d
PSNRLoss
import torch def psnr(gt, pred, data_range=None, batch=True, reduce=True): """ Compute the peak signal to noise ratio (psnr) :param gt: gt image (torch.Tensor :param pred: input image (torch.Tensor) :param data_range: if None, estimated from gt :return: (mean) psnr """ if batch: ba...
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 assert_size...
khammernik/sigmanet
PSNRLoss
false
15,823
[ "MIT" ]
50
6eb8dbd1ee350bb9baee60eb254080f7d660bbc5
https://github.com/khammernik/sigmanet/tree/6eb8dbd1ee350bb9baee60eb254080f7d660bbc5
LearnMaskedDefault
import torch import torch.nn as nn import torch.utils.data import torch.nn class LearnMaskedDefault(nn.Module): """ Learns default values to fill invalid entries within input tensors. The invalid entries are represented by a mask which is passed into forward alongside the input tensor. Note the defaul...
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 import torch.nn assert_size_stride = torch....
kevinmtian/pytorchvideo
LearnMaskedDefault
false
15,824
[ "Apache-2.0" ]
2,391
168e16859a6029ef8ebeb476f9163bebb6c6b87d
https://github.com/kevinmtian/pytorchvideo/tree/168e16859a6029ef8ebeb476f9163bebb6c6b87d
SpatialSoftArgmax
import torch from torch import Tensor import torch.nn as nn import torch.nn.functional as F class SpatialSoftArgmax(nn.Module): """Spatial softmax as defined in `1`_. Concretely, the spatial softmax of each feature map is used to compute a weighted mean of the pixel locations, effectively performing a so...
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 Tens...
kevinzakka/torchkit
SpatialSoftArgmax
false
15,825
[ "MIT" ]
144
930dba9560d2473406b59b99a474dce1a6621813
https://github.com/kevinzakka/torchkit/tree/930dba9560d2473406b59b99a474dce1a6621813
TransposeMultiheadAttention
import torch import torch.nn as nn from typing import Optional import torch.utils.data import torch.nn class TransposeMultiheadAttention(nn.Module): """ Wrapper for nn.MultiheadAttention which first transposes the input tensor from (batch_size, seq_len, feature_dim) to (seq_length, batch_size, feature_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 import triton_helpers from torch._inductor.runtime....
kevinmtian/pytorchvideo
TransposeMultiheadAttention
false
15,826
[ "Apache-2.0" ]
2,391
168e16859a6029ef8ebeb476f9163bebb6c6b87d
https://github.com/kevinmtian/pytorchvideo/tree/168e16859a6029ef8ebeb476f9163bebb6c6b87d
ScalingBlock
import torch import torch.nn as nn class ScalingBlock(nn.Module): def __init__(self, temp=5.0, **kwargs): super(ScalingBlock, self).__init__() self.temp = temp def forward(self, x): x = x / self.temp return x def extra_repr(self): return 'temp=%.3e' % 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 import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_st...
kimfunn/spatial-smoothing
ScalingBlock
false
15,827
[ "Apache-2.0" ]
438
4f849d57c66c2dbdfaa56fc28727e95eddfd337c
https://github.com/kimfunn/spatial-smoothing/tree/4f849d57c66c2dbdfaa56fc28727e95eddfd337c
ResidualBlock
import math import torch import torch.nn as nn class ConvNorm(nn.Module): """ 1D Convolution """ def __init__(self, in_channels, out_channels, kernel_size=1, stride=1, padding=None, dilation=1, bias=True, w_init_gain='linear'): super(ConvNorm, self).__init__() if padding is 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.triton_helpers import libdevice import torch.nn as ...
keonlee9420/DiffSinger
ResidualBlock
false
15,828
[ "MIT" ]
95
2bfcae4a78068c2061eae64ee675959a077aa54b
https://github.com/keonlee9420/DiffSinger/tree/2bfcae4a78068c2061eae64ee675959a077aa54b
FocalLoss
import torch import torch.nn as nn import torch.nn.functional as F def reduce_loss(loss, reduction): """Reduce loss as specified. Args: loss (Tensor): Elementwise loss tensor. reduction (str): Options are "none", "mean" and "sum". Return: Tensor: Reduced loss 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 import torc...
kivanctezoren/mmclassification
FocalLoss
false
15,829
[ "Apache-2.0" ]
1,190
5c73d4b29f61c47d379bbec4621a465099e64bd7
https://github.com/kivanctezoren/mmclassification/tree/5c73d4b29f61c47d379bbec4621a465099e64bd7
AsymmetricLoss
import torch import torch.nn as nn import torch.nn.functional as F def reduce_loss(loss, reduction): """Reduce loss as specified. Args: loss (Tensor): Elementwise loss tensor. reduction (str): Options are "none", "mean" and "sum". Return: Tensor: Reduced loss 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 import torc...
kivanctezoren/mmclassification
AsymmetricLoss
false
15,830
[ "Apache-2.0" ]
1,190
5c73d4b29f61c47d379bbec4621a465099e64bd7
https://github.com/kivanctezoren/mmclassification/tree/5c73d4b29f61c47d379bbec4621a465099e64bd7
TransformerEncoderLayerWithConv1d
import torch import torch.nn as nn import torch.nn.functional as F class TransformerEncoderLayerWithConv1d(nn.Module): """ Input and output shape: seqlen x batch_size x dim """ def __init__(self, dim_model, nheads, dim_feedforward, dropout, kernel_size, stride): super(TransformerEnc...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language 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....
jzlianglu/pykaldi2
TransformerEncoderLayerWithConv1d
false
15,831
[ "MIT" ]
179
4d31968f8dff7cccf6a8395b7e69005ae3b2b30a
https://github.com/jzlianglu/pykaldi2/tree/4d31968f8dff7cccf6a8395b7e69005ae3b2b30a
DeterministicSumming
import torch import torch.nn as nn class DeterministicSumming(nn.Module): """Transform a tensor into repetitions of its sum. Intended for use in tests, not useful for actual learning. The last dimension of the input should contain feature vectors. The result will be an array of matching shape with th...
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...
kiudee/cs-ranking
DeterministicSumming
false
15,832
[ "Apache-2.0" ]
65
47cf648fa286c37b9214bbad1926004d4d7d9796
https://github.com/kiudee/cs-ranking/tree/47cf648fa286c37b9214bbad1926004d4d7d9796
SparsityLoss
import torch import torch.nn as nn import torch.utils.data class SparsityLoss(nn.Module): """ Penalizes small values to encourage sparsity """ def __init__(self): super(SparsityLoss, self).__init__() self.power = 0.2 self.loss = nn.L1Loss() def forward(self, kernel): 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 from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math import torc...
kingsj0405/Explorable-Super-Resolution
SparsityLoss
false
15,833
[ "Apache-2.0" ]
54
6582477ec1e2b0c6f4bd781552ac880fabdb4496
https://github.com/kingsj0405/Explorable-Super-Resolution/tree/6582477ec1e2b0c6f4bd781552ac880fabdb4496
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....
BIT-ENGD/eeqa
BertSelfAttention
false
15,834
[ "MIT" ]
142
2995abbaff1fb47131246a247ee7ed62aa94f4c3
https://github.com/BIT-ENGD/eeqa/tree/2995abbaff1fb47131246a247ee7ed62aa94f4c3
WayPoly
import torch class WayPoly(torch.nn.Module): """Apply multiple modules to input and sum. It's equation for `poly_modules` length equal to :math:`N` could be expressed by !!!math I + F_1(I) + F_2(I) + ... + F_N where :math:`I` is identity and consecutive :math:`F_N` are consecutive `poly_mo...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda @triton.j...
klaudiapalasz/torchlayers
WayPoly
false
15,835
[ "MIT" ]
573
e6edd8797875325b7c0539d75a12f0d51f494127
https://github.com/klaudiapalasz/torchlayers/tree/e6edd8797875325b7c0539d75a12f0d51f494127
Spatial_Attention_layer
import torch import torch.utils.data import torch.nn.functional as F import torch.nn as nn class Spatial_Attention_layer(nn.Module): """ compute spatial attention scores """ def __init__(self, DEVICE, in_channels, num_of_vertices, num_of_timesteps): super(Spatial_Attention_layer, 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....
kevin-xuan/Traffic-Benchmark
Spatial_Attention_layer
false
15,836
[ "MIT" ]
120
b9f8e40b4df9b58f5ad88432dc070cbbbcdc0228
https://github.com/kevin-xuan/Traffic-Benchmark/tree/b9f8e40b4df9b58f5ad88432dc070cbbbcdc0228
Temporal_Attention_layer
import torch import torch.utils.data import torch.nn.functional as F import torch.nn as nn class Temporal_Attention_layer(nn.Module): def __init__(self, DEVICE, in_channels, num_of_vertices, num_of_timesteps): super(Temporal_Attention_layer, self).__init__() self.U1 = nn.Parameter(torch.FloatTens...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language 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....
kevin-xuan/Traffic-Benchmark
Temporal_Attention_layer
false
15,837
[ "MIT" ]
120
b9f8e40b4df9b58f5ad88432dc070cbbbcdc0228
https://github.com/kevin-xuan/Traffic-Benchmark/tree/b9f8e40b4df9b58f5ad88432dc070cbbbcdc0228
Optimizable_Temperature
import torch import torch.utils.data class Optimizable_Temperature(torch.nn.Module): def __init__(self, initial_temperature=None): super(Optimizable_Temperature, self).__init__() self.log_temperature = torch.nn.Parameter(data=torch.zeros([1]). type(torch.DoubleTensor)) if init...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.utils.data assert_size_stride = torch._C._dynamo.guards.assert_siz...
kingsj0405/Explorable-Super-Resolution
Optimizable_Temperature
false
15,838
[ "Apache-2.0" ]
54
6582477ec1e2b0c6f4bd781552ac880fabdb4496
https://github.com/kingsj0405/Explorable-Super-Resolution/tree/6582477ec1e2b0c6f4bd781552ac880fabdb4496
HardSigmoid
import torch def hard_sigmoid(tensor: 'torch.Tensor', inplace: 'bool'=False) ->torch.Tensor: """ Applies HardSigmoid function element-wise. See :class:`torchlayers.activations.HardSigmoid` for more details. Arguments: tensor : Tensor activated element-wise inplace : ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torc...
klaudiapalasz/torchlayers
HardSigmoid
false
15,839
[ "MIT" ]
573
e6edd8797875325b7c0539d75a12f0d51f494127
https://github.com/klaudiapalasz/torchlayers/tree/e6edd8797875325b7c0539d75a12f0d51f494127
Blur
import math import torch import torch.nn as nn import torch.nn.functional as F class SamePad(nn.Module): def __init__(self, filter_size, pad_mode='constant', **kwargs): super(SamePad, self).__init__() self.pad_size = [int((filter_size - 1) / 2.0), int(math.ceil(( filter_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 import math import torch.nn as nn import torch.nn.functional as F assert_size_st...
kimfunn/spatial-smoothing
Blur
false
15,840
[ "Apache-2.0" ]
438
4f849d57c66c2dbdfaa56fc28727e95eddfd337c
https://github.com/kimfunn/spatial-smoothing/tree/4f849d57c66c2dbdfaa56fc28727e95eddfd337c
Downsample
import torch import torch.nn as nn import torch.nn.functional as F class Downsample(nn.Module): def __init__(self, strides=(2, 2), **kwargs): super(Downsample, self).__init__() if isinstance(strides, int): strides = strides, strides self.strides = strides 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 import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_st...
kimfunn/spatial-smoothing
Downsample
false
15,841
[ "Apache-2.0" ]
438
4f849d57c66c2dbdfaa56fc28727e95eddfd337c
https://github.com/kimfunn/spatial-smoothing/tree/4f849d57c66c2dbdfaa56fc28727e95eddfd337c
SoftDiceLoss
import torch import torch.nn as nn import torch.nn.functional as F class SoftDiceLoss(nn.Module): def __init__(self, weight=None, size_average=True): super(SoftDiceLoss, self).__init__() def forward(self, logits, targets): smooth = 1.0 logits = F.sigmoid(logits) iflat = logit...
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...
kryptonite0/Global_Convolutional_Network
SoftDiceLoss
false
15,842
[ "MIT" ]
88
33de71bbe468f485eb38345f4982923945d1a0be
https://github.com/kryptonite0/Global_Convolutional_Network/tree/33de71bbe468f485eb38345f4982923945d1a0be
Swish
import torch def swish(tensor: 'torch.Tensor', beta: 'float'=1.0) ->torch.Tensor: """ Applies Swish function element-wise. See :class:`torchlayers.activations.Swish` for more details. Arguments: tensor : Tensor activated element-wise beta : Multiplier used 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 assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda @triton.j...
klaudiapalasz/torchlayers
Swish
false
15,843
[ "MIT" ]
573
e6edd8797875325b7c0539d75a12f0d51f494127
https://github.com/klaudiapalasz/torchlayers/tree/e6edd8797875325b7c0539d75a12f0d51f494127
ContextualCell
from _paritybench_helpers import _mock_config import torch from torch import nn def conv_bn_relu(C_in, C_out, kernel_size, stride, padding, affine=True): return nn.Sequential(nn.Conv2d(C_in, C_out, kernel_size, stride=stride, padding=padding, bias=False), nn.BatchNorm2d(C_out, affine=affine), nn.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 import nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_str...
DrSleep/nas-segm-pytorch
ContextualCell
false
15,844
[ "BSD-2-Clause" ]
155
5de0c5c60cc05f94305ff59ae9f822656e3e7a96
https://github.com/DrSleep/nas-segm-pytorch/tree/5de0c5c60cc05f94305ff59ae9f822656e3e7a96
DeepSet
import torch import torch.nn as nn class DeepSet(nn.Module): """Aggregate object-level embeddings with a mean reduction. This module evaluates each object individually (using a object level embedding) and then aggregates the embeddings with a mean reduction. Parameters ---------- n_features ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_s...
kiudee/cs-ranking
DeepSet
false
15,845
[ "Apache-2.0" ]
65
47cf648fa286c37b9214bbad1926004d4d7d9796
https://github.com/kiudee/cs-ranking/tree/47cf648fa286c37b9214bbad1926004d4d7d9796
ConvertFloatToUint8
import torch import torchvision import torch.utils.data import torchvision.transforms import torch.nn class ConvertFloatToUint8(torch.nn.Module): """ Converts a video from dtype float32 to dtype uint8. """ def __init__(self): super().__init__() self.convert_func = torchvision.transfor...
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 torchvision import torch.utils.data import torchvision.transforms import torch.nn assert_size_stride = torch._C._dynamo.guards.assert...
kevinmtian/pytorchvideo
ConvertFloatToUint8
false
15,846
[ "Apache-2.0" ]
2,391
168e16859a6029ef8ebeb476f9163bebb6c6b87d
https://github.com/kevinmtian/pytorchvideo/tree/168e16859a6029ef8ebeb476f9163bebb6c6b87d
NormSoftmaxLoss
import math import torch import torch.nn as nn from torch.nn import Parameter class NormSoftmaxLoss(nn.Module): """ L2 normalize weights and apply temperature scaling on logits. """ def __init__(self, dim, num_instances, temperature=0.05): super(NormSoftmaxLoss, self).__init__() self....
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
kikaitech/classification_metric_learning
NormSoftmaxLoss
false
15,847
[ "Apache-2.0" ]
93
6c90cecf8be01eda6efb7f6aa4049d8449ca33f1
https://github.com/kikaitech/classification_metric_learning/tree/6c90cecf8be01eda6efb7f6aa4049d8449ca33f1
Recon_Block
import torch from torch import nn class Recon_Block(nn.Module): def __init__(self, num_chans=64): super(Recon_Block, self).__init__() bias = True self.conv1 = nn.Conv2d(num_chans, num_chans, kernel_size=3, stride= 1, padding=1, bias=bias) self.relu2 = nn.PReLU() ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import 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...
khammernik/sigmanet
Recon_Block
false
15,848
[ "MIT" ]
50
6eb8dbd1ee350bb9baee60eb254080f7d660bbc5
https://github.com/khammernik/sigmanet/tree/6eb8dbd1ee350bb9baee60eb254080f7d660bbc5
GaussianLayer
import torch import torch.nn as nn class GaussianLayer(nn.Module): def __init__(self, std, device): super().__init__() self.std = std self.device = device def forward(self, x): return x + self.std * torch.randn_like(x) def get_inputs(): return [torch.rand([4, 4, 4, 4])]...
import torch from torch import device import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride @triton.jit def triton_poi_...
krylea/mine-pytorch
GaussianLayer
false
15,849
[ "MIT" ]
108
a638ca3e46ff21a3b9dfebe25480eaed0e3304bc
https://github.com/krylea/mine-pytorch/tree/a638ca3e46ff21a3b9dfebe25480eaed0e3304bc
Expansion2D
import torch class Expansion2D(torch.nn.Module): """ Expands a tensor in the last two dimensions, effectively to a coarse grid of smaller grids. """ def __init__(self, expsize1: 'int', expsize2: 'int'): """ :param expsize1: size of the second last dimension to be created :...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda @triton.j...
kpoeppel/pytorch_probgraph
Expansion2D
false
15,850
[ "BSD-3-Clause" ]
47
b78595ab03bbe92595ad2f6b35f5dd8bf84d6da0
https://github.com/kpoeppel/pytorch_probgraph/tree/b78595ab03bbe92595ad2f6b35f5dd8bf84d6da0
Projection
import torch from typing import Tuple class Projection(torch.nn.Module): """ | A class for a projection of an input to a different shape effectively mapping from | [..., inshape[1] .. inshape[-1]] -> [..., outshape[1] .. outshape[-1]] | only going over the subelements. | Example input (4,6) 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 from typing import Tuple assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty...
kpoeppel/pytorch_probgraph
Projection
false
15,851
[ "BSD-3-Clause" ]
47
b78595ab03bbe92595ad2f6b35f5dd8bf84d6da0
https://github.com/kpoeppel/pytorch_probgraph/tree/b78595ab03bbe92595ad2f6b35f5dd8bf84d6da0
AngleSimpleLinear
import torch import torch.nn.parallel import torch.optim import torch.utils.data.distributed import torch.nn as nn from torch.nn import Parameter import torch.nn.functional as F class AngleSimpleLinear(nn.Module): """Computes cos of angles between input vectors and weights vectors""" def __init__(self, in_fe...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
kprokofi/ML_Decoder
AngleSimpleLinear
false
15,852
[ "MIT" ]
99
c01c50e0165e607afbebd8d615708ef9c084dd5b
https://github.com/kprokofi/ML_Decoder/tree/c01c50e0165e607afbebd8d615708ef9c084dd5b
MultiHeadAttention
import torch import torch.nn as nn class MultiHeadAttention(nn.Module): def __init__(self, num_q_channels: 'int', num_kv_channels: 'int', num_heads: 'int', dropout: 'float'): super().__init__() self.attention = nn.MultiheadAttention(embed_dim=num_q_channels, num_heads=num_head...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language 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....
krasserm/perceiver-io
MultiHeadAttention
false
15,853
[ "Apache-2.0" ]
133
16e1029300304b617c0b0ae8eb06129ec103c755
https://github.com/krasserm/perceiver-io/tree/16e1029300304b617c0b0ae8eb06129ec103c755
SoftInvDiceLoss
import torch import torch.nn as nn import torch.nn.functional as F class SoftInvDiceLoss(nn.Module): def __init__(self, weight=None, size_average=True): super(SoftInvDiceLoss, self).__init__() def forward(self, logits, targets): smooth = 1.0 logits = F.sigmoid(logits) iflat =...
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...
kryptonite0/Global_Convolutional_Network
SoftInvDiceLoss
false
15,854
[ "MIT" ]
88
33de71bbe468f485eb38345f4982923945d1a0be
https://github.com/kryptonite0/Global_Convolutional_Network/tree/33de71bbe468f485eb38345f4982923945d1a0be
SelfAttention
import torch import torch.nn as nn class MultiHeadAttention(nn.Module): def __init__(self, num_q_channels: 'int', num_kv_channels: 'int', num_heads: 'int', dropout: 'float'): super().__init__() self.attention = nn.MultiheadAttention(embed_dim=num_q_channels, num_heads=num_head...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language 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....
krasserm/perceiver-io
SelfAttention
false
15,855
[ "Apache-2.0" ]
133
16e1029300304b617c0b0ae8eb06129ec103c755
https://github.com/krasserm/perceiver-io/tree/16e1029300304b617c0b0ae8eb06129ec103c755
TransitionUp
import torch from torch import nn import torch.onnx import torch.nn.functional as F import torch.utils.data class TransitionUp(nn.Module): def __init__(self, in_channels, out_channels): super().__init__() def forward(self, x, skip, concat=True): out = F.interpolate(x, size=(skip.size(2), ski...
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 import torch.onnx import torch.utils.data assert_size_stride = torch...
kuanhungchen/CenterNet-HarDNet
TransitionUp
false
15,856
[ "MIT" ]
164
050d55a532706d989105982c5bc10f1c89edc8d2
https://github.com/kuanhungchen/CenterNet-HarDNet/tree/050d55a532706d989105982c5bc10f1c89edc8d2
CrossAttention
import torch import torch.nn as nn class MultiHeadAttention(nn.Module): def __init__(self, num_q_channels: 'int', num_kv_channels: 'int', num_heads: 'int', dropout: 'float'): super().__init__() self.attention = nn.MultiheadAttention(embed_dim=num_q_channels, num_heads=num_head...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language 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....
krasserm/perceiver-io
CrossAttention
false
15,857
[ "Apache-2.0" ]
133
16e1029300304b617c0b0ae8eb06129ec103c755
https://github.com/krasserm/perceiver-io/tree/16e1029300304b617c0b0ae8eb06129ec103c755
ResNetBlock
from torch.nn import Module import torch from torch.nn import Conv2d from torch.nn import InstanceNorm2d from torch.nn.init import kaiming_normal_ from torch.nn.init import xavier_normal_ from torch import relu def create_init_function(method: 'str'='none'): def init(module: 'Module'): if method == '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....
kongdongdien/talking-head-anime-demo
ResNetBlock
false
15,858
[ "MIT" ]
1,670
d66c27a341f7256e4a37c55493b93dc9e846b423
https://github.com/kongdongdien/talking-head-anime-demo/tree/d66c27a341f7256e4a37c55493b93dc9e846b423
PoswiseFeedForwardNet
from _paritybench_helpers import _mock_config import torch import torch.nn as nn import torch.nn.functional as F class PoswiseFeedForwardNet(nn.Module): def __init__(self, config): super().__init__() self.config = config self.conv1 = nn.Conv1d(in_channels=self.config.d_hidn, out_channels ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language 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 ...
kyuhyoung/transformer-evolution
PoswiseFeedForwardNet
false
15,859
[ "Apache-2.0" ]
105
fae06f677df0be55c67cd58efea158e5517ac045
https://github.com/kyuhyoung/transformer-evolution/tree/fae06f677df0be55c67cd58efea158e5517ac045
JaccardLoss
import torch from torch import nn def jaccard(outputs, targets, per_image=False, non_empty=False, min_pixels=5): batch_size = outputs.size()[0] eps = 0.001 if not per_image: batch_size = 1 dice_target = targets.contiguous().view(batch_size, -1).float() dice_output = outputs.contiguous().vi...
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...
ktncktnc/SpaceNet_Off_Nadir_Solutions
JaccardLoss
false
15,860
[ "Apache-2.0" ]
164
2a9ef1c3b72fb749c808ddb8593a85cb16b9f1ca
https://github.com/ktncktnc/SpaceNet_Off_Nadir_Solutions/tree/2a9ef1c3b72fb749c808ddb8593a85cb16b9f1ca
dy_nconv
import torch import torch.utils.data import torch.nn as nn class dy_nconv(nn.Module): def __init__(self): super(dy_nconv, self).__init__() def forward(self, x, A): x = torch.einsum('ncvl,nvwl->ncwl', (x, A)) return x.contiguous() def get_inputs(): return [torch.rand([4, 4, 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.utils.data import torch.nn as nn assert_size_stride = torch._C._dyn...
kevin-xuan/Traffic-Benchmark
dy_nconv
false
15,861
[ "MIT" ]
120
b9f8e40b4df9b58f5ad88432dc070cbbbcdc0228
https://github.com/kevin-xuan/Traffic-Benchmark/tree/b9f8e40b4df9b58f5ad88432dc070cbbbcdc0228
BertAttention
from _paritybench_helpers import _mock_config import math import torch import torch.nn import torch.nn as nn class BertAttention(nn.Module): """BERT attention layer. Based on: BERT (pytorch-transformer) https://github.com/huggingface/transformers """ def __init__(self, config) ->None: sup...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
Project-MONAI/MONAI
BertAttention
false
15,862
[ "Apache-2.0" ]
2,971
2bab12c67c3cc1d54a4847628ce1e879064be11c
https://github.com/Project-MONAI/MONAI/tree/2bab12c67c3cc1d54a4847628ce1e879064be11c
ResBlock
import torch import torch.nn as nn import torch.nn.functional as F def get_conv(in_dim, out_dim, kernel_size, stride, padding, zero_bias=True, zero_weights=False, groups=1): c = nn.Conv2d(in_dim, out_dim, kernel_size, stride, padding, groups=groups) if zero_bias: c.bias.data *= 0.0 if zero_wei...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language 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 ...
kpandey008/DiffuseVAE
ResBlock
false
15,863
[ "MIT" ]
90
b505894668ac1e4ef9a66ec220f5b40f5c83629e
https://github.com/kpandey008/DiffuseVAE/tree/b505894668ac1e4ef9a66ec220f5b40f5c83629e
RegLoss
import torch from torch import nn import torch.onnx from torch.nn.parallel.scatter_gather import gather import torch.utils.data def _gather_feat(feat, ind, mask=None, trt=False): dim = feat.size(2) ind = ind.unsqueeze(2).expand(ind.size(0), ind.size(1), dim) if trt: feat = gather(feat, 1, ind) ...
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 i...
kuanhungchen/CenterNet-HarDNet
RegLoss
false
15,864
[ "MIT" ]
164
050d55a532706d989105982c5bc10f1c89edc8d2
https://github.com/kuanhungchen/CenterNet-HarDNet/tree/050d55a532706d989105982c5bc10f1c89edc8d2
dy_mixprop
import torch import torch.utils.data import torch.nn as nn class linear(nn.Module): def __init__(self, c_in, c_out, bias=True): super(linear, self).__init__() self.mlp = torch.nn.Conv2d(c_in, c_out, kernel_size=(1, 1), padding =(0, 0), stride=(1, 1), bias=bias) def forward(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....
kevin-xuan/Traffic-Benchmark
dy_mixprop
false
15,865
[ "MIT" ]
120
b9f8e40b4df9b58f5ad88432dc070cbbbcdc0228
https://github.com/kevin-xuan/Traffic-Benchmark/tree/b9f8e40b4df9b58f5ad88432dc070cbbbcdc0228
FBLoss
import torch from torch import nn def fb_loss(preds, trues, beta): smooth = 0.0001 beta2 = beta * beta batch = preds.size(0) classes = preds.size(1) preds = preds.view(batch, classes, -1) trues = trues.view(batch, classes, -1) weights = torch.clamp(trues.sum(-1), 0.0, 1.0) TP = (preds ...
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...
lRomul/argus-tgs-salt
FBLoss
false
15,866
[ "MIT" ]
74
2ba7db4d09256bc025c49860cd79560ced6b8a1b
https://github.com/lRomul/argus-tgs-salt/tree/2ba7db4d09256bc025c49860cd79560ced6b8a1b
PositionwiseFeedForward
import torch import torch.nn as nn import torch.nn.functional as F class PositionwiseFeedForward(nn.Module): """ A two-feed-forward-layer module """ def __init__(self, d_in, d_hid, dropout=0.1): super().__init__() self.w_1 = nn.Linear(d_in, d_hid) self.w_2 = nn.Linear(d_hid, d_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....
kyteinsky/OmniNet
PositionwiseFeedForward
false
15,867
[ "Apache-2.0" ]
525
497dfbeaa9e4bdd8b076152e71ab7999ca5cfc4a
https://github.com/kyteinsky/OmniNet/tree/497dfbeaa9e4bdd8b076152e71ab7999ca5cfc4a
RegWeightedL1Loss
import torch from torch import nn import torch.onnx from torch.nn.parallel.scatter_gather import gather import torch.nn.functional as F import torch.utils.data def _gather_feat(feat, ind, mask=None, trt=False): dim = feat.size(2) ind = ind.unsqueeze(2).expand(ind.size(0), ind.size(1), dim) if trt: ...
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 i...
kuanhungchen/CenterNet-HarDNet
RegWeightedL1Loss
false
15,868
[ "MIT" ]
164
050d55a532706d989105982c5bc10f1c89edc8d2
https://github.com/kuanhungchen/CenterNet-HarDNet/tree/050d55a532706d989105982c5bc10f1c89edc8d2
Fusion
from _paritybench_helpers import _mock_config import torch from torch import nn import torch.nn.init class Fusion(nn.Module): def __init__(self, opt): super(Fusion, self).__init__() self.f_size = opt.embed_size self.gate0 = nn.Linear(self.f_size, self.f_size) self.gate1 = nn.Linea...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import 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.init assert_size_stride = torch._C._dynamo....
kywen1119/DSRAN
Fusion
false
15,869
[ "Apache-2.0" ]
56
eb5e515c8d9e527de493f32b62469107a9d398e7
https://github.com/kywen1119/DSRAN/tree/eb5e515c8d9e527de493f32b62469107a9d398e7
folder
import torch from torch import nn import torch.nn.functional as F import torch.nn.parallel class folder(nn.Module): def __init__(self): super().__init__() def forward(self, feature_map): N, _, H, W = feature_map.size() feature_map = F.unfold(feature_map, kernel_size=3, padding=1) ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch import nn import torch.nn.parallel assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C....
lbin/AdelaiDet
folder
false
15,870
[ "BSD-2-Clause" ]
277
9bfb73c51d6e6cd1348cb9ed2174b1cb63bc662a
https://github.com/lbin/AdelaiDet/tree/9bfb73c51d6e6cd1348cb9ed2174b1cb63bc662a
CEL
import torch from torch import nn class CEL(nn.Module): def __init__(self): super(CEL, self).__init__() None self.eps = 1e-06 def forward(self, pred, target): pred = pred.sigmoid() intersection = pred * target numerator = (pred - intersection).sum() + (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 import triton_helpers from torch import nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empt...
lartpang/MINet
CEL
false
15,871
[ "MIT" ]
202
0f4ecf70010af83b432bebc614af90d86a4a6564
https://github.com/lartpang/MINet/tree/0f4ecf70010af83b432bebc614af90d86a4a6564
StackTime
import torch import torch.nn as nn import torch.utils.data import torch.jit import torch.optim import torch.utils.collect_env import torch.nn.parallel import torch.utils.data.distributed class StackTime(nn.Module): def __init__(self, factor): super().__init__() self.factor = int(factor) 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 import torch.nn as nn import torch.utils.data import torch.jit import torch.optim import torch.utils.collect_env import torch.nn.parallel im...
lamyiowce/training
StackTime
false
15,872
[ "Apache-2.0" ]
567
da4c959b5a7b65091b850872cdd4014d768c087c
https://github.com/lamyiowce/training/tree/da4c959b5a7b65091b850872cdd4014d768c087c
LayerNormalization
import torch from torch import nn from torch.autograd import * 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)...
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 from torch.autograd import * assert_size_stride = torch._C...
learnerhouse/ner-bert
LayerNormalization
false
15,873
[ "MIT" ]
391
606328a27a7313b6c22b78590e06618ad77402cd
https://github.com/learnerhouse/ner-bert/tree/606328a27a7313b6c22b78590e06618ad77402cd
D
import torch import torch.nn as nn import torch.nn.functional as F class D(nn.Module): def __init__(self): super(D, self).__init__() def forward(self, p, z): z = z.detach() p = F.normalize(p, p=2, dim=1) z = F.normalize(z, p=2, dim=1) return -(p * z).sum(dim=1).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 import torch.nn as nn assert...
leaderj1001/SimSiam
D
false
15,874
[ "MIT" ]
53
ed36348d3d5a8621674c78c3ed77c1188bd18e16
https://github.com/leaderj1001/SimSiam/tree/ed36348d3d5a8621674c78c3ed77c1188bd18e16
TishbyNet
import math import torch import numpy as np import torch.nn as nn from torch.nn import functional as F def ema(mu, alpha, past_ema): return alpha * mu + (1.0 - alpha) * past_ema def ema_loss(x, running_mean, alpha): t_exp = torch.exp(torch.logsumexp(x, 0) - math.log(x.shape[0])).detach() if running_mean...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language 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 ...
krylea/mine-pytorch
TishbyNet
false
15,875
[ "MIT" ]
108
a638ca3e46ff21a3b9dfebe25480eaed0e3304bc
https://github.com/krylea/mine-pytorch/tree/a638ca3e46ff21a3b9dfebe25480eaed0e3304bc
ConvLayer
import torch import torch.nn as nn class ConvLayer(nn.Module): """1-D Convolution layer to extract high-level features of each time-series input :param n_features: Number of input features/nodes :param window_size: length of the input sequence :param kernel_size: size of kernel to use in the convoluti...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language 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_...
lawson-source/mtad-gat-pytorch
ConvLayer
false
15,876
[ "MIT" ]
93
9e671ea99dedd82ac55f53e53af1d1b56c13ebff
https://github.com/lawson-source/mtad-gat-pytorch/tree/9e671ea99dedd82ac55f53e53af1d1b56c13ebff
MixtureSynthesizers
import torch import torch.nn as nn class MixtureSynthesizers(nn.Module): def __init__(self, in_dims, sentence_length): super(MixtureSynthesizers, self).__init__() self.attention = nn.Parameter(torch.empty(1, sentence_length, sentence_length), requires_grad=True) nn.init.xavier...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language 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....
leaderj1001/Synthesizer-Rethinking-Self-Attention-Transformer-Models
MixtureSynthesizers
false
15,877
[ "MIT" ]
58
3ee5829438a8f9c063ae485e77c9ce7649d24139
https://github.com/leaderj1001/Synthesizer-Rethinking-Self-Attention-Transformer-Models/tree/3ee5829438a8f9c063ae485e77c9ce7649d24139
FactorizedSynthesizerDense
import torch import torch.nn as nn class FactorizedSynthesizerDense(nn.Module): def __init__(self, in_dims, sentence_length): super(FactorizedSynthesizerDense, self).__init__() self.a = 4 self.b = sentence_length // self.a self.a_proj = nn.Linear(in_dims, self.a) self.b_pr...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language 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....
leaderj1001/Synthesizer-Rethinking-Self-Attention-Transformer-Models
FactorizedSynthesizerDense
false
15,878
[ "MIT" ]
58
3ee5829438a8f9c063ae485e77c9ce7649d24139
https://github.com/leaderj1001/Synthesizer-Rethinking-Self-Attention-Transformer-Models/tree/3ee5829438a8f9c063ae485e77c9ce7649d24139
TemporalAttentionLayer
import torch import torch.nn as nn class TemporalAttentionLayer(nn.Module): """Single Graph Temporal Attention Layer :param n_features: number of input features/nodes :param window_size: length of the input sequence :param dropout: percentage of nodes to dropout :param alpha: negative slope used 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....
lawson-source/mtad-gat-pytorch
TemporalAttentionLayer
false
15,879
[ "MIT" ]
93
9e671ea99dedd82ac55f53e53af1d1b56c13ebff
https://github.com/lawson-source/mtad-gat-pytorch/tree/9e671ea99dedd82ac55f53e53af1d1b56c13ebff
ResBlock3d
import torch from torch import nn class ResBlock3d(nn.Module): def __init__(self, in_ch, out_ch): super(ResBlock3d, self).__init__() self.conv1 = nn.Conv3d(in_ch, out_ch, 3, 1, padding=1) self.conv2 = nn.Conv3d(out_ch, out_ch, 3, 1, padding=1) self.bn = nn.InstanceNorm3d(in_ch) ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice from torch import n...
ldlasso2/hologan-pytorch
ResBlock3d
false
15,880
[ "BSD-3-Clause" ]
61
baec67d3673cc68e51434516d19465f3d6dd0a1b
https://github.com/ldlasso2/hologan-pytorch/tree/baec67d3673cc68e51434516d19465f3d6dd0a1b
HEL
import torch import torch.nn as nn import torch.nn.functional as F class HEL(nn.Module): def __init__(self): super(HEL, self).__init__() None self.eps = 1e-06 def edge_loss(self, pred, target): edge = target - F.avg_pool2d(target, kernel_size=5, stride=1, padding=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 from torch._inductor.runtime.triton_helpers import math as tl_math import torch.nn as nn import torch.nn.functional as F assert_size_stride ...
lartpang/HDFNet
HEL
false
15,881
[ "MIT" ]
67
e2e4136a336f171481d2a6a954e901568932b8d3
https://github.com/lartpang/HDFNet/tree/e2e4136a336f171481d2a6a954e901568932b8d3
FactorizedSynthesizerRandom
import torch import torch.nn as nn class FactorizedSynthesizerRandom(nn.Module): def __init__(self, in_dims): super(FactorizedSynthesizerRandom, self).__init__() self.k = 8 self.query_fc = nn.Linear(in_dims, self.k) self.key_fc = nn.Linear(in_dims, self.k) self.value_fc = ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language 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....
leaderj1001/Synthesizer-Rethinking-Self-Attention-Transformer-Models
FactorizedSynthesizerRandom
false
15,882
[ "MIT" ]
58
3ee5829438a8f9c063ae485e77c9ce7649d24139
https://github.com/leaderj1001/Synthesizer-Rethinking-Self-Attention-Transformer-Models/tree/3ee5829438a8f9c063ae485e77c9ce7649d24139
FeatureAttentionLayer
import torch import torch.nn as nn class FeatureAttentionLayer(nn.Module): """Single Graph Feature/Spatial Attention Layer :param n_features: Number of input features/nodes :param window_size: length of the input sequence :param dropout: percentage of nodes to dropout :param alpha: negative slope ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language 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....
lawson-source/mtad-gat-pytorch
FeatureAttentionLayer
false
15,883
[ "MIT" ]
93
9e671ea99dedd82ac55f53e53af1d1b56c13ebff
https://github.com/lawson-source/mtad-gat-pytorch/tree/9e671ea99dedd82ac55f53e53af1d1b56c13ebff
_Residual_Block
import torch from torch import nn class _Residual_Block(nn.Module): def __init__(self, num_chans=64): super(_Residual_Block, self).__init__() bias = True self.conv1 = nn.Conv2d(num_chans, num_chans, kernel_size=3, stride= 1, padding=1, bias=bias) self.relu2 = nn.PReLU(...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import 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...
khammernik/sigmanet
_Residual_Block
false
15,884
[ "MIT" ]
50
6eb8dbd1ee350bb9baee60eb254080f7d660bbc5
https://github.com/khammernik/sigmanet/tree/6eb8dbd1ee350bb9baee60eb254080f7d660bbc5
Transformer
import torch import torch.nn as nn class Transformer(nn.Module): def __init__(self, in_dims): super(Transformer, self).__init__() self.temperature = in_dims ** 0.5 self.query_fc = nn.Linear(in_dims, in_dims) self.key_fc = nn.Linear(in_dims, in_dims) self.value_fc = nn.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 from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
leaderj1001/Synthesizer-Rethinking-Self-Attention-Transformer-Models
Transformer
false
15,885
[ "MIT" ]
58
3ee5829438a8f9c063ae485e77c9ce7649d24139
https://github.com/leaderj1001/Synthesizer-Rethinking-Self-Attention-Transformer-Models/tree/3ee5829438a8f9c063ae485e77c9ce7649d24139
DiceLoss
import torch import torch.nn as nn class DiceLoss(nn.Module): def __init__(self): super(DiceLoss, self).__init__() def forward(self, input, target): N = target.size(0) smooth = 1 input_flat = input.view(N, -1) target_flat = target.view(N, -1) intersection = 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 import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_st...
lee-zq/VesselSeg-pytorch
DiceLoss
false
15,886
[ "Apache-2.0" ]
83
b4f6571fc1fb1fbdaad60ff9282a54a1f1c455fa
https://github.com/lee-zq/VesselSeg-pytorch/tree/b4f6571fc1fb1fbdaad60ff9282a54a1f1c455fa
CapsuleLoss
import torch import torch.nn.functional as F from torch import nn class CapsuleLoss(nn.Module): def __init__(self): super(CapsuleLoss, self).__init__() self.reconstruction_loss = nn.MSELoss(size_average=False) def forward(self, images, labels, classes, reconstructions): left = F.relu...
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...
leftthomas/CapsNet
CapsuleLoss
false
15,887
[ "MIT" ]
163
5de2f45daadbe4377df4ccf8a4d31683d7f397bf
https://github.com/leftthomas/CapsNet/tree/5de2f45daadbe4377df4ccf8a4d31683d7f397bf
CircularPad
import torch class CircularPad(torch.nn.Module): def __init__(self, padding=(1, 1, 0, 0)): super(CircularPad, self).__init__() self.padding = padding def forward(self, input): return torch.nn.functional.pad(input=input, pad=self.padding, mode= 'circular') def get_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 assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda @triton.j...
leggedrobotics/DeLORA
CircularPad
false
15,888
[ "BSD-3-Clause" ]
154
909948d63a9517e6dd54bedcf099f6b39ded2cb4
https://github.com/leggedrobotics/DeLORA/tree/909948d63a9517e6dd54bedcf099f6b39ded2cb4
M
import torch import torch.nn.parallel import torch.utils.data import torch.onnx import torch.fx import torch.optim import torch.utils.data.distributed class M(torch.nn.Module): def __init__(self): super().__init__() def forward(self, x, y): y = torch.cat([x, y]) return y def get_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 import torch.nn.parallel import torch.utils.data import torch.onnx import torch.fx import torch.optim import torch.utils.data.distributed as...
lenaguignard/examples
M
false
15,889
[ "BSD-3-Clause" ]
19,783
973e77b725a6028289a90170f0b237ea2e71d4f2
https://github.com/lenaguignard/examples/tree/973e77b725a6028289a90170f0b237ea2e71d4f2
FirstResBlockDiscriminator
import torch import numpy as np from torch import nn from torch.nn.utils.spectral_norm import spectral_norm as SpectralNorm class FirstResBlockDiscriminator(nn.Module): def __init__(self, in_channels, out_channels, stride=1, spec_norm=False): super(FirstResBlockDiscriminator, self).__init__() 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 numpy as np from torch...
ldlasso2/hologan-pytorch
FirstResBlockDiscriminator
false
15,890
[ "BSD-3-Clause" ]
61
baec67d3673cc68e51434516d19465f3d6dd0a1b
https://github.com/ldlasso2/hologan-pytorch/tree/baec67d3673cc68e51434516d19465f3d6dd0a1b
Tacotron2Loss
import torch import torch.utils.data from torch import nn class Tacotron2Loss(nn.Module): def __init__(self): super(Tacotron2Loss, self).__init__() def forward(self, model_output, targets): mel_target, gate_target = targets[0], targets[1] mel_out_before, mel_out_after, gate_out, _ = ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math import torc...
leijue222/tacotron2
Tacotron2Loss
false
15,891
[ "BSD-3-Clause" ]
93
5950728a91e7a9355f42f658e00db2a2aef94247
https://github.com/leijue222/tacotron2/tree/5950728a91e7a9355f42f658e00db2a2aef94247
LocationLayer
import torch import torch.utils.data from torch import nn class LinearNorm(torch.nn.Module): def __init__(self, in_dim, out_dim, bias=True, w_init_gain='linear'): super(LinearNorm, self).__init__() self.linear_layer = torch.nn.Linear(in_dim, out_dim, bias=bias) def forward(self, x): ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.utils.data from torch import nn assert_size_stride = torch._C._dyna...
leijue222/tacotron2
LocationLayer
false
15,892
[ "BSD-3-Clause" ]
93
5950728a91e7a9355f42f658e00db2a2aef94247
https://github.com/leijue222/tacotron2/tree/5950728a91e7a9355f42f658e00db2a2aef94247
ResBlock2d
import torch from torch import nn class ResBlock2d(nn.Module): def __init__(self, in_ch, out_ch): super(ResBlock2d, self).__init__() self.conv1 = nn.Conv2d(in_ch, out_ch, 3, 1, padding=1) self.conv2 = nn.Conv2d(out_ch, out_ch, 3, 1, padding=1) self.bn = nn.InstanceNorm2d(in_ch) ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice from torch import n...
ldlasso2/hologan-pytorch
ResBlock2d
false
15,893
[ "BSD-3-Clause" ]
61
baec67d3673cc68e51434516d19465f3d6dd0a1b
https://github.com/ldlasso2/hologan-pytorch/tree/baec67d3673cc68e51434516d19465f3d6dd0a1b
SpatialAttention
import torch import torch.nn as nn class SpatialAttention(nn.Module): def __init__(self, kernel_size=3): super(SpatialAttention, self).__init__() assert kernel_size in (3, 7), 'kernel size must be 3 or 7' padding = 3 if kernel_size == 7 else 1 self.conv1 = nn.Conv2d(2, 1, kernel_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 import torch.nn as nn assert_...
lee-zq/VesselSeg-pytorch
SpatialAttention
false
15,894
[ "Apache-2.0" ]
83
b4f6571fc1fb1fbdaad60ff9282a54a1f1c455fa
https://github.com/lee-zq/VesselSeg-pytorch/tree/b4f6571fc1fb1fbdaad60ff9282a54a1f1c455fa