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 |
|---|---|---|---|---|---|---|---|---|---|---|
KdLoss | import torch
import torch.nn.functional as F
import torch.utils
import torch.utils.data.distributed
class KdLoss(torch.nn.Module):
def __init__(self, alpha=0.9, T=5):
super(KdLoss, self).__init__()
self.alpha = alpha
self.T = T
self.criterion = torch.nn.KLDivLoss()
def forwar... | 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... | CQUlearningsystemgroup/LearningToBinarize | KdLoss | false | 4,949 | [
"MIT"
] | 1 | 1ecad897145af65ff52323bf2ec64a2154dc87d6 | https://github.com/CQUlearningsystemgroup/LearningToBinarize/tree/1ecad897145af65ff52323bf2ec64a2154dc87d6 |
DistributionLoss | import torch
import torch.nn.functional as F
import torch.utils
import torch.utils.data.distributed
from torch.nn.modules import loss
class DistributionLoss(loss._Loss):
def forward(self, model_output, real_output):
self.size_average = True
if real_output.requires_grad:
raise ValueErr... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | CQUlearningsystemgroup/LearningToBinarize | DistributionLoss | false | 4,950 | [
"MIT"
] | 1 | 1ecad897145af65ff52323bf2ec64a2154dc87d6 | https://github.com/CQUlearningsystemgroup/LearningToBinarize/tree/1ecad897145af65ff52323bf2ec64a2154dc87d6 |
ArcFaceLoss | import math
import torch
from torch import nn
class DenseCrossEntropy(nn.Module):
""" The CrossEntropy loss that takes the one-hot
vector of the gt label as the input, should be equivalent to the
standard CrossEntropy implementation. The one-hot vector
is meant for the ArcFaceLoss and CutMix augmenta... | 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 math... | CTPLab/IID_representation_learning | ArcFaceLoss | false | 4,951 | [
"MIT"
] | 1 | b9dc13536963f9af332b039f7cc772e2f1090c62 | https://github.com/CTPLab/IID_representation_learning/tree/b9dc13536963f9af332b039f7cc772e2f1090c62 |
ShuffleBlock | import torch
import torch.nn as nn
class ShuffleBlock(nn.Module):
def __init__(self, groups=2):
super(ShuffleBlock, self).__init__()
self.groups = groups
def forward(self, x):
"""
Channel shuffle: [N,C,H,W] -> [N,g,C/g,H,W] -> [N,C/g,g,H,w] -> [N,C,H,W]
"""
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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | CYHYCY/cifar10 | ShuffleBlock | false | 4,952 | [
"Apache-2.0"
] | 1 | 37254801045b76604a922884da87744aeb99b416 | https://github.com/CYHYCY/cifar10/tree/37254801045b76604a922884da87744aeb99b416 |
AB | import torch
import torch.nn as nn
import torch._utils
from itertools import product as product
import torch.utils.data.distributed
class AB(nn.Module):
"""
Knowledge Transfer via Distillation of Activation Boundaries Formed by Hidden Neurons
https://arxiv.org/pdf/1811.03233.pdf
"""
def __init__(self, mar... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
import torch._utils
from itertools import product as product
import... | Capetian/FaceX-Zoo | AB | false | 4,953 | [
"Apache-2.0"
] | 1 | 029786c40d8aba15d891d33973de25fcd7e5399a | https://github.com/Capetian/FaceX-Zoo/tree/029786c40d8aba15d891d33973de25fcd7e5399a |
RGAN_D | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import DataLoader as DataLoader
class RGAN_D(nn.Module):
def __init__(self, in_size, hidden_size, num_outcomes):
super(RGAN_D, self).__init__()
self.L1 = nn.Linear(in_size, hidden_size)
self.L2 = nn.L... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | COMP6248-Reproducability-Challenge/Reproducible-Or-Not-Reproducible-That-Is-The-Question | RGAN_D | false | 4,954 | [
"MIT"
] | 1 | 7e2e632189a3669397f67efa99c8de4924967968 | https://github.com/COMP6248-Reproducability-Challenge/Reproducible-Or-Not-Reproducible-That-Is-The-Question/tree/7e2e632189a3669397f67efa99c8de4924967968 |
SE | import torch
import torch.nn as nn
import torch.nn.functional as F
def swish(input):
return input * input.sigmoid()
class SE(nn.Module):
def __init__(self, in_channels, se_channels):
super(SE, self).__init__()
self.se1 = nn.Conv2d(in_channels, se_channels, kernel_size=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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | CYHYCY/cifar10 | SE | false | 4,955 | [
"Apache-2.0"
] | 1 | 37254801045b76604a922884da87744aeb99b416 | https://github.com/CYHYCY/cifar10/tree/37254801045b76604a922884da87744aeb99b416 |
ContrastLoss | import torch
import torch.nn as nn
import torch._utils
from itertools import product as product
import torch.utils.data.distributed
class ContrastLoss(nn.Module):
"""
contrastive loss, corresponding to Eq.(18)
"""
def __init__(self, n_data, eps=1e-07):
super(ContrastLoss, self).__init__()
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 math as tl_math
import torch.nn as nn
import torch._utils
from itertools import product a... | Capetian/FaceX-Zoo | ContrastLoss | false | 4,956 | [
"Apache-2.0"
] | 1 | 029786c40d8aba15d891d33973de25fcd7e5399a | https://github.com/Capetian/FaceX-Zoo/tree/029786c40d8aba15d891d33973de25fcd7e5399a |
GlobalAvgPool2d | import torch
import torch.nn as nn
import torch._utils
from itertools import product as product
import torch.utils.data.distributed
class GlobalAvgPool2d(nn.Module):
def __init__(self):
"""Global average pooling over the input's spatial dimensions"""
super(GlobalAvgPool2d, self).__init__()
d... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
import torch._utils
from itertools import product as product
import torch.utils.data.distributed
assert_size_stride = ... | Capetian/FaceX-Zoo | GlobalAvgPool2d | false | 4,957 | [
"Apache-2.0"
] | 1 | 029786c40d8aba15d891d33973de25fcd7e5399a | https://github.com/Capetian/FaceX-Zoo/tree/029786c40d8aba15d891d33973de25fcd7e5399a |
MaxPool2dStaticSamePadding | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
class MaxPool2dStaticSamePadding(nn.Module):
"""
自定义的padding、最终效果为,高宽减半,通道数不变
"""
def __init__(self, *args, **kwargs):
super().__init__()
self.pool = nn.MaxPool2d(*args, **kwargs)
self.stride = 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... | CYHYCY/EfficientDet | MaxPool2dStaticSamePadding | false | 4,958 | [
"Apache-2.0"
] | 1 | e749c29d31d611250ba63ff4dec443847dc08572 | https://github.com/CYHYCY/EfficientDet/tree/e749c29d31d611250ba63ff4dec443847dc08572 |
AT | import torch
import torch.nn.functional as F
import torch.nn as nn
import torch._utils
from itertools import product as product
import torch.utils.data.distributed
class AT(nn.Module):
"""
Paying More Attention to Attention: Improving the Performance of Convolutional
Neural Netkworks wia Attention Transfer
htt... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import torch.nn as nn
import torch._utils
from itertools impor... | Capetian/FaceX-Zoo | AT | false | 4,959 | [
"Apache-2.0"
] | 1 | 029786c40d8aba15d891d33973de25fcd7e5399a | https://github.com/Capetian/FaceX-Zoo/tree/029786c40d8aba15d891d33973de25fcd7e5399a |
FSP | import torch
import torch.nn.functional as F
import torch.nn as nn
import torch._utils
from itertools import product as product
import torch.utils.data.distributed
class FSP(nn.Module):
"""
A Gift from Knowledge Distillation: Fast Optimization, Network Minimization and Transfer Learning
http://openaccess.thecvf... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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.functional as F
import torch.nn as nn
import torch._utils
from i... | Capetian/FaceX-Zoo | FSP | false | 4,960 | [
"Apache-2.0"
] | 1 | 029786c40d8aba15d891d33973de25fcd7e5399a | https://github.com/Capetian/FaceX-Zoo/tree/029786c40d8aba15d891d33973de25fcd7e5399a |
FT | import torch
import torch.nn.functional as F
import torch.nn as nn
import torch._utils
from itertools import product as product
import torch.utils.data.distributed
class FT(nn.Module):
"""
araphrasing Complex Network: Network Compression via Factor Transfer
http://papers.nips.cc/paper/7541-paraphrasing-complex-... | 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... | Capetian/FaceX-Zoo | FT | false | 4,961 | [
"Apache-2.0"
] | 1 | 029786c40d8aba15d891d33973de25fcd7e5399a | https://github.com/Capetian/FaceX-Zoo/tree/029786c40d8aba15d891d33973de25fcd7e5399a |
CC | import math
import torch
import torch.nn.functional as F
import torch.nn as nn
import torch._utils
from itertools import product as product
import torch.utils.data.distributed
class CC(nn.Module):
"""
Correlation Congruence for Knowledge Distillation
http://openaccess.thecvf.com/content_ICCV_2019/papers/
Peng_... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | Capetian/FaceX-Zoo | CC | false | 4,962 | [
"Apache-2.0"
] | 1 | 029786c40d8aba15d891d33973de25fcd7e5399a | https://github.com/Capetian/FaceX-Zoo/tree/029786c40d8aba15d891d33973de25fcd7e5399a |
Logits | import torch
import torch.nn.functional as F
import torch.nn as nn
import torch._utils
from itertools import product as product
import torch.utils.data.distributed
class Logits(nn.Module):
"""
Do Deep Nets Really Need to be Deep?
http://papers.nips.cc/paper/5484-do-deep-nets-really-need-to-be-deep.pdf
"""
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
import torch._utils
from itertools import product as product
import... | Capetian/FaceX-Zoo | Logits | false | 4,963 | [
"Apache-2.0"
] | 1 | 029786c40d8aba15d891d33973de25fcd7e5399a | https://github.com/Capetian/FaceX-Zoo/tree/029786c40d8aba15d891d33973de25fcd7e5399a |
Recover_from_density | import torch
import torch.nn as nn
class Recover_from_density(nn.Module):
def __init__(self, upscale_factor):
super(Recover_from_density, self).__init__()
self.upscale_factor = upscale_factor
self.upsample = nn.Upsample(scale_factor=upscale_factor, mode='nearest'
)
def fo... | 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... | CastleLiang/UrbanFM | Recover_from_density | false | 4,964 | [
"MIT"
] | 1 | fb3aff0828099bff31032dc26748d758113af892 | https://github.com/CastleLiang/UrbanFM/tree/fb3aff0828099bff31032dc26748d758113af892 |
Embed | import torch
import torch.nn.functional as F
import torch.nn as nn
import torch._utils
from itertools import product as product
import torch.utils.data.distributed
class Embed(nn.Module):
def __init__(self, in_dim, out_dim):
super(Embed, self).__init__()
self.linear = nn.Linear(in_dim, out_dim)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | Capetian/FaceX-Zoo | Embed | false | 4,965 | [
"Apache-2.0"
] | 1 | 029786c40d8aba15d891d33973de25fcd7e5399a | https://github.com/Capetian/FaceX-Zoo/tree/029786c40d8aba15d891d33973de25fcd7e5399a |
DistillationLoss | import torch
import torch.nn.functional as F
import torch.utils
import torch.utils.data.distributed
from torch.nn.modules import loss
class DistributionLoss(loss._Loss):
def forward(self, model_output, real_output):
self.size_average = True
if real_output.requires_grad:
raise ValueErr... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | CQUlearningsystemgroup/LearningToBinarize | DistillationLoss | false | 4,966 | [
"MIT"
] | 1 | 1ecad897145af65ff52323bf2ec64a2154dc87d6 | https://github.com/CQUlearningsystemgroup/LearningToBinarize/tree/1ecad897145af65ff52323bf2ec64a2154dc87d6 |
SP | import torch
import torch.nn.functional as F
import torch.nn as nn
import torch._utils
from itertools import product as product
import torch.utils.data.distributed
class SP(nn.Module):
"""
Similarity-Preserving Knowledge Distillation
https://arxiv.org/pdf/1907.09682.pdf
"""
def __init__(self):
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.... | Capetian/FaceX-Zoo | SP | false | 4,967 | [
"Apache-2.0"
] | 1 | 029786c40d8aba15d891d33973de25fcd7e5399a | https://github.com/Capetian/FaceX-Zoo/tree/029786c40d8aba15d891d33973de25fcd7e5399a |
DML | import torch
import torch.nn.functional as F
import torch.nn as nn
import torch._utils
from itertools import product as product
import torch.utils.data.distributed
class DML(nn.Module):
"""
Deep Mutual Learning
https://zpascal.net/cvpr2018/Zhang_Deep_Mutual_Learning_CVPR_2018_paper.pdf
"""
def __init__(se... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import torc... | Capetian/FaceX-Zoo | DML | false | 4,968 | [
"Apache-2.0"
] | 1 | 029786c40d8aba15d891d33973de25fcd7e5399a | https://github.com/Capetian/FaceX-Zoo/tree/029786c40d8aba15d891d33973de25fcd7e5399a |
act_PR | import torch
import torch.nn as nn
import torch.utils.model_zoo
class act_PR(nn.Module):
def __init__(self, affine=True):
super(act_PR, self).__init__()
self.prelu = nn.PReLU(num_parameters=1)
self.relu = nn.ReLU(inplace=False)
def forward(self, x):
out = (self.relu(x) + 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
import torch.utils.model_zoo
assert_size_stride = torch._C._dynamo.... | Cheeun/FDSR | act_PR | false | 4,969 | [
"MIT"
] | 1 | 28b1c3c102334c5336038d0a0f6e1fceb393659a | https://github.com/Cheeun/FDSR/tree/28b1c3c102334c5336038d0a0f6e1fceb393659a |
NST | import torch
import torch.nn.functional as F
import torch.nn as nn
import torch._utils
from itertools import product as product
import torch.utils.data.distributed
class NST(nn.Module):
"""
Like What You Like: Knowledge Distill via Neuron Selectivity Transfer
https://arxiv.org/pdf/1707.01219.pdf
"""
def _... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
import... | Capetian/FaceX-Zoo | NST | false | 4,970 | [
"Apache-2.0"
] | 1 | 029786c40d8aba15d891d33973de25fcd7e5399a | https://github.com/Capetian/FaceX-Zoo/tree/029786c40d8aba15d891d33973de25fcd7e5399a |
SoftTarget | import torch
import torch.nn.functional as F
import torch.nn as nn
import torch._utils
from itertools import product as product
import torch.utils.data.distributed
class SoftTarget(nn.Module):
"""
Distilling the Knowledge in a Neural Network
https://arxiv.org/pdf/1503.02531.pdf
"""
def __init__(self, T):
... | 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... | Capetian/FaceX-Zoo | SoftTarget | false | 4,971 | [
"Apache-2.0"
] | 1 | 029786c40d8aba15d891d33973de25fcd7e5399a | https://github.com/Capetian/FaceX-Zoo/tree/029786c40d8aba15d891d33973de25fcd7e5399a |
BSS | import torch
import torch.nn.functional as F
import torch.nn as nn
import torch._utils
from itertools import product as product
import torch.utils.data.distributed
class BSS(nn.Module):
"""
Knowledge Distillation with Adversarial Samples Supporting Decision Boundary
https://arxiv.org/pdf/1805.05532.pdf
"""
... | 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... | Capetian/FaceX-Zoo | BSS | false | 4,972 | [
"Apache-2.0"
] | 1 | 029786c40d8aba15d891d33973de25fcd7e5399a | https://github.com/Capetian/FaceX-Zoo/tree/029786c40d8aba15d891d33973de25fcd7e5399a |
GradualNoiseBlock | from torch.nn import Module
import torch
from torch import nn
class GradualNoiseBlock(Module):
def __init__(self, in_c, out_c, stride, affine):
super(GradualNoiseBlock, self).__init__()
self.conv = nn.Conv2d(in_c, out_c, kernel_size=3, stride=stride,
padding=1, bias=False)
sel... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
from torch.nn impor... | CTPLab/IID_representation_learning | GradualNoiseBlock | false | 4,973 | [
"MIT"
] | 1 | b9dc13536963f9af332b039f7cc772e2f1090c62 | https://github.com/CTPLab/IID_representation_learning/tree/b9dc13536963f9af332b039f7cc772e2f1090c62 |
act_RT | import torch
import torch.nn as nn
import torch.utils.model_zoo
class act_RT(nn.Module):
def __init__(self, affine=True):
super(act_RT, self).__init__()
self.relu = nn.ReLU(inplace=False)
self.tanh = nn.Tanh()
def forward(self, x):
out = (self.relu(x) + self.tanh(x)) / 2
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
import... | Cheeun/FDSR | act_RT | false | 4,974 | [
"MIT"
] | 1 | 28b1c3c102334c5336038d0a0f6e1fceb393659a | https://github.com/Cheeun/FDSR/tree/28b1c3c102334c5336038d0a0f6e1fceb393659a |
MV_Softmax | from torch.nn import Module
import math
import torch
from torch.nn import Parameter
import torch.nn.functional as F
import torch._utils
from itertools import product as product
import torch.utils.data.distributed
class MV_Softmax(Module):
"""Implementation for "Mis-classified Vector Guided Softmax Loss for Face R... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | Capetian/FaceX-Zoo | MV_Softmax | false | 4,975 | [
"Apache-2.0"
] | 1 | 029786c40d8aba15d891d33973de25fcd7e5399a | https://github.com/Capetian/FaceX-Zoo/tree/029786c40d8aba15d891d33973de25fcd7e5399a |
DistMultLayer | import torch
import torch.utils.data
import torch.nn as nn
class DistMultLayer(nn.Module):
def __init__(self):
super(DistMultLayer, self).__init__()
def forward(self, sub_emb, obj_emb, rel_emb):
return torch.sum(sub_emb * obj_emb * rel_emb, dim=-1)
def predict(self, sub_emb, obj_emb, re... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.utils.data
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C.... | ChengzhiPiao/cogdl | DistMultLayer | false | 4,976 | [
"MIT"
] | 1 | 182e0b95b3dfbe771570037c58aacd8f677b6500 | https://github.com/ChengzhiPiao/cogdl/tree/182e0b95b3dfbe771570037c58aacd8f677b6500 |
PKTCosSim | import torch
import torch.nn as nn
import torch._utils
from itertools import product as product
import torch.utils.data.distributed
class PKTCosSim(nn.Module):
"""
Learning Deep Representations with Probabilistic Knowledge Transfer
http://openaccess.thecvf.com/content_ECCV_2018/papers/Nikolaos_Passalis_Learning... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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... | Capetian/FaceX-Zoo | PKTCosSim | false | 4,977 | [
"Apache-2.0"
] | 1 | 029786c40d8aba15d891d33973de25fcd7e5399a | https://github.com/Capetian/FaceX-Zoo/tree/029786c40d8aba15d891d33973de25fcd7e5399a |
act_PT | import torch
import torch.nn as nn
import torch.utils.model_zoo
class act_PT(nn.Module):
def __init__(self, affine=True):
super(act_PT, self).__init__()
self.prelu = nn.PReLU(num_parameters=1)
self.tanh = nn.Tanh()
def forward(self, x):
out = (self.prelu(x) + self.tanh(x)) / ... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
import torch.utils.model_zoo
assert_size_stride = torch._... | Cheeun/FDSR | act_PT | false | 4,978 | [
"MIT"
] | 1 | 28b1c3c102334c5336038d0a0f6e1fceb393659a | https://github.com/Cheeun/FDSR/tree/28b1c3c102334c5336038d0a0f6e1fceb393659a |
rSoftMax | import torch
import torch.nn.functional as F
import torch.nn as nn
import torch._utils
from itertools import product as product
import torch.utils.data.distributed
class rSoftMax(nn.Module):
def __init__(self, radix, cardinality):
super().__init__()
self.radix = radix
self.cardinality = c... | 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
... | Capetian/FaceX-Zoo | rSoftMax | false | 4,979 | [
"Apache-2.0"
] | 1 | 029786c40d8aba15d891d33973de25fcd7e5399a | https://github.com/Capetian/FaceX-Zoo/tree/029786c40d8aba15d891d33973de25fcd7e5399a |
NodeAdaptiveEncoder | import torch
import torch.utils.data
import torch.nn as nn
import torch.nn.functional as F
class NodeAdaptiveEncoder(nn.Module):
def __init__(self, num_features, dropout=0.5):
super(NodeAdaptiveEncoder, self).__init__()
self.fc = nn.Parameter(torch.zeros(size=(num_features, 1)))
nn.init.x... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.utils.data
import torch.nn as nn
assert_size_stride = torch._C._dyn... | ChengzhiPiao/cogdl | NodeAdaptiveEncoder | false | 4,980 | [
"MIT"
] | 1 | 182e0b95b3dfbe771570037c58aacd8f677b6500 | https://github.com/ChengzhiPiao/cogdl/tree/182e0b95b3dfbe771570037c58aacd8f677b6500 |
GLU | import torch
import torch.nn as nn
class GLU(nn.Module):
"""
The gating mechanism is called Gated Linear Units (GLU), which was first introduced for natural language processing
in the paper “Language Modeling with Gated Convolutional Networks”
"""
def __init__(self, dim: 'int') ->None:
su... | 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... | CherokeeLanguage/Comprehensive-Transformer-TTS | GLU | false | 4,981 | [
"MIT"
] | 1 | 2d97e7125d4e7b4e02950687dfbb6f14e7a1d531 | https://github.com/CherokeeLanguage/Comprehensive-Transformer-TTS/tree/2d97e7125d4e7b4e02950687dfbb6f14e7a1d531 |
SEModule | import torch
import torch.nn as nn
import torch.nn.functional as F
class SEModule(nn.Module):
def __init__(self, channels, reduction):
super(SEModule, self).__init__()
self.fc1 = nn.Conv2d(channels, channels // reduction, kernel_size=1,
padding=0)
self.fc2 = nn.Conv2d(channels... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | Chaucergit/iNaturalist2019 | SEModule | false | 4,982 | [
"MIT"
] | 1 | 17ae07c959fd5edf5f4a9b93ef8c21e434fadbf8 | https://github.com/Chaucergit/iNaturalist2019/tree/17ae07c959fd5edf5f4a9b93ef8c21e434fadbf8 |
Classifier | import torch
import torch.utils.data
import torch.nn as nn
class Classifier(nn.Module):
def __init__(self, n_hid, n_out):
super(Classifier, self).__init__()
self.n_hid = n_hid
self.n_out = n_out
self.linear = nn.Linear(n_hid, n_out)
def forward(self, x):
tx = self.lin... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | ChengzhiPiao/cogdl | Classifier | false | 4,983 | [
"MIT"
] | 1 | 182e0b95b3dfbe771570037c58aacd8f677b6500 | https://github.com/ChengzhiPiao/cogdl/tree/182e0b95b3dfbe771570037c58aacd8f677b6500 |
act_PRT | import torch
import torch.nn as nn
import torch.utils.model_zoo
class act_PRT(nn.Module):
def __init__(self, affine=True):
super(act_PRT, self).__init__()
self.relu = nn.ReLU(inplace=False)
self.prelu = nn.PReLU(num_parameters=1)
self.tanh = nn.Tanh()
def forward(self, x):
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
import... | Cheeun/FDSR | act_PRT | false | 4,984 | [
"MIT"
] | 1 | 28b1c3c102334c5336038d0a0f6e1fceb393659a | https://github.com/Cheeun/FDSR/tree/28b1c3c102334c5336038d0a0f6e1fceb393659a |
GELU_ | import math
import torch
import torch.nn as nn
class GELU_(nn.Module):
def forward(self, x):
return 0.5 * x * (1 + torch.tanh(math.sqrt(2 / math.pi) * (x +
0.044715 * torch.pow(x, 3))))
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_... | CherokeeLanguage/Comprehensive-Transformer-TTS | GELU_ | false | 4,985 | [
"MIT"
] | 1 | 2d97e7125d4e7b4e02950687dfbb6f14e7a1d531 | https://github.com/CherokeeLanguage/Comprehensive-Transformer-TTS/tree/2d97e7125d4e7b4e02950687dfbb6f14e7a1d531 |
Intensity_Loss | import torch
import torch.nn as nn
import torch.nn.functional
import torch.nn
class Intensity_Loss(nn.Module):
def __init__(self):
super().__init__()
def forward(self, gen_frames, gt_frames):
return torch.mean(torch.abs((gen_frames - gt_frames) ** 2))
def get_inputs():
return [torch.ra... | 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
... | ChmarsLuo/Hero_anomaly_prediction | Intensity_Loss | false | 4,986 | [
"Apache-2.0"
] | 1 | dba2322dabb3476466e296db6c316fc08e0cb11d | https://github.com/ChmarsLuo/Hero_anomaly_prediction/tree/dba2322dabb3476466e296db6c316fc08e0cb11d |
BCEFocalLoss | import torch
import torch.nn as nn
class BCEFocalLoss(nn.Module):
def __init__(self, gamma=2, alpha=None, reduction='elementwise_mean'):
super().__init__()
self.gamma = gamma
self.alpha = alpha
self.reduction = reduction
def forward(self, _input, target):
pt = torch.s... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
... | Chizuchizu/riadd | BCEFocalLoss | false | 4,987 | [
"MIT"
] | 1 | c3f55aebc0f582d9fa55dc517b1489963cf0506f | https://github.com/Chizuchizu/riadd/tree/c3f55aebc0f582d9fa55dc517b1489963cf0506f |
SqueezeExcite | import torch
import torch.nn.functional as F
import torch.nn as nn
import torch._utils
from itertools import product as product
import torch.utils.data.distributed
def _make_divisible(v, divisor, min_value=None):
"""
This function is taken from the original tf repo.
It ensures that all layers have a 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 import triton_helpers
import torch.nn.functional as... | Capetian/FaceX-Zoo | SqueezeExcite | false | 4,988 | [
"Apache-2.0"
] | 1 | 029786c40d8aba15d891d33973de25fcd7e5399a | https://github.com/Capetian/FaceX-Zoo/tree/029786c40d8aba15d891d33973de25fcd7e5399a |
TaylorSoftmax | import torch
import torch.nn as nn
class TaylorSoftmax(nn.Module):
"""
This is the autograd version
"""
def __init__(self, dim=1, n=2):
super(TaylorSoftmax, self).__init__()
assert n % 2 == 0
self.dim = dim
self.n = n
def forward(self, x):
"""
usag... | 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... | Chizuchizu/riadd | TaylorSoftmax | false | 4,989 | [
"MIT"
] | 1 | c3f55aebc0f582d9fa55dc517b1489963cf0506f | https://github.com/Chizuchizu/riadd/tree/c3f55aebc0f582d9fa55dc517b1489963cf0506f |
Adversarial_Loss | import torch
import torch.nn as nn
import torch.nn.functional
import torch.nn
class Adversarial_Loss(nn.Module):
def __init__(self):
super().__init__()
def forward(self, fake_outputs):
return torch.mean((fake_outputs - 1) ** 2 / 2)
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._inductor.runtime import triton_helpers
import torch.nn as nn
import torch.nn.functional
import torch.nn
assert_size_stride = tor... | ChmarsLuo/Hero_anomaly_prediction | Adversarial_Loss | false | 4,990 | [
"Apache-2.0"
] | 1 | dba2322dabb3476466e296db6c316fc08e0cb11d | https://github.com/ChmarsLuo/Hero_anomaly_prediction/tree/dba2322dabb3476466e296db6c316fc08e0cb11d |
ScaleNorm | import torch
import torch.nn as nn
class ScaleNorm(nn.Module):
def __init__(self, dim, eps=1e-05):
super().__init__()
self.g = nn.Parameter(torch.ones(1))
self.eps = eps
def forward(self, x):
n = torch.norm(x, dim=-1, keepdim=True).clamp(min=self.eps)
return x / n * s... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
assert... | CherokeeLanguage/Comprehensive-Transformer-TTS | ScaleNorm | false | 4,991 | [
"MIT"
] | 1 | 2d97e7125d4e7b4e02950687dfbb6f14e7a1d531 | https://github.com/CherokeeLanguage/Comprehensive-Transformer-TTS/tree/2d97e7125d4e7b4e02950687dfbb6f14e7a1d531 |
Discriminate_Loss | import torch
import torch.nn as nn
import torch.nn.functional
import torch.nn
class Discriminate_Loss(nn.Module):
def __init__(self):
super().__init__()
def forward(self, real_outputs, fake_outputs):
return torch.mean((real_outputs - 1) ** 2 / 2) + torch.mean(
fake_outputs ** 2 /... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
import torch.nn.functional
import torch.nn
assert_size_stride = tor... | ChmarsLuo/Hero_anomaly_prediction | Discriminate_Loss | false | 4,992 | [
"Apache-2.0"
] | 1 | dba2322dabb3476466e296db6c316fc08e0cb11d | https://github.com/ChmarsLuo/Hero_anomaly_prediction/tree/dba2322dabb3476466e296db6c316fc08e0cb11d |
GELU | import torch
from torch import nn
class GELU(nn.Module):
def forward(self, x):
return nn.functional.gelu(x)
def get_inputs():
return [torch.rand([4, 4, 4, 4])]
def get_init_inputs():
return [[], {}]
| import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | Chris210634/ReBeL | GELU | false | 4,993 | [
"Apache-2.0"
] | 1 | 78182e4d9636a9ea7ebcce386768f21c17eb0675 | https://github.com/Chris210634/ReBeL/tree/78182e4d9636a9ea7ebcce386768f21c17eb0675 |
EncoderImagePrecomp | import torch
import numpy as np
from collections import OrderedDict
import torch.nn as nn
import torch.nn.init
def l2norm(X, dim, eps=1e-08):
"""L2-normalize columns of X
"""
norm = torch.pow(X, 2).sum(dim=dim, keepdim=True).sqrt() + eps
X = torch.div(X, norm)
return X
class EncoderImagePrecomp(... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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
... | ChopinSharp/SCAN | EncoderImagePrecomp | false | 4,994 | [
"Apache-2.0"
] | 1 | 4a165b2aeb3007685054d0c550540893b2006b17 | https://github.com/ChopinSharp/SCAN/tree/4a165b2aeb3007685054d0c550540893b2006b17 |
GeM | import torch
import torch.nn as nn
from torch.nn import functional as F
from torch.nn.parameter import Parameter
def gem(x, p=3, eps=1e-06):
return F.avg_pool2d(x.clamp(min=eps).pow(p), (x.size(-2), x.size(-1))).pow(
1.0 / p)
class GeM(nn.Module):
def __init__(self, p=3, eps=1e-06):
super(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
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
from t... | Chizuchizu/riadd | GeM | false | 4,995 | [
"MIT"
] | 1 | c3f55aebc0f582d9fa55dc517b1489963cf0506f | https://github.com/Chizuchizu/riadd/tree/c3f55aebc0f582d9fa55dc517b1489963cf0506f |
EncoderImageWeightNormPrecomp | import torch
from collections import OrderedDict
import torch.nn as nn
import torch.nn.init
from torch.nn.utils.weight_norm import weight_norm
def l2norm(X, dim, eps=1e-08):
"""L2-normalize columns of X
"""
norm = torch.pow(X, 2).sum(dim=dim, keepdim=True).sqrt() + eps
X = torch.div(X, norm)
retur... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 collections im... | ChopinSharp/SCAN | EncoderImageWeightNormPrecomp | false | 4,996 | [
"Apache-2.0"
] | 1 | 4a165b2aeb3007685054d0c550540893b2006b17 | https://github.com/ChopinSharp/SCAN/tree/4a165b2aeb3007685054d0c550540893b2006b17 |
InstanceNorm1d | import torch
from torch import nn
class InstanceNorm1d(nn.Module):
"""
Implementation of instance normalization for a 2D tensor of shape (batch size, features)
"""
def __init__(self) ->None:
super(InstanceNorm1d, self).__init__()
def forward(self, input: 'torch.Tensor') ->torch.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.triton_helpers import libdevice
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | ChristophReich1996/3D_Baggage_Segmentation | InstanceNorm1d | false | 4,997 | [
"MIT"
] | 1 | 00392cb0fde22d3180b6baf81e404d0fcf4e2ebf | https://github.com/ChristophReich1996/3D_Baggage_Segmentation/tree/00392cb0fde22d3180b6baf81e404d0fcf4e2ebf |
LabelSmoothingLoss | import torch
import torch.nn as nn
class LabelSmoothingLoss(nn.Module):
def __init__(self, classes=5, smoothing=0.0, dim=-1):
super(LabelSmoothingLoss, self).__init__()
self.confidence = 1.0 - smoothing
self.smoothing = smoothing
self.cls = classes
self.dim = dim
def ... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
... | Chizuchizu/riadd | LabelSmoothingLoss | false | 4,998 | [
"MIT"
] | 1 | c3f55aebc0f582d9fa55dc517b1489963cf0506f | https://github.com/Chizuchizu/riadd/tree/c3f55aebc0f582d9fa55dc517b1489963cf0506f |
Critic | import torch
import torch.nn as nn
import torch.nn.functional as F
class Critic(nn.Module):
def __init__(self, state_dim, action_dim):
super(Critic, self).__init__()
self.fc1 = nn.Linear(state_dim + action_dim, 400)
self.fc2 = nn.Linear(400, 300)
self.fc3 = nn.Linear(300, 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_... | Chris0919/Deep-reinforcement-learning-with-pytorch | Critic | false | 4,999 | [
"MIT"
] | 1 | a4f458dde7659654fcae4635d25f6bd05a5d2d6c | https://github.com/Chris0919/Deep-reinforcement-learning-with-pytorch/tree/a4f458dde7659654fcae4635d25f6bd05a5d2d6c |
Actor | import torch
import torch.nn as nn
import torch.nn.functional as F
class Actor(nn.Module):
def __init__(self, state_dim, action_dim, max_action):
super(Actor, self).__init__()
self.fc1 = nn.Linear(state_dim, 400)
self.fc2 = nn.Linear(400, 300)
self.fc3 = nn.Linear(300, action_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.... | Chris0919/Deep-reinforcement-learning-with-pytorch | Actor | false | 5,000 | [
"MIT"
] | 1 | a4f458dde7659654fcae4635d25f6bd05a5d2d6c | https://github.com/Chris0919/Deep-reinforcement-learning-with-pytorch/tree/a4f458dde7659654fcae4635d25f6bd05a5d2d6c |
Attention | import torch
import torch.optim
import torch.utils.data
from torch import nn
import torch
class Attention(nn.Module):
"""
Attention Network.
"""
def __init__(self, encoder_dim, decoder_dim, attention_dim):
"""
:param encoder_dim: feature size of encoded images
:param decoder_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.... | ChoiIseungil/vilbert-multi-task | Attention | false | 5,001 | [
"MIT"
] | 1 | 37d14b9aed9c48117a820e05157c7ccd3dd20d5b | https://github.com/ChoiIseungil/vilbert-multi-task/tree/37d14b9aed9c48117a820e05157c7ccd3dd20d5b |
FocalLoss | import torch
from torch import nn
import torch.nn.functional as F
class FocalLoss(nn.Module):
"""
Implementation of the binary focal loss proposed in:
https://arxiv.org/abs/1708.02002
"""
def __init__(self, alpha: 'float'=1.0, gamma: 'float'=2.0, reduce:
'str'='mean') ->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, math as tl_math
from torch ... | ChristophReich1996/3D_Baggage_Segmentation | FocalLoss | false | 5,002 | [
"MIT"
] | 1 | 00392cb0fde22d3180b6baf81e404d0fcf4e2ebf | https://github.com/ChristophReich1996/3D_Baggage_Segmentation/tree/00392cb0fde22d3180b6baf81e404d0fcf4e2ebf |
IOUloss | import torch
import torch.nn as nn
class IOUloss(nn.Module):
def __init__(self, reduction='none', loss_type='iou'):
super(IOUloss, self).__init__()
self.reduction = reduction
self.loss_type = loss_type
def forward(self, pred, target):
assert pred.shape[0] == target.shape[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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
emp... | Chris-hughes10/YOLOX | IOUloss | false | 5,003 | [
"Apache-2.0"
] | 1 | 981df30285839469a23cb925ed0a0f3714e46514 | https://github.com/Chris-hughes10/YOLOX/tree/981df30285839469a23cb925ed0a0f3714e46514 |
DiceLoss | import torch
from torch import nn
class DiceLoss(nn.Module):
"""
Implementation of the dice loss proposed in:
https://arxiv.org/abs/1707.03237
"""
def __init__(self, smooth: 'float'=1.0) ->None:
"""
Constructor method
:param smooth: (float) Smoothness factor used in comput... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empt... | ChristophReich1996/3D_Baggage_Segmentation | DiceLoss | false | 5,004 | [
"MIT"
] | 1 | 00392cb0fde22d3180b6baf81e404d0fcf4e2ebf | https://github.com/ChristophReich1996/3D_Baggage_Segmentation/tree/00392cb0fde22d3180b6baf81e404d0fcf4e2ebf |
FastAttention | import torch
import torch.nn as nn
class FastAttention(nn.Module):
""" wuch15's Fastformer Attention module (Official) """
def __init__(self, dim, dim_head, heads, dropout=0.1, initializer_range
=0.02):
super(FastAttention, self).__init__()
self.initializer_range = initializer_range
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | CherokeeLanguage/Comprehensive-Transformer-TTS | FastAttention | false | 5,005 | [
"MIT"
] | 1 | 2d97e7125d4e7b4e02950687dfbb6f14e7a1d531 | https://github.com/CherokeeLanguage/Comprehensive-Transformer-TTS/tree/2d97e7125d4e7b4e02950687dfbb6f14e7a1d531 |
NpairLoss | import torch
import torch.nn as nn
import torch.nn.functional as F
def cross_entropy(logits, target, size_average=True):
if size_average:
return torch.mean(torch.sum(-target * F.log_softmax(logits, -1), -1))
else:
return torch.sum(torch.sum(-target * F.log_softmax(logits, -1), -1))
class Npa... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | Chilydream/SyncNet | NpairLoss | false | 5,006 | [
"MIT"
] | 1 | 8555fe13364a5ecf32fbc0eb72a733c35e256da2 | https://github.com/Chilydream/SyncNet/tree/8555fe13364a5ecf32fbc0eb72a733c35e256da2 |
SigmoidFocalClassificationLoss | import torch
import torch.nn as nn
class SigmoidFocalClassificationLoss(nn.Module):
"""
Sigmoid focal cross entropy loss.
"""
def __init__(self, gamma: 'float'=2.0, alpha: 'float'=0.25):
"""
Args:
gamma: Weighting parameter to balance loss for hard and easy examples.
... | 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... | Chuxwa/OpenPCDet | SigmoidFocalClassificationLoss | false | 5,007 | [
"Apache-2.0"
] | 1 | be064eafee68cb23f4bbe7decf2286ef13a94ebb | https://github.com/Chuxwa/OpenPCDet/tree/be064eafee68cb23f4bbe7decf2286ef13a94ebb |
SEModule | import torch
import torch.nn as nn
class SEModule(nn.Module):
def __init__(self, channels, reduction):
super(SEModule, self).__init__()
self.avg_pool = nn.AdaptiveAvgPool2d(1)
self.fc1 = nn.Conv2d(channels, channels // reduction, kernel_size=1,
padding=0)
self.relu = n... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | ChrisLiu007/Pytorch-Code-Template | SEModule | false | 5,008 | [
"MIT"
] | 1 | 25eae3ffe43f60a4f7e06651e3a3cd5d0b69b9ae | https://github.com/ChrisLiu007/Pytorch-Code-Template/tree/25eae3ffe43f60a4f7e06651e3a3cd5d0b69b9ae |
CrossEntropyLossOneHot | import torch
from torch import nn
class CrossEntropyLossOneHot(nn.Module):
def __init__(self):
super(CrossEntropyLossOneHot, self).__init__()
self.soft_max = nn.LogSoftmax(dim=-1)
self.nll_loss = nn.NLLLoss()
def forward(self, preds, labels):
"""
preds: [batch_size, l... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
from torch import nn
a... | ChrisZhangcx/reproduce_elliptic | CrossEntropyLossOneHot | false | 5,009 | [
"MIT"
] | 1 | b5297456376aa944c9b17bb2394407ec482e1bb2 | https://github.com/ChrisZhangcx/reproduce_elliptic/tree/b5297456376aa944c9b17bb2394407ec482e1bb2 |
WeightedCrossEntropyLoss | import torch
import torch.nn as nn
import torch.nn.functional as F
class WeightedCrossEntropyLoss(nn.Module):
"""
Transform input to fit the fomation of PyTorch offical cross entropy loss
with anchor-wise weighting.
"""
def __init__(self):
super(WeightedCrossEntropyLoss, self).__init__()
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
... | Chuxwa/OpenPCDet | WeightedCrossEntropyLoss | false | 5,010 | [
"Apache-2.0"
] | 1 | be064eafee68cb23f4bbe7decf2286ef13a94ebb | https://github.com/Chuxwa/OpenPCDet/tree/be064eafee68cb23f4bbe7decf2286ef13a94ebb |
GCN | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import Parameter
from torch.nn.parameter import Parameter
class GraphConvolution(nn.Module):
def __init__(self, in_feature, out_feature, bias=True):
super(GraphConvolution, self).__init__()
self.in_featur... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | CogNLP/CogKGE | GCN | false | 5,011 | [
"MIT"
] | 1 | 70d851d6489600c1e90eb25b0388a3ceba2f078c | https://github.com/CogNLP/CogKGE/tree/70d851d6489600c1e90eb25b0388a3ceba2f078c |
CharbonnierPenalty | import torch
import torch.utils.data
import torch.nn as nn
class CharbonnierPenalty(nn.Module):
def __init__(self, n=0.001, total_variation=False, lam=1e-06, per_pixel
=False):
super().__init__()
self.n = n
self.total_variation = total_variation
self.lam = lam
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
from torch._inductor.runtime.triton_helpers import libdevice
import torch.utils.data
impo... | ChristinaRunkel/HighSpeedImaging | CharbonnierPenalty | false | 5,012 | [
"MIT"
] | 1 | 392437e6c1f4b125fc4771c98b16c85155684d09 | https://github.com/ChristinaRunkel/HighSpeedImaging/tree/392437e6c1f4b125fc4771c98b16c85155684d09 |
EncoderDecoder | import torch
import torch.nn as nn
import torch.nn.functional as F
class EncoderDecoder(nn.Module):
def __init__(self):
super(EncoderDecoder, self).__init__()
def forward(self, x):
_b, _c, h, w = x.shape
x = F.adaptive_max_pool2d(x, (h // 2, w // 2))
x = F.interpolate(x, 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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
emp... | ClementPla/VisionTransformerForOphtalmicImages | EncoderDecoder | false | 5,013 | [
"MIT"
] | 1 | b99fd6c9ec076d94c8e2cd9302178888b8b50d17 | https://github.com/ClementPla/VisionTransformerForOphtalmicImages/tree/b99fd6c9ec076d94c8e2cd9302178888b8b50d17 |
MultiLabelSoftBinaryCrossEntropy | import random
import torch
import torch.nn as nn
from random import random
import random
class MultiLabelSoftBinaryCrossEntropy(nn.Module):
def __init__(self, smooth_factor: 'float'=0, weighted: 'bool'=True, mcb:
'bool'=False, hp_lambda: 'int'=10, epsilon: 'float'=0.1, logits=
True, first_class_b... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import torc... | ClementPla/Retinal-Lesions-Segmentation | MultiLabelSoftBinaryCrossEntropy | false | 5,014 | [
"MIT"
] | 1 | 20fa4ac8eae24814470095bb6e7f08d6751c4e11 | https://github.com/ClementPla/Retinal-Lesions-Segmentation/tree/20fa4ac8eae24814470095bb6e7f08d6751c4e11 |
Critic | import torch
import torch.nn as nn
class Critic(nn.Module):
def __init__(self, state_dim, action_dim):
super(Critic, self).__init__()
n_layer = 30
self.layer_1 = nn.Linear(state_dim, n_layer)
nn.init.normal_(self.layer_1.weight, 0.0, 0.1)
nn.init.constant_(self.layer_1.bia... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | Code-Notebook/RL_with_pytorch_gym | Critic | false | 5,015 | [
"MIT"
] | 1 | 5417e450ba8b6eb991c6970ffd42f26911de3d6a | https://github.com/Code-Notebook/RL_with_pytorch_gym/tree/5417e450ba8b6eb991c6970ffd42f26911de3d6a |
TuckERLoss | import torch
import torch.nn as nn
class TuckERLoss(nn.Module):
def __init__(self, margin):
super(TuckERLoss, self).__init__()
pass
def forward(self, p_score, n_score, penalty=None):
p_score = -torch.mean(torch.log(p_score))
n_score = -torch.mean(torch.log(1 - n_score))
... | 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
... | CogNLP/CogKGE | TuckERLoss | false | 5,016 | [
"MIT"
] | 1 | 70d851d6489600c1e90eb25b0388a3ceba2f078c | https://github.com/CogNLP/CogKGE/tree/70d851d6489600c1e90eb25b0388a3ceba2f078c |
SDNE_layer | import torch
import torch.utils.data
import torch.nn as nn
import torch.nn.functional as F
class SDNE_layer(nn.Module):
def __init__(self, num_node, hidden_size1, hidden_size2, droput, alpha,
beta, nu1, nu2):
super(SDNE_layer, self).__init__()
self.num_node = num_node
self.hidden_... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | ChengzhiPiao/cogdl | SDNE_layer | false | 5,017 | [
"MIT"
] | 1 | 182e0b95b3dfbe771570037c58aacd8f677b6500 | https://github.com/ChengzhiPiao/cogdl/tree/182e0b95b3dfbe771570037c58aacd8f677b6500 |
Abs | import torch
import torch.utils.data
class Abs(torch.nn.Module):
def __init__(self):
super(Abs, self).__init__()
def forward(self, input):
return torch.abs(input)
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 math as tl_math
import torch.utils.data
assert_size_stride = torch._C._dynamo.guards.asse... | CoraJung/end-to-end-spoken-language-understanding | Abs | false | 5,018 | [
"Apache-2.0"
] | 1 | d1b15dad1a8f01336bcb0adcbf95d8c6ea279d09 | https://github.com/CoraJung/end-to-end-spoken-language-understanding/tree/d1b15dad1a8f01336bcb0adcbf95d8c6ea279d09 |
RotatELoss | import torch
import torch.nn as nn
import torch.nn.functional as F
class RotatELoss(nn.Module):
def __init__(self):
super(RotatELoss, self).__init__()
def forward(self, p_score, n_score, penalty=None):
return torch.mean(-F.logsigmoid(p_score) - F.logsigmoid(-n_score))
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 libdevice, math as tl_math
import torc... | CogNLP/CogKGE | RotatELoss | false | 5,019 | [
"MIT"
] | 1 | 70d851d6489600c1e90eb25b0388a3ceba2f078c | https://github.com/CogNLP/CogKGE/tree/70d851d6489600c1e90eb25b0388a3ceba2f078c |
FinalPool | import torch
import torch.utils.data
class FinalPool(torch.nn.Module):
def __init__(self):
super(FinalPool, self).__init__()
def forward(self, input):
"""
input : Tensor of shape (batch size, T, Cin)
Outputs a Tensor of shape (batch size, Cin).
"""
return input.max(dim=1)[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
import torch.utils.data
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
e... | CoraJung/end-to-end-spoken-language-understanding | FinalPool | false | 5,020 | [
"Apache-2.0"
] | 1 | d1b15dad1a8f01336bcb0adcbf95d8c6ea279d09 | https://github.com/CoraJung/end-to-end-spoken-language-understanding/tree/d1b15dad1a8f01336bcb0adcbf95d8c6ea279d09 |
MarginLoss | import torch
import torch.nn.functional as F
class MarginLoss(torch.nn.Module):
def __init__(self, margin, C=0, reverse=False):
super(MarginLoss, self).__init__()
self.margin = margin
self.C = C
if not isinstance(reverse, bool):
raise TypeError('param reverse must be T... | 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... | CogNLP/CogKGE | MarginLoss | false | 5,021 | [
"MIT"
] | 1 | 70d851d6489600c1e90eb25b0388a3ceba2f078c | https://github.com/CogNLP/CogKGE/tree/70d851d6489600c1e90eb25b0388a3ceba2f078c |
RKDDistanceLoss | import torch
import torch.nn as nn
import torch.nn.functional as F
class RKDDistanceLoss(nn.Module):
"""
Module for calculating RKD Distance Loss
"""
def forward(self, teacher, student, normalize=False):
"""
Forward function
:param teacher (torch.FloatTensor): Prediction made... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | DA-southampton/KD_Lib | RKDDistanceLoss | false | 5,022 | [
"MIT"
] | 1 | bd4a9b93b9674607ecf467d280d5cab1c516bdc6 | https://github.com/DA-southampton/KD_Lib/tree/bd4a9b93b9674607ecf467d280d5cab1c516bdc6 |
TransformerNet | import torch
class ConvLayer(torch.nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride):
super(ConvLayer, self).__init__()
reflection_padding = kernel_size // 2
self.reflection_pad = torch.nn.ReflectionPad2d(reflection_padding)
self.conv2d = torch.nn.Conv... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | Bartolo1024/ignite | TransformerNet | false | 5,023 | [
"BSD-3-Clause"
] | 1 | b087fef0bc5f97cda415c1c56f1cd589383c54be | https://github.com/Bartolo1024/ignite/tree/b087fef0bc5f97cda415c1c56f1cd589383c54be |
DuelingModel | import torch
import torch.nn as nn
class DuelingModel(nn.Module):
def __init__(self, n_input, n_output, n_hidden):
super(DuelingModel, self).__init__()
self.adv1 = nn.Linear(n_input, n_hidden)
self.adv2 = nn.Linear(n_hidden, n_output)
self.val1 = nn.Linear(n_input, n_hidden)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | CrazyNicolas/PyTorch-1.x-Reinforcement-Learning-Cookbook | DuelingModel | false | 5,024 | [
"MIT"
] | 1 | 614ee6055039e2b4f91fc762c6bc5c92aee3ee83 | https://github.com/CrazyNicolas/PyTorch-1.x-Reinforcement-Learning-Cookbook/tree/614ee6055039e2b4f91fc762c6bc5c92aee3ee83 |
BboxHead | import torch
import torch.nn as nn
import torch._utils
from itertools import product as product
import torch.utils.data.distributed
class BboxHead(nn.Module):
def __init__(self, inchannels=512, num_anchors=3):
super(BboxHead, self).__init__()
self.conv1x1 = nn.Conv2d(inchannels, num_anchors * 4, ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
import torch._utils
from itertools import product as produ... | Capetian/FaceX-Zoo | BboxHead | false | 5,025 | [
"Apache-2.0"
] | 1 | 029786c40d8aba15d891d33973de25fcd7e5399a | https://github.com/Capetian/FaceX-Zoo/tree/029786c40d8aba15d891d33973de25fcd7e5399a |
LandmarkHead | import torch
import torch.nn as nn
import torch._utils
from itertools import product as product
import torch.utils.data.distributed
class LandmarkHead(nn.Module):
def __init__(self, inchannels=512, num_anchors=3):
super(LandmarkHead, self).__init__()
self.conv1x1 = nn.Conv2d(inchannels, num_ancho... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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
from itertools import product as produ... | Capetian/FaceX-Zoo | LandmarkHead | false | 5,026 | [
"Apache-2.0"
] | 1 | 029786c40d8aba15d891d33973de25fcd7e5399a | https://github.com/Capetian/FaceX-Zoo/tree/029786c40d8aba15d891d33973de25fcd7e5399a |
RKDAngleLoss | import torch
import torch.nn as nn
import torch.nn.functional as F
def pairwaise_distance(output):
"""
Function for calculating pairwise distance
:param output (torch.FloatTensor): Input for calculating pairwise distance
"""
output_squared = output.pow(2).sum(dim=1)
product = torch.mm(output,... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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... | DA-southampton/KD_Lib | RKDAngleLoss | false | 5,027 | [
"MIT"
] | 1 | bd4a9b93b9674607ecf467d280d5cab1c516bdc6 | https://github.com/DA-southampton/KD_Lib/tree/bd4a9b93b9674607ecf467d280d5cab1c516bdc6 |
ClassHead | import torch
import torch.nn as nn
import torch._utils
from itertools import product as product
import torch.utils.data.distributed
class ClassHead(nn.Module):
def __init__(self, inchannels=512, num_anchors=3):
super(ClassHead, self).__init__()
self.num_anchors = num_anchors
self.conv1x1 ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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
from itertools import product as produ... | Capetian/FaceX-Zoo | ClassHead | false | 5,028 | [
"Apache-2.0"
] | 1 | 029786c40d8aba15d891d33973de25fcd7e5399a | https://github.com/Capetian/FaceX-Zoo/tree/029786c40d8aba15d891d33973de25fcd7e5399a |
PetarVGAT | import torch
import torch.utils.data
import torch.nn as nn
import torch.nn.functional as F
from typing import Optional
from typing import Type
from typing import Any
from abc import ABC
from abc import abstractmethod
class BaseTrainer(ABC):
@classmethod
@abstractmethod
def build_trainer_from_args(cls, ar... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | ChengzhiPiao/cogdl | PetarVGAT | false | 5,029 | [
"MIT"
] | 1 | 182e0b95b3dfbe771570037c58aacd8f677b6500 | https://github.com/ChengzhiPiao/cogdl/tree/182e0b95b3dfbe771570037c58aacd8f677b6500 |
HSwish | import torch
from torch import nn
import torch.nn.functional as F
class HSwish(nn.Module):
def forward(self, x):
out = x * F.relu6(x + 3, inplace=True) / 6
return out
def get_inputs():
return [torch.rand([4, 4, 4, 4])]
def get_init_inputs():
return [[], {}]
| import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empt... | DYF-AI/openvino-x | HSwish | false | 5,030 | [
"Apache-2.0"
] | 1 | 0f18ebb240ea3394f7e461aca34fac158e686d95 | https://github.com/DYF-AI/openvino-x/tree/0f18ebb240ea3394f7e461aca34fac158e686d95 |
DecoderBlock | import torch
import torch.utils.data
import torch.nn as nn
import torch.onnx
import torch.autograd
import torch.backends.cudnn
class ConvRelu(nn.Module):
"""3x3 convolution followed by ReLU activation building block."""
def __init__(self, num_in, num_out):
super().__init__()
self.block = nn.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
import torch.utils.data
impor... | CorentinLemaitre/robosat.pink | DecoderBlock | false | 5,031 | [
"MIT"
] | 1 | 6ec29a4dd4c0cbf953e73818d7338ee68b2451d3 | https://github.com/CorentinLemaitre/robosat.pink/tree/6ec29a4dd4c0cbf953e73818d7338ee68b2451d3 |
VAE | import torch
from torch import nn
import torch.utils.data
from torch.nn import functional as F
import torch.cuda
class VAE(nn.Module):
def __init__(self):
super(VAE, self).__init__()
self.fc1 = nn.Linear(784, 400)
self.fc21 = nn.Linear(400, 20)
self.fc22 = nn.Linear(400, 20)
... | import torch
from torch import device
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from... | Code-Cornelius/libraries | VAE | false | 5,032 | [
"MIT"
] | 1 | 2ebd5f78dcedfdce1416280d7d40de7691906951 | https://github.com/Code-Cornelius/libraries/tree/2ebd5f78dcedfdce1416280d7d40de7691906951 |
GraphConv | import torch
from torch import nn
import torch.nn
import torch.autograd
def sparse_bmm(sparse_matrix, dense_matrix_batch):
"""
Perform torch.bmm on an unbatched sparse matrix and a batched dense matrix.
Args:
sparse_matrix (torch.sparse.FloatTensor): Shape = (m, n)
dense_matrix_batch (tor... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
import torch.nn
import torch.autograd
assert_size_stride = ... | CompileException/kaolin | GraphConv | false | 5,033 | [
"ECL-2.0",
"Apache-2.0"
] | 1 | 8b14752453956a57a4bf6295d49889518835f7a9 | https://github.com/CompileException/kaolin/tree/8b14752453956a57a4bf6295d49889518835f7a9 |
MaskL1Loss | import torch
from torch import nn
class MaskL1Loss(nn.Module):
def __init__(self, eps=1e-06):
super(MaskL1Loss, self).__init__()
self.eps = eps
def forward(self, pred: 'torch.Tensor', gt, mask):
loss = (torch.abs(pred - gt) * mask).sum() / (mask.sum() + self.eps)
return loss
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
from torch import nn
a... | DYF-AI/openvino-x | MaskL1Loss | false | 5,034 | [
"Apache-2.0"
] | 1 | 0f18ebb240ea3394f7e461aca34fac158e686d95 | https://github.com/DYF-AI/openvino-x/tree/0f18ebb240ea3394f7e461aca34fac158e686d95 |
Prototypes | import torch
import torch.nn as nn
from torch.nn import functional as F
class Prototypes(nn.Module):
def __init__(self, fdim, num_classes, temp=0.05):
super().__init__()
self.prototypes = nn.Linear(fdim, num_classes, bias=False)
self.temp = temp
def forward(self, x):
x = F.no... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | DMIRLAB-Group/Dassl.pytorch | Prototypes | false | 5,035 | [
"MIT"
] | 1 | 79052448cc0b0622f14e9768dbd6e6c0598fe6d1 | https://github.com/DMIRLAB-Group/Dassl.pytorch/tree/79052448cc0b0622f14e9768dbd6e6c0598fe6d1 |
HardSigmoid | import torch
from torch import nn
import torch.nn.functional as F
class HardSigmoid(nn.Module):
def __init__(self, slope=0.2, offset=0.5):
super().__init__()
self.slope = slope
self.offset = offset
def forward(self, x):
x = self.slope * x + self.offset
x = F.threshold... | 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... | DYF-AI/openvino-x | HardSigmoid | false | 5,036 | [
"Apache-2.0"
] | 1 | 0f18ebb240ea3394f7e461aca34fac158e686d95 | https://github.com/DYF-AI/openvino-x/tree/0f18ebb240ea3394f7e461aca34fac158e686d95 |
SinkhornDivergence | import torch
import torch.nn as nn
from torch.nn import functional as F
class OptimalTransport(nn.Module):
@staticmethod
def distance(batch1, batch2, dist_metric='cosine'):
if dist_metric == 'cosine':
batch1 = F.normalize(batch1, p=2, dim=1)
batch2 = F.normalize(batch2, p=2, 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.... | DMIRLAB-Group/Dassl.pytorch | SinkhornDivergence | false | 5,037 | [
"MIT"
] | 1 | 79052448cc0b0622f14e9768dbd6e6c0598fe6d1 | https://github.com/DMIRLAB-Group/Dassl.pytorch/tree/79052448cc0b0622f14e9768dbd6e6c0598fe6d1 |
WingLoss | import torch
import torch.nn as nn
class WingLoss(nn.Module):
def __init__(self, l1_log_cutoff, epsilon):
super().__init__()
self.l1_log_cutoff = l1_log_cutoff
self.epsilon = epsilon
log_val = torch.log(torch.FloatTensor([1 + self.l1_log_cutoff /
self.epsilon])).item()... | 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
... | Daiver/torch_fuze | WingLoss | false | 5,038 | [
"MIT"
] | 1 | 6b7ad568e2d7549c7f0c0d4c309532ac1b92881d | https://github.com/Daiver/torch_fuze/tree/6b7ad568e2d7549c7f0c0d4c309532ac1b92881d |
PartialConv | import math
import torch
import torch.nn as nn
def weights_init(init_type='gaussian'):
def init_fun(m):
classname = m.__class__.__name__
if (classname.find('Conv') == 0 or classname.find('Linear') == 0
) and hasattr(m, 'weight'):
if init_type == 'gaussian':
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import math
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.a... | DH-Diego/Homework4995.009DAP | PartialConv | false | 5,039 | [
"Apache-2.0"
] | 1 | ccbdea8b4a0debe29d2014c2cbabe92f4e7f9a4a | https://github.com/DH-Diego/Homework4995.009DAP/tree/ccbdea8b4a0debe29d2014c2cbabe92f4e7f9a4a |
ReOrgLayer | import torch
from torch import nn
import torch.utils.data
class ReOrgLayer(nn.Module):
def __init__(self, stride=2):
super(ReOrgLayer, self).__init__()
self.stride = stride
def forward(self, x):
assert x.data.dim() == 4
B, C, H, W = x.data.shape
hs = self.stride
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
import torch.utils.data
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._... | Dazz993/AlphaPose | ReOrgLayer | false | 5,040 | [
"Apache-2.0"
] | 1 | d4b9a3af5f590fa21bd033b4a19e98b5748ae683 | https://github.com/Dazz993/AlphaPose/tree/d4b9a3af5f590fa21bd033b4a19e98b5748ae683 |
DiceLoss | import torch
from torch import nn
class DiceLoss(nn.Module):
"""
Loss function from https://arxiv.org/abs/1707.03237,
where iou computation is introduced heatmap manner to measure the
diversity bwtween tow heatmaps.
"""
def __init__(self, eps=1e-06):
super(DiceLoss, self).__init__()
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_str... | DYF-AI/openvino-x | DiceLoss | false | 5,041 | [
"Apache-2.0"
] | 1 | 0f18ebb240ea3394f7e461aca34fac158e686d95 | https://github.com/DYF-AI/openvino-x/tree/0f18ebb240ea3394f7e461aca34fac158e686d95 |
L12Loss | import torch
import torch.nn as nn
class L12Loss(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x, y):
assert x.shape == y.shape
assert len(x.shape) == 3
diff = x - y
n_samples = x.size(0)
n_vertices = x.size(1)
res = torch.norm(d... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_... | Daiver/torch_fuze | L12Loss | false | 5,042 | [
"MIT"
] | 1 | 6b7ad568e2d7549c7f0c0d4c309532ac1b92881d | https://github.com/Daiver/torch_fuze/tree/6b7ad568e2d7549c7f0c0d4c309532ac1b92881d |
Net | import torch
import torch.nn as nn
import torch.nn.functional as F
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.conv1 = nn.Conv2d(3, 6, 5)
self.pool = nn.MaxPool2d(2, 2)
self.conv2 = nn.Conv2d(6, 16, 5)
self.fc1 = nn.Linear(16 * 5 * 5, 120)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | Daiver/torch_fuze | Net | false | 5,043 | [
"MIT"
] | 1 | 6b7ad568e2d7549c7f0c0d4c309532ac1b92881d | https://github.com/Daiver/torch_fuze/tree/6b7ad568e2d7549c7f0c0d4c309532ac1b92881d |
PixelUnshuffle | import torch
from torch import nn
import torch.utils.data
class PixelUnshuffle(nn.Module):
"""
Initialize: inplanes, planes, upscale_factor
OUTPUT: (planes // upscale_factor^2) * ht * wd
"""
def __init__(self, downscale_factor=2):
super(PixelUnshuffle, self).__init__()
self._r = d... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
import torch.utils.data
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._... | Dazz993/AlphaPose | PixelUnshuffle | false | 5,044 | [
"Apache-2.0"
] | 1 | d4b9a3af5f590fa21bd033b4a19e98b5748ae683 | https://github.com/Dazz993/AlphaPose/tree/d4b9a3af5f590fa21bd033b4a19e98b5748ae683 |
std_norm | import torch
import torch.nn as nn
class std_norm(nn.Module):
def __init__(self, inverse=False):
super(std_norm, self).__init__()
self.inverse = inverse
def forward(self, x, mean, std):
out = []
for i in range(len(mean)):
if not self.inverse:
norma... | 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... | DandilionLau/Visually-Imbalanced-Stereo | std_norm | false | 5,045 | [
"MIT"
] | 1 | e80b63be134c326f8a036db7af669a6b3b23ed24 | https://github.com/DandilionLau/Visually-Imbalanced-Stereo/tree/e80b63be134c326f8a036db7af669a6b3b23ed24 |
LayerNorm2d | import torch
import torch.nn as nn
import torch.nn.functional as F
class LayerNorm2d(nn.LayerNorm):
"""LayerNorm on channels for 2d images.
Args:
num_channels (int): The number of channels of the input tensor.
eps (float): a value added to the denominator for numerical stability.
D... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_... | David-19940718/mmclassification | LayerNorm2d | false | 5,046 | [
"Apache-2.0"
] | 1 | 987dd45457e38c4787237ea468799849dce11ada | https://github.com/David-19940718/mmclassification/tree/987dd45457e38c4787237ea468799849dce11ada |
SEBlock | import torch
from torch import nn
import torch.nn.functional as F
class HardSigmoid(nn.Module):
def __init__(self, slope=0.2, offset=0.5):
super().__init__()
self.slope = slope
self.offset = offset
def forward(self, x):
x = self.slope * x + self.offset
x = F.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
from torch._inductor.runtime import triton_helpers
from torch import nn
import t... | DYF-AI/openvino-x | SEBlock | false | 5,047 | [
"Apache-2.0"
] | 1 | 0f18ebb240ea3394f7e461aca34fac158e686d95 | https://github.com/DYF-AI/openvino-x/tree/0f18ebb240ea3394f7e461aca34fac158e686d95 |
AsymmetricLoss | import torch
import torch.nn as nn
import torch.nn.functional as F
def reduce_loss(loss, reduction):
"""Reduce loss as specified.
Args:
loss (Tensor): Elementwise loss tensor.
reduction (str): Options are "none", "mean" and "sum".
Return:
Tensor: Reduced loss tensor.
"""
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import torc... | David-19940718/mmclassification | AsymmetricLoss | false | 5,048 | [
"Apache-2.0"
] | 1 | 987dd45457e38c4787237ea468799849dce11ada | https://github.com/David-19940718/mmclassification/tree/987dd45457e38c4787237ea468799849dce11ada |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.