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
CategoricalAccuracy
import torch class _Metric(torch.nn.Module): def __init__(self): super().__init__() def forward(self, input: 'torch.Tensor', target: 'torch.Tensor'): raise NotImplementedError() class Accuracy(_Metric): def __init__(self): super().__init__() def forward(self, input: 'torc...
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 assert_size_stride = t...
NestLakerJasonLIN/MusicTransformer-pytorch
CategoricalAccuracy
false
5,656
[ "MIT" ]
1
5f183374833ff6b7e17f3a24e3594dedd93a5fe5
https://github.com/NestLakerJasonLIN/MusicTransformer-pytorch/tree/5f183374833ff6b7e17f3a24e3594dedd93a5fe5
Theta
from torch.autograd import Function import torch from typing import Tuple from typing import Optional import torch.nn as nn import torch.utils.data from typing import Any class GradientReverseFunction(Function): @staticmethod def forward(ctx: 'Any', input: 'torch.Tensor', coeff: 'Optional[float]'=1.0 ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch.autograd import Function from typing import Tuple from typing import ...
Neronjust2017/TransferBed
Theta
false
5,657
[ "MIT" ]
1
eaa703a4bc10eaf6216fe1394cd272f6e75489e2
https://github.com/Neronjust2017/TransferBed/tree/eaa703a4bc10eaf6216fe1394cd272f6e75489e2
GramMatrix
import torch import torch.nn as nn class GramMatrix(nn.Module): def forward(self, input): _, channels, h, w = input.size() out = input.view(-1, h * w) out = torch.mm(out, out.t()) return out.div(channels * h * w) def get_inputs(): return [torch.rand([4, 4, 4, 4])] def get_...
import torch from torch._inductor.select_algorithm import extern_kernels import 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...
NeilWangziyu/torch_light
GramMatrix
false
5,658
[ "MIT" ]
1
daf8fd62f57885cf182f1b3edc3152156d229ef3
https://github.com/NeilWangziyu/torch_light/tree/daf8fd62f57885cf182f1b3edc3152156d229ef3
Network
import torch import torch.nn as nn import torch.nn.functional as F class Network(nn.Module): def __init__(self, input_size, action_size): super(Network, self).__init__() self.fc1 = nn.Linear(input_size, 256) self.fc2 = nn.Linear(256, 256) self.logits_p = nn.Linear(256, action_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 assert_...
NeuralFlux/rl-analysis
Network
false
5,659
[ "MIT" ]
1
bb45e1f8bb9da4683cce4bd0a5e687770a4005e2
https://github.com/NeuralFlux/rl-analysis/tree/bb45e1f8bb9da4683cce4bd0a5e687770a4005e2
Actor
import torch import torch.nn as nn import torch.nn.functional as F class Actor(nn.Module): def __init__(self, input_size, action_size): super(Actor, self).__init__() self.fc1 = nn.Linear(input_size, 200) self.output = nn.Linear(200, action_size) def forward(self, x): x = F.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 from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_...
NeuralFlux/rl-analysis
Actor
false
5,660
[ "MIT" ]
1
bb45e1f8bb9da4683cce4bd0a5e687770a4005e2
https://github.com/NeuralFlux/rl-analysis/tree/bb45e1f8bb9da4683cce4bd0a5e687770a4005e2
DoubleResolutionLayer
import torch import torch.nn as nn class DoubleResolutionLayer(nn.Module): def forward(self, x): x = nn.functional.interpolate(x, scale_factor=2, mode='nearest') return x def get_inputs(): return [torch.rand([4, 4, 4, 4])] def get_init_inputs(): return [[], {}]
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_st...
NunoEdgarGFlowHub/gandissect
DoubleResolutionLayer
false
5,661
[ "MIT" ]
1
1a162a6bd3d4842139feb9f191aa1fad565dee4e
https://github.com/NunoEdgarGFlowHub/gandissect/tree/1a162a6bd3d4842139feb9f191aa1fad565dee4e
ConvSwishInplace
import torch from torch import nn import torch.cuda import torch.backends.cudnn import torch.backends.mkl import torch.backends.cuda import torch.backends.quantized class ConvSwishInplace(nn.Module): def __init__(self, in_channels, out_channels, kernel_size, image_size): super(ConvSwishInplace, self).__i...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch import nn import torch.cuda import torch.backends.cudnn import torch....
Observer007/intel-extension-for-pytorch
ConvSwishInplace
false
5,662
[ "Apache-2.0" ]
1
f8ab25c305c89d5aaf06190a4fec0727aeb4dcd7
https://github.com/Observer007/intel-extension-for-pytorch/tree/f8ab25c305c89d5aaf06190a4fec0727aeb4dcd7
PixelNormLayer
import torch import torch.nn as nn class PixelNormLayer(nn.Module): def __init__(self): super(PixelNormLayer, self).__init__() def forward(self, x): return x / torch.sqrt(torch.mean(x ** 2, dim=1, keepdim=True) + 1e-08) def get_inputs(): return [torch.rand([4, 4, 4, 4])] def get_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.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_...
NunoEdgarGFlowHub/gandissect
PixelNormLayer
false
5,663
[ "MIT" ]
1
1a162a6bd3d4842139feb9f191aa1fad565dee4e
https://github.com/NunoEdgarGFlowHub/gandissect/tree/1a162a6bd3d4842139feb9f191aa1fad565dee4e
ConvSwishOutplace
import torch from torch import nn import torch.cuda import torch.backends.cudnn import torch.backends.mkl import torch.backends.cuda import torch.backends.quantized class ConvSwishOutplace(nn.Module): def __init__(self, in_channels, out_channels, kernel_size, image_size): super(ConvSwishOutplace, 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 import nn import torch.cuda import torch.backends.cudnn import torch....
Observer007/intel-extension-for-pytorch
ConvSwishOutplace
false
5,664
[ "Apache-2.0" ]
1
f8ab25c305c89d5aaf06190a4fec0727aeb4dcd7
https://github.com/Observer007/intel-extension-for-pytorch/tree/f8ab25c305c89d5aaf06190a4fec0727aeb4dcd7
ConvHardtanh
import torch from torch import nn import torch.cuda import torch.backends.cudnn import torch.backends.mkl import torch.backends.cuda import torch.backends.quantized class ConvHardtanh(nn.Module): def __init__(self, in_channels, out_channels, kernel_size, image_size, inplace=False): super(ConvHard...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch import nn import t...
Observer007/intel-extension-for-pytorch
ConvHardtanh
false
5,665
[ "Apache-2.0" ]
1
f8ab25c305c89d5aaf06190a4fec0727aeb4dcd7
https://github.com/Observer007/intel-extension-for-pytorch/tree/f8ab25c305c89d5aaf06190a4fec0727aeb4dcd7
Network
import torch import torch.nn as nn class Network(nn.Module): def __init__(self): super().__init__() self.conv = nn.Conv3d(in_channels=1, out_channels=3, kernel_size=3) def forward(self, x): return self.conv(x) def get_inputs(): return [torch.rand([4, 1, 64, 64, 64])] def get_...
import torch from torch._inductor.select_algorithm import extern_kernels import 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...
NunoEdgarGFlowHub/torchio
Network
false
5,666
[ "MIT" ]
1
656e96c8863ecff0bb29bf880af054675bbb30fd
https://github.com/NunoEdgarGFlowHub/torchio/tree/656e96c8863ecff0bb29bf880af054675bbb30fd
ConvSigmoidInplace
import torch from torch import nn import torch.cuda import torch.backends.cudnn import torch.backends.mkl import torch.backends.cuda import torch.backends.quantized class ConvSigmoidInplace(nn.Module): def __init__(self, in_channels, out_channels, kernel_size, image_size): super(ConvSigmoidInplace, 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 import nn import torch.cuda import torch.backends.cudnn import torch....
Observer007/intel-extension-for-pytorch
ConvSigmoidInplace
false
5,667
[ "Apache-2.0" ]
1
f8ab25c305c89d5aaf06190a4fec0727aeb4dcd7
https://github.com/Observer007/intel-extension-for-pytorch/tree/f8ab25c305c89d5aaf06190a4fec0727aeb4dcd7
ConvUnit
import torch import torch.nn as nn class ConvUnit(nn.Module): def __init__(self): super(ConvUnit, self).__init__() self.conv = nn.Conv2d(in_channels=256, out_channels=32, kernel_size =5, stride=1) def forward(self, x): return self.conv(x) def get_inputs(): return [t...
import torch from torch._inductor.select_algorithm import extern_kernels import 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...
NeilWangziyu/torch_light
ConvUnit
false
5,668
[ "MIT" ]
1
daf8fd62f57885cf182f1b3edc3152156d229ef3
https://github.com/NeilWangziyu/torch_light/tree/daf8fd62f57885cf182f1b3edc3152156d229ef3
Encoder_H
import torch import torch.nn as nn class Encoder_H(nn.Module): def __init__(self, input_shape=(64, 64), z_dim=10, nc=3, padding=1): super(Encoder_H, self).__init__() self.conv2d_1 = nn.Conv2d(nc, 32, 4, 2, padding) self.conv2d_2 = nn.Conv2d(32, 32, 4, 2, padding) self.conv2d_3 = n...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_...
KinWaiCheuk/Beta-VAE
Encoder_H
false
5,669
[ "MIT" ]
1
57f538320fed76b54e8489656b11dc83c06d1584
https://github.com/KinWaiCheuk/Beta-VAE/tree/57f538320fed76b54e8489656b11dc83c06d1584
ConvGLU
import torch from torch import nn import torch.utils.data import torch.optim def str2act(txt): """Translates text to neural network activation""" return {'sigmoid': nn.Sigmoid(), 'relu': nn.ReLU(), 'none': nn. Sequential(), 'lrelu': nn.LeakyReLU(0.2), 'selu': nn.SELU()}[txt. lower()] class 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 import nn import torch.utils.data import torch.optim assert_size_stri...
Oktai15/NeMo
ConvGLU
false
5,670
[ "Apache-2.0" ]
1
5b6dd3850129898be47cf0d65587897ec45a5b59
https://github.com/Oktai15/NeMo/tree/5b6dd3850129898be47cf0d65587897ec45a5b59
UpdateNodeEmbeddingLayer
import torch import torch.nn.functional as F import torch.nn as nn class UpdateNodeEmbeddingLayer(nn.Module): def __init__(self, n_features): super().__init__() self.message_layer = nn.Linear(2 * n_features, n_features, bias=False) self.update_layer = nn.Linear(2 * n_features, 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 from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_...
NinaMaz/eco-dqn
UpdateNodeEmbeddingLayer
false
5,671
[ "MIT" ]
1
d9ea164c59014e4209ae069005029af818372ade
https://github.com/NinaMaz/eco-dqn/tree/d9ea164c59014e4209ae069005029af818372ade
GaussianKernel
import torch from typing import Optional import torch.nn as nn import torch.utils.data class GaussianKernel(nn.Module): """Gaussian Kernel Matrix Gaussian Kernel k is defined by .. math:: k(x_1, x_2) = \\exp \\left( - \\dfrac{\\| x_1 - x_2 \\|^2}{2\\sigma^2} \\right) where :math:`x_1, 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 import triton_helpers from torch._inductor.runtime.triton_helpers import math as tl_math from typing import Opt...
Neronjust2017/TransferBed
GaussianKernel
false
5,672
[ "MIT" ]
1
eaa703a4bc10eaf6216fe1394cd272f6e75489e2
https://github.com/Neronjust2017/TransferBed/tree/eaa703a4bc10eaf6216fe1394cd272f6e75489e2
ConformerFeedForward
import torch from torch import nn import torch.utils.data import torch.optim class Swish(nn.Module): """ Swish activation function introduced in 'https://arxiv.org/abs/1710.05941' """ def forward(self, x): return x * torch.sigmoid(x) class ConformerFeedForward(nn.Module): """ feed-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 import nn import torch.utils.data import torch.optim assert_size_stri...
Oktai15/NeMo
ConformerFeedForward
false
5,673
[ "Apache-2.0" ]
1
5b6dd3850129898be47cf0d65587897ec45a5b59
https://github.com/Oktai15/NeMo/tree/5b6dd3850129898be47cf0d65587897ec45a5b59
BertNonFusedLayerNorm
import torch from torch import nn class BertNonFusedLayerNorm(nn.Module): def __init__(self, hidden_size, eps=1e-12): """Construct a layernorm module in the TF style (epsilon inside the square root). """ super(BertNonFusedLayerNorm, self).__init__() self.gamma = 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.triton_helpers import libdevice from torch import nn assert_size_stride = torch._C._dynamo.guards.assert_size_s...
Og-ChRoNiC/FasterTransformer
BertNonFusedLayerNorm
false
5,674
[ "Apache-2.0" ]
1
05c7e3db209064efec4798a570a488ce08ad211c
https://github.com/Og-ChRoNiC/FasterTransformer/tree/05c7e3db209064efec4798a570a488ce08ad211c
LogSTFTMagnitudeLoss
import torch from torch.nn import functional as F import torch.utils.data import torch.optim class LogSTFTMagnitudeLoss(torch.nn.Module): """Log STFT magnitude loss module.""" def __init__(self): """Initilize los STFT magnitude loss module.""" super(LogSTFTMagnitudeLoss, self).__init__() ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import math as tl_math import torch.utils.dat...
Oktai15/NeMo
LogSTFTMagnitudeLoss
false
5,675
[ "Apache-2.0" ]
1
5b6dd3850129898be47cf0d65587897ec45a5b59
https://github.com/Oktai15/NeMo/tree/5b6dd3850129898be47cf0d65587897ec45a5b59
LayerNorm
import torch from torch import nn from torch.nn import LayerNorm import torch.utils.data import torch.optim class LayerNorm(nn.Module): def __init__(self, channels, eps=0.0001): super().__init__() self.channels = channels self.eps = eps self.gamma = nn.Parameter(torch.ones(channel...
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 import torch.optim assert_size_str...
Oktai15/NeMo
LayerNorm
false
5,676
[ "Apache-2.0" ]
1
5b6dd3850129898be47cf0d65587897ec45a5b59
https://github.com/Oktai15/NeMo/tree/5b6dd3850129898be47cf0d65587897ec45a5b59
LR
import torch class LR(torch.nn.Module): def __init__(self, input_size, output_size): super(LR, self).__init__() self.lr = torch.ones(input_size) self.lr = torch.nn.Parameter(self.lr) def forward(self, grad): return self.lr * grad 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 assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda @triton.j...
OliverWang-Au/learn2learn
LR
false
5,677
[ "MIT" ]
1
df3c3291b4681440a80a69a7815090a4bd3cd661
https://github.com/OliverWang-Au/learn2learn/tree/df3c3291b4681440a80a69a7815090a4bd3cd661
MultiLayerPerceptron
import torch import torch.utils.data import torch.optim class MultiLayerPerceptron(torch.nn.Module): """ A simple MLP that can either be used independently or put on top of pretrained models (such as BERT) and act as a classifier. Args: hidden_size (int): the size of each layer num_cla...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from 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....
Oktai15/NeMo
MultiLayerPerceptron
false
5,678
[ "Apache-2.0" ]
1
5b6dd3850129898be47cf0d65587897ec45a5b59
https://github.com/Oktai15/NeMo/tree/5b6dd3850129898be47cf0d65587897ec45a5b59
SpectralConvergenceLoss
import torch import torch.utils.data import torch.optim class SpectralConvergenceLoss(torch.nn.Module): """Spectral convergence loss module.""" def __init__(self): """Initilize spectral convergence loss module.""" super(SpectralConvergenceLoss, self).__init__() def forward(self, x_mag, y...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import libdevice import torch.utils.data impo...
Oktai15/NeMo
SpectralConvergenceLoss
false
5,679
[ "Apache-2.0" ]
1
5b6dd3850129898be47cf0d65587897ec45a5b59
https://github.com/Oktai15/NeMo/tree/5b6dd3850129898be47cf0d65587897ec45a5b59
BatchSpectralShrinkage
import torch import torch.nn as nn import torch.utils.data class BatchSpectralShrinkage(nn.Module): """ The regularization term in `Catastrophic Forgetting Meets Negative Transfer: Batch Spectral Shrinkage for Safe Transfer Learning (NIPS 2019) <https://proceedings.neurips.cc/paper/2019/file/c6bff625bdb03...
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....
Neronjust2017/TransferBed
BatchSpectralShrinkage
false
5,680
[ "MIT" ]
1
eaa703a4bc10eaf6216fe1394cd272f6e75489e2
https://github.com/Neronjust2017/TransferBed/tree/eaa703a4bc10eaf6216fe1394cd272f6e75489e2
PositionWiseFF
import torch from torch import nn from torch.nn.functional import gelu import torch.utils.data import torch.optim class PositionWiseFF(nn.Module): """ Position-wise feed-forward network of Transformer block. Args: hidden_size: size of the embeddings in the model, also known as d_model inn...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from 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....
Oktai15/NeMo
PositionWiseFF
false
5,681
[ "Apache-2.0" ]
1
5b6dd3850129898be47cf0d65587897ec45a5b59
https://github.com/Oktai15/NeMo/tree/5b6dd3850129898be47cf0d65587897ec45a5b59
LinearBlock
import torch class LinearBlock(torch.nn.Module): def __init__(self, in_features: 'int', out_features: 'int') ->None: super().__init__() self.layer_1 = torch.nn.Linear(in_features, out_features) self.layer_2 = torch.nn.Linear(out_features, out_features) self.activation = torch.nn.L...
import torch from torch._inductor.select_algorithm import extern_kernels import 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_cu...
OleguerCanal/transplanter
LinearBlock
false
5,682
[ "MIT" ]
1
854fa727747a484dedde9092eeee6884d7d1b44b
https://github.com/OleguerCanal/transplanter/tree/854fa727747a484dedde9092eeee6884d7d1b44b
InvConvNear
import torch from torch.nn import functional as F from torch import nn import torch.utils.data import torch.optim class InvConvNear(nn.Module): def __init__(self, channels, n_split=4, no_jacobian=False, **kwargs): super().__init__() assert n_split % 2 == 0 self.channels = 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 import nn import torch.utils.data import torch.optim assert_size_stri...
Oktai15/NeMo
InvConvNear
false
5,683
[ "Apache-2.0" ]
1
5b6dd3850129898be47cf0d65587897ec45a5b59
https://github.com/Oktai15/NeMo/tree/5b6dd3850129898be47cf0d65587897ec45a5b59
DQN
import random import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable class DQN(nn.Module): def __init__(self, state_dim, out_dim, capacity, bsz, epsilon): super().__init__() self.steps_done = 0 self.position = 0 self.pool = [] ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from 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 random import torch.nn...
NeilWangziyu/torch_light
DQN
false
5,684
[ "MIT" ]
1
daf8fd62f57885cf182f1b3edc3152156d229ef3
https://github.com/NeilWangziyu/torch_light/tree/daf8fd62f57885cf182f1b3edc3152156d229ef3
CNNCifaro
from _paritybench_helpers import _mock_config import torch import torch.nn as nn import torch.nn.functional as F class CNNCifaro(nn.Module): def __init__(self, args): super(CNNCifaro, self).__init__() self.conv1 = nn.Conv2d(3, 32, 3) self.pool = nn.MaxPool2d(2, 2) self.conv2 = 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 import triton_helpers import torch.nn as nn assert_...
NaiboWang/Federated-Learning-PyTorch
CNNCifaro
false
5,685
[ "MIT" ]
1
6f811ebbb783b9d279e5462789ff242968e17bc0
https://github.com/NaiboWang/Federated-Learning-PyTorch/tree/6f811ebbb783b9d279e5462789ff242968e17bc0
HypergradTransform
import torch class HypergradTransform(torch.nn.Module): """Hypergradient-style per-parameter learning rates""" def __init__(self, param, lr=0.01): super(HypergradTransform, self).__init__() self.lr = lr * torch.ones_like(param, requires_grad=True) self.lr = torch.nn.Parameter(self.lr)...
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...
OliverWang-Au/learn2learn
HypergradTransform
false
5,686
[ "MIT" ]
1
df3c3291b4681440a80a69a7815090a4bd3cd661
https://github.com/OliverWang-Au/learn2learn/tree/df3c3291b4681440a80a69a7815090a4bd3cd661
LinearNet
import torch import torch.nn import torch.optim class LinearNet(torch.nn.Module): def __init__(self, D_in, H, D_out): super().__init__() self.linear1 = torch.nn.Linear(D_in, H) self.nonlinear = torch.nn.ReLU() self.linear2 = torch.nn.Linear(H, D_out) def forward(self, x: 'tor...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
OregonWebSells/ReAgent
LinearNet
false
5,687
[ "BSD-3-Clause" ]
1
866f91785ca86db32fb67744aa063fe77791ff21
https://github.com/OregonWebSells/ReAgent/tree/866f91785ca86db32fb67744aa063fe77791ff21
GRUCell
import torch import numpy as np from torch import nn import torch.nn.functional as F class GRUCell(nn.Module): def __init__(self, input_size, hidden_size, bias=True): super(GRUCell, self).__init__() self.input_size = input_size self.hidden_size = hidden_size self.bias = bias ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import numpy as np ...
OlhaKi/PySyft
GRUCell
false
5,688
[ "Apache-2.0" ]
1
c9e16835ba0f05c3ff391e17a33d56a5c2ceb459
https://github.com/OlhaKi/PySyft/tree/c9e16835ba0f05c3ff391e17a33d56a5c2ceb459
Embedder
import math import torch from torch import nn import torch.nn import torch.optim class Embedder(nn.Module): def __init__(self, dim_in, dim_out): super(Embedder, self).__init__() self.dim_in = dim_in self.dim_out = dim_out self.linear = nn.Linear(self.dim_in, self.dim_out) 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 import nn import torch.nn import torch.optim assert_size_stride = tor...
OregonWebSells/ReAgent
Embedder
false
5,689
[ "BSD-3-Clause" ]
1
866f91785ca86db32fb67744aa063fe77791ff21
https://github.com/OregonWebSells/ReAgent/tree/866f91785ca86db32fb67744aa063fe77791ff21
ConvElu
import torch from torch import nn import torch.cuda import torch.backends.cudnn import torch.backends.mkl import torch.backends.cuda import torch.backends.quantized class ConvElu(nn.Module): def __init__(self, in_channels, out_channels, kernel_size, image_size, inplace=False): super(ConvElu, self...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice from torch import n...
Observer007/intel-extension-for-pytorch
ConvElu
false
5,690
[ "Apache-2.0" ]
1
f8ab25c305c89d5aaf06190a4fec0727aeb4dcd7
https://github.com/Observer007/intel-extension-for-pytorch/tree/f8ab25c305c89d5aaf06190a4fec0727aeb4dcd7
Attention_layer
import math import torch import torch.nn as nn def calculate_attention(query: 'torch.Tensor', key: 'torch.Tensor', value: 'torch.Tensor', mask: 'torch.Tensor'): """Calclulate Attention @param: query: torch.Tensor (Batch_size, max_seq_len, hidden_size) key: torch.Tensor (Batch_size, max_se...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
OpenNLPhub/SynSetMineOnBert
Attention_layer
false
5,691
[ "MIT" ]
1
58853363557a2397fd8b04c8e68061f9df159d6a
https://github.com/OpenNLPhub/SynSetMineOnBert/tree/58853363557a2397fd8b04c8e68061f9df159d6a
_CNN
from _paritybench_helpers import _mock_config import torch import torch.nn as nn class _CNN(nn.Module): def __init__(self, config): super(_CNN, self).__init__() self.config = config self.in_channels = 1 self.in_height = self.config.max_length self.in_width = self.config.wo...
import torch from torch._inductor.select_algorithm import extern_kernels import 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...
Lnna/OpenNRE-PyTorch
_CNN
false
5,692
[ "MIT" ]
1
907026a8bece7a867558087131cd1e97d41eb3f2
https://github.com/Lnna/OpenNRE-PyTorch/tree/907026a8bece7a867558087131cd1e97d41eb3f2
AttentionBlock
import math import torch from torch.nn import functional as F from torch import nn import torch.utils.data import torch.optim def convert_pad_shape(pad_shape): """ Used to get arguments for F.pad """ l = pad_shape[::-1] pad_shape = [item for sublist in l for item in sublist] return pad_shape ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from 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....
Oktai15/NeMo
AttentionBlock
false
5,693
[ "Apache-2.0" ]
1
5b6dd3850129898be47cf0d65587897ec45a5b59
https://github.com/Oktai15/NeMo/tree/5b6dd3850129898be47cf0d65587897ec45a5b59
MetaCurvatureTransform
import torch import numpy as np class MetaCurvatureTransform(torch.nn.Module): """ [[Source]](https://github.com/learnables/learn2learn/blob/master/learn2learn/optim/transforms/module_transform.py) **Description** Implements the Meta-Curvature transform of Park and Oliva, 2019. Unlike `ModuleTr...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import numpy as np assert_size_stride = torch._C._dynamo.guards.assert_size_stri...
OliverWang-Au/learn2learn
MetaCurvatureTransform
false
5,694
[ "MIT" ]
1
df3c3291b4681440a80a69a7815090a4bd3cd661
https://github.com/OliverWang-Au/learn2learn/tree/df3c3291b4681440a80a69a7815090a4bd3cd661
TransformerEncoderLayer
import torch import torch.nn as nn class TransformerEncoderLayer(nn.Module): def __init__(self, d_model, nhead, dim_feedforward=512, dropout=0.1): super().__init__() self.self_attn = nn.MultiheadAttention(d_model, nhead, dropout=dropout) self.linear1 = nn.Linear(d_model, dim_feedforward) ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from 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....
Nial4/Gaze_HybirdModel
TransformerEncoderLayer
false
5,695
[ "MIT" ]
1
e738179408a45c380ec7de289c84bbd3965ae924
https://github.com/Nial4/Gaze_HybirdModel/tree/e738179408a45c380ec7de289c84bbd3965ae924
Classifier
import torch import torch.distributed import torch import torch.nn as nn class Classifier(nn.Module): def __init__(self, hidden_size): super(Classifier, self).__init__() self.linear1 = nn.Linear(hidden_size, 1) self.sigmoid = nn.Sigmoid() def forward(self, x, mask_cls): h = s...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.distributed import torch import torch.nn as nn assert_size_stride =...
Omkar-Ranadive/Fine-Tuning-BERT
Classifier
false
5,696
[ "Apache-2.0" ]
1
b046092ec4007a4a59e1a478576cca7557c18d76
https://github.com/Omkar-Ranadive/Fine-Tuning-BERT/tree/b046092ec4007a4a59e1a478576cca7557c18d76
MaxpoolMatchLay
import torch import torch.nn as nn from torch.nn.functional import cosine_similarity def multi_perspective_expand_for_2D(in_tensor, decompose_params): """ Return: [batch_size, decompse_dim, dim] """ in_tensor = in_tensor.unsqueeze(1) decompose_params = decompose_params.unsqueeze(0) return torc...
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...
NeilWangziyu/torch_light
MaxpoolMatchLay
false
5,697
[ "MIT" ]
1
daf8fd62f57885cf182f1b3edc3152156d229ef3
https://github.com/NeilWangziyu/torch_light/tree/daf8fd62f57885cf182f1b3edc3152156d229ef3
ClassifierDummy
import torch import torch.distributed import torch import torch.nn as nn class ClassifierDummy(nn.Module): def __init__(self, hidden_size): super(ClassifierDummy, self).__init__() self.linear1 = nn.Linear(hidden_size, 1) self.softmax = nn.Softmax() def forward(self, x, mask_cls): ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from 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....
Omkar-Ranadive/Fine-Tuning-BERT
ClassifierDummy
false
5,698
[ "Apache-2.0" ]
1
b046092ec4007a4a59e1a478576cca7557c18d76
https://github.com/Omkar-Ranadive/Fine-Tuning-BERT/tree/b046092ec4007a4a59e1a478576cca7557c18d76
MultiHeadAttention
import math import torch from torch import nn import torch.utils.data import torch.optim class MultiHeadAttention(nn.Module): """ Multi-head scaled dot-product attention layer. Args: hidden_size: size of the embeddings in the model, also known as d_model num_attention_heads: number of hea...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from 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....
Oktai15/NeMo
MultiHeadAttention
false
5,699
[ "Apache-2.0" ]
1
5b6dd3850129898be47cf0d65587897ec45a5b59
https://github.com/Oktai15/NeMo/tree/5b6dd3850129898be47cf0d65587897ec45a5b59
Conv3D_Block
import torch import torch.nn as nn def define_norm(n_channel, norm_type, n_group=None, dim_mode=2): if norm_type == 'bn': if dim_mode == 2: return nn.BatchNorm2d(n_channel) elif dim_mode == 3: return nn.BatchNorm3d(n_channel) elif norm_type == 'gn': if n_group 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 import torch.nn as nn assert_...
Ohyeon5/SQM_basis
Conv3D_Block
false
5,700
[ "Apache-2.0" ]
1
a04662f1a4520128dd347b1e84d14717feb0655a
https://github.com/Ohyeon5/SQM_basis/tree/a04662f1a4520128dd347b1e84d14717feb0655a
LateralBlock
import torch import torch.utils.data import torch from torch import nn class LateralBlock(nn.Module): def __init__(self, conv_dim, alpha): super(LateralBlock, self).__init__() self.conv = nn.Conv3d(conv_dim, conv_dim * 2, kernel_size=(5, 1, 1), stride=(alpha, 1, 1), padding=(2, 0, 0),...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.utils.data import torch from torch import nn assert_size_stride = t...
PANBOHE/Humanpose-fight
LateralBlock
false
5,701
[ "Apache-2.0" ]
1
36e6218db526d567922fa528fa7e11497c53ad60
https://github.com/PANBOHE/Humanpose-fight/tree/36e6218db526d567922fa528fa7e11497c53ad60
PositionwiseFeedForward
import math import torch import torch.distributed import torch import torch.nn as nn def gelu(x): return 0.5 * x * (1 + torch.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 * torch.pow(x, 3)))) class PositionwiseFeedForward(nn.Module): """ A two-layer Feed-Forward-Network with residual layer norm. ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language 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 ...
Omkar-Ranadive/Fine-Tuning-BERT
PositionwiseFeedForward
false
5,702
[ "Apache-2.0" ]
1
b046092ec4007a4a59e1a478576cca7557c18d76
https://github.com/Omkar-Ranadive/Fine-Tuning-BERT/tree/b046092ec4007a4a59e1a478576cca7557c18d76
BCEDiceLoss
import torch from torch import nn import torch.utils.data import torch.nn.functional as F class BCEDiceLoss(nn.Module): def __init__(self): super().__init__() def forward(self, input, target): bce = F.binary_cross_entropy_with_logits(input, target) smooth = 1e-05 input = torc...
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 ...
Ostyk/unet-plus-plus
BCEDiceLoss
false
5,703
[ "MIT" ]
1
924edd8b90856650da2f040fa2ae2db6fcda18b1
https://github.com/Ostyk/unet-plus-plus/tree/924edd8b90856650da2f040fa2ae2db6fcda18b1
MedianPool2d
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.modules.utils import _pair from torch.nn.modules.utils import _quadruple class MedianPool2d(nn.Module): """ Median pool (usable as median filter when stride=1) module. Args: kernel_size: size of pooling kernel, int ...
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 from torch.nn.modules.utils import _pair from torch...
PJ-Steeman/2020_Masterproef
MedianPool2d
false
5,704
[ "MIT" ]
1
5bd77b4039a897d328fafe9a0b70dc8e593e2899
https://github.com/PJ-Steeman/2020_Masterproef/tree/5bd77b4039a897d328fafe9a0b70dc8e593e2899
Classifier
import torch import torch.nn as nn class Classifier(nn.Module): """MLP classifier Parameters ---------- n_dimensions : int Embedding dimension n_classes : int Number of classes. """ def __init__(self, n_dimensions, n_classes): super().__init__() self.n_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....
OrangeBaoWang/pyannote-audio
Classifier
false
5,705
[ "MIT" ]
1
ddbdf808f81e100ae8f463144fb7b3c32d8eba58
https://github.com/OrangeBaoWang/pyannote-audio/tree/ddbdf808f81e100ae8f463144fb7b3c32d8eba58
ResidualBlock
import torch import torch.optim import torch.nn as nn import torch.nn.parallel class ResidualBlock(nn.Module): def __init__(self, in_f, out_f): super(ResidualBlock, self).__init__() self.conv = nn.Conv2d(in_f, out_f, 1, 1, padding=0, bias=False) def forward(self, x): residual = 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.optim import torch.nn as nn import torch.nn.parallel assert_size_st...
PeiKaLunCi/code-cs-fairness
ResidualBlock
false
5,706
[ "MIT" ]
1
3c34d32c87ad244f6a9f302ba4f61e0acf886574
https://github.com/PeiKaLunCi/code-cs-fairness/tree/3c34d32c87ad244f6a9f302ba4f61e0acf886574
Intensity
import torch import torch.nn as nn from torch.cuda.amp import autocast as autocast from torch.cuda.amp import GradScaler as GradScaler class Intensity(nn.Module): def __init__(self, scale): super().__init__() self.scale = scale def forward(self, x): r = torch.randn((x.size(0), 1, 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 import triton_helpers import torch.nn as nn from torch.cuda.amp import autocast as aut...
PeppaCat/EfficientZero
Intensity
false
5,707
[ "MIT" ]
1
b0e98197abfc36ab34faac043ecea9b756b11d54
https://github.com/PeppaCat/EfficientZero/tree/b0e98197abfc36ab34faac043ecea9b756b11d54
LayerNorm
import torch from torch import nn class LayerNorm(nn.Module): def __init__(self, size, eps=1e-06): super(LayerNorm, self).__init__() self.eps = eps self.weight = nn.Parameter(torch.ones(size, 1, 1)) self.bias = nn.Parameter(torch.zeros(size, 1, 1)) def forward(self, x): ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice from torch import nn assert_size_stride = torch._C._dynamo.guards.assert_size_s...
ParadoxZW/CosAttention2d
LayerNorm
false
5,708
[ "Apache-2.0" ]
1
19b3e655cf0ebc40721b806eb46a3132c488a188
https://github.com/ParadoxZW/CosAttention2d/tree/19b3e655cf0ebc40721b806eb46a3132c488a188
CenterLoss
import torch import torch.nn as nn class CenterLoss(nn.Module): def __init__(self): super(CenterLoss, self).__init__() self.l2_loss = nn.MSELoss(reduction='sum') def forward(self, outputs, targets): return self.l2_loss(outputs, targets) / outputs.size(0) def get_inputs(): retur...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride emp...
Peiqi00/WS-DAN.PyTorch
CenterLoss
false
5,709
[ "MIT" ]
1
eb1307ad6d3a81ee3c18ff9ef1fb0838dd68223a
https://github.com/Peiqi00/WS-DAN.PyTorch/tree/eb1307ad6d3a81ee3c18ff9ef1fb0838dd68223a
RelativeMSE
import torch import torch as th class RelativeMSE(th.nn.Module): """Relative Mean-Squared Error. :math:`0.5 * \\frac{(x - y)^2}{y^2 + \\epsilon}` Args: eps(float): small number to avoid division by 0. """ def __init__(self, eps=0.01): super(RelativeMSE, self).__init__() ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch as th assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_...
PeterZs/sbmc
RelativeMSE
false
5,710
[ "Apache-2.0" ]
1
ac3f5452efe0166ea73942f37cc60b1f0e1ee555
https://github.com/PeterZs/sbmc/tree/ac3f5452efe0166ea73942f37cc60b1f0e1ee555
PatchApplier
import torch import torch.nn as nn class PatchApplier(nn.Module): """PatchApplier: applies adversarial patches to images. Module providing the functionality necessary to apply a patch to all detections in all images in the batch. """ def __init__(self): super(PatchApplier, self).__init__() ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_st...
PJ-Steeman/2020_Masterproef
PatchApplier
false
5,711
[ "MIT" ]
1
5bd77b4039a897d328fafe9a0b70dc8e593e2899
https://github.com/PJ-Steeman/2020_Masterproef/tree/5bd77b4039a897d328fafe9a0b70dc8e593e2899
FilterNorm
import torch import torch.nn as nn from torch.nn.init import calculate_gain import torch.nn.parallel class FilterNorm(nn.Module): def __init__(self, in_channels, kernel_size, filter_type, nonlinearity= 'linear', running_std=False, running_mean=False): assert filter_type in ('spatial', 'channel') ...
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 from torch.nn.init import calculate_gain import torch.nn....
OutBreak-hui/ddfnet
FilterNorm
false
5,712
[ "MIT" ]
1
65f67692352a2c083b5d7e003e320629a86e8460
https://github.com/OutBreak-hui/ddfnet/tree/65f67692352a2c083b5d7e003e320629a86e8460
SMAPE
import torch import torch as th class SMAPE(th.nn.Module): """Symmetric Mean Absolute error. :math:`\\frac{|x - y|} {|x| + |y| + \\epsilon}` Args: eps(float): small number to avoid division by 0. """ def __init__(self, eps=0.01): super(SMAPE, self).__init__() self.eps = ...
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 as th ass...
PeterZs/sbmc
SMAPE
false
5,713
[ "Apache-2.0" ]
1
ac3f5452efe0166ea73942f37cc60b1f0e1ee555
https://github.com/PeterZs/sbmc/tree/ac3f5452efe0166ea73942f37cc60b1f0e1ee555
MulticlassSegmentationLoss
from torch.nn import Module import torch from torch import Tensor from torch.nn import MSELoss def _split_masks_by_classes(pred: 'Tensor', target: 'Tensor') ->[]: """ Split masks by classes Args: pred (Tensor): predicted masks of shape [B, C, H, W] target (Tensor): target masks of shape [...
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.nn import Module from torch import Tensor assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = to...
PiePline/PieToolbelt
MulticlassSegmentationLoss
false
5,714
[ "MIT" ]
1
bcf9cab16bf3dbb19015c074a305f9ea8a8dc48e
https://github.com/PiePline/PieToolbelt/tree/bcf9cab16bf3dbb19015c074a305f9ea8a8dc48e
DQN
import torch import torch.nn as nn import torch.nn.functional as F class DQN(nn.Module): def __init__(self, input_size, nbr_actions): super(DQN, self).__init__() self.fc1 = nn.Linear(input_size, 256) self.fc2 = nn.Linear(256, 128) self.fc3 = nn.Linear(128, 64) self.fc4 = n...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_...
Ourdin/Phantom-of-the-Opera
DQN
false
5,715
[ "MIT" ]
1
c1ade346fadd40f6ca79033b8c6f3f74ce949d08
https://github.com/Ourdin/Phantom-of-the-Opera/tree/c1ade346fadd40f6ca79033b8c6f3f74ce949d08
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.fc1 = nn.Linear(2970, 1024) self.fc2 = nn.Linear(1024, 1) def forward(self, x, y=None): x = x.view(-1, 2970) x = self.fc1(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_...
OubaidaOubi/PP-Voice-AS-MPC
Net
false
5,716
[ "MIT" ]
1
81542b664a0e5a1ec4ccaf86142820d0c1a29023
https://github.com/OubaidaOubi/PP-Voice-AS-MPC/tree/81542b664a0e5a1ec4ccaf86142820d0c1a29023
RestrictionLoss
import torch import torch.nn as nn class RestrictionLoss(nn.Module): def __init__(self, otherbar=0): super().__init__() self.otherbar = otherbar def forward(self, predict): loss = torch.sum(((self.otherbar - predict) * (1 - predict)) ** 2) return loss 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 from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride emp...
Polarbeartnt/SP-ILC
RestrictionLoss
false
5,717
[ "MIT" ]
1
07c812dfe40461409c9714936190ba1470f91fc3
https://github.com/Polarbeartnt/SP-ILC/tree/07c812dfe40461409c9714936190ba1470f91fc3
TotalVariation
import torch import torch.nn as nn class TotalVariation(nn.Module): """TotalVariation: calculates the total variation of a patch. Module providing the functionality necessary to calculate the total vatiation (TV) of an adversarial patch. """ def __init__(self): super(TotalVariation, self)._...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import math as tl_math import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert...
PJ-Steeman/2020_Masterproef
TotalVariation
false
5,718
[ "MIT" ]
1
5bd77b4039a897d328fafe9a0b70dc8e593e2899
https://github.com/PJ-Steeman/2020_Masterproef/tree/5bd77b4039a897d328fafe9a0b70dc8e593e2899
CosNorm_Classifier
import math import torch import torch.nn as nn from torch.nn.parameter import Parameter class CosNorm_Classifier(nn.Module): def __init__(self, in_dims, out_dims, scale=16, margin=0.5, init_std=0.001 ): super(CosNorm_Classifier, self).__init__() self.in_dims = in_dims self.out_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 math import ...
PiperLiu/AliProducts
CosNorm_Classifier
false
5,719
[ "MIT" ]
1
f51884c4dae035a879dbaca2c1575797f30ee7d3
https://github.com/PiperLiu/AliProducts/tree/f51884c4dae035a879dbaca2c1575797f30ee7d3
DownConv
import copy import torch import torch.nn as nn def get_conv(dim=3): """Chooses an implementation for a convolution layer.""" if dim == 3: return nn.Conv3d elif dim == 2: return nn.Conv2d else: raise ValueError('dim has to be 2 or 3') def planar_kernel(x): """Returns a "pl...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from 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 copy import torch.nn a...
PlayWeird/ct-volume-preprocessing
DownConv
false
5,720
[ "MIT" ]
1
8bacf58c36c001fcdb809d4f74e9a39acb00bcbe
https://github.com/PlayWeird/ct-volume-preprocessing/tree/8bacf58c36c001fcdb809d4f74e9a39acb00bcbe
CustomInverse
import torch class CustomInverse(torch.nn.Module): def forward(self, x, y): ress = torch.inverse(x) + x return ress, torch.all(y) def get_inputs(): return [torch.rand([4, 4, 4, 4]), torch.rand([4, 4, 4, 4])] def get_init_inputs(): return [[], {}]
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torc...
QPC-database/onnxruntime-extensions
CustomInverse
false
5,721
[ "MIT" ]
1
7fd96c8e9700425335b479ca042b16fe92f8b8e8
https://github.com/QPC-database/onnxruntime-extensions/tree/7fd96c8e9700425335b479ca042b16fe92f8b8e8
ConvBlock
import torch import torch.nn.functional as F import torch.nn as nn class ConvBlock(nn.Module): def __init__(self): super(ConvBlock, self).__init__() self.conv1 = nn.Conv2d(3, 6, 5) self.pool = nn.MaxPool2d(2, 2) self.conv2 = nn.Conv2d(6, 16, 5) def forward(self, x): 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_...
Propaler/FedMA
ConvBlock
false
5,722
[ "MIT" ]
1
e235d971e192fb0e93abd4ad37ac603552b6484c
https://github.com/Propaler/FedMA/tree/e235d971e192fb0e93abd4ad37ac603552b6484c
ContrastiveLoss
import torch import torch.nn.functional as F from torch import nn import torch.nn import torch.optim class ContrastiveLoss(nn.Module): """ Contrastive loss Takes embeddings of two samples and a target label == 1 if samples are from the same class and label == 0 otherwise Credit due to: https://github....
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import libdevice from torch import nn import ...
QPC-database/multimodal-affinities
ContrastiveLoss
false
5,723
[ "Apache-2.0" ]
1
c3298e8db56a8b41110cc5681852f9f15d6deaa6
https://github.com/QPC-database/multimodal-affinities/tree/c3298e8db56a8b41110cc5681852f9f15d6deaa6
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....
McGill-NLP/imagecode
BertSelfAttention
false
5,724
[ "MIT" ]
1
2c636c6c41d705b4c5861841f29ff689748113d1
https://github.com/McGill-NLP/imagecode/tree/2c636c6c41d705b4c5861841f29ff689748113d1
SimpleCNNContainerConvBlocks
import torch import torch.nn.functional as F import torch.nn as nn class SimpleCNNContainerConvBlocks(nn.Module): def __init__(self, input_channel, num_filters, kernel_size, output_dim=10): super(SimpleCNNContainerConvBlocks, self).__init__() """ A testing cnn container, which allows 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 import torch.nn as nn assert_...
Propaler/FedMA
SimpleCNNContainerConvBlocks
false
5,725
[ "MIT" ]
1
e235d971e192fb0e93abd4ad37ac603552b6484c
https://github.com/Propaler/FedMA/tree/e235d971e192fb0e93abd4ad37ac603552b6484c
AE
import torch import torch.nn as nn class AE(nn.Module): def __init__(self, input_shape): super().__init__() self.encoder_hidden_layer = nn.Linear(in_features=input_shape, out_features=128) self.encoder_output_layer = nn.Linear(in_features=128, out_features=128 ) ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from 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_...
PtrMan/21V1
AE
false
5,726
[ "MIT" ]
1
fbac4deb5bec3a5e50b81e1e91c4a8a9820d6aaa
https://github.com/PtrMan/21V1/tree/fbac4deb5bec3a5e50b81e1e91c4a8a9820d6aaa
BertMixedLayer
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....
Erotemic/MONAI
BertMixedLayer
false
5,727
[ "Apache-2.0" ]
1
a9cd2d88168107281a2abcc2f63efaed80580e79
https://github.com/Erotemic/MONAI/tree/a9cd2d88168107281a2abcc2f63efaed80580e79
BertSelfOutput
from _paritybench_helpers import _mock_config import torch import torch.nn as nn class BertSelfOutput(nn.Module): def __init__(self, config): super(BertSelfOutput, self).__init__() self.dense = nn.Linear(config.hidden_size, config.hidden_size) self.dropout = nn.Dropout(config.hidden_dropo...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language 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 ...
QuLiang132/nlp-notebook
BertSelfOutput
false
5,728
[ "MIT" ]
1
b7659867b967d1e541bee5617cee017b3b67d9ba
https://github.com/QuLiang132/nlp-notebook/tree/b7659867b967d1e541bee5617cee017b3b67d9ba
SelfOutput
import torch import torch.nn as nn class SelfOutput(nn.Module): def __init__(self, hidden_size, dropout): super(SelfOutput, self).__init__() self.dense = nn.Linear(hidden_size, hidden_size) self.Layer_norm = nn.LayerNorm(hidden_size) self.dropout = nn.Dropout(dropout) 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 import torch.nn as ...
QuLiang132/nlp-notebook
SelfOutput
false
5,729
[ "MIT" ]
1
b7659867b967d1e541bee5617cee017b3b67d9ba
https://github.com/QuLiang132/nlp-notebook/tree/b7659867b967d1e541bee5617cee017b3b67d9ba
FCLayer
import torch import torch.nn as nn class FCLayer(nn.Module): def __init__(self, input_dim, output_dim, dropout_rate=0.0, use_activation=True): super(FCLayer, self).__init__() self.use_activation = use_activation self.dropout = nn.Dropout(dropout_rate) self.linear = 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.triton_helpers import libdevice import torch.nn as ...
Raiselimit/TorchBlocks
FCLayer
false
5,730
[ "MIT" ]
1
a5baecb9a2470ff175087475630f2b7db3f7ef51
https://github.com/Raiselimit/TorchBlocks/tree/a5baecb9a2470ff175087475630f2b7db3f7ef51
KdMseLoss
import torch import torch.nn as nn import torch.nn.functional as F class KdMseLoss(nn.Module): def __init__(self): super().__init__() def forward(self, logits_S, logits_T, temperature=1): """ Calculate the mse loss between logits_S and logits_T :param logits_S: Tensor of sha...
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...
Raiselimit/TorchBlocks
KdMseLoss
false
5,731
[ "MIT" ]
1
a5baecb9a2470ff175087475630f2b7db3f7ef51
https://github.com/Raiselimit/TorchBlocks/tree/a5baecb9a2470ff175087475630f2b7db3f7ef51
ANNDigitDetect
import torch import torch.nn as nn import torch.nn.functional as F class ANNDigitDetect(nn.Module): def __init__(self): super(ANNDigitDetect, self).__init__() self.fc1 = nn.Linear(32 * 32, 120) self.fc2 = nn.Linear(120, 32) self.fc3 = nn.Linear(32, 10) def forward(self, x): ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_...
Quest2GM/timestamp_detection_algorithm
ANNDigitDetect
false
5,732
[ "MIT" ]
1
8a5a7fba5a924a37402d7daece90fdf626a6a905
https://github.com/Quest2GM/timestamp_detection_algorithm/tree/8a5a7fba5a924a37402d7daece90fdf626a6a905
AttMseLoss
import torch import torch.nn as nn import torch.nn.functional as F class AttMseLoss(nn.Module): def __init__(self): super().__init__() def forward(self, attention_S, attention_T, mask=None): """ Calculate the mse loss between attention_S and attention_T. :param logits_S: Ten...
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...
Raiselimit/TorchBlocks
AttMseLoss
false
5,733
[ "MIT" ]
1
a5baecb9a2470ff175087475630f2b7db3f7ef51
https://github.com/Raiselimit/TorchBlocks/tree/a5baecb9a2470ff175087475630f2b7db3f7ef51
MaxPoolWithMask
import torch import torch.nn as nn class MaxPoolWithMask(nn.Module): """ 带mask矩阵的max pooling。在做max-pooling的时候不会考虑mask值为0的位置。 """ def __init__(self): super(MaxPoolWithMask, self).__init__() self.inf = 10000000000000.0 def forward(self, tensor, mask, dim=1): """ :pa...
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...
Raiselimit/TorchBlocks
MaxPoolWithMask
false
5,734
[ "MIT" ]
1
a5baecb9a2470ff175087475630f2b7db3f7ef51
https://github.com/Raiselimit/TorchBlocks/tree/a5baecb9a2470ff175087475630f2b7db3f7ef51
CosAttention
import torch import torch.nn as nn class CosAttention(nn.Module): def __init__(self): super(CosAttention, self).__init__() def forward(self, q, k, v): """ q: (batchsize, hidden_dim) k: (batchsize, seqlen, hidden_dim) v: (batchsize, seqlen, hidden_dim) """ ...
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...
Raiselimit/TorchBlocks
CosAttention
false
5,735
[ "MIT" ]
1
a5baecb9a2470ff175087475630f2b7db3f7ef51
https://github.com/Raiselimit/TorchBlocks/tree/a5baecb9a2470ff175087475630f2b7db3f7ef51
AvgPool
import torch import torch.nn as nn class AvgPool(nn.Module): """ 给定形如[batch_size, max_len, hidden_size]的输入,在最后一维进行avg pooling. 输出为[batch_size, hidden_size] """ def __init__(self, stride=None, padding=0): super(AvgPool, self).__init__() self.stride = stride self.padding = paddi...
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...
Raiselimit/TorchBlocks
AvgPool
false
5,736
[ "MIT" ]
1
a5baecb9a2470ff175087475630f2b7db3f7ef51
https://github.com/Raiselimit/TorchBlocks/tree/a5baecb9a2470ff175087475630f2b7db3f7ef51
FeatureAssembler
import torch from typing import Optional import torch.nn as nn import torch.nn import torch.optim class FeatureAssembler(nn.Module): def __init__(self, T: 'int', embed_static: 'Optional[FeatureEmbedder]'= None, embed_dynamic: 'Optional[FeatureEmbedder]'=None) ->None: super().__init__() 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 typing import Optional import torch.nn as nn import torch.nn import torch.optim assert_size_stride = torch._C._dynamo.guards.assert_siz...
RSNirwan/gluon-ts
FeatureAssembler
false
5,737
[ "Apache-2.0" ]
1
ae4cfdef539e49f93a87034aa2f2bec194c4b7d8
https://github.com/RSNirwan/gluon-ts/tree/ae4cfdef539e49f93a87034aa2f2bec194c4b7d8
AvgPoolWithMask
import torch import torch.nn as nn class AvgPoolWithMask(nn.Module): """ 给定形如[batch_size, max_len, hidden_size]的输入,在最后一维进行avg pooling. 输出为[batch_size, hidden_size], pooling 的时候只会考虑mask为1的位置 """ def __init__(self): super(AvgPoolWithMask, self).__init__() self.inf = 10000000000000.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 import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_st...
Raiselimit/TorchBlocks
AvgPoolWithMask
false
5,738
[ "MIT" ]
1
a5baecb9a2470ff175087475630f2b7db3f7ef51
https://github.com/Raiselimit/TorchBlocks/tree/a5baecb9a2470ff175087475630f2b7db3f7ef51
CosLoss
import torch import torch.nn as nn import torch.nn.functional as F class CosLoss(nn.Module): def __init__(self): super().__init__() def forward(self, state_S, state_T, mask=None): """ This is the loss used in DistilBERT :param state_S: Tensor of shape (batch_size, length, h...
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...
Raiselimit/TorchBlocks
CosLoss
false
5,739
[ "MIT" ]
1
a5baecb9a2470ff175087475630f2b7db3f7ef51
https://github.com/Raiselimit/TorchBlocks/tree/a5baecb9a2470ff175087475630f2b7db3f7ef51
PrimaryCaps
import torch import torch.nn as nn def squash(inputs, axis=-1): """capsule输出的激活函数""" norm = torch.norm(inputs, dim=axis, keepdim=True) scale = norm ** 2 / (1 + norm ** 2) / (norm + 1e-08) return scale * inputs class PrimaryCaps(nn.Module): """计算第一层capsules的输入,转换成32*6*6个8维的capsule vector in_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.triton_helpers import libdevice import torch.nn as ...
RacleRay/-Have_Fun_Doing
PrimaryCaps
false
5,740
[ "Apache-2.0" ]
1
8ebb7fcabc6148571d38f2f51eac47952ce54424
https://github.com/RacleRay/-Have_Fun_Doing/tree/8ebb7fcabc6148571d38f2f51eac47952ce54424
KL
import torch import torch.nn as nn import torch.nn.functional as F class KL(nn.Module): def __init__(self, reduction='batchmean'): super(KL, self).__init__() self.reduction = reduction def forward(self, input, target): input = input.float() target = target.float() los...
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...
Raiselimit/TorchBlocks
KL
false
5,741
[ "MIT" ]
1
a5baecb9a2470ff175087475630f2b7db3f7ef51
https://github.com/Raiselimit/TorchBlocks/tree/a5baecb9a2470ff175087475630f2b7db3f7ef51
PointWiseFeedForward
import torch import torch.nn as nn class PointWiseFeedForward(nn.Module): def __init__(self, d_model, d_affine, fc_dorpout=0.2): super().__init__() self.d_model = d_model self.d_affine = d_affine self.linear_1 = nn.Linear(self.d_model, self.d_affine) self.linear_2 = nn.Lin...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language 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 ...
RacleRay/TextSummerize
PointWiseFeedForward
false
5,742
[ "MIT" ]
1
fe2572d26d65bdf849ce89fbb0c5adf5607f06b1
https://github.com/RacleRay/TextSummerize/tree/fe2572d26d65bdf849ce89fbb0c5adf5607f06b1
BertAttention
from _paritybench_helpers import _mock_config import math import torch import torch.nn as nn class BertSelfAttention(nn.Module): """ self attention层 原理可看这篇博客: http://jalammar.github.io/illustrated-transformer/ """ def __init__(self, config): super(BertSelfAttention, 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....
QuLiang132/nlp-notebook
BertAttention
false
5,743
[ "MIT" ]
1
b7659867b967d1e541bee5617cee017b3b67d9ba
https://github.com/QuLiang132/nlp-notebook/tree/b7659867b967d1e541bee5617cee017b3b67d9ba
GatedConv1d
import torch import torch.nn as nn class MaskedConv1d(nn.Conv1d): def __init__(self, in_channels, out_channels, kernel_size, dilation=1, groups=1, bias=True, causal=True): if causal: padding = (kernel_size - 1) * dilation else: padding = (kernel_size - 1) * dilatio...
import torch from torch._inductor.select_algorithm import extern_kernels import 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...
Raiselimit/TorchBlocks
GatedConv1d
false
5,744
[ "MIT" ]
1
a5baecb9a2470ff175087475630f2b7db3f7ef51
https://github.com/Raiselimit/TorchBlocks/tree/a5baecb9a2470ff175087475630f2b7db3f7ef51
AttCeLoss
import torch import torch.nn as nn import torch.nn.functional as F class AttCeLoss(nn.Module): def __init__(self): super().__init__() def forward(self, attention_S, attention_T, mask=None): """ Calculate the cross entropy between attention_S and attention_T. :param logits_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 from torch._inductor.runtime.triton_helpers import math as tl_math import torch.nn as nn ...
Raiselimit/TorchBlocks
AttCeLoss
false
5,745
[ "MIT" ]
1
a5baecb9a2470ff175087475630f2b7db3f7ef51
https://github.com/Raiselimit/TorchBlocks/tree/a5baecb9a2470ff175087475630f2b7db3f7ef51
MultiHeadAttention
import math import torch from torch import nn import torch.utils.data import torch.optim class MultiHeadAttention(nn.Module): """ Multi-head scaled dot-product attention layer. Args: hidden_size: size of the embeddings in the model, also known as d_model num_attention_heads: number of hea...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from 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....
RPrenger/NeMo
MultiHeadAttention
false
5,746
[ "Apache-2.0" ]
1
e8912ca6e3321347272a6a7da18e052812fb2062
https://github.com/RPrenger/NeMo/tree/e8912ca6e3321347272a6a7da18e052812fb2062
FocalLoss
import torch import torch.nn as nn import torch.nn.functional as F class FocalLoss(nn.Module): """ Softmax and sigmoid focal loss """ def __init__(self, num_labels, activation_type='softmax', gamma=2.0, alpha=0.25, epsilon=1e-09): super(FocalLoss, self).__init__() self.num_lab...
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 ...
Raiselimit/TorchBlocks
FocalLoss
false
5,747
[ "MIT" ]
1
a5baecb9a2470ff175087475630f2b7db3f7ef51
https://github.com/Raiselimit/TorchBlocks/tree/a5baecb9a2470ff175087475630f2b7db3f7ef51
AttCeMeanLoss
import torch import torch.nn as nn import torch.nn.functional as F class AttCeMeanLoss(nn.Module): def __init__(self): super().__init__() def forward(self, attention_S, attention_T, mask=None): """ Calculate the cross entropy between attention_S and attention_T, the dim of num_heads...
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 ...
Raiselimit/TorchBlocks
AttCeMeanLoss
false
5,748
[ "MIT" ]
1
a5baecb9a2470ff175087475630f2b7db3f7ef51
https://github.com/Raiselimit/TorchBlocks/tree/a5baecb9a2470ff175087475630f2b7db3f7ef51
SKL
import torch import torch.nn as nn import torch.nn.functional as F class SKL(nn.Module): def __init__(self, epsilon=1e-08): super(SKL, self).__init__() self.epsilon = epsilon def forward(self, input, target): logit = input.view(-1, input.size(-1)).float() target = target.view...
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 ...
Raiselimit/TorchBlocks
SKL
false
5,749
[ "MIT" ]
1
a5baecb9a2470ff175087475630f2b7db3f7ef51
https://github.com/Raiselimit/TorchBlocks/tree/a5baecb9a2470ff175087475630f2b7db3f7ef51
MultiSampleDropout
import torch import torch.nn as nn class MultiSampleDropout(nn.Module): """ # multisample dropout (wut): https://arxiv.org/abs/1905.09788 """ def __init__(self, hidden_size, num_labels, K=5, p=0.5): super().__init__() self.K = K self.dropout = nn.Dropout(p) self.classi...
import torch from torch._inductor.select_algorithm import extern_kernels import 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...
Raiselimit/TorchBlocks
MultiSampleDropout
false
5,750
[ "MIT" ]
1
a5baecb9a2470ff175087475630f2b7db3f7ef51
https://github.com/Raiselimit/TorchBlocks/tree/a5baecb9a2470ff175087475630f2b7db3f7ef51
Gate
import torch import torch.nn as nn import torch.nn.functional as F class Gate(nn.Module): """Gate Unit g = sigmoid(Wx) x = g * x """ def __init__(self, input_size, dropout_rate=0.0): super(Gate, self).__init__() self.linear = nn.Linear(input_size, input_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 import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_s...
Raiselimit/TorchBlocks
Gate
false
5,751
[ "MIT" ]
1
a5baecb9a2470ff175087475630f2b7db3f7ef51
https://github.com/Raiselimit/TorchBlocks/tree/a5baecb9a2470ff175087475630f2b7db3f7ef51
SpaceToDepth
import torch from torch import nn import torch.nn.parallel class SpaceToDepth(nn.Module): def __init__(self, block_size=4): super().__init__() assert block_size == 4 self.bs = block_size def forward(self, x): N, C, H, W = x.size() x = x.view(N, C, H // self.bs, self.b...
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....
Randl/TResNet
SpaceToDepth
false
5,752
[ "Apache-2.0" ]
1
18514caf61d77c7e000a71dde9d1f86ba792b38d
https://github.com/Randl/TResNet/tree/18514caf61d77c7e000a71dde9d1f86ba792b38d
_CAEAD
import torch import torch.nn as nn import torch.nn.functional as F class _CAEAD(nn.Module): def __init__(self, input_size): super(_CAEAD, self).__init__() self.en_1 = nn.Conv1d(1, 64, 3, padding=1) self.pool1 = nn.MaxPool1d(2, 2) self.en_2 = nn.Conv1d(64, 32, 3, 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 import torch.nn as nn assert_...
Pheobe-Sun/anomaly-detection-challenge-2020
_CAEAD
false
5,753
[ "MIT" ]
1
71e34350023023a17338b7931da70af035b2454c
https://github.com/Pheobe-Sun/anomaly-detection-challenge-2020/tree/71e34350023023a17338b7931da70af035b2454c
HighwayLayer
import torch import torch.nn as nn class HighwayLayer(nn.Module): def __init__(self, in_units, out_units): super(HighwayLayer, self).__init__() self.highway_linear = nn.Linear(in_features=in_units, out_features= out_units, bias=True) self.highway_gate = nn.Linear(in_features=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 import torch.nn as nn assert_...
RandolphVI/HyperNet
HighwayLayer
false
5,754
[ "Apache-2.0" ]
1
e9f376f5eb087e57360ca41cca2533c3ca967e47
https://github.com/RandolphVI/HyperNet/tree/e9f376f5eb087e57360ca41cca2533c3ca967e47
SEModule
import torch from torch import nn import torch.nn.parallel class GlobalAvgPool2d: def __init__(self, flatten=False): self.flatten = flatten def __call__(self, x): if self.flatten: in_size = x.size() return x.view((in_size[0], in_size[1], -1)).mean(dim=2) else:...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch import nn import t...
Randl/TResNet
SEModule
false
5,755
[ "Apache-2.0" ]
1
18514caf61d77c7e000a71dde9d1f86ba792b38d
https://github.com/Randl/TResNet/tree/18514caf61d77c7e000a71dde9d1f86ba792b38d