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 |
|---|---|---|---|---|---|---|---|---|---|---|
MultiscaleRecLoss | import torch
import torch.nn as nn
class MultiscaleRecLoss(nn.Module):
def __init__(self, scale=3, rec_loss_type='l1', multiscale=True):
super(MultiscaleRecLoss, self).__init__()
self.multiscale = multiscale
if rec_loss_type == 'l1':
self.criterion = nn.L1Loss()
elif r... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
... | eezkni/UEGAN | MultiscaleRecLoss | false | 15,288 | [
"MIT"
] | 73 | a6616ac559819d487cae0f301d98cf2922a11a09 | https://github.com/eezkni/UEGAN/tree/a6616ac559819d487cae0f301d98cf2922a11a09 |
FocalLoss | import torch
def _neg_loss(pred, gt):
""" Modified focal loss. Exactly the same as CornerNet.
Runs faster and costs a little bit more memory
(https://github.com/tianweiy/CenterPoint)
Arguments:
pred (batch x c x h x w)
gt (batch x c x h x w)
"""
pos_inds = gt.eq(1).floa... | 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
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_str... | edwardzhou130/Panoptic-PolarNet | FocalLoss | false | 15,289 | [
"BSD-3-Clause"
] | 90 | 3a72f2380a4e505e191b69da596f521a9d9f1a71 | https://github.com/edwardzhou130/Panoptic-PolarNet/tree/3a72f2380a4e505e191b69da596f521a9d9f1a71 |
Sine | import torch
from torch import nn
class Sine(nn.Module):
def __init__(self, w0=30):
super().__init__()
self.w0 = w0
def forward(self, input):
return torch.sin(self.w0 * 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
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_... | eliemichel/ACORN | Sine | false | 15,290 | [
"MIT"
] | 186 | ca1b776e585251bd20468038c343decbbd62abf3 | https://github.com/eliemichel/ACORN/tree/ca1b776e585251bd20468038c343decbbd62abf3 |
CoPredictor | import torch
import torch.autograd
import torch.nn as nn
class Biaffine(nn.Module):
def __init__(self, n_in, n_out=1, bias_x=True, bias_y=True):
super(Biaffine, self).__init__()
self.n_in = n_in
self.n_out = n_out
self.bias_x = bias_x
self.bias_y = bias_y
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.triton_helpers import libdevice
import torch.autogr... | dumpmemory/W2NER | CoPredictor | false | 15,291 | [
"MIT"
] | 128 | fb1b6eb1111eb001b1c965097d995244b840bdda | https://github.com/dumpmemory/W2NER/tree/fb1b6eb1111eb001b1c965097d995244b840bdda |
ConvBlock | import math
import torch
from torch import Tensor
from typing import List
from typing import Optional
from typing import Union
from typing import Any
from typing import Tuple
from typing import NamedTuple
import torch.nn as nn
import torch.nn.functional as F
class PaddedTensor(NamedTuple):
data: '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
import math
from typing import List
from typing import Optional
from typing impo... | eivtho/PyLaia | ConvBlock | false | 15,292 | [
"MIT"
] | 89 | 2a7a6e2eeb9b5af68c0faed0c564b02063e72be0 | https://github.com/eivtho/PyLaia/tree/2a7a6e2eeb9b5af68c0faed0c564b02063e72be0 |
NNAttention | import torch
import torch.nn as nn
class NNAttention(nn.Module):
def __init__(self, in_dim, out_dim):
super().__init__()
self.q_net = nn.Linear(in_dim, out_dim)
self.k_net = nn.Linear(in_dim, out_dim)
self.v_net = nn.Linear(in_dim, out_dim)
def forward(self, Q, K, V):
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | eitin-infant/FinRL-Meta | NNAttention | false | 15,293 | [
"MIT"
] | 214 | 4c94011e58425796e7e2e5c1bf848afd65c828d6 | https://github.com/eitin-infant/FinRL-Meta/tree/4c94011e58425796e7e2e5c1bf848afd65c828d6 |
LayerNorm | import torch
import torch.fft
import torch.nn
import torch.nn as nn
class LayerNorm(nn.Module):
def __init__(self, num_channels: 'int', eps: 'float'=1e-12):
"""Uses GroupNorm implementation with group=1 for speed."""
super().__init__()
self.layer_norm = torch.nn.GroupNorm(1, num_channels=... | 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.fft
import torch.nn
import torch.nn as nn
assert_size_stride = tor... | dwromero/ckconv | LayerNorm | false | 15,294 | [
"MIT"
] | 74 | d44c6441a98792477d6259368c210089bb33fe7a | https://github.com/dwromero/ckconv/tree/d44c6441a98792477d6259368c210089bb33fe7a |
SelfAttention | import torch
import torch.nn as nn
class SelfAttention(nn.Module):
def __init__(self, *args, **kargs):
super().__init__()
self.attention = nn.MultiheadAttention(*args, **kargs)
def forward(self, x):
return self.attention(x, x, x)[0]
def get_inputs():
return [torch.rand([4, 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
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | eitin-infant/FinRL-Meta | SelfAttention | false | 15,295 | [
"MIT"
] | 214 | 4c94011e58425796e7e2e5c1bf848afd65c828d6 | https://github.com/eitin-infant/FinRL-Meta/tree/4c94011e58425796e7e2e5c1bf848afd65c828d6 |
ILN | import torch
import torch.nn as nn
import torch.utils.cpp_extension
class ILN(nn.Module):
def __init__(self, channels, resl, eps=1e-08):
super().__init__()
self.rho = nn.Parameter(torch.Tensor(1, channels, 1, 1))
self.rho.data.fill_(0.0)
self.instance_norm = nn.InstanceNorm2d(chan... | 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.cpp_extension
assert_size_stride = tor... | STomoya/animeface | ILN | false | 15,296 | [
"MIT"
] | 61 | 37b3cd26097d7874559d4c152e41e5712b7a1a42 | https://github.com/STomoya/animeface/tree/37b3cd26097d7874559d4c152e41e5712b7a1a42 |
ScalePredictor | import torch
import torch.nn as nn
class ScalePredictor(nn.Module):
def __init__(self, nz, scale_lr_decay=0.2, scale_bias=1.0):
super(ScalePredictor, self).__init__()
self.pred_layer = nn.Linear(nz, 1)
self.scale_bias = scale_bias
self.scale_lr_decay = scale_lr_decay
def forw... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | eldar/acsm | ScalePredictor | false | 15,297 | [
"Apache-2.0"
] | 52 | 04069e8bb4c12185473dc10c3355e5367fa98968 | https://github.com/eldar/acsm/tree/04069e8bb4c12185473dc10c3355e5367fa98968 |
SpatialAttention2d | import torch
import torch.nn as nn
import torch._utils
class SpatialAttention2d(nn.Module):
def __init__(self, channel):
super(SpatialAttention2d, self).__init__()
self.squeeze = nn.Conv2d(channel, 1, kernel_size=1, bias=False)
self.sigmoid = nn.Sigmoid()
def forward(self, x):
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
import torch._utils
assert_size_stride = torch._C._dynamo.... | elmajdma/seismic-deeplearning | SpatialAttention2d | false | 15,298 | [
"MIT"
] | 270 | bc084abe153509c40b45f8bf0f80dfda1049d7dc | https://github.com/elmajdma/seismic-deeplearning/tree/bc084abe153509c40b45f8bf0f80dfda1049d7dc |
InputMapping | import math
import torch
import torch.fft
import torch.nn
class InputMapping(torch.nn.Conv1d):
def __init__(self, in_channels: 'int', out_channels: 'int', omega_0:
'float', stride: 'int'=1, bias: 'bool'=True):
super().__init__(in_channels=in_channels, out_channels=out_channels,
kernel... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 math
i... | dwromero/ckconv | InputMapping | false | 15,299 | [
"MIT"
] | 74 | d44c6441a98792477d6259368c210089bb33fe7a | https://github.com/dwromero/ckconv/tree/d44c6441a98792477d6259368c210089bb33fe7a |
CMVN | import torch
import torch.onnx
class CMVN(torch.nn.Module):
eps = 1e-05
@torch.no_grad()
def forward(self, feat):
mean = feat.mean(dim=2, keepdim=True)
std = feat.std(dim=2, keepdim=True)
feat = (feat - mean) / (std + CMVN.eps)
return feat
def get_inputs():
return [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.triton_helpers import libdevice
import torch.onnx
assert_size_stride = torch._C._dynamo.guards.assert_size_stri... | entn-at/Online-Speech-Recognition | CMVN | false | 15,300 | [
"Apache-2.0"
] | 201 | 75680cef38c57d0ac60f5e23c90d24bb3046e4e7 | https://github.com/entn-at/Online-Speech-Recognition/tree/75680cef38c57d0ac60f5e23c90d24bb3046e4e7 |
PatchEmbed3D | import torch
import torch.utils.data
from itertools import chain as chain
import torch.nn as nn
class PatchEmbed3D(nn.Module):
""" Image to Patch Embedding
"""
def __init__(self, img_size=224, temporal_resolution=4, in_chans=3,
patch_size=16, z_block_size=2, embed_dim=768, flatten=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.utils.data
from itertools import chain as chain
import torch.nn as ... | dylan-campbell/Motionformer | PatchEmbed3D | false | 15,301 | [
"Apache-2.0"
] | 153 | 6c860614a3b252c6163971ba20e61ea3184d5291 | https://github.com/dylan-campbell/Motionformer/tree/6c860614a3b252c6163971ba20e61ea3184d5291 |
fChannelAttentionGG | import math
import torch
import numpy as np
import torch.optim
import torch.utils.data
class fChannelAttentionGG(torch.nn.Module):
def __init__(self, N_h_in, N_in, ratio=1, group='SE2'):
super(fChannelAttentionGG, self).__init__()
self.N_in = N_in
self.ratio = ratio
self.N_h_in = ... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import math
import numpy as np
import torch.optim
import torch.utils.data
assert_size_str... | dwromero/att_gconvs | fChannelAttentionGG | false | 15,302 | [
"MIT"
] | 53 | 872259cad49763fdcfa3e96e80b6b5c331adf084 | https://github.com/dwromero/att_gconvs/tree/872259cad49763fdcfa3e96e80b6b5c331adf084 |
DurationMSELoss | import torch
import torch.utils.data
from torch.optim import *
from torch.optim.lr_scheduler import *
class DurationMSELoss(torch.nn.Module):
"""Loss function module for duration predictor.
The loss value is Calculated in log domain to make it Gaussian.
"""
def __init__(self, offset=1.0, reduction=... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.utils.dat... | entn-at/efficient_tts | DurationMSELoss | false | 15,303 | [
"MIT"
] | 111 | 5e6ea55d0c9694f7e30eecb5048976088f1a3c66 | https://github.com/entn-at/efficient_tts/tree/5e6ea55d0c9694f7e30eecb5048976088f1a3c66 |
Classifier | import torch
import torch.nn.functional as F
from torch import nn
class Classifier(nn.Module):
def __init__(self, dims):
"""
Single hidden layer classifier
with softmax output.
"""
super(Classifier, self).__init__()
[x_dim, h_dim, y_dim] = dims
self.dense =... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | engdorm/semi-supervised-pytorch | Classifier | false | 15,304 | [
"MIT"
] | 700 | b149e06aa413dd426886149930c8c265fd9cc746 | https://github.com/engdorm/semi-supervised-pytorch/tree/b149e06aa413dd426886149930c8c265fd9cc746 |
Gate | import torch
import torch.nn as nn
import torch.nn.functional as F
class Gate(nn.Module):
def __init__(self, hidden_size):
super(Gate, self).__init__()
self.hidden_size = hidden_size
self.wrx = nn.Linear(hidden_size, hidden_size)
self.wrh = nn.Linear(hidden_size, hidden_size)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as ... | elsehow/Writing-editing-Network | Gate | false | 15,305 | [
"MIT"
] | 79 | a8551cd224a4987a6eec3cf566bcf0793ad36dfd | https://github.com/elsehow/Writing-editing-Network/tree/a8551cd224a4987a6eec3cf566bcf0793ad36dfd |
SquaredModulus | import torch
from torch import nn
class SquaredModulus(nn.Module):
"""Squared modulus layer.
Returns a keras layer that implements a squared modulus operator.
To implement the squared modulus of C complex-valued channels, the expected
input dimension is N*1*W*(2*C) where channels role alternates betw... | 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... | entn-at/leaf-audio-pytorch | SquaredModulus | false | 15,306 | [
"Apache-2.0"
] | 72 | 33f4ba4c8bdf07f125033f8e706d0d0bc6816445 | https://github.com/entn-at/leaf-audio-pytorch/tree/33f4ba4c8bdf07f125033f8e706d0d0bc6816445 |
VariantSigmoid | import torch
import torch.nn as nn
class VariantSigmoid(nn.Module):
def __init__(self, alpha):
super().__init__()
self.alpha = alpha
def forward(self, x):
y = 1 / (1 + torch.exp(-self.alpha * x))
return y
def get_inputs():
return [torch.rand([4, 4, 4, 4])]
def get_ini... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert... | entn-at/AGAIN-VC | VariantSigmoid | false | 15,307 | [
"MIT"
] | 78 | dbf94bf55882f897c312c7760cd892c51c93c9ab | https://github.com/entn-at/AGAIN-VC/tree/dbf94bf55882f897c312c7760cd892c51c93c9ab |
ClassificationTestModel | from torch.nn import Module
import torch
import torch.nn as nn
from typing import Any
from torch.nn.modules import Module
class ClassificationTestModel(Module):
def __init__(self, in_chans: 'int'=3, num_classes: 'int'=1000, **kwargs:
Any) ->None:
super().__init__()
self.conv1 = nn.Conv2d(... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch.nn import Module
import torch.nn as nn
from typing import Any
from to... | ethanwhite/torchgeo | ClassificationTestModel | false | 15,308 | [
"MIT"
] | 678 | cb20e1abfd9213f9ee7700df972385db13568642 | https://github.com/ethanwhite/torchgeo/tree/cb20e1abfd9213f9ee7700df972385db13568642 |
Upsample | import torch
from torch import nn
import torch.utils.data
class Upsample(nn.Module):
def __init__(self, dim):
super().__init__()
self.conv = nn.ConvTranspose2d(dim, dim, 4, 2, 1)
def forward(self, x):
return self.conv(x)
def get_inputs():
return [torch.rand([4, 4, 4, 4])]
def... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
import torch.utils.data
assert_size_stride = torch._C._dyna... | entn-at/GradTTS | Upsample | false | 15,309 | [
"MIT"
] | 55 | d31cbf41211615a01fffc3812715e3f7f2be214d | https://github.com/entn-at/GradTTS/tree/d31cbf41211615a01fffc3812715e3f7f2be214d |
SCse | import torch
import torch.nn as nn
import torch._utils
class SpatialAttention2d(nn.Module):
def __init__(self, channel):
super(SpatialAttention2d, self).__init__()
self.squeeze = nn.Conv2d(channel, 1, kernel_size=1, bias=False)
self.sigmoid = nn.Sigmoid()
def forward(self, x):
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
import ... | elmajdma/seismic-deeplearning | SCse | false | 15,310 | [
"MIT"
] | 270 | bc084abe153509c40b45f8bf0f80dfda1049d7dc | https://github.com/elmajdma/seismic-deeplearning/tree/bc084abe153509c40b45f8bf0f80dfda1049d7dc |
Model | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self):
super(Model, self).__init__()
self.linear1 = nn.Linear(28 * 28, 32)
self.linear2 = nn.Linear(32, 10)
def forward(self, inputs):
x = inputs.view(-1, 28 * 28)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | emirojaseng/pytorch-meta-optimizer | Model | false | 15,311 | [
"MIT"
] | 298 | 3641981c990150ceb6c55d25a05ba76388f9ec69 | https://github.com/emirojaseng/pytorch-meta-optimizer/tree/3641981c990150ceb6c55d25a05ba76388f9ec69 |
LayerNorm1D | import torch
import torch.nn as nn
class LayerNorm1D(nn.Module):
def __init__(self, num_outputs, eps=1e-05, affine=True):
super(LayerNorm1D, self).__init__()
self.eps = eps
self.weight = nn.Parameter(torch.ones(1, num_outputs))
self.bias = nn.Parameter(torch.zeros(1, num_outputs))... | 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_... | emirojaseng/pytorch-meta-optimizer | LayerNorm1D | false | 15,312 | [
"MIT"
] | 298 | 3641981c990150ceb6c55d25a05ba76388f9ec69 | https://github.com/emirojaseng/pytorch-meta-optimizer/tree/3641981c990150ceb6c55d25a05ba76388f9ec69 |
QRLoss | from torch.nn import Module
import torch
from typing import cast
from torch.nn.modules import Module
class QRLoss(Module):
"""The QR (forward) loss between class probabilities and predictions.
This loss is defined in `'Resolving label uncertainty with implicit generative
models' <https://openreview.net/f... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import math as tl_math
from torch.nn... | ethanwhite/torchgeo | QRLoss | false | 15,313 | [
"MIT"
] | 678 | cb20e1abfd9213f9ee7700df972385db13568642 | https://github.com/ethanwhite/torchgeo/tree/cb20e1abfd9213f9ee7700df972385db13568642 |
SelfAttn | import torch
from torch import nn
from torch.nn import functional as F
class SelfAttn(nn.Module):
"""
self-attention with learnable parameters
"""
def __init__(self, dhid):
super().__init__()
self.scorer = nn.Linear(dhid, 1)
def forward(self, inp):
scores = F.softmax(self... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | etaoxing/crl_alfred | SelfAttn | false | 15,314 | [
"MIT"
] | 148 | cad500cf84f71e47f1191e7810dde0c74d295f08 | https://github.com/etaoxing/crl_alfred/tree/cad500cf84f71e47f1191e7810dde0c74d295f08 |
RQLoss | from torch.nn import Module
import torch
from typing import cast
from torch.nn.modules import Module
import torch.nn.functional as F
class RQLoss(Module):
"""The RQ (backwards) loss between class probabilities and predictions.
This loss is defined in `'Resolving label uncertainty with implicit generative
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | ethanwhite/torchgeo | RQLoss | false | 15,315 | [
"MIT"
] | 678 | cb20e1abfd9213f9ee7700df972385db13568642 | https://github.com/ethanwhite/torchgeo/tree/cb20e1abfd9213f9ee7700df972385db13568642 |
SegmentationTestModel | from torch.nn import Module
import torch
import torch.nn as nn
from typing import Any
from typing import cast
from torch.nn.modules import Module
class SegmentationTestModel(Module):
def __init__(self, in_channels: 'int'=3, classes: 'int'=1000, **kwargs: Any
) ->None:
super().__init__()
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.nn import Module
import torch.nn as nn
from typing import Any
from to... | ethanwhite/torchgeo | SegmentationTestModel | false | 15,316 | [
"MIT"
] | 678 | cb20e1abfd9213f9ee7700df972385db13568642 | https://github.com/ethanwhite/torchgeo/tree/cb20e1abfd9213f9ee7700df972385db13568642 |
InvConvNear | import torch
from torch import nn
from torch.nn import functional as F
import torch.utils.data
class InvConvNear(nn.Module):
def __init__(self, channels, n_split=4, no_jacobian=False, **kwargs):
super().__init__()
assert n_split % 2 == 0
self.channels = channels
self.n_split = n_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 import nn
import torch.utils.data
assert_size_stride = torch._C._dyna... | entn-at/GradTTS | InvConvNear | false | 15,317 | [
"MIT"
] | 55 | d31cbf41211615a01fffc3812715e3f7f2be214d | https://github.com/entn-at/GradTTS/tree/d31cbf41211615a01fffc3812715e3f7f2be214d |
GaborConstraint | import math
import torch
from torch import nn
class GaborConstraint(nn.Module):
"""Constraint mu and sigma, in radians.
Mu is constrained in [0,pi], sigma s.t full-width at half-maximum of the
gaussian response is in [1,pi/2]. The full-width at half maximum of the
Gaussian response is 2*sqrt(2*log(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 import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empt... | entn-at/leaf-audio-pytorch | GaborConstraint | false | 15,318 | [
"Apache-2.0"
] | 72 | 33f4ba4c8bdf07f125033f8e706d0d0bc6816445 | https://github.com/entn-at/leaf-audio-pytorch/tree/33f4ba4c8bdf07f125033f8e706d0d0bc6816445 |
CausalConv1d | import torch
import torch.nn as nn
class CausalConv1d(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride=1):
super().__init__()
self.kernel_size = kernel_size
self.conv = nn.Conv1d(in_channels, out_channels, kernel_size,
stride=stride, padding=kernel... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | ex4sperans/freesound-classification | CausalConv1d | false | 15,319 | [
"Apache-2.0"
] | 55 | 71b9920ce0ae376aa7f1a3a2943f0f92f4820813 | https://github.com/ex4sperans/freesound-classification/tree/71b9920ce0ae376aa7f1a3a2943f0f92f4820813 |
Conv1dLinear | import torch
import torch.utils.data
from torch.optim import *
from torch.optim.lr_scheduler import *
class Conv1dLinear(torch.nn.Module):
"""Conv1D + Linear for Transformer block.
A variant of MultiLayeredConv1d, which replaces second conv-layer to linear.
"""
def __init__(self, in_chans, hidden_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
from ... | entn-at/efficient_tts | Conv1dLinear | false | 15,320 | [
"MIT"
] | 111 | 5e6ea55d0c9694f7e30eecb5048976088f1a3c66 | https://github.com/entn-at/efficient_tts/tree/5e6ea55d0c9694f7e30eecb5048976088f1a3c66 |
BahdanauAttention | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from random import *
class BahdanauAttention(nn.Module):
def __init__(self, hidden_size):
super().__init__()
self.hidden_size = hidden_size
self.w1 = nn.Linear(hidden_size, hidden_size)
self.w2 = nn.Lin... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | evinaybit/100-Days-of-NLP | BahdanauAttention | false | 15,321 | [
"MIT"
] | 239 | 81e08884dd31b7b99bef27f43a179cda09ab5732 | https://github.com/evinaybit/100-Days-of-NLP/tree/81e08884dd31b7b99bef27f43a179cda09ab5732 |
Attention | import torch
import torch.nn as nn
from random import *
class Attention(nn.Module):
def __init__(self, hidden_size):
super().__init__()
self.hidden_size = hidden_size
self.w1 = nn.Linear(hidden_size, hidden_size)
self.w2 = nn.Linear(hidden_size, hidden_size)
self.v = nn.Li... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | evinaybit/100-Days-of-NLP | Attention | false | 15,322 | [
"MIT"
] | 239 | 81e08884dd31b7b99bef27f43a179cda09ab5732 | https://github.com/evinaybit/100-Days-of-NLP/tree/81e08884dd31b7b99bef27f43a179cda09ab5732 |
ChannelAttentionGG | import math
import torch
import torch.optim
import torch.utils.data
class ChannelAttention(torch.nn.Module):
def __init__(self, N_out, N_in, ratio=1):
super(ChannelAttention, self).__init__()
self.linear = torch.nn.functional.linear
self.avg_pool = torch.nn.AdaptiveAvgPool2d(1)
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
import math
import torch.optim
import torch.utils.data
assert_size_stride = torch._C._dyn... | dwromero/att_gconvs | ChannelAttentionGG | false | 15,323 | [
"MIT"
] | 53 | 872259cad49763fdcfa3e96e80b6b5c331adf084 | https://github.com/dwromero/att_gconvs/tree/872259cad49763fdcfa3e96e80b6b5c331adf084 |
DepthL1Loss | import torch
import torch.nn as nn
class DepthL1Loss(nn.Module):
def __init__(self, eps=1e-05):
super(DepthL1Loss, self).__init__()
self.eps = eps
def forward(self, pred, gt):
bs = pred.size()[0]
img1 = torch.zeros_like(pred)
img2 = torch.zeros_like(gt)
img1 =... | 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
... | ezxzeng/FFB6D | DepthL1Loss | false | 15,324 | [
"MIT"
] | 145 | fd0ea6471532ab1dc68f9a58b52d9a63f8fb76f2 | https://github.com/ezxzeng/FFB6D/tree/fd0ea6471532ab1dc68f9a58b52d9a63f8fb76f2 |
C3D | import torch
from torch import nn
def get_10x_lr_params(model):
"""
This generator returns all the parameters for the fc layer of the net.
"""
b = [model.linear]
for j in range(len(b)):
for k in b[j].parameters():
if k.requires_grad:
yield k
def get_1x_lr_para... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch import nn
assert_s... | datamllab/autovideo | C3D | false | 15,325 | [
"MIT"
] | 233 | 34a702fe9d3114e7128dcff12cb43369e4932919 | https://github.com/datamllab/autovideo/tree/34a702fe9d3114e7128dcff12cb43369e4932919 |
OFLoss | import torch
from torch.nn.modules.loss import _Loss
def of_l1_loss(pred_ofsts, kp_targ_ofst, labels, sigma=1.0, normalize=True,
reduce=False):
"""
:param pred_ofsts: [bs, n_kpts, n_pts, c]
:param kp_targ_ofst: [bs, n_pts, n_kpts, c]
:param labels: [bs, n_pts, 1]
"""
w = (... | 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
from torch.nn.modules.loss import _Loss
assert_size_stride = torch._C._dy... | ezxzeng/FFB6D | OFLoss | false | 15,326 | [
"MIT"
] | 145 | fd0ea6471532ab1dc68f9a58b52d9a63f8fb76f2 | https://github.com/ezxzeng/FFB6D/tree/fd0ea6471532ab1dc68f9a58b52d9a63f8fb76f2 |
MinibatchStd | import torch
import torch.nn as nn
import torch.utils.tensorboard
class MinibatchStd(nn.Module):
"""
Adds the aveage std of each data point over a
slice of the minibatch to that slice as a new
feature map. This gives an output with one extra
channel.
Arguments:
group_size (int): Number... | 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.tensorboard
assert_size_stride = torch... | andoleg/stylegan2_pytorch | MinibatchStd | false | 15,327 | [
"MIT"
] | 121 | 27a367d00d35742cf66587f1bd1b1263469a8101 | https://github.com/andoleg/stylegan2_pytorch/tree/27a367d00d35742cf66587f1bd1b1263469a8101 |
CosLoss | import torch
from torch.nn.modules.loss import _Loss
class CosLoss(_Loss):
def __init__(self, eps=1e-05):
super(CosLoss, self).__init__(True)
self.eps = eps
def forward(self, pred_ofsts, kp_targ_ofst, labels, normalize=True):
"""
:param pred_ofsts: [bs, n_kpts, n_pts, 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.triton_helpers import libdevice
from torch.nn.modules.loss import _Loss
assert_size_stride = torch._C._dynamo.g... | ezxzeng/FFB6D | CosLoss | false | 15,328 | [
"MIT"
] | 145 | fd0ea6471532ab1dc68f9a58b52d9a63f8fb76f2 | https://github.com/ezxzeng/FFB6D/tree/fd0ea6471532ab1dc68f9a58b52d9a63f8fb76f2 |
TestPointLSTM | import torch
import torch.nn as nn
class PointLSTMCell(nn.Module):
def __init__(self, pts_num, in_channels, hidden_dim, offset_dim, bias):
super(PointLSTMCell, self).__init__()
self.bias = bias
self.pts_num = pts_num
self.in_channels = in_channels
self.hidden_dim = 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
from torch._inductor.runtime.... | evanfebrianto/pointlstm_gesture_recognition_pytorch | TestPointLSTM | false | 15,329 | [
"Apache-2.0"
] | 69 | 797ccdc7da5a859e28f2a8cc7ef7118358b82cb4 | https://github.com/evanfebrianto/pointlstm_gesture_recognition_pytorch/tree/797ccdc7da5a859e28f2a8cc7ef7118358b82cb4 |
ResidualBlock | import torch
import torch.utils.data
import torch
import torch.nn as nn
class ResidualBlock(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size=3, padding=1,
stride=1):
super(ResidualBlock, self).__init__()
self.padding1 = nn.ReflectionPad2d(padding)
self.conv1 =... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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... | eungbean/CoCosNet | ResidualBlock | false | 15,330 | [
"MIT"
] | 319 | f8007d9369cc11bc04709ef02dedbbf718d74414 | https://github.com/eungbean/CoCosNet/tree/f8007d9369cc11bc04709ef02dedbbf718d74414 |
PointLSTMCell | import torch
import torch.nn as nn
class PointLSTMCell(nn.Module):
def __init__(self, pts_num, in_channels, hidden_dim, offset_dim, bias):
super(PointLSTMCell, self).__init__()
self.bias = bias
self.pts_num = pts_num
self.in_channels = in_channels
self.hidden_dim = 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
from torch._inductor.runtime.... | evanfebrianto/pointlstm_gesture_recognition_pytorch | PointLSTMCell | false | 15,331 | [
"Apache-2.0"
] | 69 | 797ccdc7da5a859e28f2a8cc7ef7118358b82cb4 | https://github.com/evanfebrianto/pointlstm_gesture_recognition_pytorch/tree/797ccdc7da5a859e28f2a8cc7ef7118358b82cb4 |
BerHuLoss | import torch
import torch.nn as nn
class BerHuLoss(nn.Module):
def __init__(self, scale=0.5, eps=1e-05):
super(BerHuLoss, self).__init__()
self.scale = scale
self.eps = eps
def forward(self, pred, gt):
img1 = torch.zeros_like(pred)
img2 = torch.zeros_like(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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | ezxzeng/FFB6D | BerHuLoss | false | 15,332 | [
"MIT"
] | 145 | fd0ea6471532ab1dc68f9a58b52d9a63f8fb76f2 | https://github.com/ezxzeng/FFB6D/tree/fd0ea6471532ab1dc68f9a58b52d9a63f8fb76f2 |
LogDepthL1Loss | import torch
import torch.nn as nn
class LogDepthL1Loss(nn.Module):
def __init__(self, eps=1e-05):
super(LogDepthL1Loss, self).__init__()
self.eps = eps
def forward(self, pred, gt):
pred = pred.view(-1)
gt = gt.view(-1)
mask = gt > self.eps
diff = torch.abs(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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | ezxzeng/FFB6D | LogDepthL1Loss | false | 15,333 | [
"MIT"
] | 145 | fd0ea6471532ab1dc68f9a58b52d9a63f8fb76f2 | https://github.com/ezxzeng/FFB6D/tree/fd0ea6471532ab1dc68f9a58b52d9a63f8fb76f2 |
_Multiply | from torch.nn import Module
import abc
import torch
from torch import Tensor
from torch.nn import Linear
from torch.nn import MSELoss
import torch.nn
from torch import rand
class ConverterModule(Module, abc.ABC):
"""Interface class for test modules for converter."""
@abc.abstractmethod
def input_fn(self)... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch.nn import Module
import abc
from torch import Tensor
from torch.nn im... | f-dangel/backpack | _Multiply | false | 15,334 | [
"MIT"
] | 395 | 1da7e53ebb2c490e2b7dd9f79116583641f3cca1 | https://github.com/f-dangel/backpack/tree/1da7e53ebb2c490e2b7dd9f79116583641f3cca1 |
FactorizedReduce | import torch
import torch.nn as nn
import torch.utils.data
import torch.utils
from matplotlib import cm as cm
from torch.nn.parallel import *
from torchvision.models import *
from torchvision.datasets import *
def get_norm_layer(norm, C):
if norm in [None, '', 'none']:
norm_layer = nn.Identity()
elif ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | evdcush/ppuda | FactorizedReduce | false | 15,335 | [
"MIT"
] | 262 | 22783ac92207da6730ee618c953af230c5c39f28 | https://github.com/evdcush/ppuda/tree/22783ac92207da6730ee618c953af230c5c39f28 |
OfstMapL1Loss | import torch
import torch.nn as nn
class OfstMapL1Loss(nn.Module):
def __init__(self, eps=1e-05):
super().__init__()
self.eps = eps
def forward(self, rgb_labels, pred, gt, normalize=True, reduce=True):
wgt = (rgb_labels > 1e-08).float()
bs, n_kpts, c, h, w = pred.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.triton_helpers import math as tl_math
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert... | ezxzeng/FFB6D | OfstMapL1Loss | false | 15,336 | [
"MIT"
] | 145 | fd0ea6471532ab1dc68f9a58b52d9a63f8fb76f2 | https://github.com/ezxzeng/FFB6D/tree/fd0ea6471532ab1dc68f9a58b52d9a63f8fb76f2 |
WeightNormConv2d | import torch
import torch.nn as nn
import torch.utils.data
class WeightNormConv2d(nn.Module):
def __init__(self, in_dim, out_dim, kernel_size, stride=1, padding=0,
bias=True, weight_norm=True, scale=False):
"""Intializes a Conv2d augmented with weight normalization.
(See torch.nn.utils.w... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 ... | eyalbetzalel/GlowGAN | WeightNormConv2d | false | 15,337 | [
"MIT"
] | 54 | 144b8fef60d9dc38ca66c178a18c0c9a2a17c23e | https://github.com/eyalbetzalel/GlowGAN/tree/144b8fef60d9dc38ca66c178a18c0c9a2a17c23e |
multi_scale_spatial | import torch
import torch.nn as nn
class multi_scale_spatial(nn.Module):
def __init__(self, limb_blocks):
super(multi_scale_spatial, self).__init__()
(self.left_arm, self.right_arm, self.left_leg, self.right_leg, self
.head_spine) = limb_blocks
self.maxpool1 = nn.AdaptiveMaxPo... | 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... | fabro66/Online-Skeleton-based-Action-Recognition | multi_scale_spatial | false | 15,338 | [
"MIT"
] | 63 | de00cbf17ceea98a7d07f68bbbd966bfd02d3b40 | https://github.com/fabro66/Online-Skeleton-based-Action-Recognition/tree/de00cbf17ceea98a7d07f68bbbd966bfd02d3b40 |
LayerNormGRUCell | import torch
from typing import Optional
import torch.nn.functional as F
from torch import nn
import torch.utils.data
import torch.nn
from torch.nn import RNNCellBase
import torch.multiprocessing
from torch.nn import Identity
class LayerNormGRUCell(RNNCellBase):
"""
Implements GRUCell with layer normalisation... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
from torch import n... | faz1993/InnerEye-DeepLearning | LayerNormGRUCell | false | 15,339 | [
"MIT"
] | 402 | fb258d5c9a3ba18565b5a67e7ac1f00127d9ecb9 | https://github.com/faz1993/InnerEye-DeepLearning/tree/fb258d5c9a3ba18565b5a67e7ac1f00127d9ecb9 |
LearnedPositionalEncoding | import torch
import torch.nn as nn
import torch.cuda
import torch.distributed
class LearnedPositionalEncoding(nn.Module):
def __init__(self, context_size, embedding_dim, dropout=0):
super(LearnedPositionalEncoding, self).__init__()
self.pe = nn.Embedding(context_size, embedding_dim)
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
import torch.nn as nn
import torch.cuda
import torch.distributed
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strid... | fangleai/encoder-agnostic-adaptation | LearnedPositionalEncoding | false | 15,340 | [
"MIT"
] | 70 | d917e654152df202dd35bba49c409c3ecd24eaf7 | https://github.com/fangleai/encoder-agnostic-adaptation/tree/d917e654152df202dd35bba49c409c3ecd24eaf7 |
MLP | import math
import torch
import torch.nn as nn
import torch.cuda
import torch.distributed
def gelu(x):
return 0.5 * x * (1 + torch.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 *
torch.pow(x, 3))))
class MLP(nn.Module):
def __init__(self, n_embd, n_state, dropout):
super(MLP, 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.triton_helpers import libdevice
import math
import ... | fangleai/encoder-agnostic-adaptation | MLP | false | 15,341 | [
"MIT"
] | 70 | d917e654152df202dd35bba49c409c3ecd24eaf7 | https://github.com/fangleai/encoder-agnostic-adaptation/tree/d917e654152df202dd35bba49c409c3ecd24eaf7 |
KnowledgeDistillationLoss | import torch
import torch.nn as nn
class KnowledgeDistillationLoss(nn.Module):
def __init__(self, reduction='mean', alpha=1.0):
super().__init__()
self.reduction = reduction
self.alpha = alpha
def forward(self, inputs, targets, mask=None):
inputs = inputs.narrow(1, 0, targets... | 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
... | fcdl94/ModelingTheBackground | KnowledgeDistillationLoss | false | 15,342 | [
"MIT"
] | 105 | 1c589833ce5c1a7446469d4602ceab2cdeac1b0e | https://github.com/fcdl94/ModelingTheBackground/tree/1c589833ce5c1a7446469d4602ceab2cdeac1b0e |
ActNorm | import torch
import torch.utils.data
class ActNorm(torch.nn.Module):
def __init__(self, nsq, data_init=True):
super(ActNorm, self).__init__()
self.initialized = not data_init
self.m = torch.nn.Parameter(torch.zeros(1, nsq, 1))
self.logs = torch.nn.Parameter(torch.zeros(1, nsq, 1))... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.utils.data
assert_size_stride = torch._C._dynamo.guards.asse... | entn-at/blow | ActNorm | false | 15,343 | [
"Apache-2.0"
] | 147 | b597286b24c7ea88c8d9408f9aa35aa8df2ebe11 | https://github.com/entn-at/blow/tree/b597286b24c7ea88c8d9408f9aa35aa8df2ebe11 |
PosEnc | import torch
import torch.nn as nn
import torch.utils.data
import torch.utils
from matplotlib import cm as cm
from torch.nn.parallel import *
from torchvision.models import *
from torchvision.datasets import *
class PosEnc(nn.Module):
def __init__(self, C, ks):
super().__init__()
self.weight = nn... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
import torch.utils.data
import torch.utils
from matplotlib import cm as cm
from torch.nn.parallel import *
from torchv... | evdcush/ppuda | PosEnc | false | 15,344 | [
"MIT"
] | 262 | 22783ac92207da6730ee618c953af230c5c39f28 | https://github.com/evdcush/ppuda/tree/22783ac92207da6730ee618c953af230c5c39f28 |
LearnedUpsampling1d | import torch
from torch import nn
class LearnedUpsampling1d(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, bias=True):
super().__init__()
self.conv_t = nn.ConvTranspose1d(in_channels=in_channels,
out_channels=out_channels, kernel_size=kernel_size, stride=
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_st... | fdb/samplernn-pytorch | LearnedUpsampling1d | false | 15,345 | [
"MIT"
] | 259 | 87ce71cc2cf26601a271648597f198df33059f96 | https://github.com/fdb/samplernn-pytorch/tree/87ce71cc2cf26601a271648597f198df33059f96 |
MinibatchStdDev | import torch
import torch.utils.cpp_extension
class MinibatchStdDev(torch.nn.Module):
def __init__(self, group_size, num_channels=1):
super().__init__()
self.group_size = group_size
self.num_channels = num_channels
def forward(self, x):
N, C, H, W = x.shape
G = self.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.triton_helpers import libdevice
import torch.utils.cpp_extension
assert_size_stride = torch._C._dynamo.guards.a... | STomoya/animeface | MinibatchStdDev | false | 15,346 | [
"MIT"
] | 61 | 37b3cd26097d7874559d4c152e41e5712b7a1a42 | https://github.com/STomoya/animeface/tree/37b3cd26097d7874559d4c152e41e5712b7a1a42 |
SimpleFusionGenerator | import torch
import torch.nn as nn
import torch.cuda
import torch.distributed
class SimpleFusionGenerator(nn.Module):
def __init__(self, decoder_input_size, lm_input_size, output_size):
super(SimpleFusionGenerator, self).__init__()
self.decoder_linear = nn.Linear(decoder_input_size, output_size)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | fangleai/encoder-agnostic-adaptation | SimpleFusionGenerator | false | 15,347 | [
"MIT"
] | 70 | d917e654152df202dd35bba49c409c3ecd24eaf7 | https://github.com/fangleai/encoder-agnostic-adaptation/tree/d917e654152df202dd35bba49c409c3ecd24eaf7 |
PointwiseFeedForward | import torch
import torch.nn as nn
class PointwiseFeedForward(nn.Module):
"""
A two-feed-forward-layer module
"""
def __init__(self, d_hid, d_inner_hid=None, d_out=None, dropout=0):
super(PointwiseFeedForward, self).__init__()
if d_inner_hid is None:
d_inner_hid = d_hid
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | fhamborg/NewsMTSC | PointwiseFeedForward | false | 15,348 | [
"MIT"
] | 46 | 5a8f88d7fbb921090e984cc378b02d75524c1025 | https://github.com/fhamborg/NewsMTSC/tree/5a8f88d7fbb921090e984cc378b02d75524c1025 |
Noise | import torch
import torch.utils.data
import torch.nn as nn
class Noise(nn.Module):
def __init__(self):
super(Noise, self).__init__()
def forward(self, input, train=False):
input = input * 255.0
if train:
noise = torch.nn.init.uniform_(torch.zeros_like(input), -0.5, 0.5)
... | 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... | felixcheng97/IICNet | Noise | false | 15,349 | [
"MIT"
] | 50 | 2648d7148c01a03226128c24a285c4a52e2b5aa0 | https://github.com/felixcheng97/IICNet/tree/2648d7148c01a03226128c24a285c4a52e2b5aa0 |
Decoder | import torch
import torch.nn as nn
class Decoder(nn.Module):
def __init__(self, latent_size, out_size):
super().__init__()
self.linear1 = nn.Linear(latent_size, int(out_size / 4))
self.linear2 = nn.Linear(int(out_size / 4), int(out_size / 2))
self.linear3 = nn.Linear(int(out_size ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | finloop/usad | Decoder | false | 15,350 | [
"BSD-3-Clause"
] | 65 | 5e1bf326af5f1325fa4676a2de978cae6db0481c | https://github.com/finloop/usad/tree/5e1bf326af5f1325fa4676a2de978cae6db0481c |
BasicBlock | import torch
import torch.nn as nn
import torch.utils.data
def conv1x1(in_planes, out_planes, stride=1):
"""1x1 convolution"""
return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=stride,
bias=False)
def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1):
"""3x3 convolution ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | ferodia/MichiGAN | BasicBlock | false | 15,351 | [
"MIT"
] | 235 | a49acb49f9659d7538e62faa3ed08e46afb0ddae | https://github.com/ferodia/MichiGAN/tree/a49acb49f9659d7538e62faa3ed08e46afb0ddae |
Attention | import math
import torch
import torch.nn.functional as F
import torch.nn as nn
class Attention(nn.Module):
def __init__(self, embed_dim, hidden_dim=None, out_dim=None, n_head=1,
score_function='dot_product', dropout=0):
""" Attention Mechanism
:param embed_dim:
:param 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
from torch._inductor.runtime.... | fhamborg/NewsMTSC | Attention | false | 15,352 | [
"MIT"
] | 46 | 5a8f88d7fbb921090e984cc378b02d75524c1025 | https://github.com/fhamborg/NewsMTSC/tree/5a8f88d7fbb921090e984cc378b02d75524c1025 |
Round | import torch
import torch.utils.data
import torch.nn as nn
class Quant(torch.autograd.Function):
@staticmethod
def forward(ctx, input):
input = torch.clamp(input, 0, 255.0)
output = input.round() * 1.0
return output
@staticmethod
def backward(ctx, grad_output):
return... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
import torch.utils.data
impo... | felixcheng97/IICNet | Round | false | 15,353 | [
"MIT"
] | 50 | 2648d7148c01a03226128c24a285c4a52e2b5aa0 | https://github.com/felixcheng97/IICNet/tree/2648d7148c01a03226128c24a285c4a52e2b5aa0 |
PadSameConv2d | import math
import torch
import torch.nn.functional as F
class PadSameConv2d(torch.nn.Module):
def __init__(self, kernel_size, stride=1):
"""
Imitates padding_mode="same" from tensorflow.
:param kernel_size: Kernelsize of the convolution, int or tuple/list
:param stride: Stride of... | 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... | fish258/MonoRec | PadSameConv2d | false | 15,354 | [
"MIT"
] | 388 | c0612d2710802004cdd83205e63d0582de543c41 | https://github.com/fish258/MonoRec/tree/c0612d2710802004cdd83205e63d0582de543c41 |
Encoder | import torch
import torch.nn as nn
class Encoder(nn.Module):
def __init__(self, in_size, latent_size):
super().__init__()
self.linear1 = nn.Linear(in_size, int(in_size / 2))
self.linear2 = nn.Linear(int(in_size / 2), int(in_size / 4))
self.linear3 = nn.Linear(int(in_size / 4), lat... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | finloop/usad | Encoder | false | 15,355 | [
"BSD-3-Clause"
] | 65 | 5e1bf326af5f1325fa4676a2de978cae6db0481c | https://github.com/finloop/usad/tree/5e1bf326af5f1325fa4676a2de978cae6db0481c |
Offset | import torch
from torch import nn
class Offset(nn.Module):
def __init__(self, init_value=0.0):
super(Offset, self).__init__()
self.bias = nn.Parameter(torch.FloatTensor([init_value]))
def forward(self, input):
return input + self.bias
def get_inputs():
return [torch.rand([4, 4,... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_str... | flipson/dd3d | Offset | false | 15,356 | [
"MIT"
] | 227 | 86d8660c29612b79836dad9b6c39972ac2ca1557 | https://github.com/flipson/dd3d/tree/86d8660c29612b79836dad9b6c39972ac2ca1557 |
GlobalSumPool2d | import torch
import torch.nn as nn
import torch.utils.cpp_extension
class GlobalSumPool2d(nn.Module):
def forward(self, x):
return torch.sum(x, [2, 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
import torch.nn as nn
import torch.utils.cpp_extension
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = ... | STomoya/animeface | GlobalSumPool2d | false | 15,357 | [
"MIT"
] | 61 | 37b3cd26097d7874559d4c152e41e5712b7a1a42 | https://github.com/STomoya/animeface/tree/37b3cd26097d7874559d4c152e41e5712b7a1a42 |
period_L2 | import torch
import numpy as np
import torch.nn as nn
def reduction_mean(loss):
return loss.mean()
def reduction_none(loss):
return loss
def reduction_sum(loss):
return loss.sum()
class period_L2(nn.Module):
def __init__(self, reduction='sum'):
"""
periodic Squared Error
... | 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... | flytocc/RAPiD | period_L2 | false | 15,358 | [
"MIT"
] | 142 | 92e6a44b8a0107def055e93c971d78fd548562f8 | https://github.com/flytocc/RAPiD/tree/92e6a44b8a0107def055e93c971d78fd548562f8 |
ConvReLU2 | import math
import torch
import torch.nn.functional as F
from torch.nn import Conv2d
from torch.nn import LeakyReLU
class PadSameConv2d(torch.nn.Module):
def __init__(self, kernel_size, stride=1):
"""
Imitates padding_mode="same" from tensorflow.
:param kernel_size: Kernelsize of the 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
import math
import torch.nn.functional as F
from torch.nn import Conv2d
from tor... | fish258/MonoRec | ConvReLU2 | false | 15,359 | [
"MIT"
] | 388 | c0612d2710802004cdd83205e63d0582de543c41 | https://github.com/fish258/MonoRec/tree/c0612d2710802004cdd83205e63d0582de543c41 |
ChannelSELayer | import torch
import torch.nn as nn
import torch.utils.data
import torch.utils
from matplotlib import cm as cm
from torch.nn.parallel import *
from torchvision.models import *
from torchvision.datasets import *
class ChannelSELayer(nn.Module):
"""
Copied from https://github.com/ai-med/squeeze_and_excitation/bl... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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 ... | evdcush/ppuda | ChannelSELayer | false | 15,360 | [
"MIT"
] | 262 | 22783ac92207da6730ee618c953af230c5c39f28 | https://github.com/evdcush/ppuda/tree/22783ac92207da6730ee618c953af230c5c39f28 |
Upconv | import math
import torch
import torch.nn.functional as F
from torch.nn import Conv2d
from torch.nn import Upsample
class PadSameConv2d(torch.nn.Module):
def __init__(self, kernel_size, stride=1):
"""
Imitates padding_mode="same" from tensorflow.
:param kernel_size: Kernelsize of the convo... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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.functional as F
from torch.nn import Conv2d
from tor... | fish258/MonoRec | Upconv | false | 15,361 | [
"MIT"
] | 388 | c0612d2710802004cdd83205e63d0582de543c41 | https://github.com/fish258/MonoRec/tree/c0612d2710802004cdd83205e63d0582de543c41 |
OrthogonalFusion | import torch
import torch.nn as nn
class OrthogonalFusion(nn.Module):
def __init__(self):
super().__init__()
def forward(self, local_feat, global_feat):
global_feat_norm = torch.norm(global_feat, p=2, dim=1)
projection = torch.bmm(global_feat.unsqueeze(1), torch.flatten(
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 ... | flrngel/DOLG-pytorch | OrthogonalFusion | false | 15,362 | [
"MIT"
] | 56 | 97732d2932ef6733f17cf8ac1aee990effe6fd64 | https://github.com/flrngel/DOLG-pytorch/tree/97732d2932ef6733f17cf8ac1aee990effe6fd64 |
compute_g_spa | import torch
import torch.nn as nn
class cnn1x1(nn.Module):
def __init__(self, dim1=3, dim2=3, bias=True):
super(cnn1x1, self).__init__()
self.cnn = nn.Conv2d(dim1, dim2, kernel_size=1, bias=bias)
def forward(self, x):
x = self.cnn(x)
return x
class compute_g_spa(nn.Module)... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | fabro66/Online-Skeleton-based-Action-Recognition | compute_g_spa | false | 15,363 | [
"MIT"
] | 63 | de00cbf17ceea98a7d07f68bbbd966bfd02d3b40 | https://github.com/fabro66/Online-Skeleton-based-Action-Recognition/tree/de00cbf17ceea98a7d07f68bbbd966bfd02d3b40 |
CompositeActivation | import torch
class CompositeActivation(torch.nn.Module):
def forward(self, x):
x = torch.atan(x)
return torch.cat([x / 0.67, x * x / 0.6], 1)
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
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_c... | fuzhanrahmanian/lucent | CompositeActivation | false | 15,364 | [
"Apache-2.0"
] | 449 | 13b24c3c37784185275da73c7a11095b2ae809c5 | https://github.com/fuzhanrahmanian/lucent/tree/13b24c3c37784185275da73c7a11095b2ae809c5 |
AddAndNorm | import torch
import torch.nn as nn
class AddAndNorm(nn.Module):
def __init__(self, d_model):
super(AddAndNorm, self).__init__()
self.layer_norm = nn.LayerNorm(d_model)
def forward(self, x, residual):
return self.layer_norm(x + residual)
def get_inputs():
return [torch.rand([4, ... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_... | francismontalbo/attention-is-all-you-need-paper | AddAndNorm | false | 15,365 | [
"MIT"
] | 167 | 21ba3e48917da0c6808126d183bece6a9969cfd2 | https://github.com/francismontalbo/attention-is-all-you-need-paper/tree/21ba3e48917da0c6808126d183bece6a9969cfd2 |
ConvSig | import math
import torch
import torch.nn.functional as F
from torch.nn import Conv2d
from torch.nn import Sigmoid
class PadSameConv2d(torch.nn.Module):
def __init__(self, kernel_size, stride=1):
"""
Imitates padding_mode="same" from tensorflow.
:param kernel_size: Kernelsize of the convol... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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.functional as F
from torch.nn import Conv2d
from tor... | fish258/MonoRec | ConvSig | false | 15,366 | [
"MIT"
] | 388 | c0612d2710802004cdd83205e63d0582de543c41 | https://github.com/fish258/MonoRec/tree/c0612d2710802004cdd83205e63d0582de543c41 |
SqueezeEmbedding | import torch
import torch.nn as nn
class SqueezeEmbedding(nn.Module):
"""
Squeeze sequence embedding length to the longest one in the batch
"""
def __init__(self, batch_first=True):
super(SqueezeEmbedding, self).__init__()
self.batch_first = batch_first
def forward(self, x, x_len... | 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... | froth-synthesio/PyABSA | SqueezeEmbedding | false | 15,367 | [
"MIT"
] | 199 | 61406e7a49f93f6c986dfd7e583d730b69c2861c | https://github.com/froth-synthesio/PyABSA/tree/61406e7a49f93f6c986dfd7e583d730b69c2861c |
period_L1 | import torch
import numpy as np
import torch.nn as nn
class period_L1(nn.Module):
def __init__(self, reduction='sum'):
"""
periodic Squared Error
"""
super().__init__()
self.reduction = reduction
def forward(self, theta_pred, theta_gt):
dt = theta_pred - theta... | 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... | flytocc/RAPiD | period_L1 | false | 15,368 | [
"MIT"
] | 142 | 92e6a44b8a0107def055e93c971d78fd548562f8 | https://github.com/flytocc/RAPiD/tree/92e6a44b8a0107def055e93c971d78fd548562f8 |
ConvReLU | import math
import torch
import torch.nn.functional as F
from torch.nn import Conv2d
from torch.nn import LeakyReLU
class PadSameConv2d(torch.nn.Module):
def __init__(self, kernel_size, stride=1):
"""
Imitates padding_mode="same" from tensorflow.
:param kernel_size: Kernelsize of the 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
import math
import torch.nn.functional as F
from torch.nn import Conv2d
from tor... | fish258/MonoRec | ConvReLU | false | 15,369 | [
"MIT"
] | 388 | c0612d2710802004cdd83205e63d0582de543c41 | https://github.com/fish258/MonoRec/tree/c0612d2710802004cdd83205e63d0582de543c41 |
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.... | fiveflowers/ViLT | Block | false | 15,370 | [
"Apache-2.0"
] | 587 | 762fd3975c180db6fc88f577cf39549983fa373a | https://github.com/fiveflowers/ViLT/tree/762fd3975c180db6fc88f577cf39549983fa373a |
ATLoss | import torch
import torch.nn as nn
def multilabel_categorical_crossentropy(y_pred, y_true):
y_pred = (1 - 2 * y_true) * y_pred
y_pred_neg = y_pred - y_true * 1000000000000.0
y_pred_pos = y_pred - (1 - y_true) * 1000000000000.0
zeros = torch.zeros_like(y_pred[..., :1])
y_pred_neg = torch.cat([y_pre... | 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
... | fmc123653/DeepKE | ATLoss | false | 15,371 | [
"MIT"
] | 676 | 4d30e51368681c7cb73e2ecacf9b922b441cbe99 | https://github.com/fmc123653/DeepKE/tree/4d30e51368681c7cb73e2ecacf9b922b441cbe99 |
GeM | import torch
import torch.nn as nn
import torch.nn.functional as F
class GeM(nn.Module):
def __init__(self, p=3, eps=1e-06, requires_grad=False):
super(GeM, self).__init__()
self.p = nn.Parameter(torch.ones(1) * p, requires_grad=requires_grad)
self.eps = eps
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... | flrngel/DOLG-pytorch | GeM | false | 15,372 | [
"MIT"
] | 56 | 97732d2932ef6733f17cf8ac1aee990effe6fd64 | https://github.com/flrngel/DOLG-pytorch/tree/97732d2932ef6733f17cf8ac1aee990effe6fd64 |
fusion | import torch
import torch.nn as nn
from torch.nn import Linear
class fusion(nn.Module):
def __init__(self, feature_size=768):
super(fusion, self).__init__()
self.fc1 = Linear(feature_size * 3, 1)
self.fc2 = Linear(feature_size * 3, 1)
self.fc3 = Linear(feature_size * 3, 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
import torch.nn as nn
from torch.nn import Linear
assert_size_stride = torch._C.... | funnyzhou/REFERS | fusion | false | 15,373 | [
"MIT"
] | 46 | 392eddf13cbf3c3a7dc0bf8bfffd108ca4a65a19 | https://github.com/funnyzhou/REFERS/tree/392eddf13cbf3c3a7dc0bf8bfffd108ca4a65a19 |
LossesOfConVIRT | import torch
import torch.nn as nn
class LossesOfConVIRT(nn.Module):
"""
"""
def __init__(self, tau=0.1, lambd=0.75):
super(LossesOfConVIRT, self).__init__()
self.tau = tau
self.lambd = lambd
def tmp_loss(self, v, u, index):
"""
"""
assert v.size(0) ... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import torc... | funnyzhou/REFERS | LossesOfConVIRT | false | 15,374 | [
"MIT"
] | 46 | 392eddf13cbf3c3a7dc0bf8bfffd108ca4a65a19 | https://github.com/funnyzhou/REFERS/tree/392eddf13cbf3c3a7dc0bf8bfffd108ca4a65a19 |
LocalResponseNormLayer | import torch
import torch.nn as nn
import torch.nn.functional as F
class LocalResponseNormLayer(nn.Module):
def forward(self, tensor, size=5, alpha=9.999999747378752e-05, beta=
0.75, k=1.0):
return F.local_response_norm(tensor, size=size, alpha=alpha, beta=
beta, k=k)
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.triton_helpers import libdevice
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_... | fuzhanrahmanian/lucent | LocalResponseNormLayer | false | 15,375 | [
"Apache-2.0"
] | 449 | 13b24c3c37784185275da73c7a11095b2ae809c5 | https://github.com/fuzhanrahmanian/lucent/tree/13b24c3c37784185275da73c7a11095b2ae809c5 |
LinearTextualHead | import torch
import torch.nn as nn
from typing import Optional
class TextualHead(nn.Module):
"""
Base class for all textual heads. All child classes can simply inherit
from :class:`~torch.nn.Module`, however this is kept here for uniform
type annotations.
Parameters
----------
visual_feat... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | funnyzhou/REFERS | LinearTextualHead | false | 15,376 | [
"MIT"
] | 46 | 392eddf13cbf3c3a7dc0bf8bfffd108ca4a65a19 | https://github.com/funnyzhou/REFERS/tree/392eddf13cbf3c3a7dc0bf8bfffd108ca4a65a19 |
MultiHeadAttention | import math
import torch
import torch.nn as nn
class ScaledDotProductAttention(nn.Module):
def __init__(self, d_head):
super(ScaledDotProductAttention, self).__init__()
self.d_head = d_head
self.attention_dropout = nn.Dropout(p=0.1)
def forward(self, q, k, v, mask=None):
atte... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | francismontalbo/attention-is-all-you-need-paper | MultiHeadAttention | false | 15,377 | [
"MIT"
] | 167 | 21ba3e48917da0c6808126d183bece6a9969cfd2 | https://github.com/francismontalbo/attention-is-all-you-need-paper/tree/21ba3e48917da0c6808126d183bece6a9969cfd2 |
TransformerGPTEncoderLayer | import math
import torch
import torch.nn as nn
import torch.cuda
import torch.distributed
def gelu(x):
return 0.5 * x * (1 + torch.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 *
torch.pow(x, 3))))
def generate_relative_positions_matrix(length, max_relative_positions,
cache=False):
"""Generate the... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | fangleai/encoder-agnostic-adaptation | TransformerGPTEncoderLayer | false | 15,378 | [
"MIT"
] | 70 | d917e654152df202dd35bba49c409c3ecd24eaf7 | https://github.com/fangleai/encoder-agnostic-adaptation/tree/d917e654152df202dd35bba49c409c3ecd24eaf7 |
DiceLoss | import torch
import torch.nn as nn
class DiceLoss(nn.Module):
"""Sørensen–Dice coefficient loss to calculate
the mean loss over a batch of data.This loss mainly
calculates the similarity between two samples.
To know more about this loss check this link:
https://en.wikipedia.org/wiki/S%C3%B8rensen%... | 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... | g-freire/Brain-Tumor-Segmentation | DiceLoss | false | 15,379 | [
"MIT"
] | 156 | e4f258feb64c11815570e295c58bda78afd21ab9 | https://github.com/g-freire/Brain-Tumor-Segmentation/tree/e4f258feb64c11815570e295c58bda78afd21ab9 |
MaxPool2dLayer | import torch
import torch.nn as nn
import torch.nn.functional as F
class MaxPool2dLayer(nn.Module):
def forward(self, tensor, kernel_size=(3, 3), stride=(1, 1), padding=0,
ceil_mode=False):
return F.max_pool2d(tensor, kernel_size, stride=stride, padding=
padding, ceil_mode=ceil_mode)
... | 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... | fuzhanrahmanian/lucent | MaxPool2dLayer | false | 15,380 | [
"Apache-2.0"
] | 449 | 13b24c3c37784185275da73c7a11095b2ae809c5 | https://github.com/fuzhanrahmanian/lucent/tree/13b24c3c37784185275da73c7a11095b2ae809c5 |
CosineBasisLinear | import torch
import numpy as np
from torch import nn
def cosine_basis_functions(x, n_basis_functions=64):
"""Cosine basis functions used to embed quantile thresholds.
Args:
x (torch.Tensor): Input.
n_basis_functions (int): Number of cosine basis functions.
Returns:
ndarray: Embed... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 numpy ... | g-votte/pfrl | CosineBasisLinear | false | 15,381 | [
"MIT"
] | 824 | 4c30c1d73f0941a2b649b62937eec346bb55a95e | https://github.com/g-votte/pfrl/tree/4c30c1d73f0941a2b649b62937eec346bb55a95e |
FCLateActionSAQFunction | import torch
import numpy as np
from torch import nn
from abc import ABCMeta
from abc import abstractmethod
import torch.nn.functional as F
def init_lecun_normal(tensor, scale=1.0):
"""Initializes the tensor with LeCunNormal."""
fan_in = torch.nn.init._calculate_correct_fan(tensor, 'fan_in')
std = scale *... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import numpy as np
from torch... | g-votte/pfrl | FCLateActionSAQFunction | false | 15,382 | [
"MIT"
] | 824 | 4c30c1d73f0941a2b649b62937eec346bb55a95e | https://github.com/g-votte/pfrl/tree/4c30c1d73f0941a2b649b62937eec346bb55a95e |
BertAttention | from _paritybench_helpers import _mock_config
import math
import torch
from torch import nn
class BertLayerNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-12):
"""Construct a layernorm module in the TF style (epsilon inside the square root).
"""
super(BertLayerNorm, self).__init__... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | BIT-ENGD/eeqa | BertAttention | false | 15,383 | [
"MIT"
] | 142 | 2995abbaff1fb47131246a247ee7ed62aa94f4c3 | https://github.com/BIT-ENGD/eeqa/tree/2995abbaff1fb47131246a247ee7ed62aa94f4c3 |
FocalLoss | import torch
from torch import nn
def log_minus_sigmoid(x):
return torch.clamp(-x, max=0) - torch.log(1 + torch.exp(-torch.abs(x))
) + 0.5 * torch.clamp(x, min=0, max=0)
def log_sigmoid(x):
return torch.clamp(x, max=0) - torch.log(1 + torch.exp(-torch.abs(x))
) + 0.5 * torch.clamp(x, min=0, ... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
from torch import nn
a... | gabrielsluz/vince | FocalLoss | false | 15,384 | [
"Apache-2.0"
] | 61 | f4e17a2cf70c080a7e01e46d15537e33224c869b | https://github.com/gabrielsluz/vince/tree/f4e17a2cf70c080a7e01e46d15537e33224c869b |
PPO | import random
import torch
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
class BatchMaker:
def __init__(self, states, actions, returns, advantages, old_policies):
self.states = states
self.actions = actions
self.returns = returns
self.advantages = advant... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | g6ling/Pytorch-Cartpole | PPO | false | 15,385 | [
"MIT"
] | 116 | ecb7b622cfefe825ac95388cceb6752413d90a2a | https://github.com/g6ling/Pytorch-Cartpole/tree/ecb7b622cfefe825ac95388cceb6752413d90a2a |
BCEDiceLoss | import torch
import torch.nn as nn
import torch.nn.functional as F
class DiceLoss(nn.Module):
"""Sørensen–Dice coefficient loss to calculate
the mean loss over a batch of data.This loss mainly
calculates the similarity between two samples.
To know more about this loss check this link:
https://en.w... | 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... | g-freire/Brain-Tumor-Segmentation | BCEDiceLoss | false | 15,386 | [
"MIT"
] | 156 | e4f258feb64c11815570e295c58bda78afd21ab9 | https://github.com/g-freire/Brain-Tumor-Segmentation/tree/e4f258feb64c11815570e295c58bda78afd21ab9 |
TNPG | import torch
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
def flat_grad(grads):
grad_flatten = []
for grad in grads:
grad_flatten.append(grad.view(-1))
grad_flatten = torch.cat(grad_flatten)
return grad_flatten
def flat_hessian(hessians):
hessians_flatten = []... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | g6ling/Pytorch-Cartpole | TNPG | false | 15,387 | [
"MIT"
] | 116 | ecb7b622cfefe825ac95388cceb6752413d90a2a | https://github.com/g6ling/Pytorch-Cartpole/tree/ecb7b622cfefe825ac95388cceb6752413d90a2a |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.