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 |
|---|---|---|---|---|---|---|---|---|---|---|
CrossEntropyLoss | import torch
from torch import nn
from torch.nn import CrossEntropyLoss
import torch.nn.functional as F
def _is_long(x):
if hasattr(x, 'data'):
x = x.data
return isinstance(x, torch.LongTensor) or isinstance(x, torch.LongTensor)
def cross_entropy(inputs, target, weight=None, ignore_index=-100, reduc... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
from torch import nn
i... | MutualMarkets/gap | CrossEntropyLoss | false | 8,589 | [
"MIT"
] | 29 | 328b0b7bee1aad8738ddb0f94b4fe49b2e250034 | https://github.com/MutualMarkets/gap/tree/328b0b7bee1aad8738ddb0f94b4fe49b2e250034 |
DaiNet | import torch
import torch.nn as nn
import torch.nn.functional as F
class DaiNet(nn.Module):
def __init__(self):
super(DaiNet, self).__init__()
self.conv1 = nn.Conv2d(3, 12, 5)
self.dp = nn.Dropout(0.5)
self.pool = nn.MaxPool2d(2, 2)
self.conv2 = nn.Conv2d(12, 24, 3)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | MaxChanger/pytorch-cifar | DaiNet | false | 8,590 | [
"MIT"
] | 20 | 217fd2cf7e603fe9a8d3d97f2085606bc43a356a | https://github.com/MaxChanger/pytorch-cifar/tree/217fd2cf7e603fe9a8d3d97f2085606bc43a356a |
LayerNormGRUCell | import math
import torch
class LayerNormGRUCell(torch.nn.Module):
def __init__(self, input_size, hidden_size, bias=True):
super(LayerNormGRUCell, self).__init__()
self.ln_i2h = torch.nn.LayerNorm(2 * hidden_size,
elementwise_affine=False)
self.ln_h2h = torch.nn.LayerNorm(2 * 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 math
assert_... | NeuroAI-PI/AI-Grand-Challenge-2021 | LayerNormGRUCell | false | 8,591 | [
"MIT"
] | 21 | aed2c31ce90cafe15895a11fadb9d88abd0c8765 | https://github.com/NeuroAI-PI/AI-Grand-Challenge-2021/tree/aed2c31ce90cafe15895a11fadb9d88abd0c8765 |
PositionalEncoding | import torch
import torch.nn as nn
import torch.optim
import torch.nn.init
class PositionalEncoding(nn.Module):
def __init__(self, emb_size: 'int', spatial_size: 'int'):
super(PositionalEncoding, self).__init__()
self.emb_size = emb_size
self.spatial_size = spatial_size
self.posit... | 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.optim
import torch.nn.init
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_... | NimrodShabtay/transformers-dip | PositionalEncoding | false | 8,592 | [
"MIT"
] | 25 | 61bc3008114ca950e7ea6341ae8ff317d9353f40 | https://github.com/NimrodShabtay/transformers-dip/tree/61bc3008114ca950e7ea6341ae8ff317d9353f40 |
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... | NTDXYG/Text-Classify-based-pytorch | Multi_Head_Attention | false | 8,593 | [
"Apache-2.0"
] | 20 | b12a264a0ea64b2f8b46fafd5383ef0a8025ef2f | https://github.com/NTDXYG/Text-Classify-based-pytorch/tree/b12a264a0ea64b2f8b46fafd5383ef0a8025ef2f |
Mul | import torch
class Mul(torch.nn.Module):
def __init__(self, weight):
super(Mul, self).__init__()
self.weight = weight
def forward(self, x):
return x * self.weight
def get_inputs():
return [torch.rand([4, 4, 4, 4])]
def get_init_inputs():
return [[], {'weight': 4}]
| import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
@triton.j... | NehzUx/autodl | Mul | false | 8,594 | [
"Apache-2.0"
] | 25 | c80fdc4b297ed1ec2b9e6911d313f1fe31d83cb9 | https://github.com/NehzUx/autodl/tree/c80fdc4b297ed1ec2b9e6911d313f1fe31d83cb9 |
DeepSVDDLoss | import torch
from functools import reduce
import torch.nn as nn
class BaseModule(nn.Module):
"""
Implements the basic module.
All other modules inherit from this one
"""
def load_w(self, checkpoint_path):
"""
Loads a checkpoint into the state_dict.
:param checkpoint_path:... | 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 functools import reduce
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torc... | NjuHaoZhang/AutoregressModel-AE_VAD_CVPR2019 | DeepSVDDLoss | false | 8,595 | [
"MIT"
] | 12 | b9843f34ecb59f908d78ddf977ee4670e0ed6cb4 | https://github.com/NjuHaoZhang/AutoregressModel-AE_VAD_CVPR2019/tree/b9843f34ecb59f908d78ddf977ee4670e0ed6cb4 |
FFNLayer | import math
import torch
import torch.nn as nn
def gelu(x):
return x * 0.5 * (1.0 + torch.erf(x / math.sqrt(2.0)))
class FFNLayer(nn.Module):
def __init__(self, input_dim, intermediate_dim, output_dim, dropout,
layer_norm=True):
super(FFNLayer, self).__init__()
self.fc1 = nn.Linear(... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import math
import ... | NExTplusplus/tat-qa | FFNLayer | false | 8,596 | [
"MIT"
] | 23 | 4ce5d8e637b80143de0d2492ecd4b861d6ba9a89 | https://github.com/NExTplusplus/tat-qa/tree/4ce5d8e637b80143de0d2492ecd4b861d6ba9a89 |
MessagePassing | import torch
import torch._C
import torch.serialization
from torch import nn
from torch.nn import Parameter
def make_onehot_kernel(kernel_size, index):
"""
Make 2D one hot square kernel, i.e. h=w
k[kernel_size, kernel_size] = 0 except k.view(-1)[index] = 1
"""
kernel = torch.zeros(kernel_size, ker... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | Molly6/segmentation_shengteng2021 | MessagePassing | false | 8,597 | [
"Apache-2.0"
] | 21 | 33dfefa80193586f504069793d9e141944549e99 | https://github.com/Molly6/segmentation_shengteng2021/tree/33dfefa80193586f504069793d9e141944549e99 |
MlpWithAttention | import torch
import torch.nn as nn
class Self_Attn1D(nn.Module):
""" Self attention Layer """
def __init__(self, in_dim, activation, k=8):
super(Self_Attn1D, self).__init__()
self.chanel_in = in_dim
self.activation = activation
self.query_conv = nn.Conv1d(in_channels=in_dim, 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.triton_helpers import math as tl_math
import torch.... | Malta-Lab/IUPE | MlpWithAttention | false | 8,600 | [
"MIT"
] | 10 | 44ddf119917538f02bb69509fec7a8314eed419f | https://github.com/Malta-Lab/IUPE/tree/44ddf119917538f02bb69509fec7a8314eed419f |
IWEncoder | import torch
from torch import nn
class IWConv2d(nn.Module):
def __init__(self, input_dim, output_dim, kernel_size, he_init=True,
stride=1, bias=True):
super(IWConv2d, self).__init__()
self.he_init = he_init
self.padding = int((kernel_size - 1) / 2)
self.conv = nn.Conv2d(i... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | MIC-DKFZ/mood | IWEncoder | false | 8,601 | [
"Apache-2.0"
] | 42 | a01303adb4256653b133e2f7cd4741d366b681f7 | https://github.com/MIC-DKFZ/mood/tree/a01303adb4256653b133e2f7cd4741d366b681f7 |
ReconstructionLoss | import torch
from functools import reduce
import torch.nn as nn
class BaseModule(nn.Module):
"""
Implements the basic module.
All other modules inherit from this one
"""
def load_w(self, checkpoint_path):
"""
Loads a checkpoint into the state_dict.
:param checkpoint_path:... | 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 functools import reduce
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torc... | NjuHaoZhang/AutoregressModel-AE_VAD_CVPR2019 | ReconstructionLoss | false | 8,607 | [
"MIT"
] | 12 | b9843f34ecb59f908d78ddf977ee4670e0ed6cb4 | https://github.com/NjuHaoZhang/AutoregressModel-AE_VAD_CVPR2019/tree/b9843f34ecb59f908d78ddf977ee4670e0ed6cb4 |
Mish | from torch.nn import Module
import torch
from torch import Tensor
import torch.optim
class Mish(Module):
"""
Mish Activation Layer
Applies a Mish activation function to the input
Inherits from:
Module (nn.module.Module)
"""
def __init__(self) ->None:
super().... | 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
from torch.nn import Module
import torch.optim
assert_size_str... | PABannier/nanograd | Mish | false | 8,609 | [
"MIT"
] | 18 | 5acd355c638885cbfc0fd0f1c4903964e7fb7de9 | https://github.com/PABannier/nanograd/tree/5acd355c638885cbfc0fd0f1c4903964e7fb7de9 |
EdgeLoss | import torch
import torch.nn as nn
class EdgeLoss(nn.Module):
def __init__(self):
"""
Return Binary Entropy Loss with mean of all losses in each mini-batch
"""
super(EdgeLoss, self).__init__()
self.cross_entropy = nn.BCELoss(reduction='mean')
def forward(self, y, y_pr... | 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... | Nikronic/EdgeNet | EdgeLoss | false | 8,610 | [
"MIT"
] | 12 | ec649af303bd7d5397fd3d4cbf8736bd83756abb | https://github.com/Nikronic/EdgeNet/tree/ec649af303bd7d5397fd3d4cbf8736bd83756abb |
CNNEncoder | import torch
import torch.nn as nn
from torch.nn import functional as F
class CNNEncoder(nn.Module):
def __init__(self, out_channels: 'int', kernel_size: 'tuple'):
super(CNNEncoder, self).__init__()
self.cnn_encoder = nn.Conv2d(in_channels=1, out_channels=
out_channels, kernel_size=ke... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | OwenLeng/Early-Detection-of-Fake-News-on-Social-Media-Through-Propagation-Path-Classification-with-pytorch- | CNNEncoder | false | 8,612 | [
"MIT"
] | 38 | 39f8b7508240ebf58a3cdcf69fbb838a4239e0e5 | https://github.com/OwenLeng/Early-Detection-of-Fake-News-on-Social-Media-Through-Propagation-Path-Classification-with-pytorch-/tree/39f8b7508240ebf58a3cdcf69fbb838a4239e0e5 |
_Mean | import torch
import torch.nn as nn
import torch.jit
class _Mean(nn.Module):
def forward(self, input: 'torch.Tensor') ->torch.Tensor:
return input.mean()
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
import torch.nn as nn
import torch.jit
assert_size_stride = torch._C._dynamo.guards.asser... | One-sixth/ms_ssim_pytorch | _Mean | false | 8,615 | [
"MIT"
] | 42 | 6269c62e0dd29c91fa38e4ba73d906d0c84ca966 | https://github.com/One-sixth/ms_ssim_pytorch/tree/6269c62e0dd29c91fa38e4ba73d906d0c84ca966 |
NetTan2018 | import torch
import torch.nn as nn
import torch.nn.functional as F
class NetTan2018(nn.Module):
def __init__(self, in_channels=3, out_classes=2):
super(NetTan2018, self).__init__()
oc = 16
self.conv1 = nn.Conv2d(in_channels=in_channels, out_channels=oc,
kernel_size=(3, 3), 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 import triton_helpers
import torch.nn as nn
assert_... | Nicolik/SimpleCNNClassifier | NetTan2018 | false | 8,616 | [
"MIT"
] | 11 | e5cd37fbde90f4096183658abe3f8836be92a8f2 | https://github.com/Nicolik/SimpleCNNClassifier/tree/e5cd37fbde90f4096183658abe3f8836be92a8f2 |
CRFRNN | import torch
import torch._C
import torch.serialization
from torch import nn
from torch.nn import init
from torch.nn import Parameter
def make_onehot_kernel(kernel_size, index):
"""
Make 2D one hot square kernel, i.e. h=w
k[kernel_size, kernel_size] = 0 except k.view(-1)[index] = 1
"""
kernel = to... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | Molly6/segmentation_shengteng2021 | CRFRNN | false | 8,617 | [
"Apache-2.0"
] | 21 | 33dfefa80193586f504069793d9e141944549e99 | https://github.com/Molly6/segmentation_shengteng2021/tree/33dfefa80193586f504069793d9e141944549e99 |
Net | import torch
import torch.nn as nn
import torch.nn.functional as F
class Net(nn.Module):
def __init__(self, in_channels=3, out_features=2):
super(Net, self).__init__()
self.conv1 = nn.Conv2d(in_channels=in_channels, out_channels=32,
kernel_size=(3, 3), padding=1)
self.pool1 = ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | Nicolik/SimpleCNNClassifier | Net | false | 8,618 | [
"MIT"
] | 11 | e5cd37fbde90f4096183658abe3f8836be92a8f2 | https://github.com/Nicolik/SimpleCNNClassifier/tree/e5cd37fbde90f4096183658abe3f8836be92a8f2 |
CELoss | import torch
import torch.nn as nn
import torch.nn.functional as F
class CELoss(nn.Module):
def __init__(self):
super(CELoss, self).__init__()
def forward(self, y_pred, y_true):
return -torch.mean(torch.sum(y_true * torch.log(F.softmax(y_pred,
dim=1)), dim=1))
def get_inputs():... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
... | PARMAGroup/UNet-Instance-Cell-Segmentation | CELoss | false | 8,620 | [
"MIT"
] | 30 | 79655a2c5781d2e20c7d5760f631fbb0be392292 | https://github.com/PARMAGroup/UNet-Instance-Cell-Segmentation/tree/79655a2c5781d2e20c7d5760f631fbb0be392292 |
PositionalEncoder | import math
import torch
class PositionalEncoder(torch.nn.Module):
def __init__(self, max_freq, feat_size, dimensionality, base=2):
super().__init__()
self.max_freq = max_freq
self.dimensionality = dimensionality
self.num_bands = math.floor(feat_size / dimensionality / 2)
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import math
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda... | PRBonn/contrastive_association | PositionalEncoder | false | 8,622 | [
"MIT"
] | 19 | 649693494197c8d3948252daee6767b66a89c868 | https://github.com/PRBonn/contrastive_association/tree/649693494197c8d3948252daee6767b66a89c868 |
WrapperKLDiv | import torch
from torch import Tensor
from torch import nn
class WrapperKLDiv(nn.Module):
"""Wrapper for KL-Divergence for easy argument passing."""
def __init__(self, reduction: 'str'='mean') ->None:
"""Constructor.
Args:
reduction (str, optional): One of 'none','batchmean','sum... | 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 ... | PaccMann/paccmann_datasets | WrapperKLDiv | false | 8,623 | [
"MIT"
] | 14 | 0cb0cee349ffab8e227f09f7df0a8bca6a71f22e | https://github.com/PaccMann/paccmann_datasets/tree/0cb0cee349ffab8e227f09f7df0a8bca6a71f22e |
DiceLoss | import torch
import torch.nn as nn
class DiceLoss(nn.Module):
def __init__(self, smooth=1):
super(DiceLoss, self).__init__()
self.smooth = smooth
def dice_coef(self, y_pred, y_true):
pred_probs = torch.sigmoid(y_pred)
y_true_f = y_true.view(-1)
y_pred_f = pred_probs.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 import triton_helpers
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
emp... | PARMAGroup/UNet-Instance-Cell-Segmentation | DiceLoss | false | 8,624 | [
"MIT"
] | 30 | 79655a2c5781d2e20c7d5760f631fbb0be392292 | https://github.com/PARMAGroup/UNet-Instance-Cell-Segmentation/tree/79655a2c5781d2e20c7d5760f631fbb0be392292 |
RMSELoss | import torch
import torch.nn as nn
class RMSELoss(nn.Module):
def __init__(self):
super(RMSELoss, self).__init__()
self.mse = nn.MSELoss()
def forward(self, yhat, y):
return torch.sqrt(self.mse(yhat, y))
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
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
assert... | PARMAGroup/UNet-Instance-Cell-Segmentation | RMSELoss | false | 8,626 | [
"MIT"
] | 30 | 79655a2c5781d2e20c7d5760f631fbb0be392292 | https://github.com/PARMAGroup/UNet-Instance-Cell-Segmentation/tree/79655a2c5781d2e20c7d5760f631fbb0be392292 |
IoULoss | import torch
import torch.nn as nn
class IoULoss(nn.Module):
"""
Intersection over Union Loss.
IoU = Area of Overlap / Area of Union
IoU loss is modified to use for heatmaps.
"""
def __init__(self):
super(IoULoss, self).__init__()
self.EPSILON = 1e-06
def _op_sum(self, x)... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | OlgaChernytska/2D-Hand-Pose-Estimation-RGB | IoULoss | false | 8,627 | [
"MIT"
] | 24 | 31096d628ca11ec4a9b6fa8b2509a2b3e5272125 | https://github.com/OlgaChernytska/2D-Hand-Pose-Estimation-RGB/tree/31096d628ca11ec4a9b6fa8b2509a2b3e5272125 |
SpatialGate | import torch
import torch.nn as nn
class SpatialGate(nn.Module):
"""docstring for SpatialGate"""
def __init__(self, out_channels):
super(SpatialGate, self).__init__()
self.conv = nn.ConvTranspose2d(out_channels, 1, kernel_size=3,
stride=1, padding=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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | PRIS-CV/AP-CNN_Pytorch-master | SpatialGate | false | 8,630 | [
"MIT"
] | 26 | 00ddefee69ab35b8435b732bdf3bd7514a3e4545 | https://github.com/PRIS-CV/AP-CNN_Pytorch-master/tree/00ddefee69ab35b8435b732bdf3bd7514a3e4545 |
WCELoss | import torch
import torch.nn as nn
import torch.nn.functional as F
class WCELoss(nn.Module):
def __init__(self):
super(WCELoss, self).__init__()
def forward(self, y_pred, y_true, weights):
y_true = y_true / y_true.sum(2).sum(2, dtype=torch.float).unsqueeze(-1
).unsqueeze(-1)
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
... | PARMAGroup/UNet-Instance-Cell-Segmentation | WCELoss | false | 8,631 | [
"MIT"
] | 30 | 79655a2c5781d2e20c7d5760f631fbb0be392292 | https://github.com/PARMAGroup/UNet-Instance-Cell-Segmentation/tree/79655a2c5781d2e20c7d5760f631fbb0be392292 |
Quantizer | import torch
import torch.quantization
import torch.nn as nn
import torch.utils.data
class Quantizer(nn.Module):
def __init__(self):
super(Quantizer, self).__init__()
def forward(self, x, fine_tune=False):
cur_device = x.device
if self.training or fine_tune:
res = x + (to... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.quantization
import torch.nn as nn
import torch.utils.data
assert_... | Orange-OpenSource/AIVC | Quantizer | false | 8,632 | [
"BSD-3-Clause"
] | 18 | 8534111d1e08cdbf7efa92ebbb105af3c9044521 | https://github.com/Orange-OpenSource/AIVC/tree/8534111d1e08cdbf7efa92ebbb105af3c9044521 |
_Sum | import torch
import torch.nn as nn
import torch.jit
class _Sum(nn.Module):
def forward(self, input: 'torch.Tensor') ->torch.Tensor:
return input.sum()
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
import torch.nn as nn
import torch.jit
assert_size_stride = torch._C._dynamo.guards.asser... | One-sixth/ms_ssim_pytorch | _Sum | false | 8,634 | [
"MIT"
] | 42 | 6269c62e0dd29c91fa38e4ba73d906d0c84ca966 | https://github.com/One-sixth/ms_ssim_pytorch/tree/6269c62e0dd29c91fa38e4ba73d906d0c84ca966 |
Temperature | import torch
import torch.nn as nn
class Temperature(nn.Module):
"""Temperature wrapper for nn.Sequential."""
def __init__(self, temperature):
super(Temperature, self).__init__()
self.temperature = temperature
def forward(self, data):
return data / self.temperature
def get_inpu... | 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... | PaccMann/paccmann_predictor | Temperature | false | 8,636 | [
"MIT"
] | 19 | 58071311310c45c1efabb34a4003b96a1c58901a | https://github.com/PaccMann/paccmann_predictor/tree/58071311310c45c1efabb34a4003b96a1c58901a |
DeConvNet2 | import torch
import torch.nn as nn
import torch.nn.functional as F
def spectral_norm(module, init=True, std=1, bound=False):
if init:
nn.init.normal_(module.weight, 0, std)
if hasattr(module, 'bias') and module.bias is not None:
module.bias.data.zero_()
SpectralNorm.apply(module, 'weight',... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | Neural-Diffusion-Research/normalized-autoencoders | DeConvNet2 | false | 8,637 | [
"MIT"
] | 30 | 0c77f7e29289e336c0fe5e941aaec8baa4a4fb82 | https://github.com/Neural-Diffusion-Research/normalized-autoencoders/tree/0c77f7e29289e336c0fe5e941aaec8baa4a4fb82 |
DeConvNet3 | import torch
import torch.nn as nn
def get_activation(s_act):
if s_act == 'relu':
return nn.ReLU(inplace=True)
elif s_act == 'sigmoid':
return nn.Sigmoid()
elif s_act == 'softplus':
return nn.Softplus()
elif s_act == 'linear':
return None
elif s_act == 'tanh':
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | Neural-Diffusion-Research/normalized-autoencoders | DeConvNet3 | false | 8,638 | [
"MIT"
] | 30 | 0c77f7e29289e336c0fe5e941aaec8baa4a4fb82 | https://github.com/Neural-Diffusion-Research/normalized-autoencoders/tree/0c77f7e29289e336c0fe5e941aaec8baa4a4fb82 |
ConvNet2FC | import torch
import torch.nn as nn
def spectral_norm(module, init=True, std=1, bound=False):
if init:
nn.init.normal_(module.weight, 0, std)
if hasattr(module, 'bias') and module.bias is not None:
module.bias.data.zero_()
SpectralNorm.apply(module, 'weight', bound=bound)
return 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
import torch.nn as nn
assert_... | Neural-Diffusion-Research/normalized-autoencoders | ConvNet2FC | false | 8,639 | [
"MIT"
] | 30 | 0c77f7e29289e336c0fe5e941aaec8baa4a4fb82 | https://github.com/Neural-Diffusion-Research/normalized-autoencoders/tree/0c77f7e29289e336c0fe5e941aaec8baa4a4fb82 |
FixupResUnit | import torch
import torch.nn.functional as F
import torch.nn as nn
class FixupResUnit(nn.Module):
def __init__(self, in_channels, out_channels, stride=1):
super().__init__()
self.bias1a = nn.Parameter(torch.zeros(1))
self.conv1 = nn.Conv2d(in_channels, out_channels, 3, padding=1,
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | OpenXAIProject/dac | FixupResUnit | false | 8,640 | [
"MIT"
] | 17 | 652776e21b56dcb68839363bb077d5c5ea28d81e | https://github.com/OpenXAIProject/dac/tree/652776e21b56dcb68839363bb077d5c5ea28d81e |
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.... | NTDXYG/Text-Classify-based-pytorch | Encoder | false | 8,641 | [
"Apache-2.0"
] | 20 | b12a264a0ea64b2f8b46fafd5383ef0a8025ef2f | https://github.com/NTDXYG/Text-Classify-based-pytorch/tree/b12a264a0ea64b2f8b46fafd5383ef0a8025ef2f |
SAB | import math
import torch
import torch.nn.functional as F
import torch.nn as nn
class MAB(nn.Module):
def __init__(self, dim_X, dim_Y, dim, num_heads=4, ln=False, p=None):
super().__init__()
self.num_heads = num_heads
self.fc_q = nn.Linear(dim_X, dim)
self.fc_k = nn.Linear(dim_Y, d... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | OpenXAIProject/dac | SAB | false | 8,642 | [
"MIT"
] | 17 | 652776e21b56dcb68839363bb077d5c5ea28d81e | https://github.com/OpenXAIProject/dac/tree/652776e21b56dcb68839363bb077d5c5ea28d81e |
GatedLinear | import torch
import torch.nn as nn
class GatedLinear(nn.Module):
def __init__(self, input_size, output_size):
super(GatedLinear, self).__init__()
self.linear = nn.Linear(input_size, output_size * 2)
self.glu = nn.GLU(dim=-1)
def forward(self, x, y=None, x_mask=None, y_mask=None, rel_... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | ParadoxZW/mmnas | GatedLinear | false | 8,643 | [
"Apache-2.0"
] | 23 | 186ef8648e71b5fc4433faf80431a0f8bc9261a0 | https://github.com/ParadoxZW/mmnas/tree/186ef8648e71b5fc4433faf80431a0f8bc9261a0 |
BlurPool2d | import torch
import torch.nn as nn
import torch.utils.data
class BlurPool2d(nn.Sequential):
"""Blur Pooling Layer (MaxPool2d replacement)
See: https://richzhang.github.io/antialiased-cnns/
Paper: https://arxiv.org/abs/1904.11486
"""
__constants__ = ['in_features']
_blur_kernel = torch.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
import torch.nn as nn
import ... | Noodles-321/RegistrationEval | BlurPool2d | false | 8,644 | [
"MIT"
] | 38 | 3631d3d5bd65acf980fcfed803fa6125970f3e88 | https://github.com/Noodles-321/RegistrationEval/tree/3631d3d5bd65acf980fcfed803fa6125970f3e88 |
VarifocalLoss | import torch
import torch.nn as nn
import torch.nn.functional as F
def reduce_loss(loss, reduction):
"""Reduce loss as specified.
Args:
loss (Tensor): Elementwise loss tensor.
reduction (str): Options are "none", "mean" and "sum".
Return:
Tensor: Reduced loss tensor.
"""
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import torc... | NEUdeep/TileDetection | VarifocalLoss | false | 8,645 | [
"Apache-2.0"
] | 41 | f453ac868de195a7859b9bf07c813e46eb35d2d0 | https://github.com/NEUdeep/TileDetection/tree/f453ac868de195a7859b9bf07c813e46eb35d2d0 |
ConvNet64 | import torch
import torch.nn as nn
def get_activation(s_act):
if s_act == 'relu':
return nn.ReLU(inplace=True)
elif s_act == 'sigmoid':
return nn.Sigmoid()
elif s_act == 'softplus':
return nn.Softplus()
elif s_act == 'linear':
return None
elif s_act == 'tanh':
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | Neural-Diffusion-Research/normalized-autoencoders | ConvNet64 | false | 8,646 | [
"MIT"
] | 30 | 0c77f7e29289e336c0fe5e941aaec8baa4a4fb82 | https://github.com/Neural-Diffusion-Research/normalized-autoencoders/tree/0c77f7e29289e336c0fe5e941aaec8baa4a4fb82 |
MAB | import math
import torch
import torch.nn.functional as F
import torch.nn as nn
class MAB(nn.Module):
def __init__(self, dim_X, dim_Y, dim, num_heads=4, ln=False, p=None):
super().__init__()
self.num_heads = num_heads
self.fc_q = nn.Linear(dim_X, dim)
self.fc_k = nn.Linear(dim_Y, d... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | OpenXAIProject/dac | MAB | false | 8,647 | [
"MIT"
] | 17 | 652776e21b56dcb68839363bb077d5c5ea28d81e | https://github.com/OpenXAIProject/dac/tree/652776e21b56dcb68839363bb077d5c5ea28d81e |
RMSPE | import torch
import torch.nn as nn
class RMSPE(nn.Module):
def __init__(self, eps: 'float'=1e-08):
super().__init__()
self.eps = eps
def forward(self, pred: 'torch.Tensor', target: 'torch.Tensor'):
return torch.sqrt(torch.mean(torch.square((pred - target).abs() / (
target... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import torc... | Phimos/SIGSPATIAL-2021-GISCUP-3rd-Solution | RMSPE | false | 8,648 | [
"MIT"
] | 11 | 79fcf9941c28cdb2eb38a3654e1514a1d998a41c | https://github.com/Phimos/SIGSPATIAL-2021-GISCUP-3rd-Solution/tree/79fcf9941c28cdb2eb38a3654e1514a1d998a41c |
AdaIN | import torch
import torch.nn as nn
import torch.utils.data
class AdaIN(nn.Module):
def __init__(self, style_dim, num_features):
super().__init__()
self.norm = nn.InstanceNorm2d(num_features, affine=False)
self.fc = nn.Linear(style_dim, num_features * 2)
def forward(self, x, s):
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as ... | Noodles-321/RegistrationEval | AdaIN | false | 8,649 | [
"MIT"
] | 38 | 3631d3d5bd65acf980fcfed803fa6125970f3e88 | https://github.com/Noodles-321/RegistrationEval/tree/3631d3d5bd65acf980fcfed803fa6125970f3e88 |
Model | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, num_inputs, num_outputs, hidden_size=256):
super(Model, self).__init__()
self.linear1 = nn.Linear(num_inputs, hidden_size)
self.linear2 = nn.Linear(hidden_size, num_outputs)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | PacktPublishing/Hands-On-Reinforcement-Learning-for-Games | Model | false | 8,650 | [
"MIT"
] | 41 | 045b8846f2558aa8fb8ac8cef5c71ee098cb9b22 | https://github.com/PacktPublishing/Hands-On-Reinforcement-Learning-for-Games/tree/045b8846f2558aa8fb8ac8cef5c71ee098cb9b22 |
ResBlk | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
def normalize(x, eps=1e-10):
return x * torch.rsqrt(torch.sum(x ** 2, dim=1, keepdim=True) + eps)
class ResBlk(nn.Module):
def __init__(self, dim_in, dim_out, actv=nn.LeakyReLU(0.2), normalize=
Fa... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
as... | Noodles-321/RegistrationEval | ResBlk | false | 8,651 | [
"MIT"
] | 38 | 3631d3d5bd65acf980fcfed803fa6125970f3e88 | https://github.com/Noodles-321/RegistrationEval/tree/3631d3d5bd65acf980fcfed803fa6125970f3e88 |
SimpleModel | import torch
import torch.nn as nn
import torch.onnx
import torch.nn.functional as F
class SimpleModel(nn.Module):
def __init__(self):
super(SimpleModel, self).__init__()
self.conv1 = nn.Conv2d(3, 32, 3)
self.conv2 = nn.Conv2d(32, 64, 3)
self.conv3 = nn.Conv2d(64, 128, 3)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
import ... | PanJinquan/pytorch-base-trainer | SimpleModel | false | 8,652 | [
"MIT"
] | 11 | 37799c948f72b2f9d3771ff469e06cdbff4a1d07 | https://github.com/PanJinquan/pytorch-base-trainer/tree/37799c948f72b2f9d3771ff469e06cdbff4a1d07 |
DiceBCELoss | import torch
import torch.nn as nn
import torch.nn.functional as F
class DiceBCELoss(nn.Module):
def __init__(self, weight=None, size_average=True):
super(DiceBCELoss, self).__init__()
def forward(self, inputs, targets, smooth=1):
inputs = torch.sigmoid(inputs)
inputs = inputs.view(-... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import torc... | ProfessorHuang/2D-UNet-Pytorch | DiceBCELoss | false | 8,653 | [
"MIT"
] | 11 | b3941e8dc0ac3e76b6eedb656f943f1bd66fa799 | https://github.com/ProfessorHuang/2D-UNet-Pytorch/tree/b3941e8dc0ac3e76b6eedb656f943f1bd66fa799 |
ContrastiveLoss | import torch
import torch.nn.functional as F
class ContrastiveLoss(torch.nn.Module):
"""
Contrastive loss function.
Based on: http://yann.lecun.com/exdb/publis/pdf/hadsell-chopra-lecun-06.pdf
Modified from: https://hackernoon.com/facial-similarity-with-siamese-networks-in-pytorch-9642aa9db2f7
"""... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
assert_size_stride = torch._... | QTIM-Lab/SiameseChange | ContrastiveLoss | false | 8,654 | [
"MIT"
] | 14 | a58fe2a93487b3e164f1d7e0b27f5a3321bc2672 | https://github.com/QTIM-Lab/SiameseChange/tree/a58fe2a93487b3e164f1d7e0b27f5a3321bc2672 |
SEConv2d | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.modules.utils import _pair
class SEConv2d(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride=1,
padding=0, dilation=1, groups=1, bias=False, size_splits=64,
threshold=0.005, sign_threshold=... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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.modules.utils import _pair
assert_size_strid... | PannenetsF/TQT | SEConv2d | false | 8,655 | [
"BSD-3-Clause"
] | 14 | 3c3125327d00efe6318b28cb1d0a199b734c2c7b | https://github.com/PannenetsF/TQT/tree/3c3125327d00efe6318b28cb1d0a199b734c2c7b |
ReconstructionCriterion | import torch
import torch.nn as nn
import torch.nn.functional as F
class ReconstructionCriterion(nn.Module):
"""
Here we calculate the criterion for -log p(x|z), we list two forms, the binary cross entropy form
as well as the mse loss form
"""
def __init__(self, x_sigma=1, bce_reconstruction=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
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import torc... | PaperCodeSubmission/ICML2020-697 | ReconstructionCriterion | false | 8,656 | [
"MIT"
] | 12 | 00f7732c236b9c6234e76a47dfebe5de314d5c01 | https://github.com/PaperCodeSubmission/ICML2020-697/tree/00f7732c236b9c6234e76a47dfebe5de314d5c01 |
KLDiscCriterion | import torch
import torch.nn as nn
class KLDiscCriterion(nn.Module):
"""
calculate
sum (j=1,...,K) D_KL[q(c_j|x)||p(c_j|x)]
"""
def __init__(self):
super(KLDiscCriterion, self).__init__()
def forward(self, disc_log_pre, disc_gt, qp_order=True):
batch_size = disc_log_pre.size(... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
... | PaperCodeSubmission/ICML2020-697 | KLDiscCriterion | false | 8,657 | [
"MIT"
] | 12 | 00f7732c236b9c6234e76a47dfebe5de314d5c01 | https://github.com/PaperCodeSubmission/ICML2020-697/tree/00f7732c236b9c6234e76a47dfebe5de314d5c01 |
M1Criterion | import torch
import torch.nn as nn
import torch.nn.functional as F
class M1Criterion(nn.Module):
def __init__(self, x_sigma=1, bce_reconstruction=True):
super(M1Criterion, self).__init__()
self.x_sigma = x_sigma
self.bce_reconstruction = bce_reconstruction
def forward(self, x, x_reco... | 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... | PaperCodeSubmission/ICML2020-697 | M1Criterion | false | 8,658 | [
"MIT"
] | 12 | 00f7732c236b9c6234e76a47dfebe5de314d5c01 | https://github.com/PaperCodeSubmission/ICML2020-697/tree/00f7732c236b9c6234e76a47dfebe5de314d5c01 |
ada_mask | import torch
import torch.nn as nn
import torch.nn.functional as F
class ResBlock(nn.Module):
def __init__(self, in_channel, out_channel, ker_size, stri, pad):
super(ResBlock, self).__init__()
self.conv1 = nn.Conv2d(in_channel, out_channel, 3, 1, 1)
self.conv2 = nn.Conv2d(out_channel, 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
import torch.nn as nn
import ... | NJUVISION/AWnet | ada_mask | false | 8,659 | [
"MIT"
] | 16 | f47a1692819a778b513b882d36ed727f7732d37b | https://github.com/NJUVISION/AWnet/tree/f47a1692819a778b513b882d36ed727f7732d37b |
Classify | import torch
import torch.nn as nn
def autopad(k, p=None):
if p is None:
p = k // 2 if isinstance(k, int) else [(x // 2) for x in k]
return p
class Classify(nn.Module):
def __init__(self, c1, c2, k=1, s=1, p=None, g=1):
super(Classify, self).__init__()
self.aap = nn.AdaptiveAvgP... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | PoCInnovation/Koic | Classify | false | 8,660 | [
"MIT"
] | 13 | eca53b53b7242c1e83213ef9408366ca0a346358 | https://github.com/PoCInnovation/Koic/tree/eca53b53b7242c1e83213ef9408366ca0a346358 |
ClsCriterion | import torch
import torch.nn as nn
class ClsCriterion(nn.Module):
def __init__(self):
super(ClsCriterion, self).__init__()
def forward(self, predict, label, batch_weight=None):
"""
:param predict: B*C log_softmax result
:param label: B*C one-hot label
:param batch_wei... | 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... | PaperCodeSubmission/ICML2020-697 | ClsCriterion | false | 8,661 | [
"MIT"
] | 12 | 00f7732c236b9c6234e76a47dfebe5de314d5c01 | https://github.com/PaperCodeSubmission/ICML2020-697/tree/00f7732c236b9c6234e76a47dfebe5de314d5c01 |
IWDiscriminator | import torch
from torch import nn
class IWConv2d(nn.Module):
def __init__(self, input_dim, output_dim, kernel_size, he_init=True,
stride=1, bias=True):
super(IWConv2d, self).__init__()
self.he_init = he_init
self.padding = int((kernel_size - 1) / 2)
self.conv = nn.Conv2d(i... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | MIC-DKFZ/mood | IWDiscriminator | false | 8,662 | [
"Apache-2.0"
] | 42 | a01303adb4256653b133e2f7cd4741d366b681f7 | https://github.com/MIC-DKFZ/mood/tree/a01303adb4256653b133e2f7cd4741d366b681f7 |
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... | PoCInnovation/Koic | MetaAconC | false | 8,663 | [
"MIT"
] | 13 | eca53b53b7242c1e83213ef9408366ca0a346358 | https://github.com/PoCInnovation/Koic/tree/eca53b53b7242c1e83213ef9408366ca0a346358 |
ConvBlock | import torch
import torch.nn as nn
import torch.nn.functional as F
class ConvBlock(nn.Module):
def __init__(self):
super(ConvBlock, self).__init__()
self.conv1 = nn.Conv2d(3, 6, 5)
self.pool = nn.MaxPool2d(2, 2)
self.conv2 = nn.Conv2d(6, 16, 5)
def forward(self, x):
x... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | QinbinLi/FedKT | ConvBlock | false | 8,664 | [
"MIT"
] | 14 | 0bb9a89ea266c057990a4a326b586ed3d2fb2df8 | https://github.com/QinbinLi/FedKT/tree/0bb9a89ea266c057990a4a326b586ed3d2fb2df8 |
FixupResidual | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
class FixupResidual(nn.Module):
def __init__(self, depth, num_residual):
super().__init__()
self.conv1 = nn.Conv2d(depth, depth, 3, padding=1, bias=False)
self.conv2 = nn.Conv2d(depth, depth, 3, padding=1, bias... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import math
import torch.nn a... | PacktPublishing/Hands-On-Reinforcement-Learning-for-Games | FixupResidual | false | 8,665 | [
"MIT"
] | 41 | 045b8846f2558aa8fb8ac8cef5c71ee098cb9b22 | https://github.com/PacktPublishing/Hands-On-Reinforcement-Learning-for-Games/tree/045b8846f2558aa8fb8ac8cef5c71ee098cb9b22 |
MaxPooling | import torch
class MaxPooling(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, x, y):
x = torch.cat((x.unsqueeze(dim=1), y.unsqueeze(dim=1)), dim=1)
return x.max(dim=1)[0]
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
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torc... | Qualcomm-AI-research/FrameExit | MaxPooling | false | 8,666 | [
"BSD-3-Clause-Clear"
] | 21 | fc5815fd092019d58bcac5d5e6fcc45ce666311f | https://github.com/Qualcomm-AI-research/FrameExit/tree/fc5815fd092019d58bcac5d5e6fcc45ce666311f |
KLNormCriterion | import torch
import torch.nn as nn
class KLNormCriterion(nn.Module):
def __init__(self):
super(KLNormCriterion, self).__init__()
def forward(self, z_mean_pre, z_log_sigma_pre, z_mean_gt=None,
z_sigma_gt=None):
batch_size = z_mean_pre.size(0)
if z_mean_gt is None or z_sigma_gt... | 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
... | PaperCodeSubmission/ICML2020-697 | KLNormCriterion | false | 8,667 | [
"MIT"
] | 12 | 00f7732c236b9c6234e76a47dfebe5de314d5c01 | https://github.com/PaperCodeSubmission/ICML2020-697/tree/00f7732c236b9c6234e76a47dfebe5de314d5c01 |
QNetwork | import torch
import torch.nn as nn
import torch.nn.functional as F
def weights_init_(m):
if isinstance(m, nn.Linear):
torch.nn.init.xavier_uniform_(m.weight, gain=1)
torch.nn.init.constant_(m.bias, 0)
class QNetwork(nn.Module):
def __init__(self, num_inputs, num_actions, hidden_dim):
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | QwQ2000/E2GAN | QNetwork | false | 8,668 | [
"MIT"
] | 34 | f27b715362de4459129206217d100ae5b6cf82c8 | https://github.com/QwQ2000/E2GAN/tree/f27b715362de4459129206217d100ae5b6cf82c8 |
FixedSubnetConv | import math
import torch
import torch.multiprocessing
import torch.nn as nn
import torch.nn.parallel
import torch.optim
import torch.utils.data
import torch.utils.data.distributed
import torch.nn.functional as F
class FixedSubnetConv(nn.Conv2d):
def __init__(self, *args, **kwargs):
super().__init__(*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
import math
import torch.multiprocessing
import torch.nn as nn
import torch.nn.p... | RICE-EIC/Robust_Scratch_Ticket | FixedSubnetConv | false | 8,669 | [
"MIT"
] | 13 | f77b41cdaab6db4922a6d4b5970db75a9bfc7257 | https://github.com/RICE-EIC/Robust_Scratch_Ticket/tree/f77b41cdaab6db4922a6d4b5970db75a9bfc7257 |
ImpalaResidual | import torch
import torch.nn as nn
import torch.nn.functional as F
class ImpalaResidual(nn.Module):
"""
A residual block for an IMPALA CNN.
"""
def __init__(self, depth):
super().__init__()
self.conv1 = nn.Conv2d(depth, depth, 3, padding=1)
self.conv2 = nn.Conv2d(depth, depth,... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | PacktPublishing/Hands-On-Reinforcement-Learning-for-Games | ImpalaResidual | false | 8,670 | [
"MIT"
] | 41 | 045b8846f2558aa8fb8ac8cef5c71ee098cb9b22 | https://github.com/PacktPublishing/Hands-On-Reinforcement-Learning-for-Games/tree/045b8846f2558aa8fb8ac8cef5c71ee098cb9b22 |
distLinear | import torch
import torch.nn as nn
from torch.nn.utils.weight_norm import WeightNorm
class distLinear(nn.Module):
def __init__(self, indim, outdim):
super(distLinear, self).__init__()
self.L = nn.Linear(indim, outdim, bias=False)
self.class_wise_learnable_norm = True
if self.class... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 ... | RafLaf/easy | distLinear | false | 8,671 | [
"MIT"
] | 25 | 3e3603aef7dfb1cf469820330d695b93ba76dfd4 | https://github.com/RafLaf/easy/tree/3e3603aef7dfb1cf469820330d695b93ba76dfd4 |
SelfAttentionLayer2 | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import *
class SelfAttentionLayer2(nn.Module):
def __init__(self, dim, da):
super(SelfAttentionLayer2, self).__init__()
self.dim = dim
self.Wq = nn.Parameter(torch.zeros(self.dim, self.dim... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | RUCAIBox/TG_CRS_Code | SelfAttentionLayer2 | false | 8,672 | [
"Apache-2.0"
] | 27 | 0428a3a069c4d0d4888f2d476dba2cafd7918524 | https://github.com/RUCAIBox/TG_CRS_Code/tree/0428a3a069c4d0d4888f2d476dba2cafd7918524 |
NoiseLayer | import torch
from torch import nn
import torch.nn
class NoiseLayer(nn.Module):
"""adds noise. noise is per pixel (constant over channels) with per-channel weight"""
def __init__(self, channels):
super().__init__()
self.weight = nn.Parameter(torch.zeros(channels))
self.noise = None
... | 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 import nn
import torch.nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_... | Qingyang-Xu/GANInversion_with_ConsecutiveImgs | NoiseLayer | false | 8,673 | [
"MIT"
] | 23 | 9078a48ec3474dacdd02693b051e3addef1c5697 | https://github.com/Qingyang-Xu/GANInversion_with_ConsecutiveImgs/tree/9078a48ec3474dacdd02693b051e3addef1c5697 |
CNN | import torch
import torch.nn.functional as F
import torch.nn as nn
class CNN(nn.Module):
def __init__(self, num_classes):
super(CNN, self).__init__()
self.conv1 = nn.Conv2d(1, 64, 5)
self.mp1 = nn.MaxPool2d(2, 2)
self.conv2 = nn.Conv2d(64, 128, 5)
self.mp2 = nn.MaxPool2d(2... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | Psarpei/Handwritten-Text-Recognition | CNN | false | 8,674 | [
"MIT"
] | 15 | be8f12092e385f3e117ae79b08fb06d0681f67e3 | https://github.com/Psarpei/Handwritten-Text-Recognition/tree/be8f12092e385f3e117ae79b08fb06d0681f67e3 |
SelfAttentionLayer | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import *
class SelfAttentionLayer(nn.Module):
def __init__(self, dim, da, alpha=0.2, dropout=0.5):
super(SelfAttentionLayer, self).__init__()
self.dim = dim
self.da = da
self.alpha = alpha
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | RUCAIBox/TG_CRS_Code | SelfAttentionLayer | false | 8,675 | [
"Apache-2.0"
] | 27 | 0428a3a069c4d0d4888f2d476dba2cafd7918524 | https://github.com/RUCAIBox/TG_CRS_Code/tree/0428a3a069c4d0d4888f2d476dba2cafd7918524 |
StddevLayer | import torch
from torch import nn
import torch.nn
class StddevLayer(nn.Module):
def __init__(self, group_size=4, num_new_features=1):
super().__init__()
self.group_size = 4
self.num_new_features = 1
def forward(self, x):
b, c, h, w = x.shape
group_size = min(self.grou... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
from torch import nn
import torch.nn
assert_size_stride = torch._C._dynamo.guar... | Qingyang-Xu/GANInversion_with_ConsecutiveImgs | StddevLayer | false | 8,676 | [
"MIT"
] | 23 | 9078a48ec3474dacdd02693b051e3addef1c5697 | https://github.com/Qingyang-Xu/GANInversion_with_ConsecutiveImgs/tree/9078a48ec3474dacdd02693b051e3addef1c5697 |
SoftCrossEntropyLoss | import torch
from torch import Tensor
from torch.backends import cudnn as cudnn
from torch import nn as nn
from torch.nn import functional as F
from torch.nn import init as init
from typing import List
class SoftCrossEntropyLoss(nn.Module):
"""Calculate the CrossEntropyLoss with soft targets.
:param 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
from torch.backends im... | PushparajaMurugan/dauphin | SoftCrossEntropyLoss | false | 8,677 | [
"Apache-2.0"
] | 18 | 4d9832c72288282e6b3d03be1b0ad8708282b005 | https://github.com/PushparajaMurugan/dauphin/tree/4d9832c72288282e6b3d03be1b0ad8708282b005 |
CoralLayer | import torch
class CoralLayer(torch.nn.Module):
""" Implements CORAL layer described in
Cao, Mirjalili, and Raschka (2020)
*Rank Consistent Ordinal Regression for Neural Networks
with Application to Age Estimation*
Pattern Recognition Letters, https://doi.org/10.1016/j.patrec.2020.11.008
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cu... | Raschka-research-group/coral-pytorch | CoralLayer | false | 8,678 | [
"MIT"
] | 32 | 6b85e287118476095bac85d6f3dabc6ffb89a326 | https://github.com/Raschka-research-group/coral-pytorch/tree/6b85e287118476095bac85d6f3dabc6ffb89a326 |
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... | PoCInnovation/Koic | AconC | false | 8,679 | [
"MIT"
] | 13 | eca53b53b7242c1e83213ef9408366ca0a346358 | https://github.com/PoCInnovation/Koic/tree/eca53b53b7242c1e83213ef9408366ca0a346358 |
SimpleShortCut | import torch
import torch.nn as nn
import torch.nn.functional as F
class SimpleShortCut(nn.Module):
def __init__(self, planes):
super().__init__()
self.planes = planes // 4
def forward(self, x):
return F.pad(x[:, :, ::2, ::2], (0, 0, 0, 0, self.planes, self.
planes), 'con... | 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... | RaoefTaki/MNTDP-forked | SimpleShortCut | false | 8,680 | [
"MIT"
] | 15 | d9ea59a6638f6cdc93eca180ab02672f5bf5d2a1 | https://github.com/RaoefTaki/MNTDP-forked/tree/d9ea59a6638f6cdc93eca180ab02672f5bf5d2a1 |
DoubleDeltaTransform | import torch
import torchaudio
class DoubleDeltaTransform(torch.nn.Module):
"""A transformation to compute delta and double delta features.
Args:
win_length (int): The window length to use for computing deltas (Default: 5).
mode (str): Mode parameter passed to padding (Default: replicate).
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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 torchaudio
assert_size_stride = torch._C._dynamo.guards.assert_size_strid... | RUB-SysSec/WaveFake | DoubleDeltaTransform | false | 8,681 | [
"MIT"
] | 20 | d52d51b9ccdb0cec3f484e84b228791f06b955be | https://github.com/RUB-SysSec/WaveFake/tree/d52d51b9ccdb0cec3f484e84b228791f06b955be |
Conv2d | import torch
import numpy as np
import torch.utils.data
import torch
import torch.nn as nn
import torch.nn.init as init
import torch.nn.functional as F
def get_causal_padding(kernel_size, strides, dilation_rate, n_dims=2):
p_ = []
for i in range(n_dims - 1, -1, -1):
if strides[i] > 1 and dilation_rate... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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.utils.data
import torch
import torch.nn as nn
im... | Rayhane-mamah/Efficient-VDVAE | Conv2d | false | 8,682 | [
"MIT"
] | 41 | 07bcb8ba58c228ab0ed62c5cf374c19a10932010 | https://github.com/Rayhane-mamah/Efficient-VDVAE/tree/07bcb8ba58c228ab0ed62c5cf374c19a10932010 |
MyLinear | import torch
from torch import nn
import torch.nn
import torch.nn.functional as F
class MyLinear(nn.Module):
"""Linear layer with equalized learning rate and custom learning rate multiplier."""
def __init__(self, input_size, output_size, gain=2 ** 0.5, use_wscale=
False, lrmul=1, bias=True):
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
import torch.nn
assert_size_stride = torch._C._dynamo.guard... | Qingyang-Xu/GANInversion_with_ConsecutiveImgs | MyLinear | false | 8,683 | [
"MIT"
] | 23 | 9078a48ec3474dacdd02693b051e3addef1c5697 | https://github.com/Qingyang-Xu/GANInversion_with_ConsecutiveImgs/tree/9078a48ec3474dacdd02693b051e3addef1c5697 |
SPoC | import torch
import torch.nn as nn
import torch.nn.functional as F
class SPoC(nn.Module):
def __init__(self):
super(SPoC, self).__init__()
def forward(self, x):
return F.avg_pool2d(x, (x.size(-2), x.size(-1)))
def __repr__(self):
return self.__class__.__name__ + '()'
def get_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... | RetrainIt/Perfect-Half-Million-Beauty-Product-Image-Recognition-Challenge | SPoC | false | 8,684 | [
"Apache-2.0"
] | 15 | 080aa5ae2f2755c6dc10b7cdc910ec0f76bc82c3 | https://github.com/RetrainIt/Perfect-Half-Million-Beauty-Product-Image-Recognition-Challenge/tree/080aa5ae2f2755c6dc10b7cdc910ec0f76bc82c3 |
Deconv2d | import torch
import torch.nn as nn
class Deconv2d(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride=1, bn
=False, activation='leakyrelu', dropout=False):
super(Deconv2d, self).__init__()
padding = int((kernel_size - 1) / 2)
self.conv = nn.ConvTranspose2... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | RQuispeC/pytorch-ACSCP | Deconv2d | false | 8,685 | [
"MIT"
] | 25 | c83f08632012c2245250ff9c5140814461db575c | https://github.com/RQuispeC/pytorch-ACSCP/tree/c83f08632012c2245250ff9c5140814461db575c |
ConstMult | import torch
import torch.nn as nn
class ConstMult(nn.Module):
def __init__(self, alpha=1.0):
super().__init__()
self.alpha = nn.Parameter(torch.Tensor(1))
nn.init.constant_(self.alpha, alpha)
def forward(self, x):
return self.alpha * x
def get_inputs():
return [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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | RaoefTaki/MNTDP-forked | ConstMult | false | 8,686 | [
"MIT"
] | 15 | d9ea59a6638f6cdc93eca180ab02672f5bf5d2a1 | https://github.com/RaoefTaki/MNTDP-forked/tree/d9ea59a6638f6cdc93eca180ab02672f5bf5d2a1 |
ncm_output | import torch
import torch.nn as nn
class ncm_output(nn.Module):
def __init__(self, indim, outdim):
super(ncm_output, self).__init__()
self.linear = nn.Linear(indim, outdim)
def forward(self, x):
return -1 * torch.norm(x.reshape(x.shape[0], 1, -1) - self.linear.
weight.tra... | 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_... | RafLaf/easy | ncm_output | false | 8,687 | [
"MIT"
] | 25 | 3e3603aef7dfb1cf469820330d695b93ba76dfd4 | https://github.com/RafLaf/easy/tree/3e3603aef7dfb1cf469820330d695b93ba76dfd4 |
ValueFunction | import torch
import numpy as np
import torch.nn as nn
class ValueFunction(nn.Module):
def __init__(self, width, n_states):
super(ValueFunction, self).__init__()
self.linear1 = nn.Linear(n_states, width)
nn.init.normal_(self.linear1.weight, 0.0, 1 / np.sqrt(n_states))
torch.nn.init... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import numpy as np
... | RajGhugare19/VE-principle-for-model-based-RL | ValueFunction | false | 8,688 | [
"MIT"
] | 16 | a9f94dfc9317a0ccc60bc7c558dcec1ebc6d0c63 | https://github.com/RajGhugare19/VE-principle-for-model-based-RL/tree/a9f94dfc9317a0ccc60bc7c558dcec1ebc6d0c63 |
DotProductAttention | import torch
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
class BaseAttention(nn.Module):
def __init__(self):
super().__init__()
def forward(self, *args, **kwargs):
raise NotImplementedError
class DotProductAttention(BaseAttention):
"""Dot Product Attention"... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | ROBINADC/BiGRU-CRF-with-Attention-for-NER | DotProductAttention | false | 8,689 | [
"MIT"
] | 27 | b9e037ebd6e1d56500ffb60c6030013982c17ded | https://github.com/ROBINADC/BiGRU-CRF-with-Attention-for-NER/tree/b9e037ebd6e1d56500ffb60c6030013982c17ded |
Block | import torch
import torch.nn as nn
class Mlp(nn.Module):
def __init__(self, in_features, hidden_features=None, out_features=None,
act_layer=nn.GELU, drop=0.0):
super().__init__()
out_features = out_features or in_features
hidden_features = hidden_features or in_features
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.... | Pang-Yatian/Point-MAE | Block | false | 8,690 | [
"MIT"
] | 42 | 61727f76e9d0c28babf422505073bd43c2f517bc | https://github.com/Pang-Yatian/Point-MAE/tree/61727f76e9d0c28babf422505073bd43c2f517bc |
ContextAttentionLayer | import torch
from collections import OrderedDict
import torch.nn as nn
class Squeeze(nn.Module):
"""Squeeze wrapper for nn.Sequential."""
def forward(self, data):
return torch.squeeze(data)
class Temperature(nn.Module):
"""Temperature wrapper for nn.Sequential."""
def __init__(self, temper... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | PaccMann/paccmann_predictor | ContextAttentionLayer | false | 8,691 | [
"MIT"
] | 19 | 58071311310c45c1efabb34a4003b96a1c58901a | https://github.com/PaccMann/paccmann_predictor/tree/58071311310c45c1efabb34a4003b96a1c58901a |
StyleMod | import torch
from torch import nn
import torch.nn
import torch.nn.functional as F
class MyLinear(nn.Module):
"""Linear layer with equalized learning rate and custom learning rate multiplier."""
def __init__(self, input_size, output_size, gain=2 ** 0.5, use_wscale=
False, lrmul=1, bias=True):
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
import torch.nn
import torch.nn.functional as F
assert_size... | Qingyang-Xu/GANInversion_with_ConsecutiveImgs | StyleMod | false | 8,692 | [
"MIT"
] | 23 | 9078a48ec3474dacdd02693b051e3addef1c5697 | https://github.com/Qingyang-Xu/GANInversion_with_ConsecutiveImgs/tree/9078a48ec3474dacdd02693b051e3addef1c5697 |
DC | import torch
from torch import nn
import torch.nn.functional
class DC(nn.Module):
def __init__(self, nb_classes):
super(DC, self).__init__()
self.softmax = nn.Softmax(1)
self.nb_classes = nb_classes
@staticmethod
def onehot(gt, shape):
gt = gt.long()
y_onehot = to... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
from torch import nn
i... | ReubenDo/InExtremIS | DC | false | 8,693 | [
"MIT"
] | 17 | 1512ddf9b8c11c4d9f0ebd465d904ef3d539d350 | https://github.com/ReubenDo/InExtremIS/tree/1512ddf9b8c11c4d9f0ebd465d904ef3d539d350 |
ExponentialUpdate | import torch
from torch import Tensor
from torch import nn
from torch.jit import Final
class ExponentialUpdate(nn.Module):
alpha: 'Final[int]'
def __init__(self, alpha: 'float'):
super().__init__()
self.alpha = float(alpha)
def forward(self, x: 'Tensor', state: 'Tensor') ->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 import nn
from torch.jit import Final
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch.... | Rikorose/clc-dns-challenge-2020 | ExponentialUpdate | false | 8,694 | [
"Apache-2.0"
] | 12 | 4f1c078691327a75b3a338fe372ba356b450a6da | https://github.com/Rikorose/clc-dns-challenge-2020/tree/4f1c078691327a75b3a338fe372ba356b450a6da |
Network | import torch
import torch.nn as nn
import torch.nn.functional as F
class Network(nn.Module):
def __init__(self, input_size, number_of_actions):
super(Network, self).__init__()
self.input_size = input_size
self.number_of_actions = number_of_actions
self.full_connection1 = nn.Linear... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | Radu-Raicea/self-driving-car-ai | Network | false | 8,695 | [
"MIT"
] | 16 | cf2b42472f7e78dd3bd530c0c7cd547988a8b0d2 | https://github.com/Radu-Raicea/self-driving-car-ai/tree/cf2b42472f7e78dd3bd530c0c7cd547988a8b0d2 |
GatedPooling1 | import torch
import torch.nn as nn
class GatedPooling1(nn.Module):
"""
Gated pooling as defined in https://arxiv.org/abs/1509.08985
This implementation is the L variant ( entire layer, one parameter )
"""
def __init__(self, kernel_size):
super(GatedPooling1, self).__init__()
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | RicherMans/Dcase2018_pooling | GatedPooling1 | false | 8,696 | [
"Apache-2.0"
] | 13 | 10540502bba7215a1ba157614b39fedecb079d9b | https://github.com/RicherMans/Dcase2018_pooling/tree/10540502bba7215a1ba157614b39fedecb079d9b |
Actor | import torch
import torch.nn as nn
import torch.nn.functional as F
def weight_init(m):
"""Custom weight init for Conv2D and Linear layers."""
if isinstance(m, nn.Linear):
nn.init.orthogonal_(m.weight.data)
m.bias.data.fill_(0.0)
elif isinstance(m, nn.Conv2d) or isinstance(m, nn.ConvTranspo... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | LQNew/LWDRL | Actor | false | 8,697 | [
"MIT"
] | 11 | 0e4fab077a0cfbd27590b840557f4fda033c74ff | https://github.com/LQNew/LWDRL/tree/0e4fab077a0cfbd27590b840557f4fda033c74ff |
Conv2d | import torch
import torch.nn as nn
class Conv2d(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride=1, bn
=False, activation='leakyrelu', dropout=False):
super(Conv2d, self).__init__()
padding = int((kernel_size - 1) / 2)
self.conv = nn.Conv2d(in_channels... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | RQuispeC/pytorch-ACSCP | Conv2d | false | 8,698 | [
"MIT"
] | 25 | c83f08632012c2245250ff9c5140814461db575c | https://github.com/RQuispeC/pytorch-ACSCP/tree/c83f08632012c2245250ff9c5140814461db575c |
GatedPooling | import torch
import torch.nn as nn
class GatedPooling(nn.Module):
"""
Gated pooling as defined in https://arxiv.org/abs/1509.08985
This implementation is the LR variant
"""
def __init__(self, kernel_size, filter):
super(GatedPooling, self).__init__()
self.avgpool = nn.AvgP... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | RicherMans/Dcase2018_pooling | GatedPooling | false | 8,699 | [
"Apache-2.0"
] | 13 | 10540502bba7215a1ba157614b39fedecb079d9b | https://github.com/RicherMans/Dcase2018_pooling/tree/10540502bba7215a1ba157614b39fedecb079d9b |
StaticArchGenerator | import torch
import numpy as np
import torch.nn as nn
import torch.nn.init as weight_init
from torch.nn import Parameter
class ArchSampler(nn.Module):
def __init__(self, distrib_dim, all_same, deter_eval, var_names=None, *
args, **kwargs):
super().__init__()
self.distrib_dim = distrib_dim... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import numpy as np
import torch.nn as nn
import torch.nn.init as weight_init
from torch.nn import Parameter
assert_size_stride = torch._C._d... | RaoefTaki/MNTDP-forked | StaticArchGenerator | false | 8,700 | [
"MIT"
] | 15 | d9ea59a6638f6cdc93eca180ab02672f5bf5d2a1 | https://github.com/RaoefTaki/MNTDP-forked/tree/d9ea59a6638f6cdc93eca180ab02672f5bf5d2a1 |
PMA | import math
import torch
import torch.nn.functional as F
import torch.nn as nn
class MAB(nn.Module):
def __init__(self, dim_X, dim_Y, dim, num_heads=4, ln=False, p=None):
super().__init__()
self.num_heads = num_heads
self.fc_q = nn.Linear(dim_X, dim)
self.fc_k = nn.Linear(dim_Y, d... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | OpenXAIProject/dac | PMA | false | 8,701 | [
"MIT"
] | 17 | 652776e21b56dcb68839363bb077d5c5ea28d81e | https://github.com/OpenXAIProject/dac/tree/652776e21b56dcb68839363bb077d5c5ea28d81e |
GlobalAttention | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
class GlobalAttention(nn.Module):
"""
Global attention takes a matrix and a query vector. It
then computes a parameterized convex combination of the matrix
based on the input query.
Constructs a unit mapping a quer... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | Roc-Ng/HANet | GlobalAttention | false | 8,702 | [
"MIT"
] | 34 | e679703e9e725205424d87f750358fb4f62ceec5 | https://github.com/Roc-Ng/HANet/tree/e679703e9e725205424d87f750358fb4f62ceec5 |
ScoreLayer | import torch
from torchvision.transforms import functional as F
from torch.nn import functional as F
import torch.nn as nn
class ScoreLayer(nn.Module):
def __init__(self, k):
super(ScoreLayer, self).__init__()
self.score = nn.Conv2d(k, 1, 1, 1)
def forward(self, x, x_size=None):
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
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | Res2Net/Res2Net-PoolNet | ScoreLayer | false | 8,703 | [
"MIT"
] | 35 | 7bef0652e83a6c4ebe4ed47f1b03ab5b7b16074a | https://github.com/Res2Net/Res2Net-PoolNet/tree/7bef0652e83a6c4ebe4ed47f1b03ab5b7b16074a |
ISAB | import math
import torch
import torch.nn.functional as F
import torch.nn as nn
class MAB(nn.Module):
def __init__(self, dim_X, dim_Y, dim, num_heads=4, ln=False, p=None):
super().__init__()
self.num_heads = num_heads
self.fc_q = nn.Linear(dim_X, dim)
self.fc_k = nn.Linear(dim_Y, d... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | OpenXAIProject/dac | ISAB | false | 8,704 | [
"MIT"
] | 17 | 652776e21b56dcb68839363bb077d5c5ea28d81e | https://github.com/OpenXAIProject/dac/tree/652776e21b56dcb68839363bb077d5c5ea28d81e |
ExponentialDecay | import torch
from torch import Tensor
from torch import nn
from torch.jit import Final
class ExponentialUpdate(nn.Module):
alpha: 'Final[int]'
def __init__(self, alpha: 'float'):
super().__init__()
self.alpha = float(alpha)
def forward(self, x: 'Tensor', state: 'Tensor') ->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 import Tensor
from torch import nn
from torch.jit import Final
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
em... | Rikorose/clc-dns-challenge-2020 | ExponentialDecay | false | 8,705 | [
"Apache-2.0"
] | 12 | 4f1c078691327a75b3a338fe372ba356b450a6da | https://github.com/Rikorose/clc-dns-challenge-2020/tree/4f1c078691327a75b3a338fe372ba356b450a6da |
LayerNorm | import torch
from typing import Callable
from typing import Tuple
import torch.utils.data
from typing import Union
import torch.nn
import torch.cuda
import torch.backends.cudnn
def batch_elementwise(input: 'torch.Tensor', param: 'torch.Tensor', op:
'Callable[[torch.Tensor, torch.Tensor], torch.Tensor]', input_bat... | 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 typing import Callable
from typing import Tuple
import torch.utils.data
fr... | RobertCsordas/modules | LayerNorm | false | 8,706 | [
"BSD-3-Clause"
] | 22 | efdb8790b074862581e035c9ab5bf889440a8023 | https://github.com/RobertCsordas/modules/tree/efdb8790b074862581e035c9ab5bf889440a8023 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.