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 |
|---|---|---|---|---|---|---|---|---|---|---|
ToRGB | from torch.autograd import Function
import math
import random
import torch
from torch import nn
from torch.nn import functional as F
def upsample(in_tens, out_H=64):
in_H = in_tens.shape[2]
scale_factor = 1.0 * out_H / in_H
return nn.Upsample(scale_factor=scale_factor, mode='bilinear',
align_corne... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch.autograd import Function
import math
import random
from torch import ... | SavvaI/stylegan2-pytorch | ToRGB | false | 9,522 | [
"MIT",
"BSD-2-Clause",
"Apache-2.0"
] | 0 | b8e4b605bd951283ef2c9a784e7afa0a486975bb | https://github.com/SavvaI/stylegan2-pytorch/tree/b8e4b605bd951283ef2c9a784e7afa0a486975bb |
Encoder_mse | import torch
from typing import Iterable
from torch.distributions import Normal
from torch import nn as nn
def reparameterize_gaussian(mu, var):
return Normal(mu, var.sqrt()).rsample()
class Encoder_mse(nn.Module):
"""Encodes data of ``n_input`` dimensions into a latent space of ``n_output``
dimensions ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
fr... | Famingzhao/scMVP | Encoder_mse | false | 9,523 | [
"MIT"
] | 0 | fb0d2d2523d0ae10e10725babe8da7de63c2eef4 | https://github.com/Famingzhao/scMVP/tree/fb0d2d2523d0ae10e10725babe8da7de63c2eef4 |
SelfAttentionSublayer | import math
import torch
from torch import nn
import torch.optim
class ScaledDotAttention(torch.nn.Module):
def __init__(self, model_dim, n_heads, dropout=0.0):
"""
Creates a ScaledDotAttention.
:param model_dim: The model dimensions.
:param n_heads: The number of heads.
:... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | Nickeilf/pysimt | SelfAttentionSublayer | false | 9,524 | [
"MIT"
] | 0 | 05c8de92d0e2b930e40939ad3695d8d2c2954dda | https://github.com/Nickeilf/pysimt/tree/05c8de92d0e2b930e40939ad3695d8d2c2954dda |
Block | import torch
import torch.nn as nn
class Block(nn.Module):
def __init__(self, planes):
super(Block, self).__init__()
self.conv1 = nn.Conv2d(planes, planes, kernel_size=3, stride=1,
padding=1, bias=False)
self.prelu1 = nn.PReLU(planes)
self.conv2 = nn.Conv2d(planes, pla... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | T-Visor/face-encryption | Block | false | 9,525 | [
"Apache-2.0"
] | 0 | b09c4daecb7c77b4caa8cf898c4b09981260179c | https://github.com/T-Visor/face-encryption/tree/b09c4daecb7c77b4caa8cf898c4b09981260179c |
Polynomial3 | import torch
import torch.quantization
import torch.onnx
import torch.nn.parallel
import torch.utils.data
import torch.fx
import torch.nn
import torch.optim
import torch.profiler
class Polynomial3(torch.nn.Module):
def __init__(self):
"""
In the constructor we instantiate four parameters and assi... | 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.quantization
import torch.onnx
import torch.nn.parallel
import torch.utils.data
import torch.fx
import torch.nn
import torch.op... | Nayef211/tutorials | Polynomial3 | false | 9,526 | [
"BSD-3-Clause"
] | 0 | faf2c476fc3be855051fbea3cce77eaf7b2a2175 | https://github.com/Nayef211/tutorials/tree/faf2c476fc3be855051fbea3cce77eaf7b2a2175 |
Skew | import torch
import torch.nn as nn
import torch.quantization
import torch.onnx
import torch.nn.parallel
import torch.utils.data
import torch.fx
import torch.nn
import torch.optim
import torch.profiler
class Skew(nn.Module):
def forward(self, X):
A = X.triu(1)
return A - A.transpose(-1, -2)
d... | 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.quantization
import torch.onnx
import torch.nn.parallel
import torch.utils.data
import torch.fx
import to... | Nayef211/tutorials | Skew | false | 9,527 | [
"BSD-3-Clause"
] | 0 | faf2c476fc3be855051fbea3cce77eaf7b2a2175 | https://github.com/Nayef211/tutorials/tree/faf2c476fc3be855051fbea3cce77eaf7b2a2175 |
TwoMLPHead | import torch
from torch import nn
import torch.nn.functional as F
class TwoMLPHead(nn.Module):
"""
Standard heads for FPN-based models
Arguments:
in_channels (int): number of input channels
representation_size (int): size of the intermediate representation
"""
def __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 import nn
assert_s... | GreenCUBIC/GasBotty | TwoMLPHead | false | 9,528 | [
"MIT"
] | 0 | 158f5991201c80bf4cbbbb9deabc9954ff19bbb1 | https://github.com/GreenCUBIC/GasBotty/tree/158f5991201c80bf4cbbbb9deabc9954ff19bbb1 |
DownBlock | import torch
from torchvision.transforms import *
class ConvBlock(torch.nn.Module):
def __init__(self, input_size, output_size, kernel_size=3, stride=1,
padding=1, bias=True, activation='prelu', norm=None):
super(ConvBlock, self).__init__()
self.conv = torch.nn.Conv2d(input_size, output_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 torchvision.transforms import *
assert_size_stride = torch._C._dynamo.guard... | EvgeneyZ/RBPN | DownBlock | false | 9,529 | [
"MIT"
] | 0 | acfe636cc48a4fbfea78f934a251c32e53367659 | https://github.com/EvgeneyZ/RBPN/tree/acfe636cc48a4fbfea78f934a251c32e53367659 |
GreedyTop1 | import torch
from typing import Optional
import torch as pt
import torch.distributed
import torch.distributed.elastic.multiprocessing.errors
class GreedyTop1(pt.nn.Module):
"""
Implements picking the highest scoring next word with support for vocabulary selection and target factors.
"""
def forward(s... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch as pt
import torch.distributed
import torch.distributed.elastic.multiprocessing.errors
assert_size_stride = torch._C._dynamo.gu... | SamuelLarkin/sockeye | GreedyTop1 | false | 9,530 | [
"Apache-2.0"
] | 0 | 7fcf6c96b15a887897aa712903ecf93c665ebddf | https://github.com/SamuelLarkin/sockeye/tree/7fcf6c96b15a887897aa712903ecf93c665ebddf |
VAE | import torch
import torch.nn as nn
class VAE(nn.Module):
def __init__(self, x_dim, h_dim1, h_dim2, h_dim3, z_dim):
super(VAE, self).__init__()
self.x_dim = x_dim
self.fc1 = nn.Linear(x_dim, h_dim1)
self.fc2 = nn.Linear(h_dim1, h_dim2)
self.fc3 = nn.Linear(h_dim2, h_dim3)
... | import torch
from torch import device
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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... | Sumeer1/VAE_Impute | VAE | false | 9,532 | [
"MIT"
] | 0 | 803195af20fe54352aedf26147a84a470637d560 | https://github.com/Sumeer1/VAE_Impute/tree/803195af20fe54352aedf26147a84a470637d560 |
PyTorchLHUC | import torch
import torch as pt
import torch.distributed
import torch.distributed.elastic.multiprocessing.errors
class PyTorchLHUC(pt.nn.Module):
"""
Learning Hidden Unit Contribution
David Vilar. "Learning Hidden Unit Contribution for Adapting Neural
Machine Translation Models" NAACL 2018
:para... | 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 as pt
import torch.distributed
import torch.distributed.elastic.multiprocessing.errors
assert_size_stride = torch._C._dynamo.gu... | SamuelLarkin/sockeye | PyTorchLHUC | false | 9,533 | [
"Apache-2.0"
] | 0 | 7fcf6c96b15a887897aa712903ecf93c665ebddf | https://github.com/SamuelLarkin/sockeye/tree/7fcf6c96b15a887897aa712903ecf93c665ebddf |
FocalLoss | import torch
from torch import nn
import torch.nn.functional as F
class FocalLoss(nn.Module):
def __init__(self, gamma=2):
super().__init__()
self.gamma = gamma
def forward(self, logit, target):
target = target.float()
max_val = (-logit).clamp(min=0)
loss = logit - lo... | 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 ... | Thagio/kaggle-aptos | FocalLoss | false | 9,534 | [
"MIT"
] | 0 | f565335d34b46b7fa7ca925b7d325397df8e1fee | https://github.com/Thagio/kaggle-aptos/tree/f565335d34b46b7fa7ca925b7d325397df8e1fee |
RecurrentNeuralRegressor | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.optim import Adam
from torch.utils.data import BatchSampler
from torch.utils.data import SubsetRandomSampler
class RecurrentNeuralRegressor(nn.Module):
def __init__(self, sizes, prior, nonlin='relu'):
super(RecurrentNeuralRegre... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | TheCamusean/sds | RecurrentNeuralRegressor | false | 9,535 | [
"MIT"
] | 0 | 65e1736eb27dcd8829f5bff452fc09ccab3e0ae2 | https://github.com/TheCamusean/sds/tree/65e1736eb27dcd8829f5bff452fc09ccab3e0ae2 |
TracedModule | import torch
import torch.quantization
import torch.onnx
import torch.nn.parallel
import torch.utils.data
import torch.fx
import torch.nn
import torch.optim
import torch.profiler
class TracedModule(torch.nn.Module):
def forward(self, x):
x = x.type(torch.float32)
return torch.floor(torch.sqrt(x) ... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.quantization
import torch.onnx
import torch.nn.parallel
import tor... | Nayef211/tutorials | TracedModule | false | 9,536 | [
"BSD-3-Clause"
] | 0 | faf2c476fc3be855051fbea3cce77eaf7b2a2175 | https://github.com/Nayef211/tutorials/tree/faf2c476fc3be855051fbea3cce77eaf7b2a2175 |
CustomMSELoss | import torch
import torch.nn as nn
class CustomMSELoss(nn.Module):
def __init__(self):
super(CustomMSELoss, self).__init__()
def forward(self, x, y):
return torch.mean(torch.pow(torch.log(torch.exp(x) - torch.exp(y)), 2))
def get_inputs():
return [torch.rand([4, 4, 4, 4]), torch.rand([... | 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
... | TAN-OpenLab/TCSE-net | CustomMSELoss | false | 9,537 | [
"Apache-2.0"
] | 0 | fc6ecf704a9c128a9b5b6853cffa8486ee0f54e8 | https://github.com/TAN-OpenLab/TCSE-net/tree/fc6ecf704a9c128a9b5b6853cffa8486ee0f54e8 |
PyTorchSSRU | import torch
from typing import Tuple
from abc import abstractmethod
import torch as pt
import torch.distributed
import torch.distributed.elastic.multiprocessing.errors
class AutoregressiveLayer(pt.nn.Module):
@property
@abstractmethod
def num_state_tensors(self) ->int:
""" Number of state tensor... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from typing import Tuple
from... | SamuelLarkin/sockeye | PyTorchSSRU | false | 9,538 | [
"Apache-2.0"
] | 0 | 7fcf6c96b15a887897aa712903ecf93c665ebddf | https://github.com/SamuelLarkin/sockeye/tree/7fcf6c96b15a887897aa712903ecf93c665ebddf |
Network | import torch
import torch.nn as nn
import torch.nn.functional as F
class Network(nn.Module):
"""Agent network"""
def __init__(self, in_size, out_size):
super().__init__()
self.fc1 = nn.Linear(in_size, 200)
self.fc2 = nn.Linear(200, 100)
self.fc3 = nn.Linear(100, 50)
se... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | Thytu/Deep-Q-Learning | Network | false | 9,539 | [
"MIT"
] | 0 | b17fbc66829932a9a3814a8f29d8c8146898b413 | https://github.com/Thytu/Deep-Q-Learning/tree/b17fbc66829932a9a3814a8f29d8c8146898b413 |
TokenEmbedding | import math
import torch
from torch import Tensor
import torch.nn as nn
import torch.quantization
import torch.onnx
import torch.nn.parallel
import torch.utils.data
import torch.fx
import torch.nn
import torch.optim
import torch.profiler
class TokenEmbedding(nn.Module):
def __init__(self, vocab_size: 'int', emb_... | 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.quantization
import torch.onnx
import torch.nn.parallel
import torch.utils.data
import torch.fx
import to... | Nayef211/tutorials | TokenEmbedding | false | 9,540 | [
"BSD-3-Clause"
] | 0 | faf2c476fc3be855051fbea3cce77eaf7b2a2175 | https://github.com/Nayef211/tutorials/tree/faf2c476fc3be855051fbea3cce77eaf7b2a2175 |
RegWeightedL1Loss | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
def _gather_feat(feat, ind, mask=None):
dim = feat.size(2)
ind = ind.unsqueeze(2).expand(ind.size(0), ind.size(1), dim)
feat = feat.gather(1, ind)
if mask is not None:
mask = mask.unsqueeze(2).expand_as(... | 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
... | Ssong24/CenterNet_Custom | RegWeightedL1Loss | false | 9,541 | [
"MIT"
] | 0 | 526ec70f8dfabf9fb9179c9be28ce50fb2a7961c | https://github.com/Ssong24/CenterNet_Custom/tree/526ec70f8dfabf9fb9179c9be28ce50fb2a7961c |
ClusterAssignment | import torch
import torch.nn as nn
from torch.nn import Parameter
from typing import Optional
class ClusterAssignment(nn.Module):
def __init__(self, cluster_number: 'int', embedding_dimension: 'int',
alpha: 'float'=1.0, cluster_centers: 'Optional[torch.Tensor]'=None
) ->None:
"""
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
from torch.nn import Parameter
from typing import Optional
assert_size_stride = torch._C._dynamo.guards.assert_size_st... | Vaaaas/OpenNRE | ClusterAssignment | false | 9,542 | [
"MIT"
] | 0 | d43859975ed3523d9a8cea02adff5c7b43f94da0 | https://github.com/Vaaaas/OpenNRE/tree/d43859975ed3523d9a8cea02adff5c7b43f94da0 |
AvgPool | import torch
from torch import nn
import torch.nn.functional as F
class AvgPool(nn.Module):
def forward(self, x):
return F.avg_pool2d(x, x.shape[2:])
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
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_str... | Thagio/kaggle-aptos | AvgPool | false | 9,543 | [
"MIT"
] | 0 | f565335d34b46b7fa7ca925b7d325397df8e1fee | https://github.com/Thagio/kaggle-aptos/tree/f565335d34b46b7fa7ca925b7d325397df8e1fee |
RegLoss | import torch
import torch.nn as nn
import torch.utils.data
def _gather_feat(feat, ind, mask=None):
dim = feat.size(2)
ind = ind.unsqueeze(2).expand(ind.size(0), ind.size(1), dim)
feat = feat.gather(1, ind)
if mask is not None:
mask = mask.unsqueeze(2).expand_as(feat)
feat = feat[mask]
... | 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
... | Ssong24/CenterNet_Custom | RegLoss | false | 9,544 | [
"MIT"
] | 0 | 526ec70f8dfabf9fb9179c9be28ce50fb2a7961c | https://github.com/Ssong24/CenterNet_Custom/tree/526ec70f8dfabf9fb9179c9be28ce50fb2a7961c |
SeasonalityBasis | import torch
import numpy as np
import torch as t
class SeasonalityBasis(t.nn.Module):
"""
Harmonic functions to model seasonality.
"""
def __init__(self, harmonics: 'int', backcast_size: 'int',
forecast_size: 'int'):
super().__init__()
self.frequency = np.append(np.zeros(1, d... | 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 numpy as np
import torch as t
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.g... | TaeniKim/nbeats_reproduce | SeasonalityBasis | false | 9,545 | [
"MIT"
] | 0 | dd9375ad3fb4bb3c6c973391e250b5dd60a219ab | https://github.com/TaeniKim/nbeats_reproduce/tree/dd9375ad3fb4bb3c6c973391e250b5dd60a219ab |
ChebConv | import torch
import torch.nn as nn
class ChebConv(nn.Module):
"""
The ChebNet convolution operation.
Laplacian is motified for direct-graph
:param in_c: int, number of input channels.
:param out_c: int, number of output channels.
:param K: int, the order of Chebyshev Polynomial.
"""
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | TAN-OpenLab/TCSE-net | ChebConv | false | 9,546 | [
"Apache-2.0"
] | 0 | fc6ecf704a9c128a9b5b6853cffa8486ee0f54e8 | https://github.com/TAN-OpenLab/TCSE-net/tree/fc6ecf704a9c128a9b5b6853cffa8486ee0f54e8 |
Remap | import torch
import numpy as np
import torch.nn as nn
from abc import abstractmethod
from typing import Union
from typing import Tuple
from typing import List
class BaseModel(nn.Module):
"""
Base class for all models
"""
@abstractmethod
def forward(self, *inputs):
"""
Forward pass... | 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 numpy as np
import torch.nn as nn
from abc import abstractmethod
from typing import Union
from typing import Tuple
from typing import... | SuikaSibyl/ReproduceNSRR | Remap | false | 9,547 | [
"MIT"
] | 0 | 732377413fd44f6e5acf40bfb4ae9e6430f586e3 | https://github.com/SuikaSibyl/ReproduceNSRR/tree/732377413fd44f6e5acf40bfb4ae9e6430f586e3 |
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... | TomFrederik/EfficientZero | Intensity | false | 9,548 | [
"MIT"
] | 0 | d310ec87602076e2ebc84a79f4e54b248ccbe62e | https://github.com/TomFrederik/EfficientZero/tree/d310ec87602076e2ebc84a79f4e54b248ccbe62e |
MaxFeature | import torch
import torch.nn as nn
class MaxFeature(nn.Module):
"""Conv2d or Linear layer with max feature selector
Generate feature maps with double channels, split them and select the max
feature.
Args:
in_channels (int): Channel number of inputs.
out_channels (int): Channel nu... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | Serene99-09/mmediting | MaxFeature | false | 9,549 | [
"Apache-2.0"
] | 0 | be49e33650627ac26fdd065fbbaff66f726e3fde | https://github.com/Serene99-09/mmediting/tree/be49e33650627ac26fdd065fbbaff66f726e3fde |
Up | import torch
import torch.nn as nn
import torch.nn.functional as F
class Up(nn.Module):
def __init__(self, in_channels, out_channels, factor=2):
super(Up, self).__init__()
self.up = nn.ConvTranspose2d(in_channels, out_channels, kernel_size
=2, stride=2)
def forward(self, x):
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as ... | Smith42/unet-pytorch | Up | false | 9,550 | [
"MIT"
] | 0 | 45a0459da69cee7f57fb369a8e2fc58668d81167 | https://github.com/Smith42/unet-pytorch/tree/45a0459da69cee7f57fb369a8e2fc58668d81167 |
Down | import torch
import torch.nn as nn
import torch.nn.functional as F
class Down(nn.Module):
def __init__(self, in_channels, out_channels, factor=2):
super(Down, self).__init__()
self.down = nn.Conv2d(in_channels, out_channels, kernel_size=3,
stride=factor, padding=1)
def forward(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.triton_helpers import libdevice
import torch.nn as ... | Smith42/unet-pytorch | Down | false | 9,551 | [
"MIT"
] | 0 | 45a0459da69cee7f57fb369a8e2fc58668d81167 | https://github.com/Smith42/unet-pytorch/tree/45a0459da69cee7f57fb369a8e2fc58668d81167 |
AttentiveStatsPool | import torch
import torch.nn as nn
class AttentiveStatsPool(nn.Module):
def __init__(self, in_dim, bottleneck_dim):
super().__init__()
self.linear1 = nn.Conv1d(in_dim, bottleneck_dim, kernel_size=1)
self.linear2 = nn.Conv1d(bottleneck_dim, in_dim, kernel_size=1)
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
from torch._inductor.runtime.... | SecretKeyTeam/voxceleb_trainer | AttentiveStatsPool | false | 9,552 | [
"MIT"
] | 0 | e235cbc2961d32395d30cf606ee830cd47716383 | https://github.com/SecretKeyTeam/voxceleb_trainer/tree/e235cbc2961d32395d30cf606ee830cd47716383 |
CosineLinearLayer | import torch
from torch import Tensor
import torch.nn as nn
from torch.nn import Parameter
class CosineLinearLayer(nn.Module):
def __init__(self, in_features: 'int', out_features: 'int') ->None:
super(CosineLinearLayer, self).__init__()
self.in_features = in_features
self.out_features = o... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | SecretKeyTeam/voxceleb_trainer | CosineLinearLayer | false | 9,553 | [
"MIT"
] | 0 | e235cbc2961d32395d30cf606ee830cd47716383 | https://github.com/SecretKeyTeam/voxceleb_trainer/tree/e235cbc2961d32395d30cf606ee830cd47716383 |
MetaBilinear | import re
import torch
import warnings
import torch.nn as nn
import torch.nn.functional as F
from collections import OrderedDict
class MetaModule(nn.Module):
"""
Base class for PyTorch meta-learning modules. These modules accept an
additional argument `params` in their `forward` method.
Notes
---... | 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 re
import warnings
import torch.nn as nn
from collections import OrderedDict
assert_size_stride = torch._C._dynamo.guards.assert_size... | Steffen-Wolf/pytorch-meta | MetaBilinear | false | 9,554 | [
"MIT"
] | 0 | d2dfb902cfa49574eac898045c8e9cf64ce29f96 | https://github.com/Steffen-Wolf/pytorch-meta/tree/d2dfb902cfa49574eac898045c8e9cf64ce29f96 |
MLPClassifier | import torch
import torch.nn as nn
class MLPClassifier(nn.Module):
def __init__(self, embedding_dim, label_size, hidden_dim):
super(MLPClassifier, self).__init__()
self.layer1 = torch.nn.Linear(embedding_dim, hidden_dim)
self.relu = torch.nn.ReLU()
self.layer2 = torch.nn.Linear(hi... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | UKPLab/curriculum-annotation | MLPClassifier | false | 9,555 | [
"Apache-2.0"
] | 0 | 1d6ca490ea180019bb09d1d3818874f4321d4d0f | https://github.com/UKPLab/curriculum-annotation/tree/1d6ca490ea180019bb09d1d3818874f4321d4d0f |
MuSigmaEncoder | import torch
import torch.nn as nn
class MuSigmaEncoder(nn.Module):
"""
Maps a representation r to mu and sigma which will define the normal
distribution from which we sample the latent variable z.
Parameters
----------
r_dim : int
Dimension of output representation r.
z_dim : 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
import torch.nn as nn
assert_... | TheBonheurs/neural-processes | MuSigmaEncoder | false | 9,556 | [
"MIT"
] | 0 | 5834bc65f406456e53c363ade1cb0f2a5f23a033 | https://github.com/TheBonheurs/neural-processes/tree/5834bc65f406456e53c363ade1cb0f2a5f23a033 |
D_UpBlock | import torch
from torchvision.transforms import *
class ConvBlock(torch.nn.Module):
def __init__(self, input_size, output_size, kernel_size=3, stride=1,
padding=1, bias=True, activation='prelu', norm=None):
super(ConvBlock, self).__init__()
self.conv = torch.nn.Conv2d(input_size, output_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 torchvision.transforms import *
assert_size_stride = torch._C._dynamo.guard... | EvgeneyZ/RBPN | D_UpBlock | false | 9,557 | [
"MIT"
] | 0 | acfe636cc48a4fbfea78f934a251c32e53367659 | https://github.com/EvgeneyZ/RBPN/tree/acfe636cc48a4fbfea78f934a251c32e53367659 |
MLPPolicy | import math
import torch
import numpy as np
import torch.nn as nn
from torch.nn import functional as F
def log_normal_density(x, mean, log_std, std):
"""returns guassian density given x on log scale"""
variance = std.pow(2)
log_density = -(x - mean).pow(2) / (2 * variance) - 0.5 * np.log(2 * np.pi
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
im... | Timliang/RL-Competition | MLPPolicy | false | 9,558 | [
"MIT"
] | 0 | 638462b95a5aab0bbae46677a59ffc90ba6cd971 | https://github.com/Timliang/RL-Competition/tree/638462b95a5aab0bbae46677a59ffc90ba6cd971 |
FocalLoss | import torch
import torch.utils.data
import torch
import torch.nn as nn
from torch.nn import functional as F
class FocalLoss(nn.Module):
def __init__(self, weight=None, gamma=1.0, num_classes=80):
super(FocalLoss, self).__init__()
assert gamma >= 0
self.gamma = gamma
self.weight =... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.utils.dat... | WdBlink/Teacher-Student-Faster-Rcnn | FocalLoss | false | 9,559 | [
"MIT"
] | 0 | df8085c61e334abb04bab5e8192de8cb4ce2b2af | https://github.com/WdBlink/Teacher-Student-Faster-Rcnn/tree/df8085c61e334abb04bab5e8192de8cb4ce2b2af |
NegSamplingLoss | import torch
import torch.nn as nn
class NegSamplingLoss(nn.Module):
def __init__(self):
super(NegSamplingLoss, self).__init__()
def forward(self, score, sign):
return -torch.mean(torch.sigmoid(sign * score))
def get_inputs():
return [torch.rand([4, 4, 4, 4]), torch.rand([4, 4, 4, 4])]... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
emp... | MIracleyin/RecBole-notebook | NegSamplingLoss | false | 9,560 | [
"MIT"
] | 0 | ef32b3e57a297ff4889dec1f63c7984f8f901a23 | https://github.com/MIracleyin/RecBole-notebook/tree/ef32b3e57a297ff4889dec1f63c7984f8f901a23 |
UpBlock | import torch
from torchvision.transforms import *
class ConvBlock(torch.nn.Module):
def __init__(self, input_size, output_size, kernel_size=3, stride=1,
padding=1, bias=True, activation='prelu', norm=None):
super(ConvBlock, self).__init__()
self.conv = torch.nn.Conv2d(input_size, output_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 torchvision.transforms import *
assert_size_stride = torch._C._dynamo.guard... | EvgeneyZ/RBPN | UpBlock | false | 9,561 | [
"MIT"
] | 0 | acfe636cc48a4fbfea78f934a251c32e53367659 | https://github.com/EvgeneyZ/RBPN/tree/acfe636cc48a4fbfea78f934a251c32e53367659 |
AUGRUCell | import torch
import torch.nn as nn
import torch.nn.functional as F
class AUGRUCell(nn.Module):
' Effect of GRU with attentional update gate (AUGRU). AUGRU combines attention mechanism and GRU seamlessly.\n\n Formally:\n ..math: \tilde{{u}}_{t}^{\\prime}=a_{t} * {u}_{t}^{\\prime} \\\n {h}_... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as ... | MIracleyin/RecBole-notebook | AUGRUCell | false | 9,562 | [
"MIT"
] | 0 | ef32b3e57a297ff4889dec1f63c7984f8f901a23 | https://github.com/MIracleyin/RecBole-notebook/tree/ef32b3e57a297ff4889dec1f63c7984f8f901a23 |
RegLoss | import torch
import torch.nn as nn
class RegLoss(nn.Module):
""" RegLoss, L2 regularization on model parameters
"""
def __init__(self):
super(RegLoss, self).__init__()
def forward(self, parameters):
reg_loss = None
for W in parameters:
if reg_loss is None:
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_... | MIracleyin/RecBole-notebook | RegLoss | false | 9,563 | [
"MIT"
] | 0 | ef32b3e57a297ff4889dec1f63c7984f8f901a23 | https://github.com/MIracleyin/RecBole-notebook/tree/ef32b3e57a297ff4889dec1f63c7984f8f901a23 |
FCN8s | import torch
import numpy as np
from torch import nn
def get_upsampling_weight(in_channels, out_channels, kernel_size):
"""Make a 2D bilinear kernel suitable for upsampling"""
factor = (kernel_size + 1) // 2
if kernel_size % 2 == 1:
center = factor - 1
else:
center = factor - 0.5
o... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import numpy as np
from torch... | Design-AILab/Attention-Tracker | FCN8s | false | 9,564 | [
"MIT"
] | 0 | 3dfe5edabdff0cb6db9c99ed59afd8c0383b6233 | https://github.com/Design-AILab/Attention-Tracker/tree/3dfe5edabdff0cb6db9c99ed59afd8c0383b6233 |
eSEModule | import torch
from torch import nn
import torch.nn.functional as F
class Hsigmoid(nn.Module):
def __init__(self, inplace=True):
super(Hsigmoid, self).__init__()
self.inplace = inplace
def forward(self, x):
return F.relu6(x + 3.0, inplace=self.inplace) / 6.0
class eSEModule(nn.Module... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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... | UWO-CCPL/AdelaiDet | eSEModule | false | 9,565 | [
"BSD-2-Clause"
] | 0 | 29a59575697dbbb4cfe7b7ab821805913348cf61 | https://github.com/UWO-CCPL/AdelaiDet/tree/29a59575697dbbb4cfe7b7ab821805913348cf61 |
Symmetric | import torch
import torch.nn as nn
import torch.quantization
import torch.onnx
import torch.nn.parallel
import torch.utils.data
import torch.fx
import torch.nn
import torch.optim
import torch.profiler
class Symmetric(nn.Module):
def forward(self, X):
return X.triu() + X.triu(1).transpose(-1, -2)
def ge... | 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.quantization
import torch.onnx
import torch.nn.parallel
import torch.utils.data
import torch.fx
import to... | Nayef211/tutorials | Symmetric | false | 9,566 | [
"BSD-3-Clause"
] | 0 | faf2c476fc3be855051fbea3cce77eaf7b2a2175 | https://github.com/Nayef211/tutorials/tree/faf2c476fc3be855051fbea3cce77eaf7b2a2175 |
MetaLayerNorm | import re
import torch
import warnings
import torch.nn as nn
import torch.nn.functional as F
from collections import OrderedDict
class MetaModule(nn.Module):
"""
Base class for PyTorch meta-learning modules. These modules accept an
additional argument `params` in their `forward` method.
Notes
---... | 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 re
import warnings
import torch.nn as nn
from collections import Ordered... | Steffen-Wolf/pytorch-meta | MetaLayerNorm | false | 9,567 | [
"MIT"
] | 0 | d2dfb902cfa49574eac898045c8e9cf64ce29f96 | https://github.com/Steffen-Wolf/pytorch-meta/tree/d2dfb902cfa49574eac898045c8e9cf64ce29f96 |
InnerProductLayer | import torch
import torch.nn as nn
class InnerProductLayer(nn.Module):
"""InnerProduct Layer used in PNN that compute the element-wise
product or inner product between feature vectors.
"""
def __init__(self, num_feature_field, device):
"""
Args:
num_feature_field(int) :nu... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | MIracleyin/RecBole-notebook | InnerProductLayer | false | 9,568 | [
"MIT"
] | 0 | ef32b3e57a297ff4889dec1f63c7984f8f901a23 | https://github.com/MIracleyin/RecBole-notebook/tree/ef32b3e57a297ff4889dec1f63c7984f8f901a23 |
AttLayer | import torch
import torch.nn as nn
import torch.nn.functional as fn
class AttLayer(nn.Module):
"""Calculate the attention signal(weight) according the input tensor.
Args:
infeatures (torch.FloatTensor): A 3D input tensor with shape of[batch_size, M, embed_dim].
Returns:
torch.FloatTensor... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | MIracleyin/RecBole-notebook | AttLayer | false | 9,569 | [
"MIT"
] | 0 | ef32b3e57a297ff4889dec1f63c7984f8f901a23 | https://github.com/MIracleyin/RecBole-notebook/tree/ef32b3e57a297ff4889dec1f63c7984f8f901a23 |
GatedConv2d | import torch
from torch import nn
import torch.utils.data
class GatedConv2d(nn.Module):
def __init__(self, input_channels, output_channels, kernel_size, stride,
padding, dilation=1, activation=None):
super(GatedConv2d, self).__init__()
self.activation = activation
self.sigmoid = 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 import nn
import torch.utils.data
assert_size_stride = torch._C._dyna... | RobertYCXu/vae_vampprior | GatedConv2d | false | 9,570 | [
"MIT"
] | 0 | edcec4f5f7af673172c5b5b9aa2a22f993564fab | https://github.com/RobertYCXu/vae_vampprior/tree/edcec4f5f7af673172c5b5b9aa2a22f993564fab |
ResizeConv2d | import torch
from torch import nn
import torch.utils.data
class ResizeConv2d(nn.Module):
def __init__(self, input_channels, output_channels, kernel_size, stride,
padding, dilation=1, scale_factor=2, activation=None):
super(ResizeConv2d, self).__init__()
self.activation = activation
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import 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
assert_size_stride = torch._C._dyna... | RobertYCXu/vae_vampprior | ResizeConv2d | false | 9,571 | [
"MIT"
] | 0 | edcec4f5f7af673172c5b5b9aa2a22f993564fab | https://github.com/RobertYCXu/vae_vampprior/tree/edcec4f5f7af673172c5b5b9aa2a22f993564fab |
ItemToInterestAggregation | import torch
import torch.nn as nn
class ItemToInterestAggregation(nn.Module):
def __init__(self, seq_len, hidden_size, k_interests=5):
super().__init__()
self.k_interests = k_interests
self.theta = nn.Parameter(torch.randn([hidden_size, k_interests]))
def forward(self, input_tensor)... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | MIracleyin/RecBole-notebook | ItemToInterestAggregation | false | 9,572 | [
"MIT"
] | 0 | ef32b3e57a297ff4889dec1f63c7984f8f901a23 | https://github.com/MIracleyin/RecBole-notebook/tree/ef32b3e57a297ff4889dec1f63c7984f8f901a23 |
SE_Connect | import torch
import torch.nn as nn
import torch.nn.functional as F
class SE_Connect(nn.Module):
def __init__(self, channels, s=2):
super().__init__()
assert channels % s == 0, '{} % {} != 0'.format(channesl, s)
self.linear1 = nn.Linear(channels, channels // s)
self.linear2 = nn.Li... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | SecretKeyTeam/voxceleb_trainer | SE_Connect | false | 9,573 | [
"MIT"
] | 0 | e235cbc2961d32395d30cf606ee830cd47716383 | https://github.com/SecretKeyTeam/voxceleb_trainer/tree/e235cbc2961d32395d30cf606ee830cd47716383 |
BaseFactorizationMachine | import torch
import torch.nn as nn
class BaseFactorizationMachine(nn.Module):
"""Calculate FM result over the embeddings
Args:
reduce_sum: bool, whether to sum the result, default is True.
Input:
input_x: tensor, A 3D tensor with shape:``(batch_size,field_size,embed_dim)``.
Output
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | MIracleyin/RecBole-notebook | BaseFactorizationMachine | false | 9,574 | [
"MIT"
] | 0 | ef32b3e57a297ff4889dec1f63c7984f8f901a23 | https://github.com/MIracleyin/RecBole-notebook/tree/ef32b3e57a297ff4889dec1f63c7984f8f901a23 |
ConvNCFBPRLoss | import torch
import torch.nn as nn
class ConvNCFBPRLoss(nn.Module):
""" ConvNCFBPRLoss, based on Bayesian Personalized Ranking,
Shape:
- Pos_score: (N)
- Neg_score: (N), same shape as the Pos_score
- Output: scalar.
Examples::
>>> loss = ConvNCFBPRLoss()
>>> ... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
... | MIracleyin/RecBole-notebook | ConvNCFBPRLoss | false | 9,575 | [
"MIT"
] | 0 | ef32b3e57a297ff4889dec1f63c7984f8f901a23 | https://github.com/MIracleyin/RecBole-notebook/tree/ef32b3e57a297ff4889dec1f63c7984f8f901a23 |
BPRLoss | import torch
import torch.nn as nn
class BPRLoss(nn.Module):
""" BPRLoss, based on Bayesian Personalized Ranking
Args:
- gamma(float): Small value to avoid division by zero
Shape:
- Pos_score: (N)
- Neg_score: (N), same shape as the Pos_score
- Output: scalar.
Exampl... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
... | MIracleyin/RecBole-notebook | BPRLoss | false | 9,576 | [
"MIT"
] | 0 | ef32b3e57a297ff4889dec1f63c7984f8f901a23 | https://github.com/MIracleyin/RecBole-notebook/tree/ef32b3e57a297ff4889dec1f63c7984f8f901a23 |
ReLU | import torch
import numpy as np
import torch.nn as nn
from numbers import Number
def normcdf(value, mu=0.0, stddev=1.0):
sinv = 1.0 / stddev if isinstance(stddev, Number) else stddev.reciprocal()
return 0.5 * (1.0 + torch.erf((value - mu) * sinv / np.sqrt(2.0)))
def _normal_log_pdf(value, mu, stddev):
v... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import numpy as np
import torch.nn as nn
from numbers import N... | SaumilShah66/dqn_uav | ReLU | false | 9,577 | [
"MIT"
] | 0 | 2bf780369e964b870624aebcff16c0714cad03c1 | https://github.com/SaumilShah66/dqn_uav/tree/2bf780369e964b870624aebcff16c0714cad03c1 |
AvgPoolPad | import torch
import torch.nn as nn
class AvgPoolPad(nn.Module):
def __init__(self, stride=2, padding=1):
super(AvgPoolPad, self).__init__()
self.pad = nn.ZeroPad2d((1, 0, 1, 0))
self.pool = nn.AvgPool2d(3, stride=stride, padding=padding,
count_include_pad=False)
def forwa... | 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... | ArronHZG/ABD-Net | AvgPoolPad | false | 9,578 | [
"MIT"
] | 0 | 4f6d15f4d389a55549ea10a2e00d4a5cdecb5753 | https://github.com/ArronHZG/ABD-Net/tree/4f6d15f4d389a55549ea10a2e00d4a5cdecb5753 |
MaxPool2d | import torch
import numpy as np
import torch.nn as nn
from numbers import Number
def normcdf(value, mu=0.0, stddev=1.0):
sinv = 1.0 / stddev if isinstance(stddev, Number) else stddev.reciprocal()
return 0.5 * (1.0 + torch.erf((value - mu) * sinv / np.sqrt(2.0)))
def _normal_log_pdf(value, mu, stddev):
v... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import numpy as np
import torch.nn as nn
from numbers import N... | SaumilShah66/dqn_uav | MaxPool2d | false | 9,579 | [
"MIT"
] | 0 | 2bf780369e964b870624aebcff16c0714cad03c1 | https://github.com/SaumilShah66/dqn_uav/tree/2bf780369e964b870624aebcff16c0714cad03c1 |
GatedDense | import torch
from torch import nn
import torch.utils.data
class GatedDense(nn.Module):
def __init__(self, input_size, output_size, activation=None):
super(GatedDense, self).__init__()
self.activation = activation
self.sigmoid = nn.Sigmoid()
self.h = nn.Linear(input_size, output_si... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import 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
assert_size_stride = torch._C._dyna... | RobertYCXu/vae_vampprior | GatedDense | false | 9,580 | [
"MIT"
] | 0 | edcec4f5f7af673172c5b5b9aa2a22f993564fab | https://github.com/RobertYCXu/vae_vampprior/tree/edcec4f5f7af673172c5b5b9aa2a22f993564fab |
AGRUCell | import torch
import torch.nn as nn
import torch.nn.functional as F
class AGRUCell(nn.Module):
' Attention based GRU (AGRU). AGRU uses the attention score to replace the update gate of GRU, and changes the\n hidden state directly.\n\n Formally:\n ..math: {h}_{t}^{\\prime}=\\left(1-a_{t}\right) * {h}_{... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as ... | MIracleyin/RecBole-notebook | AGRUCell | false | 9,581 | [
"MIT"
] | 0 | ef32b3e57a297ff4889dec1f63c7984f8f901a23 | https://github.com/MIracleyin/RecBole-notebook/tree/ef32b3e57a297ff4889dec1f63c7984f8f901a23 |
OuterProductLayer | import torch
import torch.nn as nn
class OuterProductLayer(nn.Module):
"""OuterProduct Layer used in PNN. This implementation is
adapted from code that the author of the paper published on https://github.com/Atomu2014/product-nets.
"""
def __init__(self, num_feature_field, embedding_size, device):
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | MIracleyin/RecBole-notebook | OuterProductLayer | false | 9,582 | [
"MIT"
] | 0 | ef32b3e57a297ff4889dec1f63c7984f8f901a23 | https://github.com/MIracleyin/RecBole-notebook/tree/ef32b3e57a297ff4889dec1f63c7984f8f901a23 |
Conv2d | import torch
from torch.nn import functional as F
from torch.nn.modules.conv import _ConvNd
from torch.nn.modules.utils import _pair
class Conv2d(_ConvNd):
def __init__(self, in_channels, out_channels, kernel_size, stride=1,
padding=0, dilation=1, groups=1, bias=True, keep_variance_fn=None,
paddi... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import 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.modules.conv import _ConvNd
from torch.nn.modules.utils import _pa... | SaumilShah66/dqn_uav | Conv2d | false | 9,583 | [
"MIT"
] | 0 | 2bf780369e964b870624aebcff16c0714cad03c1 | https://github.com/SaumilShah66/dqn_uav/tree/2bf780369e964b870624aebcff16c0714cad03c1 |
Softmax | import torch
import torch.nn as nn
class Softmax(nn.Module):
def __init__(self, dim=1, keep_variance_fn=None):
super(Softmax, self).__init__()
self.dim = dim
self._keep_variance_fn = keep_variance_fn
def forward(self, features_mean, features_variance, eps=1e-05):
"""Softmax f... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert... | SaumilShah66/dqn_uav | Softmax | false | 9,584 | [
"MIT"
] | 0 | 2bf780369e964b870624aebcff16c0714cad03c1 | https://github.com/SaumilShah66/dqn_uav/tree/2bf780369e964b870624aebcff16c0714cad03c1 |
Linear | import torch
import torch.nn as nn
from torch.nn.parameter import Parameter
from torch.nn import functional as F
class Linear(nn.Module):
def __init__(self, in_features, out_features, bias=True,
keep_variance_fn=None):
super(Linear, self).__init__()
self._keep_variance_fn = keep_variance_... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
from torch.nn.parameter import Parameter
assert_size_strid... | SaumilShah66/dqn_uav | Linear | false | 9,585 | [
"MIT"
] | 0 | 2bf780369e964b870624aebcff16c0714cad03c1 | https://github.com/SaumilShah66/dqn_uav/tree/2bf780369e964b870624aebcff16c0714cad03c1 |
HardAttn | import torch
import torch.nn as nn
import torch.nn.functional as F
class HardAttn(nn.Module):
"""Hard Attention (Sec. 3.1.II)"""
def __init__(self, in_channels):
super(HardAttn, self).__init__()
self.fc = nn.Linear(in_channels, 4 * 2)
self.init_params()
def init_params(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
import torch.nn as ... | ArronHZG/ABD-Net | HardAttn | false | 9,586 | [
"MIT"
] | 0 | 4f6d15f4d389a55549ea10a2e00d4a5cdecb5753 | https://github.com/ArronHZG/ABD-Net/tree/4f6d15f4d389a55549ea10a2e00d4a5cdecb5753 |
SimpleDropoutOptimizer | import torch
import torch.nn as nn
class SimpleDropoutOptimizer(nn.Module):
def __init__(self, p):
super().__init__()
if p is not None:
self.dropout = nn.Dropout(p=p)
else:
self.dropout = None
def forward(self, x):
if self.dropout is not None:
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | ArronHZG/ABD-Net | SimpleDropoutOptimizer | false | 9,587 | [
"MIT"
] | 0 | 4f6d15f4d389a55549ea10a2e00d4a5cdecb5753 | https://github.com/ArronHZG/ABD-Net/tree/4f6d15f4d389a55549ea10a2e00d4a5cdecb5753 |
RingLoss | import torch
import warnings
import torch.nn as nn
class RingLoss(nn.Module):
"""Ring loss.
Reference:
Zheng et al. Ring loss: Convex Feature Normalization for Face Recognition. CVPR 2018.
"""
def __init__(self):
super(RingLoss, self).__init__()
warnings.warn('This method is ... | 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 warnings
import torch.nn as nn
assert_size_stride = torch._C._dynamo.gua... | ArronHZG/ABD-Net | RingLoss | false | 9,588 | [
"MIT"
] | 0 | 4f6d15f4d389a55549ea10a2e00d4a5cdecb5753 | https://github.com/ArronHZG/ABD-Net/tree/4f6d15f4d389a55549ea10a2e00d4a5cdecb5753 |
GatedResUnit | import torch
from torch import nn
import torch.utils.data
class GatedConv2d(nn.Module):
def __init__(self, input_channels, output_channels, kernel_size, stride,
padding, dilation=1, activation=None):
super(GatedConv2d, self).__init__()
self.activation = activation
self.sigmoid = 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 import nn
import torch.utils.data
assert_size_stride = torch._C._dyna... | RobertYCXu/vae_vampprior | GatedResUnit | false | 9,589 | [
"MIT"
] | 0 | edcec4f5f7af673172c5b5b9aa2a22f993564fab | https://github.com/RobertYCXu/vae_vampprior/tree/edcec4f5f7af673172c5b5b9aa2a22f993564fab |
Fire | import torch
import torch.nn as nn
class Fire(nn.Module):
def __init__(self, inplanes, squeeze_planes, expand1x1_planes,
expand3x3_planes):
super(Fire, self).__init__()
self.inplanes = inplanes
self.squeeze = nn.Conv2d(inplanes, squeeze_planes, kernel_size=1)
self.squeeze_... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | ArronHZG/ABD-Net | Fire | false | 9,590 | [
"MIT"
] | 0 | 4f6d15f4d389a55549ea10a2e00d4a5cdecb5753 | https://github.com/ArronHZG/ABD-Net/tree/4f6d15f4d389a55549ea10a2e00d4a5cdecb5753 |
SEModule | import torch
import torch.nn as nn
class SEModule(nn.Module):
def __init__(self, channels, reduction):
super(SEModule, self).__init__()
self.avg_pool = nn.AdaptiveAvgPool2d(1)
self.fc1 = nn.Conv2d(channels, channels // reduction, kernel_size=1,
padding=0)
self.relu = 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_... | ArronHZG/ABD-Net | SEModule | false | 9,591 | [
"MIT"
] | 0 | 4f6d15f4d389a55549ea10a2e00d4a5cdecb5753 | https://github.com/ArronHZG/ABD-Net/tree/4f6d15f4d389a55549ea10a2e00d4a5cdecb5753 |
LinearModel | import torch
import torch.nn as nn
class LinearModel(nn.Module):
def __init__(self, input_size, output_size, hidden_size):
super(LinearModel, self).__init__()
self.linear1 = nn.Linear(input_size, hidden_size)
self.linear2 = nn.Linear(hidden_size, hidden_size)
self.linear3 = 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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | VVKot/mlinseconds-die-hard | LinearModel | false | 9,592 | [
"MIT"
] | 0 | dacbd448180bc992e0dab9e4b27bb594235d8c44 | https://github.com/VVKot/mlinseconds-die-hard/tree/dacbd448180bc992e0dab9e4b27bb594235d8c44 |
FocalLossBinary | import torch
import torch.jit
import torch.nn.functional as F
from functools import partial
import torch.utils.data
import torch.nn.functional
from torch.nn.modules.loss import _Loss
def reduced_focal_loss(outputs: 'torch.Tensor', targets: 'torch.Tensor',
threshold: 'float'=0.5, gamma: 'float'=2.0, reduction='mea... | 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... | Magnety/nnUNet | FocalLossBinary | false | 9,593 | [
"Apache-2.0"
] | 0 | f07e6fdf191377550c57bcdc8859798486f60443 | https://github.com/Magnety/nnUNet/tree/f07e6fdf191377550c57bcdc8859798486f60443 |
ExpLayer | import torch
import torch.cuda
import torch.nn as nn
class ExpLayer(nn.Module):
def __init__(self, vMF_kappa):
super(ExpLayer, self).__init__()
self.vMF_kappa = nn.Parameter(torch.Tensor([vMF_kappa]))
def forward(self, x, binary=False):
if binary:
x = torch.exp(self.vMF_k... | 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.cuda
import torch.nn as nn
assert_size_stride = torch._C._dy... | XD7479/Robust-Instance-Segmentation-through-Reasoning-about-Multi-Object-Occlusion | ExpLayer | false | 9,594 | [
"MIT"
] | 0 | 593622afbd83981b4c42940d39770ddf9c1b566c | https://github.com/XD7479/Robust-Instance-Segmentation-through-Reasoning-about-Multi-Object-Occlusion/tree/593622afbd83981b4c42940d39770ddf9c1b566c |
Model4 | import torch
from torch import nn
class Model4(nn.Module):
def __init__(self, input_dim, output_dim, hidden=64):
super(Model4, self).__init__()
self.fc1 = nn.Linear(input_dim, hidden)
self.relu1 = nn.ReLU()
self.fc2 = nn.Linear(hidden, hidden)
self.relu2 = nn.ReLU()
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch import nn
assert_s... | TonyMTH/Resume-Ranking | Model4 | false | 9,595 | [
"MIT"
] | 0 | 6f560f7219848ddc7ee4bdbfabbd980905af4642 | https://github.com/TonyMTH/Resume-Ranking/tree/6f560f7219848ddc7ee4bdbfabbd980905af4642 |
MaxPoolPad | import torch
import torch.nn as nn
class MaxPoolPad(nn.Module):
def __init__(self):
super(MaxPoolPad, self).__init__()
self.pad = nn.ZeroPad2d((1, 0, 1, 0))
self.pool = nn.MaxPool2d(3, stride=2, padding=1)
def forward(self, x):
x = self.pad(x)
x = self.pool(x)
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
emp... | ArronHZG/ABD-Net | MaxPoolPad | false | 9,596 | [
"MIT"
] | 0 | 4f6d15f4d389a55549ea10a2e00d4a5cdecb5753 | https://github.com/ArronHZG/ABD-Net/tree/4f6d15f4d389a55549ea10a2e00d4a5cdecb5753 |
CAE | import torch
import torch.nn as nn
class CAE(nn.Module):
"""
The Cobb Angle Estimator (CAE), which :
1. maps #nDense1 landmark features to #nDense2 angle features
2. adds the #nDense2 angle features (from step 1) to #nDense2 landmarks features (from previous layer)
3. maps summed #nDe... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 ... | VincentYCYao/MVC-Net-pytorch | CAE | false | 9,597 | [
"MIT"
] | 0 | 31f826825cdfe862fbfe0fe19edc78c04d1dec55 | https://github.com/VincentYCYao/MVC-Net-pytorch/tree/31f826825cdfe862fbfe0fe19edc78c04d1dec55 |
Model1 | import torch
from torch import nn
from torch.nn.functional import relu
class Model1(nn.Module):
def __init__(self, input_dim, output_dim, hidden1=16, hidden2=16,
hidden3=16):
super(Model1, self).__init__()
self.fc1 = nn.Linear(input_dim, hidden1)
self.fc2 = nn.Linear(hidden1, hidd... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | TonyMTH/Resume-Ranking | Model1 | false | 9,598 | [
"MIT"
] | 0 | 6f560f7219848ddc7ee4bdbfabbd980905af4642 | https://github.com/TonyMTH/Resume-Ranking/tree/6f560f7219848ddc7ee4bdbfabbd980905af4642 |
StdConv3d | import torch
from torch import nn
import torch.jit
import torch.nn.functional as F
import torch.utils.data
import torch.nn.functional
class StdConv3d(nn.Conv3d):
def forward(self, x):
w = self.weight
v, m = torch.var_mean(w, dim=[1, 2, 3], keepdim=True, unbiased=False)
w = (w - m) / torch... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
from torch import n... | Magnety/nnUNet | StdConv3d | false | 9,599 | [
"Apache-2.0"
] | 0 | f07e6fdf191377550c57bcdc8859798486f60443 | https://github.com/Magnety/nnUNet/tree/f07e6fdf191377550c57bcdc8859798486f60443 |
wSummation | import torch
import torch.nn as nn
class wSummation(nn.Module):
"""
The spatial weighted summation layer.
"""
def __init__(self, input_dim):
"""
:param input_dim: input dimension [C,H,W]
"""
super(wSummation, self).__init__()
self.Q = nn.Parameter(torch.rand(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... | VincentYCYao/MVC-Net-pytorch | wSummation | false | 9,600 | [
"MIT"
] | 0 | 31f826825cdfe862fbfe0fe19edc78c04d1dec55 | https://github.com/VincentYCYao/MVC-Net-pytorch/tree/31f826825cdfe862fbfe0fe19edc78c04d1dec55 |
SE | import torch
from itertools import chain as chain
import torch.utils.data
import torch.nn as nn
class SwishEfficient(torch.autograd.Function):
"""Swish activation function: x * sigmoid(x)."""
@staticmethod
def forward(ctx, x):
result = x * torch.sigmoid(x)
ctx.save_for_backward(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
from itertools import chain a... | WoojuLee24/SlowFast | SE | false | 9,601 | [
"Apache-2.0"
] | 0 | 1fa9fda86a83ee09af5d38e11b14d2a2a18e419b | https://github.com/WoojuLee24/SlowFast/tree/1fa9fda86a83ee09af5d38e11b14d2a2a18e419b |
GraphAttention | import torch
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
class GraphAttention(nn.Module):
def __init__(self, in_features, out_features, dropout, alpha=0.2,
concat=True, return_attention=False):
super(GraphAttention, self).__init__()
self.dropout = dropout
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | Supermaxman/covid19-data | GraphAttention | false | 9,602 | [
"Apache-2.0"
] | 0 | 13e8e0c30a063c60e2160896458cd290a85ea0e2 | https://github.com/Supermaxman/covid19-data/tree/13e8e0c30a063c60e2160896458cd290a85ea0e2 |
Repeat_Explore_Mechanism | import torch
import torch.nn as nn
class Repeat_Explore_Mechanism(nn.Module):
def __init__(self, device, hidden_size, seq_len, dropout_prob):
super(Repeat_Explore_Mechanism, self).__init__()
self.dropout = nn.Dropout(dropout_prob)
self.hidden_size = hidden_size
self.device = devic... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | MIracleyin/RecBole-notebook | Repeat_Explore_Mechanism | false | 9,603 | [
"MIT"
] | 0 | ef32b3e57a297ff4889dec1f63c7984f8f901a23 | https://github.com/MIracleyin/RecBole-notebook/tree/ef32b3e57a297ff4889dec1f63c7984f8f901a23 |
Contract | import torch
import torch.nn as nn
class Contract(nn.Module):
def __init__(self, gain=2):
super().__init__()
self.gain = gain
def forward(self, x):
b, c, h, w = x.size()
s = self.gain
x = x.view(b, c, h // s, s, w // s, s)
x = x.permute(0, 3, 5, 1, 2, 4).conti... | 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... | Lalihoo/yolov5-detect | Contract | false | 9,604 | [
"MIT"
] | 0 | 265c3137ea3586d913541501a1562488fbe59e9e | https://github.com/Lalihoo/yolov5-detect/tree/265c3137ea3586d913541501a1562488fbe59e9e |
PEG | import torch
from torch import nn
class Residual(nn.Module):
def __init__(self, fn):
super().__init__()
self.fn = fn
def forward(self, x, **kwargs):
return self.fn(x, **kwargs) + x
class PEG(nn.Module):
def __init__(self, dim, kernel_size=3):
super().__init__()
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_st... | Steffen-Wolf/vit-pytorch | PEG | false | 9,605 | [
"MIT"
] | 0 | 4f590b9bd570091d9070a039ad33301516caa341 | https://github.com/Steffen-Wolf/vit-pytorch/tree/4f590b9bd570091d9070a039ad33301516caa341 |
Expand | import torch
import torch.nn as nn
class Expand(nn.Module):
def __init__(self, gain=2):
super().__init__()
self.gain = gain
def forward(self, x):
b, c, h, w = x.size()
s = self.gain
x = x.view(b, s, s, c // s ** 2, h, w)
x = x.permute(0, 3, 4, 1, 5, 2).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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | Lalihoo/yolov5-detect | Expand | false | 9,606 | [
"MIT"
] | 0 | 265c3137ea3586d913541501a1562488fbe59e9e | https://github.com/Lalihoo/yolov5-detect/tree/265c3137ea3586d913541501a1562488fbe59e9e |
GEGLU | import torch
from torch import nn
import torch.nn.functional as F
class GEGLU(nn.Module):
def forward(self, x):
x, gates = x.chunk(2, dim=-1)
return F.gelu(gates) * 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
from torch._inductor.runtime.triton_helpers import libdevice
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | Steffen-Wolf/vit-pytorch | GEGLU | false | 9,607 | [
"MIT"
] | 0 | 4f590b9bd570091d9070a039ad33301516caa341 | https://github.com/Steffen-Wolf/vit-pytorch/tree/4f590b9bd570091d9070a039ad33301516caa341 |
LeakyReLU | import torch
import numpy as np
import torch.nn as nn
from numbers import Number
def normcdf(value, mu=0.0, stddev=1.0):
sinv = 1.0 / stddev if isinstance(stddev, Number) else stddev.reciprocal()
return 0.5 * (1.0 + torch.erf((value - mu) * sinv / np.sqrt(2.0)))
def _normal_log_pdf(value, mu, stddev):
v... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import numpy as np
import torch.nn as nn
from numbers import N... | SaumilShah66/dqn_uav | LeakyReLU | false | 9,608 | [
"MIT"
] | 0 | 2bf780369e964b870624aebcff16c0714cad03c1 | https://github.com/SaumilShah66/dqn_uav/tree/2bf780369e964b870624aebcff16c0714cad03c1 |
L2Norm | import torch
from torch import nn
class L2Norm(nn.Module):
def forward(self, x, eps=1e-06):
norm = x.norm(dim=1, keepdim=True).clamp(min=eps)
return x / norm
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
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
from torch import nn
assert_... | Steffen-Wolf/vit-pytorch | L2Norm | false | 9,609 | [
"MIT"
] | 0 | 4f590b9bd570091d9070a039ad33301516caa341 | https://github.com/Steffen-Wolf/vit-pytorch/tree/4f590b9bd570091d9070a039ad33301516caa341 |
SpatialAttention | import torch
from torch import nn
from torch import einsum
class SpatialAttention(nn.Module):
def __init__(self):
super().__init__()
def similarity(self, spatial_embedding):
e0 = spatial_embedding.unsqueeze(2)
e1 = spatial_embedding.unsqueeze(1)
dist = (e0 - e1).norm(2, 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, math as tl_math
fr... | Steffen-Wolf/vit-pytorch | SpatialAttention | false | 9,610 | [
"MIT"
] | 0 | 4f590b9bd570091d9070a039ad33301516caa341 | https://github.com/Steffen-Wolf/vit-pytorch/tree/4f590b9bd570091d9070a039ad33301516caa341 |
LayerNorm | import torch
from torch import nn
class LayerNorm(nn.Module):
def __init__(self, dim, eps=1e-05):
super().__init__()
self.eps = eps
self.g = nn.Parameter(torch.ones(1, dim, 1, 1))
self.b = nn.Parameter(torch.zeros(1, dim, 1, 1))
def forward(self, x):
std = torch.var(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... | Steffen-Wolf/vit-pytorch | LayerNorm | false | 9,611 | [
"MIT"
] | 0 | 4f590b9bd570091d9070a039ad33301516caa341 | https://github.com/Steffen-Wolf/vit-pytorch/tree/4f590b9bd570091d9070a039ad33301516caa341 |
BCEBlurWithLogitsLoss | import torch
import torch.nn as nn
class BCEBlurWithLogitsLoss(nn.Module):
def __init__(self, alpha=0.05):
super(BCEBlurWithLogitsLoss, self).__init__()
self.loss_fcn = nn.BCEWithLogitsLoss(reduction='none')
self.alpha = alpha
def forward(self, pred, true):
loss = self.loss_f... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import torc... | Lalihoo/yolov5-detect | BCEBlurWithLogitsLoss | false | 9,612 | [
"MIT"
] | 0 | 265c3137ea3586d913541501a1562488fbe59e9e | https://github.com/Lalihoo/yolov5-detect/tree/265c3137ea3586d913541501a1562488fbe59e9e |
InnerProductLoss | import torch
import torch.nn as nn
import torch.nn.functional as F
class InnerProductLoss(nn.Module):
"""This is the inner-product loss used in CFKG for optimization.
"""
def __init__(self):
super(InnerProductLoss, self).__init__()
def forward(self, anchor, positive, negative):
pos_s... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import torch.nn as nn
assert_size_stride = torch._C._dynamo.gu... | MIracleyin/RecBole-notebook | InnerProductLoss | false | 9,613 | [
"MIT"
] | 0 | ef32b3e57a297ff4889dec1f63c7984f8f901a23 | https://github.com/MIracleyin/RecBole-notebook/tree/ef32b3e57a297ff4889dec1f63c7984f8f901a23 |
MultiHeadAttention | import math
import torch
import torch.nn as nn
class MultiHeadAttention(nn.Module):
"""
Multi-head Self-attention layers, a attention score dropout layer is introduced.
Args:
input_tensor (torch.Tensor): the input of the multi-head self-attention layer
attention_mask (torch.Tensor): the a... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | MIracleyin/RecBole-notebook | MultiHeadAttention | false | 9,614 | [
"MIT"
] | 0 | ef32b3e57a297ff4889dec1f63c7984f8f901a23 | https://github.com/MIracleyin/RecBole-notebook/tree/ef32b3e57a297ff4889dec1f63c7984f8f901a23 |
Sum | import torch
import torch.nn as nn
class Sum(nn.Module):
def __init__(self, n, weight=False):
super().__init__()
self.weight = weight
self.iter = range(n - 1)
if weight:
self.w = nn.Parameter(-torch.arange(1.0, n) / 2, requires_grad=True
)
def forw... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | Lalihoo/yolov5-detect | Sum | false | 9,615 | [
"MIT"
] | 0 | 265c3137ea3586d913541501a1562488fbe59e9e | https://github.com/Lalihoo/yolov5-detect/tree/265c3137ea3586d913541501a1562488fbe59e9e |
Conv2d | import torch
from torch import nn
import torch.utils.data
class Conv2d(nn.Module):
def __init__(self, input_channels, output_channels, kernel_size, stride,
padding, dilation=1, activation=None, bias=True):
super(Conv2d, self).__init__()
self.activation = activation
self.conv = 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 import nn
import torch.utils.data
assert_size_stride = torch._C._dyna... | RobertYCXu/vae_vampprior | Conv2d | false | 9,616 | [
"MIT"
] | 0 | edcec4f5f7af673172c5b5b9aa2a22f993564fab | https://github.com/RobertYCXu/vae_vampprior/tree/edcec4f5f7af673172c5b5b9aa2a22f993564fab |
AconC | import torch
import torch.nn as nn
class AconC(nn.Module):
""" ACON activation (activate or not).
AconC: (p1*x-p2*x) * sigmoid(beta*(p1*x-p2*x)) + p2*x, beta is a learnable parameter
according to "Activate or Not: Learning Customized Activation" <https://arxiv.org/pdf/2009.04759.pdf>.
"""
def __i... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | Lalihoo/yolov5-detect | AconC | false | 9,617 | [
"MIT"
] | 0 | 265c3137ea3586d913541501a1562488fbe59e9e | https://github.com/Lalihoo/yolov5-detect/tree/265c3137ea3586d913541501a1562488fbe59e9e |
QMaxPooling2d | from torch.autograd import Function
import torch
import torch.nn as nn
import torch.nn.functional as F
def calcScaleZeroPoint(min_val, max_val, num_bits=8):
qmin = 0
qmax = 2 ** num_bits - 1
scale = (max_val - min_val) / (qmax - qmin)
zero_point = qmax - max_val / scale
if zero_point < qmin:
... | 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.autograd import Function
import torch.nn as nn
import torch.nn.functional as F... | XHX00008888/pytorch-quantization-xhx | QMaxPooling2d | false | 9,618 | [
"Apache-2.0"
] | 0 | 8031511f9b9364be006b37b0b3df6c62f765c40a | https://github.com/XHX00008888/pytorch-quantization-xhx/tree/8031511f9b9364be006b37b0b3df6c62f765c40a |
QAvgPooling2d | from torch.autograd import Function
import torch
import torch.nn as nn
import torch.nn.functional as F
def calcScaleZeroPoint(min_val, max_val, num_bits=8):
qmin = 0
qmax = 2 ** num_bits - 1
scale = (max_val - min_val) / (qmax - qmin)
zero_point = qmax - max_val / scale
if zero_point < qmin:
... | 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.autograd import Function
import torch.nn as nn
import torch.nn.functional as F
assert_size_stride = torch._C._dynamo.guards.asser... | XHX00008888/pytorch-quantization-xhx | QAvgPooling2d | false | 9,619 | [
"Apache-2.0"
] | 0 | 8031511f9b9364be006b37b0b3df6c62f765c40a | https://github.com/XHX00008888/pytorch-quantization-xhx/tree/8031511f9b9364be006b37b0b3df6c62f765c40a |
MetaAconC | import torch
import torch.nn as nn
class MetaAconC(nn.Module):
""" ACON activation (activate or not).
MetaAconC: (p1*x-p2*x) * sigmoid(beta*(p1*x-p2*x)) + p2*x, beta is generated by a small network
according to "Activate or Not: Learning Customized Activation" <https://arxiv.org/pdf/2009.04759.pdf>.
"... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | Lalihoo/yolov5-detect | MetaAconC | false | 9,620 | [
"MIT"
] | 0 | 265c3137ea3586d913541501a1562488fbe59e9e | https://github.com/Lalihoo/yolov5-detect/tree/265c3137ea3586d913541501a1562488fbe59e9e |
HardMish | import torch
from torch import nn
def hard_mish(x, inplace: 'bool'=False):
if inplace:
return x.mul_(0.5 * (x + 2).clamp(min=0, max=2))
else:
return 0.5 * x * (x + 2).clamp(min=0, max=2)
class HardMish(nn.Module):
"""
Hard Mish
Experimental, based on notes by Mish author Diganta ... | 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... | SimonCqk/towhee | HardMish | false | 9,621 | [
"Apache-2.0"
] | 0 | a187833b1411216106a80a71e6f2c6e68e1be330 | https://github.com/SimonCqk/towhee/tree/a187833b1411216106a80a71e6f2c6e68e1be330 |
ResizeGatedConv2d | import torch
from torch import nn
import torch.utils.data
class GatedConv2d(nn.Module):
def __init__(self, input_channels, output_channels, kernel_size, stride,
padding, dilation=1, activation=None):
super(GatedConv2d, self).__init__()
self.activation = activation
self.sigmoid = 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 import nn
import torch.utils.data
assert_size_stride = torch._C._dyna... | RobertYCXu/vae_vampprior | ResizeGatedConv2d | false | 9,622 | [
"MIT"
] | 0 | edcec4f5f7af673172c5b5b9aa2a22f993564fab | https://github.com/RobertYCXu/vae_vampprior/tree/edcec4f5f7af673172c5b5b9aa2a22f993564fab |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.