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 |
|---|---|---|---|---|---|---|---|---|---|---|
ContrastiveLoss | from torch.nn import Module
import torch
import torch.nn as nn
from torch.nn.modules import Module
class ContrastiveLoss(Module):
def __init__(self, margin=3):
super(ContrastiveLoss, self).__init__()
self.margin = margin
self.loss = nn.BCELoss()
def forward(self, output, label):
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch.nn import Module
import torch.nn as nn
from torch.nn.modules import Module
ass... | Brain03Yao/M2TGCN | ContrastiveLoss | false | 17,013 | [
"MIT"
] | 6 | 72c65687fa52c618740cd6d1db7366116f68398c | https://github.com/Brain03Yao/M2TGCN/tree/72c65687fa52c618740cd6d1db7366116f68398c |
BCEFocalLoss | import torch
class BCEFocalLoss(torch.nn.Module):
"""
二分类的Focalloss alpha 固定
"""
def __init__(self, gamma=2, alpha=0.25, reduction='elementwise_mean'):
super().__init__()
self.gamma = gamma
self.alpha = alpha
self.reduction = reduction
def forward(self, _input, ta... | 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... | CCChenhao997/CCL2020-Humor-Computation | BCEFocalLoss | false | 17,014 | [
"MIT"
] | 7 | 700e539588904da40a9db899668437188a6b4613 | https://github.com/CCChenhao997/CCL2020-Humor-Computation/tree/700e539588904da40a9db899668437188a6b4613 |
ScaledDotProductAttention | import torch
import torch.nn as nn
import torch.optim
class Bottle(nn.Module):
""" Perform the reshape routine before and after an operation """
def forward(self, input):
if len(input.size()) <= 2:
return super(Bottle, self).forward(input)
size = input.size()[:2]
out = 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.... | Blickwinkel1107/NJUNMT-pytorch | ScaledDotProductAttention | false | 17,015 | [
"MIT"
] | 9 | 82f684fe768b137ca0649b7b79a1820077917385 | https://github.com/Blickwinkel1107/NJUNMT-pytorch/tree/82f684fe768b137ca0649b7b79a1820077917385 |
WeightNormConv2d | import torch
import torch.nn as nn
from torch.nn.utils.weight_norm import weight_norm
import torch.onnx
class WeightNormConv2d(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride=1,
padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros'):
super(WeightNormConv2d... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 ... | AntixK/Neural-Blocks | WeightNormConv2d | false | 17,016 | [
"MIT"
] | 3 | 018a44bbb703fc848234b95a3e604576bd9df88f | https://github.com/AntixK/Neural-Blocks/tree/018a44bbb703fc848234b95a3e604576bd9df88f |
WeightNormLinear | import torch
import torch.nn as nn
from torch.nn.utils.weight_norm import weight_norm
import torch.onnx
class WeightNormLinear(nn.Module):
def __init__(self, in_features, out_features, bias=True):
super(WeightNormLinear, self).__init__()
self.lin = weight_norm(nn.Linear(in_features, out_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.triton_helpers import libdevice
import torch.nn as ... | AntixK/Neural-Blocks | WeightNormLinear | false | 17,017 | [
"MIT"
] | 3 | 018a44bbb703fc848234b95a3e604576bd9df88f | https://github.com/AntixK/Neural-Blocks/tree/018a44bbb703fc848234b95a3e604576bd9df88f |
RegressionNN | import torch
import numpy as np
import torch.nn as nn
class RegressionNN(nn.Module):
def __init__(self, feature_number):
super(RegressionNN, self).__init__()
self.feature_number = feature_number
self.fc1 = nn.Linear(self.feature_number, 12)
self.fc2 = nn.Linear(12, 8)
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 numpy as np
... | BuildFL/BuildFL | RegressionNN | false | 17,018 | [
"MIT"
] | 6 | 2b9fb786c9655b52d54b53e3efaf25e033a5b532 | https://github.com/BuildFL/BuildFL/tree/2b9fb786c9655b52d54b53e3efaf25e033a5b532 |
RationalHat_transform | import torch
import torch.nn as nn
class RationalHat_transform(nn.Module):
"""
Coordinate function as defined in
/Hofer, C., Kwitt, R., and Niethammer, M.
Learning representations of persistence barcodes.
JMLR, 20(126):1–45, 2019b./
"""
def __init__(self, output_dim, input_dim=1):
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert... | BorgwardtLab/TOGL | RationalHat_transform | false | 17,019 | [
"BSD-3-Clause"
] | 6 | d0c986cf829ca6bbae1a23e5cdab1c99146503cd | https://github.com/BorgwardtLab/TOGL/tree/d0c986cf829ca6bbae1a23e5cdab1c99146503cd |
GeneralizedMeanPooling | from torch.nn import Module
import torch
import torch.nn.functional as F
from torch.nn.modules import Module
class GeneralizedMeanPooling(Module):
"""Applies a 2D power-average adaptive pooling over an input signal composed of several input planes.
The function computed is: :math:`f(X) = pow(sum(pow(X, p)), ... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
from torch.nn import Module
... | ByungHeeCha/visual_localization | GeneralizedMeanPooling | false | 17,020 | [
"BSD-3-Clause"
] | 3 | 787fb8f6ee5c6e69ece9e83a016d15596e5524bc | https://github.com/ByungHeeCha/visual_localization/tree/787fb8f6ee5c6e69ece9e83a016d15596e5524bc |
KeypointRCNNPredictor | import torch
from torch import nn
import torch.utils.data
class KeypointRCNNPredictor(nn.Module):
def __init__(self, in_channels, num_keypoints):
super(KeypointRCNNPredictor, self).__init__()
input_features = in_channels
deconv_kernel = 4
self.kps_score_lowres = nn.ConvTranspose2d... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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... | BoChenYS/ROPE | KeypointRCNNPredictor | false | 17,021 | [
"BSD-3-Clause"
] | 6 | 3e50f134259b555cf547e4a3ef8b14cf5cda4e00 | https://github.com/BoChenYS/ROPE/tree/3e50f134259b555cf547e4a3ef8b14cf5cda4e00 |
GatedConnection | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim
class GatedConnection(nn.Module):
def __init__(self, d_model):
super().__init__()
self.w = nn.Linear(d_model * 2, d_model, True)
def forward(self, t1, t2):
g = F.sigmoid(self.w(torch.cat([t1, t2], -... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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.optim
assert_size_stride = torch._C._dynamo.g... | Blickwinkel1107/NJUNMT-pytorch | GatedConnection | false | 17,022 | [
"MIT"
] | 9 | 82f684fe768b137ca0649b7b79a1820077917385 | https://github.com/Blickwinkel1107/NJUNMT-pytorch/tree/82f684fe768b137ca0649b7b79a1820077917385 |
Pow | import torch
import torch.nn as nn
class Pow(nn.Module):
"""
Applies `x ** sigmoid(a)`, with `a` fixed or trainable.
"""
def __init__(self, a=0, trainable=False):
super(Pow, self).__init__()
if trainable:
a = nn.Parameter(torch.tensor(a, dtype=torch.get_default_dtype()))
... | 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_... | CPJKU/kagglebirds2020 | Pow | false | 17,023 | [
"MIT"
] | 4 | f86b459389b1d0b0af96ebc9252ffc8496c272e8 | https://github.com/CPJKU/kagglebirds2020/tree/f86b459389b1d0b0af96ebc9252ffc8496c272e8 |
TripletGCN | from torch.nn import Module
import math
import torch
from torch.nn.modules import Module
import torch.nn.functional as F
from torch.nn.parameter import Parameter
class GraphConvolution(Module):
"""
Simple GCN layer, similar to https://arxiv.org/abs/1609.02907
Z = f(X, A) = softmax(A` * ReLU(A` * X * W0)* ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | Brain03Yao/M2TGCN | TripletGCN | false | 17,024 | [
"MIT"
] | 6 | 72c65687fa52c618740cd6d1db7366116f68398c | https://github.com/Brain03Yao/M2TGCN/tree/72c65687fa52c618740cd6d1db7366116f68398c |
FCDiscriminator | import torch
from torch import nn
import torch.utils.data
import torch.distributed
import torch.backends.cudnn
import torch.utils
import torch.backends
class FCDiscriminator(nn.Module):
def __init__(self, num_classes, ndf=64):
super(FCDiscriminator, self).__init__()
self.conv1 = nn.Conv2d(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 import nn
import torch.utils.data
import torch.distributed
import tor... | BinhuiXie/SPCL | FCDiscriminator | false | 17,025 | [
"MIT"
] | 6 | 9e5bab7b5d38fde847f9e8f85ca64498baaf86be | https://github.com/BinhuiXie/SPCL/tree/9e5bab7b5d38fde847f9e8f85ca64498baaf86be |
GlobalAttention | import torch
import torch.nn as nn
def aeq(*args):
base = args[0]
for a in args[1:]:
assert a == base, str(args)
class Bottle(nn.Module):
def forward(self, input):
if len(input.size()) <= 2:
return super(Bottle, self).forward(input)
size = input.size()[:2]
ou... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | BurakaKrishna/Question-Generation | GlobalAttention | false | 17,026 | [
"MIT"
] | 4 | 4614bf07243ab1b3df337fc1cb22175947c71a14 | https://github.com/BurakaKrishna/Question-Generation/tree/4614bf07243ab1b3df337fc1cb22175947c71a14 |
TripletLogExpLoss | import torch
import numpy as np
from torch import nn
import torch.nn.functional as F
class TripletLogExpLoss(nn.Module):
"""Creates a criterion that measures the triplet loss given an input
tensors x1, x2, x3.
This is used for measuring a relative similarity between samples. A triplet
is composed by `... | 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
from torch import nn
assert_size_stride = t... | ByungHeeCha/visual_localization | TripletLogExpLoss | false | 17,027 | [
"BSD-3-Clause"
] | 3 | 787fb8f6ee5c6e69ece9e83a016d15596e5524bc | https://github.com/ByungHeeCha/visual_localization/tree/787fb8f6ee5c6e69ece9e83a016d15596e5524bc |
GeneralizedMeanPooling | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.autograd
class GeneralizedMeanPooling(nn.Module):
"""Applies a 2D power-average adaptive pooling over an input signal composed of several input planes.
The function computed is: :math:`f(X) = pow(sum(pow(X, p)), 1/p)`
- At... | 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
import... | CASIA-IVA-Lab/PASS_reID | GeneralizedMeanPooling | false | 17,028 | [
"Apache-2.0"
] | 5 | 46dc6d25f4396e35ac1a766ad2dcaa580beccf15 | https://github.com/CASIA-IVA-Lab/PASS_reID/tree/46dc6d25f4396e35ac1a766ad2dcaa580beccf15 |
PositionwiseFeedForward | import torch
import torch.nn as nn
import torch.nn.functional as F
class PositionwiseFeedForward(nn.Module):
""" A two-feed-forward-layer module """
def __init__(self, d_in, d_hid, dropout=0.1):
super().__init__()
self.w_1 = nn.Conv1d(d_in, d_hid, 1)
self.w_2 = nn.Conv1d(d_hid, d_in, ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | CSLT-THU/Vivi_3.0 | PositionwiseFeedForward | false | 17,029 | [
"Apache-2.0"
] | 3 | 86996d99d662cd33100755501a971c41ce30ca70 | https://github.com/CSLT-THU/Vivi_3.0/tree/86996d99d662cd33100755501a971c41ce30ca70 |
SpatialLogMeanExp | import torch
import numpy as np
import torch.nn as nn
def _lme(x, alpha, dim=-1, keepdim=False):
"""
Apply log-mean-exp pooling with sharpness `alpha` across dimension `dim`.
"""
if x.shape[dim] <= 1:
return x if keepdim else x.squeeze(dim)
if not torch.is_tensor(alpha) and alpha == 0:
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import numpy as np
imp... | CPJKU/kagglebirds2020 | SpatialLogMeanExp | false | 17,030 | [
"MIT"
] | 4 | f86b459389b1d0b0af96ebc9252ffc8496c272e8 | https://github.com/CPJKU/kagglebirds2020/tree/f86b459389b1d0b0af96ebc9252ffc8496c272e8 |
WeightNormTransConv2d | import torch
import torch.nn as nn
from torch.nn.utils.weight_norm import weight_norm
import torch.onnx
class WeightNormTransConv2d(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride=1,
padding=0, output_padding=0, dilation=1, groups=1, bias=True,
padding_mode='zeros'):... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 ... | AntixK/Neural-Blocks | WeightNormTransConv2d | false | 17,031 | [
"MIT"
] | 3 | 018a44bbb703fc848234b95a3e604576bd9df88f | https://github.com/AntixK/Neural-Blocks/tree/018a44bbb703fc848234b95a3e604576bd9df88f |
IndRNNCell | from torch.nn import Module
import math
import torch
import torch.nn.functional as F
from torch.nn import Parameter
def clip_grad(v, min, max):
v_tmp = v.expand_as(v)
v_tmp.register_hook(lambda g: g.clamp(min, max))
return v_tmp
class RNNCellBase(Module):
def __repr__(self):
s = '{name}({in... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch.nn import Module
i... | CSLT-THU/Vivi_3.0 | IndRNNCell | false | 17,032 | [
"Apache-2.0"
] | 3 | 86996d99d662cd33100755501a971c41ce30ca70 | https://github.com/CSLT-THU/Vivi_3.0/tree/86996d99d662cd33100755501a971c41ce30ca70 |
GeneralizedMeanPoolingFpn | import torch
import torch.nn as nn
from abc import ABC
import torch.autograd
class GeneralizedMeanPoolingFpn(nn.Module, ABC):
"""Applies a 2D power-average adaptive pooling over an input signal composed of
several input planes.
The function computed is: :math:`f(X) = pow(sum(pow(X, p)), 1/p)`
- At... | 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
from a... | CASIA-IVA-Lab/PASS_reID | GeneralizedMeanPoolingFpn | false | 17,033 | [
"Apache-2.0"
] | 5 | 46dc6d25f4396e35ac1a766ad2dcaa580beccf15 | https://github.com/CASIA-IVA-Lab/PASS_reID/tree/46dc6d25f4396e35ac1a766ad2dcaa580beccf15 |
Log1p | import torch
import torch.nn as nn
class Log1p(nn.Module):
"""
Applies `log(1 + 10**a * x)`, with `a` fixed or trainable.
"""
def __init__(self, a=0, trainable=False):
super(Log1p, self).__init__()
if trainable:
a = nn.Parameter(torch.tensor(a, dtype=torch.get_default_dtyp... | 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_... | CPJKU/kagglebirds2020 | Log1p | false | 17,034 | [
"MIT"
] | 4 | f86b459389b1d0b0af96ebc9252ffc8496c272e8 | https://github.com/CPJKU/kagglebirds2020/tree/f86b459389b1d0b0af96ebc9252ffc8496c272e8 |
PositionwiseFeedForward | import torch
import torch.nn as nn
import torch.optim
class PositionwiseFeedForward(nn.Module):
""" A two-layer Feed-Forward-Network with residual layer norm.
Args:
size (int): the size of input for the first-layer of the FFN.
hidden_size (int): the hidden layer size of the second... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | Blickwinkel1107/NJUNMT-pytorch | PositionwiseFeedForward | false | 17,035 | [
"MIT"
] | 9 | 82f684fe768b137ca0649b7b79a1820077917385 | https://github.com/Blickwinkel1107/NJUNMT-pytorch/tree/82f684fe768b137ca0649b7b79a1820077917385 |
RED_CNN | import torch
import torch.nn as nn
class RED_CNN(nn.Module):
def __init__(self, out_ch=96):
super(RED_CNN, self).__init__()
self.conv1 = nn.Conv2d(1, out_ch, kernel_size=5, stride=1, padding=0)
self.conv2 = nn.Conv2d(out_ch, out_ch, kernel_size=5, stride=1,
padding=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._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | BennyZhang-Codes/LDCT-denoising-with-DL-Methods-and-Dicom-Viewer-by-Benny | RED_CNN | false | 17,036 | [
"MIT"
] | 7 | 07e3dc1e3c6dcdea314b2a9e3cf9ac1036cf5eb6 | https://github.com/BennyZhang-Codes/LDCT-denoising-with-DL-Methods-and-Dicom-Viewer-by-Benny/tree/07e3dc1e3c6dcdea314b2a9e3cf9ac1036cf5eb6 |
Classifier_MLP | import torch
import torch.nn as nn
import torch.nn.functional as F
class Classifier_MLP(nn.Module):
def __init__(self, in_dim, hidden_dim, out_dim):
super(Classifier_MLP, self).__init__()
self.h1 = nn.Linear(in_dim, hidden_dim)
self.h2 = nn.Linear(hidden_dim, hidden_dim)
self.out ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | CORE-Robotics-Lab/Personalized_Neural_Trees | Classifier_MLP | false | 17,037 | [
"MIT"
] | 3 | 3e8dd12fe4fc850be65c96c847eb143ef3bcdc2e | https://github.com/CORE-Robotics-Lab/Personalized_Neural_Trees/tree/3e8dd12fe4fc850be65c96c847eb143ef3bcdc2e |
MultiHeadAttn | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim
class MultiHeadAttn(nn.Module):
def __init__(self, n_head, d_model, d_head, dropout, dropatt=0,
pre_lnorm=False):
super(MultiHeadAttn, self).__init__()
self.n_head = n_head
self.d_model = d_model... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | Blickwinkel1107/NJUNMT-pytorch | MultiHeadAttn | false | 17,038 | [
"MIT"
] | 9 | 82f684fe768b137ca0649b7b79a1820077917385 | https://github.com/Blickwinkel1107/NJUNMT-pytorch/tree/82f684fe768b137ca0649b7b79a1820077917385 |
MGRUCell | from torch.nn import Module
import math
import torch
import torch.nn.functional as F
from torch.nn import Parameter
def clip_grad(v, min, max):
v_tmp = v.expand_as(v)
v_tmp.register_hook(lambda g: g.clamp(min, max))
return v_tmp
class RNNCellBase(Module):
def __repr__(self):
s = '{name}({in... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch.nn import Module
i... | CSLT-THU/Vivi_3.0 | MGRUCell | false | 17,039 | [
"Apache-2.0"
] | 3 | 86996d99d662cd33100755501a971c41ce30ca70 | https://github.com/CSLT-THU/Vivi_3.0/tree/86996d99d662cd33100755501a971c41ce30ca70 |
APLoss_dist | import torch
import numpy as np
from torch import nn
def sim_to_dist(scores):
return 1 - torch.sqrt(2.001 - 2 * scores)
class APLoss(nn.Module):
""" Differentiable AP loss, through quantization. From the paper:
Learning with Average Precision: Training Image Retrieval with a Listwise Loss
J... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | ByungHeeCha/visual_localization | APLoss_dist | false | 17,040 | [
"BSD-3-Clause"
] | 3 | 787fb8f6ee5c6e69ece9e83a016d15596e5524bc | https://github.com/ByungHeeCha/visual_localization/tree/787fb8f6ee5c6e69ece9e83a016d15596e5524bc |
GeneralizedMeanPoolingList | import torch
import torch.nn as nn
from abc import ABC
import torch.autograd
class GeneralizedMeanPoolingList(nn.Module, ABC):
"""Applies a 2D power-average adaptive pooling over an input signal composed of
several input planes.
The function computed is: :math:`f(X) = pow(sum(pow(X, p)), 1/p)`
- A... | 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
from abc import ABC
import torch.autograd
assert_size_stride = torc... | CASIA-IVA-Lab/PASS_reID | GeneralizedMeanPoolingList | false | 17,041 | [
"Apache-2.0"
] | 5 | 46dc6d25f4396e35ac1a766ad2dcaa580beccf15 | https://github.com/CASIA-IVA-Lab/PASS_reID/tree/46dc6d25f4396e35ac1a766ad2dcaa580beccf15 |
RNNCell | from torch.nn import Module
import math
import torch
import torch.nn.functional as F
from torch.nn import Parameter
def clip_grad(v, min, max):
v_tmp = v.expand_as(v)
v_tmp.register_hook(lambda g: g.clamp(min, max))
return v_tmp
class RNNCellBase(Module):
def __repr__(self):
s = '{name}({in... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch.nn import Module
i... | CSLT-THU/Vivi_3.0 | RNNCell | false | 17,042 | [
"Apache-2.0"
] | 3 | 86996d99d662cd33100755501a971c41ce30ca70 | https://github.com/CSLT-THU/Vivi_3.0/tree/86996d99d662cd33100755501a971c41ce30ca70 |
Shift | import torch
import torch.nn as nn
class Shift(nn.Module):
def __init__(self, amount, inplace=False):
super(Shift, self).__init__()
self.amount = amount
self.inplace = inplace
def extra_repr(self):
return 'amount={}'.format(self.amount)
def forward(self, x):
if s... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | CPJKU/kagglebirds2020 | Shift | false | 17,043 | [
"MIT"
] | 4 | f86b459389b1d0b0af96ebc9252ffc8496c272e8 | https://github.com/CPJKU/kagglebirds2020/tree/f86b459389b1d0b0af96ebc9252ffc8496c272e8 |
SpatialMeanPool | import torch
import torch.nn as nn
class SpatialMeanPool(nn.Module):
"""
Performs mean pooling over spatial dimensions; keeps only the first `ndim`
dimensions of the input.
"""
def __init__(self, ndim=2):
super(SpatialMeanPool, self).__init__()
self.ndim = ndim
def forward(se... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | CPJKU/kagglebirds2020 | SpatialMeanPool | false | 17,044 | [
"MIT"
] | 4 | f86b459389b1d0b0af96ebc9252ffc8496c272e8 | https://github.com/CPJKU/kagglebirds2020/tree/f86b459389b1d0b0af96ebc9252ffc8496c272e8 |
SubtractMedian | import torch
import torch.nn as nn
class SubtractMedian(nn.Module):
"""
Subtracts the median over the last axis.
"""
def forward(self, x):
return x - x.median(-1, keepdim=True).values
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... | CPJKU/kagglebirds2020 | SubtractMedian | false | 17,045 | [
"MIT"
] | 4 | f86b459389b1d0b0af96ebc9252ffc8496c272e8 | https://github.com/CPJKU/kagglebirds2020/tree/f86b459389b1d0b0af96ebc9252ffc8496c272e8 |
SpatialMaxPool | import torch
import torch.nn as nn
class SpatialMaxPool(nn.Module):
"""
Performs max pooling over spatial dimensions; keeps only the first `ndim`
dimensions of the input.
"""
def __init__(self, ndim=2):
super(SpatialMaxPool, self).__init__()
self.ndim = ndim
def forward(self,... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
emp... | CPJKU/kagglebirds2020 | SpatialMaxPool | false | 17,046 | [
"MIT"
] | 4 | f86b459389b1d0b0af96ebc9252ffc8496c272e8 | https://github.com/CPJKU/kagglebirds2020/tree/f86b459389b1d0b0af96ebc9252ffc8496c272e8 |
NNSmall | import torch
import torch.nn as nn
class NNSmall(nn.Module):
"""
Sammut et. al. benchmark
"""
def __init__(self, state_dim, output_dim):
super(NNSmall, self).__init__()
self.fc1 = nn.Linear(state_dim, 128)
self.relu1 = nn.ReLU()
self.fc2 = nn.Linear(128, 128)
s... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | CORE-Robotics-Lab/Personalized_Neural_Trees | NNSmall | false | 17,047 | [
"MIT"
] | 3 | 3e8dd12fe4fc850be65c96c847eb143ef3bcdc2e | https://github.com/CORE-Robotics-Lab/Personalized_Neural_Trees/tree/3e8dd12fe4fc850be65c96c847eb143ef3bcdc2e |
SimMinLoss | import torch
class SimMinLoss(torch.nn.Module):
def __init__(self, margin=0):
super(SimMinLoss, self).__init__()
self.margin = margin
def forward(self, x, weights):
return -(torch.log(1 - x + self.margin) * weights).mean()
def get_inputs():
return [torch.rand([4, 4, 4, 4]), tor... | 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... | CVI-SZU/CLIMS | SimMinLoss | false | 17,048 | [
"MIT"
] | 4 | 9d3d0123b625b2c6941069e8fb359019a5cabd59 | https://github.com/CVI-SZU/CLIMS/tree/9d3d0123b625b2c6941069e8fb359019a5cabd59 |
SimMaxLoss | import torch
class SimMaxLoss(torch.nn.Module):
def __init__(self, margin=0):
super(SimMaxLoss, self).__init__()
self.margin = margin
def forward(self, x, weights):
return -(torch.log(x + self.margin) * weights).mean()
def get_inputs():
return [torch.rand([4, 4, 4, 4]), torch.r... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
assert_size_stride = t... | CVI-SZU/CLIMS | SimMaxLoss | false | 17,049 | [
"MIT"
] | 4 | 9d3d0123b625b2c6941069e8fb359019a5cabd59 | https://github.com/CVI-SZU/CLIMS/tree/9d3d0123b625b2c6941069e8fb359019a5cabd59 |
GRUCell | from torch.nn import Module
import math
import torch
import torch.nn.functional as F
from torch.nn import Parameter
def clip_grad(v, min, max):
v_tmp = v.expand_as(v)
v_tmp.register_hook(lambda g: g.clamp(min, max))
return v_tmp
class RNNCellBase(Module):
def __repr__(self):
s = '{name}({in... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch.nn import Module
i... | CSLT-THU/Vivi_3.0 | GRUCell | false | 17,050 | [
"Apache-2.0"
] | 3 | 86996d99d662cd33100755501a971c41ce30ca70 | https://github.com/CSLT-THU/Vivi_3.0/tree/86996d99d662cd33100755501a971c41ce30ca70 |
GradientReversalLayer | import torch
import torch.nn as nn
class GradientReversalFunction(torch.autograd.Function):
"""
From:
https://github.com/jvanvugt/pytorch-domain-adaptation/blob/cb65581f20b71ff9883dd2435b2275a1fd4b90df/utils.py#L26
Gradient Reversal Layer from:
Unsupervised Domain Adaptation by Backpropagation (G... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | CZSLwithCVAE/CZSL_CVAE | GradientReversalLayer | false | 17,051 | [
"MIT"
] | 5 | b77d40f7efde96d2512ac15ebe592ef56b13f2e3 | https://github.com/CZSLwithCVAE/CZSL_CVAE/tree/b77d40f7efde96d2512ac15ebe592ef56b13f2e3 |
EncoderBlock | import math
import torch
import torch.nn as nn
import torch.optim
class MultiHeadedAttention(nn.Module):
def __init__(self, model_dim, head_count, dim_per_head=None, dropout=0.1):
super(MultiHeadedAttention, self).__init__()
if dim_per_head is None:
assert model_dim % head_count == 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._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | Blickwinkel1107/NJUNMT-pytorch | EncoderBlock | false | 17,052 | [
"MIT"
] | 9 | 82f684fe768b137ca0649b7b79a1820077917385 | https://github.com/Blickwinkel1107/NJUNMT-pytorch/tree/82f684fe768b137ca0649b7b79a1820077917385 |
Block | import torch
import torch.nn as nn
import torch.autograd
def drop_path(x, drop_prob: 'float'=0.0, training: 'bool'=False):
"""Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks).
This is the same as the DropConnect impl I created for EfficientNet, etc networks, however,
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | CASIA-IVA-Lab/PASS_reID | Block | false | 17,053 | [
"Apache-2.0"
] | 5 | 46dc6d25f4396e35ac1a766ad2dcaa580beccf15 | https://github.com/CASIA-IVA-Lab/PASS_reID/tree/46dc6d25f4396e35ac1a766ad2dcaa580beccf15 |
ExampleBackbone | import torch
import torch.nn as nn
import torch._C
import torch.serialization
class ExampleBackbone(nn.Module):
def __init__(self):
super(ExampleBackbone, self).__init__()
self.conv = nn.Conv2d(3, 3, 3)
def init_weights(self, pretrained=None):
pass
def forward(self, x):
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
import torch._C
import torch.serialization
assert_size_str... | CVIU-CSU/M2MRF-Lesion-Segmentation | ExampleBackbone | false | 17,054 | [
"Apache-2.0"
] | 10 | 13af87927f4cdeca70e35d570edd1aec43b387b6 | https://github.com/CVIU-CSU/M2MRF-Lesion-Segmentation/tree/13af87927f4cdeca70e35d570edd1aec43b387b6 |
RelPartialLearnableMultiHeadAttn | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim
class RelMultiHeadAttn(nn.Module):
def __init__(self, n_head, d_model, d_head, dropout, dropatt=0, tgt_len
=None, ext_len=None, mem_len=None, pre_lnorm=False):
super(RelMultiHeadAttn, self).__init__()
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.... | Blickwinkel1107/NJUNMT-pytorch | RelPartialLearnableMultiHeadAttn | false | 17,055 | [
"MIT"
] | 9 | 82f684fe768b137ca0649b7b79a1820077917385 | https://github.com/Blickwinkel1107/NJUNMT-pytorch/tree/82f684fe768b137ca0649b7b79a1820077917385 |
SpatialGatherModule | import torch
import torch.nn.functional as F
import torch.nn as nn
import torch._C
import torch.serialization
class SpatialGatherModule(nn.Module):
"""Aggregate the context features according to the initial predicted
probability distribution.
Employ the soft-weighted method to aggregate the context.
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | CVIU-CSU/M2MRF-Lesion-Segmentation | SpatialGatherModule | false | 17,056 | [
"Apache-2.0"
] | 10 | 13af87927f4cdeca70e35d570edd1aec43b387b6 | https://github.com/CVIU-CSU/M2MRF-Lesion-Segmentation/tree/13af87927f4cdeca70e35d570edd1aec43b387b6 |
Downscale2d | import torch
from torch import nn
class Downscale2d(nn.Module):
def __init__(self, factor=2):
super().__init__()
self.downsample = nn.AvgPool2d(kernel_size=factor, stride=factor)
def forward(self, x):
return self.downsample(x)
def get_inputs():
return [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 import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_str... | BillyXYB/TransEditor | Downscale2d | false | 17,057 | [
"MIT"
] | 4 | 0194cd6f0e96c801d55c0cb9683e1f552bcf6d48 | https://github.com/BillyXYB/TransEditor/tree/0194cd6f0e96c801d55c0cb9683e1f552bcf6d48 |
InputInjection | import torch
import torch.nn as nn
import torch._C
import torch.serialization
class InputInjection(nn.Module):
"""Downsampling module for CGNet."""
def __init__(self, num_downsampling):
super(InputInjection, self).__init__()
self.pool = nn.ModuleList()
for i in range(num_downsampling)... | 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._C
import torch.serialization
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strid... | CVIU-CSU/M2MRF-Lesion-Segmentation | InputInjection | false | 17,058 | [
"Apache-2.0"
] | 10 | 13af87927f4cdeca70e35d570edd1aec43b387b6 | https://github.com/CVIU-CSU/M2MRF-Lesion-Segmentation/tree/13af87927f4cdeca70e35d570edd1aec43b387b6 |
Flatten | import torch
from torch import nn
class Flatten(nn.Module):
def __init__(self):
super(Flatten, self).__init__()
def forward(self, x):
"""
Arguments:
x: a float tensor with shape [batch_size, c, h, w].
Returns:
a float tensor with shape [batch_size, c*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 import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_str... | BillyXYB/TransEditor | Flatten | false | 17,059 | [
"MIT"
] | 4 | 0194cd6f0e96c801d55c0cb9683e1f552bcf6d48 | https://github.com/BillyXYB/TransEditor/tree/0194cd6f0e96c801d55c0cb9683e1f552bcf6d48 |
DiffLoss | import torch
class DiffLoss(torch.nn.Module):
def __init__(self):
super(DiffLoss, self).__init__()
def forward(self, D1, D2):
D1 = D1.view(D1.size(0), -1)
D1_norm = torch.norm(D1, p=2, dim=1, keepdim=True).detach()
D1_norm = D1.div(D1_norm.expand_as(D1) + 1e-06)
D2 = ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
assert_size_stride ... | CZSLwithCVAE/CZSL_CVAE | DiffLoss | false | 17,060 | [
"MIT"
] | 5 | b77d40f7efde96d2512ac15ebe592ef56b13f2e3 | https://github.com/CZSLwithCVAE/CZSL_CVAE/tree/b77d40f7efde96d2512ac15ebe592ef56b13f2e3 |
EqualConv2d | import math
import torch
from torch.nn import functional as F
from torch import nn
class EqualConv2d(nn.Module):
def __init__(self, in_channel, out_channel, kernel_size, stride=1,
padding=0, bias=True):
super().__init__()
self.weight = nn.Parameter(torch.randn(out_channel, in_channel,
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import math
from torch import nn
assert_size_stride = torch._C._dynamo.guards.as... | BillyXYB/TransEditor | EqualConv2d | false | 17,061 | [
"MIT"
] | 4 | 0194cd6f0e96c801d55c0cb9683e1f552bcf6d48 | https://github.com/BillyXYB/TransEditor/tree/0194cd6f0e96c801d55c0cb9683e1f552bcf6d48 |
NoiseInjection | import torch
from torch import nn
class NoiseInjection(nn.Module):
def __init__(self):
super().__init__()
self.weight = nn.Parameter(torch.zeros(1))
def forward(self, image, noise=None):
if noise is None:
batch, _, height, width = image.shape
noise = image.new... | 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... | BillyXYB/TransEditor | NoiseInjection | false | 17,062 | [
"MIT"
] | 4 | 0194cd6f0e96c801d55c0cb9683e1f552bcf6d48 | https://github.com/BillyXYB/TransEditor/tree/0194cd6f0e96c801d55c0cb9683e1f552bcf6d48 |
CrossEntropyLoss | import torch
import torch.nn.functional as F
import torch.nn as nn
import torch._C
import torch.serialization
def reduce_loss(loss, reduction):
"""Reduce loss as specified.
Args:
loss (Tensor): Elementwise loss tensor.
reduction (str): Options are "none", "mean" and "sum".
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 math as tl_math
import torch.nn.functi... | CVIU-CSU/M2MRF-Lesion-Segmentation | CrossEntropyLoss | false | 17,063 | [
"Apache-2.0"
] | 10 | 13af87927f4cdeca70e35d570edd1aec43b387b6 | https://github.com/CVIU-CSU/M2MRF-Lesion-Segmentation/tree/13af87927f4cdeca70e35d570edd1aec43b387b6 |
PixelNorm | import torch
from torch import nn
class PixelNorm(nn.Module):
def __init__(self, pixel_norm_op_dim):
super().__init__()
self.pixel_norm_op_dim = pixel_norm_op_dim
def forward(self, input):
return input * torch.rsqrt(torch.mean(input ** 2, dim=self.
pixel_norm_op_dim, keep... | 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... | BillyXYB/TransEditor | PixelNorm | false | 17,064 | [
"MIT"
] | 4 | 0194cd6f0e96c801d55c0cb9683e1f552bcf6d48 | https://github.com/BillyXYB/TransEditor/tree/0194cd6f0e96c801d55c0cb9683e1f552bcf6d48 |
PPMConcat | import torch
import torch.nn as nn
import torch._C
import torch.serialization
class PPMConcat(nn.ModuleList):
"""Pyramid Pooling Module that only concat the features of each layer.
Args:
pool_scales (tuple[int]): Pooling scales used in Pooling Pyramid
Module.
"""
def __init__(sel... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
import torch._C
import torch.serialization
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strid... | CVIU-CSU/M2MRF-Lesion-Segmentation | PPMConcat | false | 17,065 | [
"Apache-2.0"
] | 10 | 13af87927f4cdeca70e35d570edd1aec43b387b6 | https://github.com/CVIU-CSU/M2MRF-Lesion-Segmentation/tree/13af87927f4cdeca70e35d570edd1aec43b387b6 |
Encoding | import torch
import torch.nn.functional as F
import torch.nn as nn
import torch._C
import torch.serialization
class Encoding(nn.Module):
"""Encoding Layer: a learnable residual encoder.
Input is of shape (batch_size, channels, height, width).
Output is of shape (batch_size, num_codes, channels).
Ar... | 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
... | CVIU-CSU/M2MRF-Lesion-Segmentation | Encoding | false | 17,066 | [
"Apache-2.0"
] | 10 | 13af87927f4cdeca70e35d570edd1aec43b387b6 | https://github.com/CVIU-CSU/M2MRF-Lesion-Segmentation/tree/13af87927f4cdeca70e35d570edd1aec43b387b6 |
ScaledLeakyReLU | import math
import torch
from torch.nn import functional as F
from torch import nn
class ScaledLeakyReLU(nn.Module):
def __init__(self, negative_slope=0.2):
super().__init__()
self.negative_slope = negative_slope
def forward(self, input):
out = F.leaky_relu(input, negative_slope=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 import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_str... | BillyXYB/TransEditor | ScaledLeakyReLU | false | 17,067 | [
"MIT"
] | 4 | 0194cd6f0e96c801d55c0cb9683e1f552bcf6d48 | https://github.com/BillyXYB/TransEditor/tree/0194cd6f0e96c801d55c0cb9683e1f552bcf6d48 |
EqualLinear | from torch.autograd import Function
import math
import torch
from torch.nn import functional as F
from torch import nn
def fused_leaky_relu(input, bias, negative_slope=0.2, scale=2 ** 0.5):
return FusedLeakyReLUFunction.apply(input, bias, negative_slope, scale)
class FusedLeakyReLUFunctionBackward(Function):
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import 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
from torch import nn
assert_size... | BillyXYB/TransEditor | EqualLinear | false | 17,068 | [
"MIT"
] | 4 | 0194cd6f0e96c801d55c0cb9683e1f552bcf6d48 | https://github.com/BillyXYB/TransEditor/tree/0194cd6f0e96c801d55c0cb9683e1f552bcf6d48 |
MinibatchStdLayer | import torch
from torch import nn
class MinibatchStdLayer(nn.Module):
def __init__(self, group_size=4):
super().__init__()
self.group_size = group_size
def forward(self, x):
group_size = min(self.group_size, x.shape[0])
s = x.shape
y = x.view([group_size, -1, s[1], 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
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | BillyXYB/TransEditor | MinibatchStdLayer | false | 17,069 | [
"MIT"
] | 4 | 0194cd6f0e96c801d55c0cb9683e1f552bcf6d48 | https://github.com/BillyXYB/TransEditor/tree/0194cd6f0e96c801d55c0cb9683e1f552bcf6d48 |
h_swish | import torch
import torch.nn as nn
class h_sigmoid(nn.Module):
def __init__(self, inplace=True):
super(h_sigmoid, self).__init__()
self.relu = nn.ReLU6(inplace=inplace)
def forward(self, x):
return self.relu(x + 3) / 6
class h_swish(nn.Module):
def __init__(self, inplace=True)... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
emp... | CYHYCY/voice-classification | h_swish | false | 17,071 | [
"Apache-2.0"
] | 8 | a6f62e2f1c39b08323da3632411f4ba6b04d5f37 | https://github.com/CYHYCY/voice-classification/tree/a6f62e2f1c39b08323da3632411f4ba6b04d5f37 |
PAConv | import torch
import torch.nn as nn
class PAConv(nn.Module):
def __init__(self, nf, k_size=3):
super(PAConv, self).__init__()
self.k2 = nn.Conv2d(nf, nf, 1)
self.sigmoid = nn.Sigmoid()
self.k3 = nn.Conv2d(nf, nf, kernel_size=k_size, padding=(k_size - 1
) // 2, bias=Fals... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | Cai631/MBMFN | PAConv | false | 17,072 | [
"Apache-2.0"
] | 6 | 9a48744d7de87a6a7ec08ad87b2d0bd727e1d23c | https://github.com/Cai631/MBMFN/tree/9a48744d7de87a6a7ec08ad87b2d0bd727e1d23c |
PA | import torch
import torch.nn as nn
class PA(nn.Module):
"""PA is pixel attention"""
def __init__(self, nf):
super(PA, self).__init__()
self.conv = nn.Conv2d(nf, nf, 1)
self.sigmoid = nn.Sigmoid()
def forward(self, x):
y = self.conv(x)
y = self.sigmoid(y)
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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | Cai631/MBMFN | PA | false | 17,073 | [
"Apache-2.0"
] | 6 | 9a48744d7de87a6a7ec08ad87b2d0bd727e1d23c | https://github.com/Cai631/MBMFN/tree/9a48744d7de87a6a7ec08ad87b2d0bd727e1d23c |
h_sigmoid | import torch
import torch.nn as nn
class h_sigmoid(nn.Module):
def __init__(self, inplace=True):
super(h_sigmoid, self).__init__()
self.relu = nn.ReLU6(inplace=inplace)
def forward(self, x):
return self.relu(x + 3) / 6
def get_inputs():
return [torch.rand([4, 4, 4, 4])]
def g... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
emp... | CYHYCY/voice-classification | h_sigmoid | false | 17,074 | [
"Apache-2.0"
] | 8 | a6f62e2f1c39b08323da3632411f4ba6b04d5f37 | https://github.com/CYHYCY/voice-classification/tree/a6f62e2f1c39b08323da3632411f4ba6b04d5f37 |
Self_Attn | import torch
from torch import nn
class Self_Attn(nn.Module):
""" Self attention Layer"""
def __init__(self, in_dim, activation):
super(Self_Attn, self).__init__()
self.chanel_in = in_dim
self.activation = activation
if in_dim >= 8:
self.query_conv = nn.Conv2d(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 import triton_helpers
from torch._inductor.runtime.... | CVPR2020/EnAET | Self_Attn | false | 17,075 | [
"MIT"
] | 3 | f490777980d20c68ca63764b7fc25537d7e72660 | https://github.com/CVPR2020/EnAET/tree/f490777980d20c68ca63764b7fc25537d7e72660 |
Scaled_Dot_Product_Attention | import torch
import torch.nn as nn
import torch.nn.functional as F
class Scaled_Dot_Product_Attention(nn.Module):
"""Scaled Dot-Product Attention """
def __init__(self):
super(Scaled_Dot_Product_Attention, self).__init__()
def forward(self, Q, K, V, scale=None):
"""
Args:
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | Ch4ndelier/Transformer_Zero_Velocity_classification | Scaled_Dot_Product_Attention | false | 17,076 | [
"MIT"
] | 6 | 857efb66189c503e983c11bd7dde16ad19c51ada | https://github.com/Ch4ndelier/Transformer_Zero_Velocity_classification/tree/857efb66189c503e983c11bd7dde16ad19c51ada |
HardSigmoid | import torch
import torch.nn as nn
class HardSigmoid(nn.Module):
def __init__(self):
super(HardSigmoid, self).__init__()
self.act = nn.Hardtanh()
def forward(self, x):
return (self.act(x) + 1.0) / 2.0
def get_inputs():
return [torch.rand([4, 4, 4, 4])]
def get_init_inputs():
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
emp... | Chandrima-04/gimmebio | HardSigmoid | false | 17,077 | [
"MIT"
] | 3 | cb3e66380006d5c5c00ff70bfb87317dd252c312 | https://github.com/Chandrima-04/gimmebio/tree/cb3e66380006d5c5c00ff70bfb87317dd252c312 |
Normalize3D | import torch
import torch.nn as nn
class Normalize3D(nn.Module):
"""
Scale Spectrogram to be between 0 and 1
"""
def __init__(self):
super(Normalize3D, self).__init__()
def forward(self, X: 'torch.Tensor'):
if len(X.shape) != 3:
raise ValueError(
'Inp... | 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... | CiscoDevNet/vo-id | Normalize3D | false | 17,079 | [
"MIT"
] | 7 | 9a01f866c7539a9cd095d9627ba4f65ad540ea6b | https://github.com/CiscoDevNet/vo-id/tree/9a01f866c7539a9cd095d9627ba4f65ad540ea6b |
SplAtConv2d | from torch.nn import Module
import torch
import torch.nn.functional as F
import torch.nn as nn
from torch.nn import Conv2d
from torch.nn import ReLU
from torch.nn.modules.utils import _pair
class DropBlock2D(object):
def __init__(self, *args, **kwargs):
raise NotImplementedError
class rSoftMax(nn.Modul... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | CVI-SZU/CLIMS | SplAtConv2d | false | 17,080 | [
"MIT"
] | 4 | 9d3d0123b625b2c6941069e8fb359019a5cabd59 | https://github.com/CVI-SZU/CLIMS/tree/9d3d0123b625b2c6941069e8fb359019a5cabd59 |
DiceLoss | import torch
import torch.nn.functional as F
import torch.nn as nn
import torch._C
import torch.serialization
def binary_dice_loss(pred, label, smooth=1e-05):
"""
:param pred: [N, *]: here should be scores in [0,1]
:param label: [N, *]
:param power: 1 for abs, 2 for square
:return: [N]
"""
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn.functi... | CVIU-CSU/M2MRF-Lesion-Segmentation | DiceLoss | false | 17,081 | [
"Apache-2.0"
] | 10 | 13af87927f4cdeca70e35d570edd1aec43b387b6 | https://github.com/CVIU-CSU/M2MRF-Lesion-Segmentation/tree/13af87927f4cdeca70e35d570edd1aec43b387b6 |
GlobalAveragePooling | import torch
from torch import nn
import torch.nn.functional as F
class GlobalAveragePooling(nn.Module):
def __init__(self):
super(GlobalAveragePooling, self).__init__()
def forward(self, feat):
num_channels = feat.size(1)
return F.avg_pool2d(feat, (feat.size(2), feat.size(3))).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 import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_str... | CVPR2020/EnAET | GlobalAveragePooling | false | 17,082 | [
"MIT"
] | 3 | f490777980d20c68ca63764b7fc25537d7e72660 | https://github.com/CVPR2020/EnAET/tree/f490777980d20c68ca63764b7fc25537d7e72660 |
Rescale | import torch
import torch.nn as nn
import torch.utils.data
class Rescale(nn.Module):
"""Per-channel rescaling. Need a proper `nn.Module` so we can wrap it
with `torch.nn.utils.weight_norm`.
Args:
num_channels (int): Number of channels in the input.
"""
def __init__(self, num_channels):
super(Res... | 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.... | Catherine0505/mar-scf-flow | Rescale | false | 17,083 | [
"Apache-2.0"
] | 10 | aa7c3564cb9f2967c5e580a633516dba1b597f98 | https://github.com/Catherine0505/mar-scf-flow/tree/aa7c3564cb9f2967c5e580a633516dba1b597f98 |
ToRGB | from torch.autograd import Function
import math
import torch
from torch.nn import functional as F
from torch import nn
def make_kernel(k):
k = torch.tensor(k, dtype=torch.float32)
if k.ndim == 1:
k = k[None, :] * k[:, None]
k /= k.sum()
return k
def upfirdn2d(input, kernel, up=1, down=1, pad... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import 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
from torch.nn import functional ... | BillyXYB/TransEditor | ToRGB | false | 17,084 | [
"MIT"
] | 4 | 0194cd6f0e96c801d55c0cb9683e1f552bcf6d48 | https://github.com/BillyXYB/TransEditor/tree/0194cd6f0e96c801d55c0cb9683e1f552bcf6d48 |
BinaryLoss | import torch
import torch.nn.functional as F
import torch.nn as nn
import torch._C
import torch.serialization
def binary_cbce_loss(pred, label, **kwargs):
"""
:param pred: [N, *]: here should be scores in [0,1]
:param label: [N, *]: values in [0,1]
:return: [N]
"""
mask = (label > 0.5).float()... | 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... | CVIU-CSU/M2MRF-Lesion-Segmentation | BinaryLoss | false | 17,085 | [
"Apache-2.0"
] | 10 | 13af87927f4cdeca70e35d570edd1aec43b387b6 | https://github.com/CVIU-CSU/M2MRF-Lesion-Segmentation/tree/13af87927f4cdeca70e35d570edd1aec43b387b6 |
Conv2dZeros | import torch
import torch.nn as nn
import torch.utils.data
def cpd_mean(tensor, dim=None, keepdims=False):
if dim is None:
return tensor.mean(tensor)
else:
if isinstance(dim, int):
dim = [dim]
dim = sorted(dim)
for d in dim:
tensor = tensor.mean(dim=d, k... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | Catherine0505/mar-scf-flow | Conv2dZeros | false | 17,086 | [
"Apache-2.0"
] | 10 | aa7c3564cb9f2967c5e580a633516dba1b597f98 | https://github.com/Catherine0505/mar-scf-flow/tree/aa7c3564cb9f2967c5e580a633516dba1b597f98 |
Multi_Head_Attention | import torch
import torch.nn as nn
import torch.nn.functional as F
class Scaled_Dot_Product_Attention(nn.Module):
"""Scaled Dot-Product Attention """
def __init__(self):
super(Scaled_Dot_Product_Attention, self).__init__()
def forward(self, Q, K, V, scale=None):
"""
Args:
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
im... | Ch4ndelier/Transformer_Zero_Velocity_classification | Multi_Head_Attention | false | 17,087 | [
"MIT"
] | 6 | 857efb66189c503e983c11bd7dde16ad19c51ada | https://github.com/Ch4ndelier/Transformer_Zero_Velocity_classification/tree/857efb66189c503e983c11bd7dde16ad19c51ada |
FCNet | import torch
import torch.utils.data
import torch.nn as nn
from torch.nn.utils import weight_norm
import torch.nn.modules.module
class FCNet(nn.Module):
def __init__(self, in_size, out_size, activate=None, drop=0.0):
super(FCNet, self).__init__()
self.lin = weight_norm(nn.Linear(in_size, out_size... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.utils.... | ChCh1999/RTPB | FCNet | false | 17,088 | [
"MIT"
] | 8 | 1066a3bfe4fe1b41eff74fd152936880302a60a2 | https://github.com/ChCh1999/RTPB/tree/1066a3bfe4fe1b41eff74fd152936880302a60a2 |
ModulatedConv2d | from torch.autograd import Function
import math
import torch
from torch.nn import functional as F
from torch import nn
def make_kernel(k):
k = torch.tensor(k, dtype=torch.float32)
if k.ndim == 1:
k = k[None, :] * k[:, None]
k /= k.sum()
return k
def upfirdn2d(input, kernel, up=1, down=1, pad... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
from torch.autograd... | BillyXYB/TransEditor | ModulatedConv2d | false | 17,089 | [
"MIT"
] | 4 | 0194cd6f0e96c801d55c0cb9683e1f552bcf6d48 | https://github.com/BillyXYB/TransEditor/tree/0194cd6f0e96c801d55c0cb9683e1f552bcf6d48 |
Position_wise_Feed_Forward | import torch
import torch.nn as nn
import torch.nn.functional as F
class Position_wise_Feed_Forward(nn.Module):
def __init__(self, dim_model, hidden, dropout=0.0):
super(Position_wise_Feed_Forward, self).__init__()
self.fc1 = nn.Linear(dim_model, hidden)
self.fc2 = nn.Linear(hidden, dim_m... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | Ch4ndelier/Transformer_Zero_Velocity_classification | Position_wise_Feed_Forward | false | 17,090 | [
"MIT"
] | 6 | 857efb66189c503e983c11bd7dde16ad19c51ada | https://github.com/Ch4ndelier/Transformer_Zero_Velocity_classification/tree/857efb66189c503e983c11bd7dde16ad19c51ada |
Block | import torch
import torch.nn.functional as F
from torch import nn
class LayerNorm(nn.Module):
""" LayerNorm that supports two data formats: channels_last (default) or channels_first.
The ordering of the dimensions in the inputs. channels_last corresponds to inputs with
shape (batch_size, height, width, ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.fun... | CarnoZhao/mmdetection | Block | false | 17,091 | [
"Apache-2.0"
] | 10 | b85eaffdf1af28eaffcc2263110a059237cf5b23 | https://github.com/CarnoZhao/mmdetection/tree/b85eaffdf1af28eaffcc2263110a059237cf5b23 |
Normalize | import torch
import torch.nn as nn
class Normalize(nn.Module):
"""
Scale Audio to be between -1 and 1
"""
def __init__(self):
super(Normalize, self).__init__()
def forward(self, audio: 'torch.Tensor'):
if len(audio.shape) != 2:
raise ValueError('Audio should be 2D: [... | 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... | CiscoDevNet/vo-id | Normalize | false | 17,092 | [
"MIT"
] | 7 | 9a01f866c7539a9cd095d9627ba4f65ad540ea6b | https://github.com/CiscoDevNet/vo-id/tree/9a01f866c7539a9cd095d9627ba4f65ad540ea6b |
WNConv2d | import torch
import torch.nn as nn
import torch.utils.data
class WNConv2d(nn.Module):
"""Weight-normalized 2d convolution.
Args:
in_channels (int): Number of channels in the input.
out_channels (int): Number of channels in the output.
kernel_size (int): Side length of each convolutional kernel.
padding (... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 ... | Catherine0505/mar-scf-flow | WNConv2d | false | 17,093 | [
"Apache-2.0"
] | 10 | aa7c3564cb9f2967c5e580a633516dba1b597f98 | https://github.com/Catherine0505/mar-scf-flow/tree/aa7c3564cb9f2967c5e580a633516dba1b597f98 |
GeLU | import torch
import torch.nn as nn
class GeLU(nn.Module):
def forward(self, x):
return 0.5 * x * (1.0 + torch.tanh(x * 0.7978845608 * (1.0 +
0.044715 * x * 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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_... | Chriskuei/FedMatch | GeLU | false | 17,094 | [
"Apache-2.0"
] | 4 | 305e8c4bbb398712b00c883a986dfec17b500f76 | https://github.com/Chriskuei/FedMatch/tree/305e8c4bbb398712b00c883a986dfec17b500f76 |
ApplySingleAttention | import torch
import torch.utils.data
import torch.nn as nn
from torch.nn.utils import weight_norm
import torch.nn.modules.module
class FCNet(nn.Module):
def __init__(self, in_size, out_size, activate=None, drop=0.0):
super(FCNet, self).__init__()
self.lin = weight_norm(nn.Linear(in_size, out_size... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | ChCh1999/RTPB | ApplySingleAttention | false | 17,095 | [
"MIT"
] | 8 | 1066a3bfe4fe1b41eff74fd152936880302a60a2 | https://github.com/ChCh1999/RTPB/tree/1066a3bfe4fe1b41eff74fd152936880302a60a2 |
BothContextGate | import torch
import torch.nn as nn
import torch.cuda
import torch.distributed
class ContextGate(nn.Module):
"""
Context gate is a decoder module that takes as input the previous word
embedding, the current decoder state and the attention state, and
produces a gate.
The gate can be used to select 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
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as ... | ChenRocks/Distill-BERT-Textgen-ONMT | BothContextGate | false | 17,096 | [
"MIT"
] | 7 | d83dd1a95af7513cbfae4a2768f6effc2f3a589f | https://github.com/ChenRocks/Distill-BERT-Textgen-ONMT/tree/d83dd1a95af7513cbfae4a2768f6effc2f3a589f |
SourceContextGate | import torch
import torch.nn as nn
import torch.cuda
import torch.distributed
class ContextGate(nn.Module):
"""
Context gate is a decoder module that takes as input the previous word
embedding, the current decoder state and the attention state, and
produces a gate.
The gate can be used to select 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
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as ... | ChenRocks/Distill-BERT-Textgen-ONMT | SourceContextGate | false | 17,097 | [
"MIT"
] | 7 | d83dd1a95af7513cbfae4a2768f6effc2f3a589f | https://github.com/ChenRocks/Distill-BERT-Textgen-ONMT/tree/d83dd1a95af7513cbfae4a2768f6effc2f3a589f |
NoiseInjection | import torch
from typing import Optional
import torch.nn as nn
class NoiseInjection(nn.Module):
"""
Model injects noisy bias to input tensor
"""
def __init__(self) ->None:
"""
Constructor method
"""
super(NoiseInjection, self).__init__()
self.weight = nn.Parame... | import torch
from torch import device
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C... | ChristophReich1996/Multi-StyleGAN | NoiseInjection | false | 17,098 | [
"MIT"
] | 7 | 988f2dfea85b3205126b40c61edfb28107eb3173 | https://github.com/ChristophReich1996/Multi-StyleGAN/tree/988f2dfea85b3205126b40c61edfb28107eb3173 |
TargetContextGate | import torch
import torch.nn as nn
import torch.cuda
import torch.distributed
class ContextGate(nn.Module):
"""
Context gate is a decoder module that takes as input the previous word
embedding, the current decoder state and the attention state, and
produces a gate.
The gate can be used to select 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
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as ... | ChenRocks/Distill-BERT-Textgen-ONMT | TargetContextGate | false | 17,099 | [
"MIT"
] | 7 | d83dd1a95af7513cbfae4a2768f6effc2f3a589f | https://github.com/ChenRocks/Distill-BERT-Textgen-ONMT/tree/d83dd1a95af7513cbfae4a2768f6effc2f3a589f |
ContextGate | import torch
import torch.nn as nn
import torch.cuda
import torch.distributed
class ContextGate(nn.Module):
"""
Context gate is a decoder module that takes as input the previous word
embedding, the current decoder state and the attention state, and
produces a gate.
The gate can be used to select 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
import torch.cuda
import torch.distributed
assert_size_str... | ChenRocks/Distill-BERT-Textgen-ONMT | ContextGate | false | 17,100 | [
"MIT"
] | 7 | d83dd1a95af7513cbfae4a2768f6effc2f3a589f | https://github.com/ChenRocks/Distill-BERT-Textgen-ONMT/tree/d83dd1a95af7513cbfae4a2768f6effc2f3a589f |
PositionwiseFeedForward | import torch
import torch.nn as nn
import torch.cuda
import torch.distributed
class PositionwiseFeedForward(nn.Module):
""" A two-layer Feed-Forward-Network with residual layer norm.
Args:
d_model (int): the size of input for the first-layer of the FFN.
d_ff (int): the hidden layer size of th... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | ChenRocks/Distill-BERT-Textgen-ONMT | PositionwiseFeedForward | false | 17,101 | [
"MIT"
] | 7 | d83dd1a95af7513cbfae4a2768f6effc2f3a589f | https://github.com/ChenRocks/Distill-BERT-Textgen-ONMT/tree/d83dd1a95af7513cbfae4a2768f6effc2f3a589f |
WassersteinDiscriminatorLossCutMix | import torch
from typing import Tuple
import torch.nn as nn
class WassersteinDiscriminatorLossCutMix(nn.Module):
"""
This class implements the Wasserstein loss for a discriminator network when utilizing cut mix augmentation.
"""
def __init__(self) ->None:
"""
Constructor method
... | 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... | ChristophReich1996/Multi-StyleGAN | WassersteinDiscriminatorLossCutMix | false | 17,102 | [
"MIT"
] | 7 | 988f2dfea85b3205126b40c61edfb28107eb3173 | https://github.com/ChristophReich1996/Multi-StyleGAN/tree/988f2dfea85b3205126b40c61edfb28107eb3173 |
NonSaturatingLogisticDiscriminatorLossCutMix | import torch
from typing import Tuple
import torch.nn as nn
import torch.nn.functional as F
class NonSaturatingLogisticDiscriminatorLossCutMix(nn.Module):
"""
Implementation of the non saturating GAN loss for the discriminator network when performing cut mix augmentation.
"""
def __init__(self) ->Non... | 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... | ChristophReich1996/Multi-StyleGAN | NonSaturatingLogisticDiscriminatorLossCutMix | false | 17,103 | [
"MIT"
] | 7 | 988f2dfea85b3205126b40c61edfb28107eb3173 | https://github.com/ChristophReich1996/Multi-StyleGAN/tree/988f2dfea85b3205126b40c61edfb28107eb3173 |
MinibatchStdDev | import torch
import torch.nn as nn
class MinibatchStdDev(nn.Module):
"""
Mini-batch standard deviation module computes the standard deviation of every feature
vector of a pixel and concatenates the resulting map to the original tensor
"""
def __init__(self, alpha: 'float'=1e-08) ->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 import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
assert... | ChristophReich1996/Multi-StyleGAN | MinibatchStdDev | false | 17,104 | [
"MIT"
] | 7 | 988f2dfea85b3205126b40c61edfb28107eb3173 | https://github.com/ChristophReich1996/Multi-StyleGAN/tree/988f2dfea85b3205126b40c61edfb28107eb3173 |
Encoder | import torch
import torch.nn as nn
import torch.nn.functional as F
class Scaled_Dot_Product_Attention(nn.Module):
"""Scaled Dot-Product Attention """
def __init__(self):
super(Scaled_Dot_Product_Attention, self).__init__()
def forward(self, Q, K, V, scale=None):
"""
Args:
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | Ch4ndelier/Transformer_Zero_Velocity_classification | Encoder | false | 17,105 | [
"MIT"
] | 6 | 857efb66189c503e983c11bd7dde16ad19c51ada | https://github.com/Ch4ndelier/Transformer_Zero_Velocity_classification/tree/857efb66189c503e983c11bd7dde16ad19c51ada |
DiffLoss | import torch
import torch.nn as nn
class DiffLoss(nn.Module):
def __init__(self):
super(DiffLoss, self).__init__()
def forward(self, input1, input2):
batch_size = input1.size(0)
input1 = input1.view(batch_size, -1)
input2 = input2.view(batch_size, -1)
input1_mean = to... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as ... | Columbine21/TFR-Net | DiffLoss | false | 17,106 | [
"MIT"
] | 7 | 1da01577542e7f477fdf7323ec0696aebc632357 | https://github.com/Columbine21/TFR-Net/tree/1da01577542e7f477fdf7323ec0696aebc632357 |
MSE | import torch
import torch.nn as nn
class MSE(nn.Module):
def __init__(self):
super(MSE, self).__init__()
def forward(self, pred, real):
diffs = torch.add(real, -pred)
n = torch.numel(diffs.data)
mse = torch.sum(diffs.pow(2)) / n
return mse
def get_inputs():
retu... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
emp... | Columbine21/TFR-Net | MSE | false | 17,107 | [
"MIT"
] | 7 | 1da01577542e7f477fdf7323ec0696aebc632357 | https://github.com/Columbine21/TFR-Net/tree/1da01577542e7f477fdf7323ec0696aebc632357 |
Unet | import torch
import torch.nn as nn
class ConvBlock(nn.Module):
def __init__(self, in_channels, out_channels, dropout=False, norm=
'batch', residual=True, activation='leakyrelu', transpose=False):
super(ConvBlock, self).__init__()
self.dropout = dropout
self.residual = residual
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | BoHuangLab/timeunet | Unet | false | 17,108 | [
"MIT"
] | 7 | 8fd34b18e9c4420db8172a402c243f7d03c853f1 | https://github.com/BoHuangLab/timeunet/tree/8fd34b18e9c4420db8172a402c243f7d03c853f1 |
GatedConv | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
def concat_elu(x):
"""Concatenated ReLU (http://arxiv.org/abs/1603.05201), but with ELU."""
return F.elu(torch.cat((x, -x), dim=1))
class WNConv2d(nn.Module):
"""Weight-normalized 2d convolution.
Args:
in_chann... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as ... | Catherine0505/mar-scf-flow | GatedConv | false | 17,109 | [
"Apache-2.0"
] | 10 | aa7c3564cb9f2967c5e580a633516dba1b597f98 | https://github.com/Catherine0505/mar-scf-flow/tree/aa7c3564cb9f2967c5e580a633516dba1b597f98 |
L1Loss | import functools
import torch
import torch.nn.functional as F
import torch.nn as nn
def reduce_loss(loss, reduction):
"""Reduce loss as specified.
Args:
loss (Tensor): Elementwise loss tensor.
reduction (str): Options are "none", "mean" and "sum".
Return:
Tensor: Reduced loss 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
from torch._inductor.runtime.triton_helpers import math as tl_math
import functools
impor... | CityU-AIM-Group/HTD | L1Loss | false | 17,110 | [
"MIT"
] | 5 | 0be9fd844118c275abc6053b3cbd5ffb589e62ee | https://github.com/CityU-AIM-Group/HTD/tree/0be9fd844118c275abc6053b3cbd5ffb589e62ee |
MSELoss | import functools
import torch
import torch.nn.functional as F
import torch.nn as nn
def reduce_loss(loss, reduction):
"""Reduce loss as specified.
Args:
loss (Tensor): Elementwise loss tensor.
reduction (str): Options are "none", "mean" and "sum".
Return:
Tensor: Reduced loss 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 functools
import torch.nn.functional as F
import torch.nn as nn
assert_size_stride... | CityU-AIM-Group/HTD | MSELoss | false | 17,111 | [
"MIT"
] | 5 | 0be9fd844118c275abc6053b3cbd5ffb589e62ee | https://github.com/CityU-AIM-Group/HTD/tree/0be9fd844118c275abc6053b3cbd5ffb589e62ee |
HingeDiscriminatorLossCutMix | import torch
from typing import Tuple
import torch.nn as nn
class HingeDiscriminatorLossCutMix(nn.Module):
"""
This class implements the hinge gan loss for the discriminator network when utilizing cut mix augmentation.
"""
def __init__(self) ->None:
"""
Constructor method
"""
... | 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... | ChristophReich1996/Multi-StyleGAN | HingeDiscriminatorLossCutMix | false | 17,112 | [
"MIT"
] | 7 | 988f2dfea85b3205126b40c61edfb28107eb3173 | https://github.com/ChristophReich1996/Multi-StyleGAN/tree/988f2dfea85b3205126b40c61edfb28107eb3173 |
GlobalAttention | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.cuda
import torch.distributed
def aeq(*args):
"""
Assert all arguments have the same value
"""
arguments = (arg for arg in args)
first = next(arguments)
assert all(arg == first for arg in arguments
), 'Not ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | ChenRocks/Distill-BERT-Textgen-ONMT | GlobalAttention | false | 17,113 | [
"MIT"
] | 7 | d83dd1a95af7513cbfae4a2768f6effc2f3a589f | https://github.com/ChenRocks/Distill-BERT-Textgen-ONMT/tree/d83dd1a95af7513cbfae4a2768f6effc2f3a589f |
VarifocalLoss | import torch
import torch.nn.functional as F
import torch.nn as nn
def reduce_loss(loss, reduction):
"""Reduce loss as specified.
Args:
loss (Tensor): Elementwise loss tensor.
reduction (str): Options are "none", "mean" and "sum".
Return:
Tensor: Reduced loss tensor.
"""
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import torc... | CityU-AIM-Group/HTD | VarifocalLoss | false | 17,114 | [
"MIT"
] | 5 | 0be9fd844118c275abc6053b3cbd5ffb589e62ee | https://github.com/CityU-AIM-Group/HTD/tree/0be9fd844118c275abc6053b3cbd5ffb589e62ee |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.