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 |
|---|---|---|---|---|---|---|---|---|---|---|
Attention | import torch
from torch import nn
import torch.nn.utils
class Attention(nn.Module):
def __init__(self, hidden_dim):
super(Attention, self).__init__()
self.hidden_dim = hidden_dim
self.ff = nn.Linear(in_features=hidden_dim, out_features=1)
self.softmax = nn.Softmax(dim=-1)
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._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | bstee615/ReVeal | Attention | false | 14,982 | [
"MIT"
] | 63 | fc22d0d54a3a23d4e0bc45a249b7eea22749685e | https://github.com/bstee615/ReVeal/tree/fc22d0d54a3a23d4e0bc45a249b7eea22749685e |
TriangularSylvester | import torch
from torch import nn
class TriangularSylvester(nn.Module):
"""
Sylvester normalizing flow with Q=P or Q=I.
"""
def __init__(self, z_size):
super(TriangularSylvester, self).__init__()
self.z_size = z_size
self.h = nn.Tanh()
def der_h(self, x):
return s... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
fr... | boldsort/NeuralDX7 | TriangularSylvester | false | 14,983 | [
"MIT"
] | 119 | 327844cea18a6dfe35e0dc8f5de0832343487366 | https://github.com/boldsort/NeuralDX7/tree/327844cea18a6dfe35e0dc8f5de0832343487366 |
MSE | import torch
import torch.nn as nn
import torch.utils.checkpoint
class MSE(nn.Module):
def __init__(self):
super(MSE, self).__init__()
def forward(self, pred, real):
diffs = torch.add(real, -pred)
n = torch.numel(diffs.data)
mse = torch.sum(diffs.pow(2)) / n
return ms... | 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.checkpoint
assert_size_stride = torch._C._dynamo... | byamao1/MMSA | MSE | false | 14,984 | [
"MIT"
] | 198 | 1a894d042144c9ac75b3465d38871ce8c2987251 | https://github.com/byamao1/MMSA/tree/1a894d042144c9ac75b3465d38871ce8c2987251 |
LRN | import torch
import torch.nn as nn
class LRN(nn.Module):
def __init__(self, local_size=1, alpha=1.0, beta=0.75, ACROSS_CHANNELS=True
):
super(LRN, self).__init__()
self.ACROSS_CHANNELS = ACROSS_CHANNELS
if ACROSS_CHANNELS:
self.average = nn.AvgPool3d(kernel_size=(local... | 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_... | bruinxiong/BNM | LRN | false | 14,985 | [
"MIT"
] | 252 | 71d4b8c9beca00e77fcbc62a12b69bb093736a82 | https://github.com/bruinxiong/BNM/tree/71d4b8c9beca00e77fcbc62a12b69bb093736a82 |
SIMSE | import torch
import torch.nn as nn
import torch.utils.checkpoint
class SIMSE(nn.Module):
def __init__(self):
super(SIMSE, self).__init__()
def forward(self, pred, real):
diffs = torch.add(real, -pred)
n = torch.numel(diffs.data)
simse = torch.sum(diffs).pow(2) / n ** 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.utils.checkpoint
assert_size_stride = torch._C._dynamo... | byamao1/MMSA | SIMSE | false | 14,986 | [
"MIT"
] | 198 | 1a894d042144c9ac75b3465d38871ce8c2987251 | https://github.com/byamao1/MMSA/tree/1a894d042144c9ac75b3465d38871ce8c2987251 |
ActorCriticMLP | import torch
from torch import Tensor
from torch import nn
from typing import Tuple
from torch.nn import functional as F
class ActorCriticMLP(nn.Module):
"""MLP network with heads for actor and critic."""
def __init__(self, input_shape: 'Tuple[int]', n_actions: 'int',
hidden_size: 'int'=128):
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | bzrry/lightning-bolts | ActorCriticMLP | false | 14,987 | [
"Apache-2.0"
] | 822 | bd392ad858039290c72c20cc3f10df39384e90b9 | https://github.com/bzrry/lightning-bolts/tree/bd392ad858039290c72c20cc3f10df39384e90b9 |
Mlp | import torch
import numpy as np
from torch import nn
import torch.nn.functional as F
class GELU(nn.Module):
def __init__(self):
super(GELU, self).__init__()
def forward(self, x):
return 0.5 * x * (1 + F.tanh(np.sqrt(2 / np.pi) * (x + 0.044715 *
torch.pow(x, 3))))
class Mlp(nn.M... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import numpy as np
... | bubbliiiing/classification-pytorch | Mlp | false | 14,988 | [
"MIT"
] | 88 | ee62c05bd3094c3fab48bada5a57cb2ed8b61c11 | https://github.com/bubbliiiing/classification-pytorch/tree/ee62c05bd3094c3fab48bada5a57cb2ed8b61c11 |
PatchEmbed | import torch
from torch import nn
class PatchEmbed(nn.Module):
def __init__(self, input_shape=[224, 224], patch_size=16, in_chans=3,
num_features=768, norm_layer=None, flatten=True):
super().__init__()
self.num_patches = input_shape[0] // patch_size * (input_shape[1] //
patch_... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import 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... | bubbliiiing/classification-pytorch | PatchEmbed | false | 14,989 | [
"MIT"
] | 88 | ee62c05bd3094c3fab48bada5a57cb2ed8b61c11 | https://github.com/bubbliiiing/classification-pytorch/tree/ee62c05bd3094c3fab48bada5a57cb2ed8b61c11 |
QRNNLayer | import torch
import torch.nn as nn
from torch.optim import *
class ForgetMult(torch.nn.Module):
"""ForgetMult computes a simple recurrent equation:
h_t = f_t * x_t + (1 - f_t) * h_{t-1}
This equation is equivalent to dynamic weighted averaging.
Inputs: X, hidden
- X (seq_len, batch, input_si... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as ... | boshining/NeuronBlocks | QRNNLayer | false | 14,990 | [
"MIT"
] | 1,257 | 74fbb8658fb3f1cffea5c9bc84b2a1da59c20dd9 | https://github.com/boshining/NeuronBlocks/tree/74fbb8658fb3f1cffea5c9bc84b2a1da59c20dd9 |
DiffLoss | import torch
import torch.nn as nn
import torch.utils.checkpoint
class DiffLoss(nn.Module):
def __init__(self):
super(DiffLoss, self).__init__()
def forward(self, input1, input2):
batch_size = input1.size(0)
input1 = input1.view(batch_size, -1)
input2 = input2.view(batch_size... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 ... | byamao1/MMSA | DiffLoss | false | 14,991 | [
"MIT"
] | 198 | 1a894d042144c9ac75b3465d38871ce8c2987251 | https://github.com/byamao1/MMSA/tree/1a894d042144c9ac75b3465d38871ce8c2987251 |
MultiheadAttention | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.parameter import Parameter
import torch.utils.checkpoint
from torch.nn import Parameter
class MultiheadAttention(nn.Module):
"""Multi-headed attention.
See "Attention Is All You Need" for more details.
"""
def __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._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | byamao1/MMSA | MultiheadAttention | false | 14,992 | [
"MIT"
] | 198 | 1a894d042144c9ac75b3465d38871ce8c2987251 | https://github.com/byamao1/MMSA/tree/1a894d042144c9ac75b3465d38871ce8c2987251 |
Discriminator | import torch
import numpy as np
from torch import nn
from torch.nn import functional as F
class Discriminator(nn.Module):
def __init__(self, img_shape, hidden_dim=1024):
super().__init__()
in_dim = int(np.prod(img_shape))
self.fc1 = nn.Linear(in_dim, hidden_dim)
self.fc2 = nn.Line... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import numpy as np
from torch import nn
assert_size_stride = torch._C._dynamo.gu... | bzrry/lightning-bolts | Discriminator | false | 14,993 | [
"Apache-2.0"
] | 822 | bd392ad858039290c72c20cc3f10df39384e90b9 | https://github.com/bzrry/lightning-bolts/tree/bd392ad858039290c72c20cc3f10df39384e90b9 |
SchedulerTestNet | import torch
from torch.nn import functional as F
class SchedulerTestNet(torch.nn.Module):
"""adapted from: https://github.com/pytorch/pytorch/blob/master/test/test_optim.py."""
def __init__(self):
super().__init__()
self.conv1 = torch.nn.Conv2d(1, 1, 1)
self.conv2 = torch.nn.Conv2d(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
assert_size_stride = torch._C... | bzrry/lightning-bolts | SchedulerTestNet | false | 14,994 | [
"Apache-2.0"
] | 822 | bd392ad858039290c72c20cc3f10df39384e90b9 | https://github.com/bzrry/lightning-bolts/tree/bd392ad858039290c72c20cc3f10df39384e90b9 |
SELoss | import torch
from torch import Tensor
from torch import nn
class SELoss(nn.MSELoss):
def __init__(self):
super().__init__(reduction='none')
def forward(self, inputs: 'Tensor', target: 'Tensor') ->Tensor:
return super().forward(inputs, target).sum(1)
def get_inputs():
return [torch.rand... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_str... | bzrry/lightning-bolts | SELoss | false | 14,995 | [
"Apache-2.0"
] | 822 | bd392ad858039290c72c20cc3f10df39384e90b9 | https://github.com/bzrry/lightning-bolts/tree/bd392ad858039290c72c20cc3f10df39384e90b9 |
Discriminator | import torch
import torch.nn as nn
class Discriminator(nn.Module):
def __init__(self, n_in, n_out):
super(Discriminator, self).__init__()
self.f_k = nn.Bilinear(n_in, n_out, 1)
self.sigm = nn.Sigmoid()
for m in self.modules():
self.weights_init(m)
def weights_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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
reinterpret_tensor = torch._C._dynamo.guards._reinterp... | caojiangxia/BiGI | Discriminator | false | 14,996 | [
"MIT"
] | 57 | ed54c20523a5b3f295b90a9c08f7c54e8258d04a | https://github.com/caojiangxia/BiGI/tree/ed54c20523a5b3f295b90a9c08f7c54e8258d04a |
GCN | from torch.nn import Module
import math
import torch
import torch.nn as nn
from torch.nn.modules.module import Module
class GraphConvolution(Module):
def __init__(self, in_features, out_features, bias=True):
super(GraphConvolution, self).__init__()
self.in_features = in_features
self.out_... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch.nn import Module
import math
import torch.nn as nn
from torch.nn.modu... | caojiangxia/BiGI | GCN | false | 14,997 | [
"MIT"
] | 57 | ed54c20523a5b3f295b90a9c08f7c54e8258d04a | https://github.com/caojiangxia/BiGI/tree/ed54c20523a5b3f295b90a9c08f7c54e8258d04a |
Block | import torch
import numpy as np
from torch import nn
import torch.nn.functional as F
def drop_path(x, drop_prob: 'float'=0.0, training: 'bool'=False):
if drop_prob == 0.0 or not training:
return x
keep_prob = 1 - drop_prob
shape = (x.shape[0],) + (1,) * (x.ndim - 1)
random_tensor = keep_prob +... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | bubbliiiing/classification-pytorch | Block | false | 14,998 | [
"MIT"
] | 88 | ee62c05bd3094c3fab48bada5a57cb2ed8b61c11 | https://github.com/bubbliiiing/classification-pytorch/tree/ee62c05bd3094c3fab48bada5a57cb2ed8b61c11 |
Ln_distance | import torch
from torch import nn
import torch.utils.data
class Ln_distance(nn.Module):
"""If dims is None Compute across all dimensions except first"""
def __init__(self, n, dim=None):
super(Ln_distance, self).__init__()
self.n = n
self.dim = dim
def forward(self, x, y):
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch import nn
import torch.utils.data
assert_size_strid... | carla-recourse/CARLA | Ln_distance | false | 15,000 | [
"MIT"
] | 140 | e9bb3152598a94e700c38d7377825054959dcf48 | https://github.com/carla-recourse/CARLA/tree/e9bb3152598a94e700c38d7377825054959dcf48 |
CombinedTargetMSELoss | import torch
import torch.nn as nn
class CombinedTargetMSELoss(nn.Module):
"""MSE loss for combined target.
CombinedTarget: The combination of classification target
(response map) and regression target (offset map).
Paper ref: Huang et al. The Devil is in the Details: Delving into
... | 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... | carolchenyx/mmpose | CombinedTargetMSELoss | false | 15,001 | [
"Apache-2.0"
] | 367 | cd74bf1d0b13954188cc678415fd0ef98a74b46b | https://github.com/carolchenyx/mmpose/tree/cd74bf1d0b13954188cc678415fd0ef98a74b46b |
Square | import torch
import torch.nn as nn
class Square(nn.Module):
def __init__(self):
super(Square, self).__init__()
def forward(self, x):
return torch.mul(x, x)
def get_inputs():
return [torch.rand([4, 4, 4, 4])]
def get_init_inputs():
return [[], {}]
| import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | carlzhangweiwen/gazelle_mpc | Square | false | 15,002 | [
"MIT"
] | 50 | 45818ccf6375100a8fe2680f44f37d713380aa5c | https://github.com/carlzhangweiwen/gazelle_mpc/tree/45818ccf6375100a8fe2680f44f37d713380aa5c |
Attention | from _paritybench_helpers import _mock_config
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
class Attention(nn.Module):
def __init__(self, opt):
super(Attention, self).__init__()
self.lin_u = nn.Linear(opt['hidden_dim'], opt['hidden_dim'])
self.lin_v = nn.... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | caojiangxia/BiGI | Attention | false | 15,003 | [
"MIT"
] | 57 | ed54c20523a5b3f295b90a9c08f7c54e8258d04a | https://github.com/caojiangxia/BiGI/tree/ed54c20523a5b3f295b90a9c08f7c54e8258d04a |
SplitChannels | import torch
class SplitChannels(torch.nn.Module):
def __init__(self, split_location):
super(SplitChannels, self).__init__()
self.split_location = split_location
def forward(self, x):
a, b = x[:, :self.split_location], x[:, self.split_location:]
a, b = a.clone(), b.clone()
... | 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... | cetmann/iunets | SplitChannels | false | 15,004 | [
"MIT"
] | 86 | 80ed7cce0e505a0396c42359eaf27819222d71f6 | https://github.com/cetmann/iunets/tree/80ed7cce0e505a0396c42359eaf27819222d71f6 |
SoftTargetCrossEntropy | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.distributed
class SoftTargetCrossEntropy(nn.Module):
def forward(self, x, target):
loss = torch.sum(-target * F.log_softmax(x, dim=-1), dim=-1)
return loss.mean()
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
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
... | ccjlovewsy/relabel_imagenet | SoftTargetCrossEntropy | false | 15,005 | [
"Apache-2.0"
] | 344 | 6cd84dffe4ce8005395970b2938b3196d0958351 | https://github.com/ccjlovewsy/relabel_imagenet/tree/6cd84dffe4ce8005395970b2938b3196d0958351 |
SmoothCrossEntropyLoss | import torch
import torch.nn.functional as F
from torch.nn.modules.loss import _WeightedLoss
class SmoothCrossEntropyLoss(_WeightedLoss):
def __init__(self, weight=None, reduction='mean', smoothing=0.0):
super().__init__(weight=weight, reduction=reduction)
self.smoothing = smoothing
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 math as tl_math
from torch.nn.modules.... | cclauss/archai | SmoothCrossEntropyLoss | false | 15,006 | [
"MIT"
] | 344 | a5fb8f937f7f1319e3204120803b2a045e9f768b | https://github.com/cclauss/archai/tree/a5fb8f937f7f1319e3204120803b2a045e9f768b |
GAT | from _paritybench_helpers import _mock_config
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
class Attention(nn.Module):
def __init__(self, opt):
super(Attention, self).__init__()
self.lin_u = nn.Linear(opt['hidden_dim'], opt['hidden_dim'])
self.lin_v = nn.... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | caojiangxia/BiGI | GAT | false | 15,007 | [
"MIT"
] | 57 | ed54c20523a5b3f295b90a9c08f7c54e8258d04a | https://github.com/caojiangxia/BiGI/tree/ed54c20523a5b3f295b90a9c08f7c54e8258d04a |
LinfDistance | import torch
from torch import nn
import torch.autograd
class LinfDistance(nn.Module):
def forward(self, img1, img2):
return (img1 - img2).reshape(img1.shape[0], -1).abs().max(dim=1)[0]
def get_inputs():
return [torch.rand([4, 4, 4, 4]), torch.rand([4, 4, 4, 4])]
def get_init_inputs():
return... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
from torch import nn
i... | cassidylaidlaw/perceptual-advex | LinfDistance | false | 15,008 | [
"MIT"
] | 45 | d39136eb5b5e950442456ddade6b4f4fba3dd8f6 | https://github.com/cassidylaidlaw/perceptual-advex/tree/d39136eb5b5e950442456ddade6b4f4fba3dd8f6 |
ImageNetNormalizer | import torch
from torch import nn
import torch.autograd
class ImageNetNormalizer(nn.Module):
def __init__(self, mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]):
super().__init__()
self.mean = mean
self.std = std
def forward(self, x):
mean = torch.tensor(self.mean, devi... | 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.autograd
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dy... | cassidylaidlaw/perceptual-advex | ImageNetNormalizer | false | 15,009 | [
"MIT"
] | 45 | d39136eb5b5e950442456ddade6b4f4fba3dd8f6 | https://github.com/cassidylaidlaw/perceptual-advex/tree/d39136eb5b5e950442456ddade6b4f4fba3dd8f6 |
L2Distance | import torch
from torch import nn
import torch.autograd
class L2Distance(nn.Module):
def forward(self, img1, img2):
return (img1 - img2).reshape(img1.shape[0], -1).norm(dim=1)
def get_inputs():
return [torch.rand([4, 4, 4, 4]), 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
import torch.autograd
assert_size_stride = torch._C._dynam... | cassidylaidlaw/perceptual-advex | L2Distance | false | 15,010 | [
"MIT"
] | 45 | d39136eb5b5e950442456ddade6b4f4fba3dd8f6 | https://github.com/cassidylaidlaw/perceptual-advex/tree/d39136eb5b5e950442456ddade6b4f4fba3dd8f6 |
GaussianConv2d | import torch
import numpy as np
import torch.nn.functional as F
import torch.nn as nn
import torch.utils.data
from torch.nn.parameter import Parameter
class GaussianConv2d(nn.Module):
def __init__(self, in_channels, out_channels, ksize=5):
"""Applies 2-D Gaussian Blur.
Args:
in_channels: An in... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import numpy as np
import torch.nn as nn
import torch.utils.data
from torch.nn.p... | cenkbircanoglu/SPML | GaussianConv2d | false | 15,011 | [
"MIT"
] | 68 | f09e4c30ecf2030d42ac70b2c35e7fdeee9bf468 | https://github.com/cenkbircanoglu/SPML/tree/f09e4c30ecf2030d42ac70b2c35e7fdeee9bf468 |
ContrastiveLoss | import torch
from torch import nn
from torch.nn import functional as F
from torch.utils.data import *
from torch.distributions import *
import torch.nn.parallel
import torch.optim
import torch.utils.data
import torch.utils.data.distributed
class ContrastiveLoss(nn.Module):
"""
Contrastive loss
Takes embed... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
from torch import nn
from to... | cgsas/LOB | ContrastiveLoss | false | 15,012 | [
"MIT"
] | 97 | 4175912194c2a066b2d7df038a376484b57ed76c | https://github.com/cgsas/LOB/tree/4175912194c2a066b2d7df038a376484b57ed76c |
CombinedTargetMSELoss | import torch
import torch.nn as nn
class CombinedTargetMSELoss(nn.Module):
"""MSE loss for combined target.
CombinedTarget: The combination of classification target
(response map) and regression target (offset map).
Paper ref: Huang et al. The Devil is in the Details: Delving i... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | chaowentao/mmpose | CombinedTargetMSELoss | false | 15,013 | [
"Apache-2.0"
] | 367 | b528c60ef4fab56d35d1ed7e187023794639be26 | https://github.com/chaowentao/mmpose/tree/b528c60ef4fab56d35d1ed7e187023794639be26 |
MoEHead | import math
import torch
from torch.nn import functional as F
from torch.autograd import Variable
from torch import nn
def softmax(x):
if x.dim() == 3:
return F.softmax(x.transpose(0, 2)).transpose(0, 2)
return F.softmax(x)
def gumbel_softmax(input, beta=0.5, tau=1.0):
noise = input.data.new(*in... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | cclauss/nonauto-nmt | MoEHead | false | 15,014 | [
"BSD-3-Clause"
] | 262 | efcbe4f2329b140ac3ce06abb6409457cebc8e49 | https://github.com/cclauss/nonauto-nmt/tree/efcbe4f2329b140ac3ce06abb6409457cebc8e49 |
InvertibleChannelMixing1D | from torch.autograd import Function
import torch
from torch import nn
from warnings import warn
def _cayley(A):
I = torch.eye(A.shape[-1], device=A.device)
LU = torch.lu(I + A, pivot=True)
return torch.lu_solve(I - A, *LU)
def _cayley_frechet(A, H, Q=None):
I = torch.eye(A.shape[-1], device=A.device... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch.autograd import Function
from torch import nn
from warnings import wa... | cetmann/iunets | InvertibleChannelMixing1D | false | 15,015 | [
"MIT"
] | 86 | 80ed7cce0e505a0396c42359eaf27819222d71f6 | https://github.com/cetmann/iunets/tree/80ed7cce0e505a0396c42359eaf27819222d71f6 |
InvertibleChannelMixing3D | from torch.autograd import Function
import torch
from torch import nn
from warnings import warn
def _cayley(A):
I = torch.eye(A.shape[-1], device=A.device)
LU = torch.lu(I + A, pivot=True)
return torch.lu_solve(I - A, *LU)
def _cayley_frechet(A, H, Q=None):
I = torch.eye(A.shape[-1], device=A.device... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch.autograd import Function
from torch import nn
from warnings import wa... | cetmann/iunets | InvertibleChannelMixing3D | false | 15,016 | [
"MIT"
] | 86 | 80ed7cce0e505a0396c42359eaf27819222d71f6 | https://github.com/cetmann/iunets/tree/80ed7cce0e505a0396c42359eaf27819222d71f6 |
InvertibleChannelMixing2D | from torch.autograd import Function
import torch
from torch import nn
from warnings import warn
def _cayley(A):
I = torch.eye(A.shape[-1], device=A.device)
LU = torch.lu(I + A, pivot=True)
return torch.lu_solve(I - A, *LU)
def _cayley_frechet(A, H, Q=None):
I = torch.eye(A.shape[-1], device=A.device... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch.autograd import Function
from torch import nn
from warnings import wa... | cetmann/iunets | InvertibleChannelMixing2D | false | 15,017 | [
"MIT"
] | 86 | 80ed7cce0e505a0396c42359eaf27819222d71f6 | https://github.com/cetmann/iunets/tree/80ed7cce0e505a0396c42359eaf27819222d71f6 |
homo_Gauss_mloglike | import torch
import numpy as np
import torch.nn.parallel
import torch.utils.data
import torch.utils.data.distributed
import torch.nn as nn
import torch.optim
from torch.distributions import Normal
class homo_Gauss_mloglike(nn.Module):
def __init__(self, Ndims=1, sig=None):
super(homo_Gauss_mloglike, 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 math as tl_math
import numpy as np
imp... | chelsealuisa/DUN | homo_Gauss_mloglike | false | 15,018 | [
"MIT"
] | 58 | 1ccd9bc49b91b13089350f003a25bdb11003d843 | https://github.com/chelsealuisa/DUN/tree/1ccd9bc49b91b13089350f003a25bdb11003d843 |
ContrastiveLoss | import torch
import torchvision.transforms.functional as F
import torch.nn.functional as F
import torch.nn as nn
class ContrastiveLoss(nn.Module):
"""
Contrastive loss function.
Based on: http://yann.lecun.com/exdb/publis/pdf/hadsell-chopra-lecun-06.pdf
"""
def __init__(self, margin=2.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
import torch.nn as nn
assert... | chenyanghungry/person-reid-lib | ContrastiveLoss | false | 15,019 | [
"MIT"
] | 81 | 783e66c9bfedf582e2cf935b9f5be960b543ac3c | https://github.com/chenyanghungry/person-reid-lib/tree/783e66c9bfedf582e2cf935b9f5be960b543ac3c |
MLP | import torch
from torch import nn
import torch.utils.data
class MLP(nn.Module):
def __init__(self, input_size, output_size, hidden_size=None, dropout=0.1):
super().__init__()
if hidden_size is None:
hidden_size = input_size * 4
self.w_1 = nn.Linear(input_size * 2, 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 import triton_helpers
from torch import nn
import t... | chenyangh/tensor2struct-public | MLP | false | 15,020 | [
"MIT"
] | 69 | d3257cba6d76d3c658a58a78f687d986bdc755cf | https://github.com/chenyangh/tensor2struct-public/tree/d3257cba6d76d3c658a58a78f687d986bdc755cf |
InvertibleDownsampling2D | from torch.autograd import Function
import torch
import numpy as np
from warnings import warn
from typing import Union
from typing import Tuple
from torch.nn.common_types import _size_2_t
from torch.nn.modules.utils import _pair
import torch.nn.functional as F
def _cayley(A):
I = torch.eye(A.shape[-1], device=A.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.autograd import Function
import numpy as np
from warnings import warn... | cetmann/iunets | InvertibleDownsampling2D | false | 15,021 | [
"MIT"
] | 86 | 80ed7cce0e505a0396c42359eaf27819222d71f6 | https://github.com/cetmann/iunets/tree/80ed7cce0e505a0396c42359eaf27819222d71f6 |
EncoderLayer | from _paritybench_helpers import _mock_config
import math
import torch
from torch.nn import functional as F
from torch.autograd import Variable
from torch import nn
def softmax(x):
if x.dim() == 3:
return F.softmax(x.transpose(0, 2)).transpose(0, 2)
return F.softmax(x)
def gumbel_softmax(input, beta... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | cclauss/nonauto-nmt | EncoderLayer | false | 15,022 | [
"BSD-3-Clause"
] | 262 | efcbe4f2329b140ac3ce06abb6409457cebc8e49 | https://github.com/cclauss/nonauto-nmt/tree/efcbe4f2329b140ac3ce06abb6409457cebc8e49 |
BatchHardTripletLoss | import torch
import torch.nn as nn
class BatchHardTripletLoss(nn.Module):
def __init__(self, margin=0):
super(BatchHardTripletLoss, self).__init__()
self.margin = margin
self.ranking_loss = nn.MarginRankingLoss(margin=margin)
def forward(self, inputs, targets):
batch_size = i... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | chenyanghungry/person-reid-lib | BatchHardTripletLoss | false | 15,023 | [
"MIT"
] | 81 | 783e66c9bfedf582e2cf935b9f5be960b543ac3c | https://github.com/chenyanghungry/person-reid-lib/tree/783e66c9bfedf582e2cf935b9f5be960b543ac3c |
SelfAttentive | import torch
import torch.nn as nn
class SelfAttentive(nn.Module):
def __init__(self, hidden_size, att_hops=1, att_unit=200, dropout=0.2):
super(SelfAttentive, self).__init__()
self.drop = nn.Dropout(dropout)
self.ws1 = nn.Linear(hidden_size, att_unit, bias=False)
self.ws2 = 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.... | chenyangh/SemEval2019-Task3 | SelfAttentive | false | 15,024 | [
"MIT"
] | 50 | c6204797b4b6cc08cb4d2d88108405f959d63ee9 | https://github.com/chenyangh/SemEval2019-Task3/tree/c6204797b4b6cc08cb4d2d88108405f959d63ee9 |
Attention | import torch
import torch.nn as nn
import torch.nn
class Attention(nn.Module):
def __init__(self, dim_i, dim_o):
"""
build the target-aware attention
input schema:
dim_i: the dimension of the input feature vector
dim_o: the dimension of the output feature vector
output schema:
return a agg... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | chencsgit/luoxi_models | Attention | false | 15,025 | [
"Apache-2.0"
] | 58 | ea9e69dfb81b29f41ed92c75faacf81114c69a2f | https://github.com/chencsgit/luoxi_models/tree/ea9e69dfb81b29f41ed92c75faacf81114c69a2f |
PoseNormalize | import torch
import torch.nn as nn
class PoseNormalize(nn.Module):
@torch.no_grad()
def forward(self, x):
return x * 2 - 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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | chinitaberrio/DeepPrivacy | PoseNormalize | false | 15,026 | [
"MIT"
] | 1,128 | d50e1b5ae762b47ab5a8f54cb90e66465057bd25 | https://github.com/chinitaberrio/DeepPrivacy/tree/d50e1b5ae762b47ab5a8f54cb90e66465057bd25 |
InvertibleDownsampling3D | from torch.autograd import Function
import torch
import numpy as np
from warnings import warn
from typing import Union
from typing import Tuple
from torch.nn.common_types import _size_3_t
from torch.nn.modules.utils import _triple
import torch.nn.functional as F
def _cayley(A):
I = torch.eye(A.shape[-1], device=A... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch.autograd import Function
import numpy as np
from warnings import warn... | cetmann/iunets | InvertibleDownsampling3D | false | 15,027 | [
"MIT"
] | 86 | 80ed7cce0e505a0396c42359eaf27819222d71f6 | https://github.com/cetmann/iunets/tree/80ed7cce0e505a0396c42359eaf27819222d71f6 |
ToyNet | import torch
import torch.nn as nn
import torch.nn.functional as F
class ToyNet(nn.Module):
def __init__(self):
super(ToyNet, self).__init__()
self.conv1 = nn.Conv2d(3, 6, 5)
self.pool = nn.MaxPool2d(2, 2)
self.conv2 = nn.Conv2d(6, 16, 5)
self.conv3 = nn.Conv2d(16, 64, 3)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | asalmanp/MIVisionX | ToyNet | false | 15,028 | [
"MIT"
] | 153 | a964774944331827c8d6e9bb1ffbb2578f335056 | https://github.com/asalmanp/MIVisionX/tree/a964774944331827c8d6e9bb1ffbb2578f335056 |
MS_Block | import torch
import torch.nn as nn
import torch.multiprocessing
class MS_Block(nn.Module):
def __init__(self, input_feature, out_feature, d=[1, 2, 4], group=1):
super(MS_Block, self).__init__()
self.l1 = nn.Conv2d(input_feature, out_feature, 3, padding=d[0],
dilation=d[0], bias=False,... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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.multiprocessing
assert_size_stride = torch._C... | chiukin/RANet | MS_Block | false | 15,029 | [
"Apache-2.0"
] | 267 | 681a47d9b1f114653290678f02f2d3ecdf4010bc | https://github.com/chiukin/RANet/tree/681a47d9b1f114653290678f02f2d3ecdf4010bc |
InvertibleUpsampling2D | from torch.autograd import Function
import torch
import numpy as np
from warnings import warn
from typing import Union
from typing import Tuple
from torch.nn.common_types import _size_2_t
from torch.nn.modules.utils import _pair
import torch.nn.functional as F
def _cayley(A):
I = torch.eye(A.shape[-1], device=A.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.autograd import Function
import numpy as np
from warnings import warn... | cetmann/iunets | InvertibleUpsampling2D | false | 15,030 | [
"MIT"
] | 86 | 80ed7cce0e505a0396c42359eaf27819222d71f6 | https://github.com/cetmann/iunets/tree/80ed7cce0e505a0396c42359eaf27819222d71f6 |
EPE | import torch
from torch import nn
import torch.utils.cpp_extension
class EPE(nn.Module):
def __init__(self):
super(EPE, self).__init__()
def forward(self, flow, gt, loss_mask):
loss_map = (flow - gt.detach()) ** 2
loss_map = (loss_map.sum(1, True) + 1e-06) ** 0.5
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.triton_helpers import libdevice
from torch import nn
import torch.utils.cpp_extension
assert_size_stride = torc... | P2Oileen/oh-my-face | EPE | false | 15,031 | [
"MIT"
] | 45 | b73cb8ea713205bbf2bc1408145fa668c715359b | https://github.com/P2Oileen/oh-my-face/tree/b73cb8ea713205bbf2bc1408145fa668c715359b |
InvertibleDownsampling1D | from torch.autograd import Function
import torch
import numpy as np
from warnings import warn
from typing import Union
from typing import Tuple
from torch.nn.common_types import _size_1_t
from torch.nn.modules.utils import _single
import torch.nn.functional as F
def _cayley(A):
I = torch.eye(A.shape[-1], device=A... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch.autograd import Function
import numpy as np
from warnings import warn... | cetmann/iunets | InvertibleDownsampling1D | false | 15,032 | [
"MIT"
] | 86 | 80ed7cce0e505a0396c42359eaf27819222d71f6 | https://github.com/cetmann/iunets/tree/80ed7cce0e505a0396c42359eaf27819222d71f6 |
MLP_G | from _paritybench_helpers import _mock_config
import torch
import torch.nn as nn
def weights_init(m):
classname = m.__class__.__name__
if classname.find('Linear') != -1:
m.weight.data.normal_(0.0, 0.02)
m.bias.data.fill_(0)
elif classname.find('BatchNorm') != -1:
m.weight.data.norm... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | Huihui-z/CE-GZSL | MLP_G | false | 15,033 | [
"MIT"
] | 58 | 7bf5358ac4727ea1dc2dc9dec2f453b014500bd8 | https://github.com/Huihui-z/CE-GZSL/tree/7bf5358ac4727ea1dc2dc9dec2f453b014500bd8 |
SqueezeExcite | import torch
import torch.nn as nn
import torch.nn.functional as F
from itertools import product as product
def _make_divisible(v, divisor, min_value=None):
"""
This function is taken from the original tf repo.
It ensures that all layers have a channel number that is divisible by 8
It can be seen here... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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 ... | chuanli11/SynergyNet | SqueezeExcite | false | 15,034 | [
"MIT"
] | 82 | a8044d8dabbfb811d4299f59e64e0fb749027e86 | https://github.com/chuanli11/SynergyNet/tree/a8044d8dabbfb811d4299f59e64e0fb749027e86 |
BasicBlock_ins | import torch
import torch.nn as nn
import torch.multiprocessing
def conv3x3(in_planes, out_planes, stride=1):
"""3x3 convolution with padding"""
return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride,
padding=1, bias=False)
class BasicBlock_ins(nn.Module):
expansion = 1
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._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | chiukin/RANet | BasicBlock_ins | false | 15,035 | [
"Apache-2.0"
] | 267 | 681a47d9b1f114653290678f02f2d3ecdf4010bc | https://github.com/chiukin/RANet/tree/681a47d9b1f114653290678f02f2d3ecdf4010bc |
ResBlock2 | import torch
import torch.nn as nn
import torch.multiprocessing
class ResBlock2(nn.Module):
def __init__(self, input_feature, planes, dilated=1, group=1):
super(ResBlock2, self).__init__()
self.conv1 = nn.Conv2d(input_feature, planes, kernel_size=1, bias=
False, groups=group)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | chiukin/RANet | ResBlock2 | false | 15,036 | [
"Apache-2.0"
] | 267 | 681a47d9b1f114653290678f02f2d3ecdf4010bc | https://github.com/chiukin/RANet/tree/681a47d9b1f114653290678f02f2d3ecdf4010bc |
FPNHead | import torch
import torch.nn as nn
import torch.nn.parallel
import torch.optim
import torch.utils.data
class FPNHead(nn.Module):
def __init__(self, num_in, num_mid, num_out):
super().__init__()
self.block0 = nn.Conv2d(num_in, num_mid, kernel_size=3, padding=1,
bias=False)
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
import torch.nn as nn
import ... | choprahetarth/DeblurGANv2 | FPNHead | false | 15,037 | [
"BSD-3-Clause"
] | 321 | e36dc2fef169b8a37036abe62192b6a925fb6c81 | https://github.com/choprahetarth/DeblurGANv2/tree/e36dc2fef169b8a37036abe62192b6a925fb6c81 |
ScaledDotProductAttention | import torch
import torch.nn as nn
import torch.nn.functional as F
class ScaledDotProductAttention(nn.Module):
""" Scaled Dot-Product Attention """
def __init__(self, temperature, attn_dropout=0.1):
super().__init__()
self.temperature = temperature
self.dropout = nn.Dropout(attn_dropo... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | cjy97/FEAT | ScaledDotProductAttention | false | 15,038 | [
"MIT"
] | 330 | 9d48b254bc5f0a2211c2aad0a60388a8a2c8081c | https://github.com/cjy97/FEAT/tree/9d48b254bc5f0a2211c2aad0a60388a8a2c8081c |
MFBFusion | from _paritybench_helpers import _mock_config
import time
import torch
from torch import nn
class BaseModel(nn.Module):
def __init__(self):
super(BaseModel, self).__init__()
self.model_name = str(type(self))
def load(self, path):
self.load_state_dict(torch.load(path))
def save(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
import time
from torch import nn
assert_size_stride = torch._C._dynamo.guards.as... | chorseng/UMD | MFBFusion | false | 15,039 | [
"MIT"
] | 48 | 680681fea76abcea02ff5f351727bcbb468c372a | https://github.com/chorseng/UMD/tree/680681fea76abcea02ff5f351727bcbb468c372a |
SimpleConvNetBlock | import torch
import torch.nn as nn
class SimpleConvNetBlock(nn.Module):
def __init__(self, in_channels, out_channels, kernel):
nn.Module.__init__(self)
self.conv = nn.Conv2d(in_channels=in_channels, out_channels=
out_channels, kernel_size=kernel, padding=1)
self.relu = nn.ReLU... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | cle-ros/RoutingNetworks | SimpleConvNetBlock | false | 15,040 | [
"Apache-2.0"
] | 63 | 0f1fe1221c67a224a02bca6247d3c4488ede0a04 | https://github.com/cle-ros/RoutingNetworks/tree/0f1fe1221c67a224a02bca6247d3c4488ede0a04 |
PositionwiseFeedForward | import math
import torch
from torch import nn
def gelu(x):
return 0.5 * x * (1 + torch.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 *
torch.pow(x, 3))))
class PositionwiseFeedForward(nn.Module):
""" A two-layer Feed-Forward-Network with residual layer norm.
Args:
d_model (int): the 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 math
from to... | clairett/fast-bert | PositionwiseFeedForward | false | 15,041 | [
"Apache-2.0"
] | 1,542 | 506771b930aa70e7ca2852e5e8ebb14656d97bfa | https://github.com/clairett/fast-bert/tree/506771b930aa70e7ca2852e5e8ebb14656d97bfa |
SparsemaxBisect | from torch.autograd import Function
import torch
import torch.nn as nn
def sparsemax_bisect(X, dim=-1, n_iter=50, ensure_sum_one=True):
"""sparsemax: normalizing sparse transform (a la softmax), via bisection.
Solves the projection:
min_p ||x - p||_2 s.t. p >= 0, sum(p) == 1.
Parameters
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch.autograd import Function
import torch.nn as nn
assert_size_stride = torch._C._... | cifkao/entmax | SparsemaxBisect | false | 15,042 | [
"MIT"
] | 298 | f18bab9318f9d2471a36545ee0b4c97be6d48a87 | https://github.com/cifkao/entmax/tree/f18bab9318f9d2471a36545ee0b4c97be6d48a87 |
AttentionModule | from _paritybench_helpers import _mock_config
import torch
class AttentionModule(torch.nn.Module):
"""
SimGNN Attention Module to make a pass on graph.
"""
def __init__(self, args):
"""
:param args: Arguments object.
"""
super(AttentionModule, 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
assert_size_stride ... | cloudcjf/SG_PR | AttentionModule | false | 15,043 | [
"MIT"
] | 105 | 1339d00811ea3c4c18963efa24bf6fc778e15794 | https://github.com/cloudcjf/SG_PR/tree/1339d00811ea3c4c18963efa24bf6fc778e15794 |
GraphConvolution | from torch.nn import Module
import torch
from torch.nn import Parameter
from torch.nn import functional as F
import torch.multiprocessing
import torch.utils.data
from torch.nn.modules.module import Module
from torch.nn.parameter import Parameter
import torch.nn.modules.loss
class GraphConvolution(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.nn import Module
f... | cminusQAQ/graph4nlp | GraphConvolution | false | 15,044 | [
"Apache-2.0"
] | 1,269 | d980e897131f1b9d3766750c06316d94749904fa | https://github.com/cminusQAQ/graph4nlp/tree/d980e897131f1b9d3766750c06316d94749904fa |
DilatedResidualLayer | import torch
import torch.nn as nn
import torch.nn.functional as F
class DilatedResidualLayer(nn.Module):
def __init__(self, dilation, in_channels, out_channels):
super(DilatedResidualLayer, self).__init__()
self.conv_dilated = nn.Conv1d(in_channels, out_channels, 3, padding
=dilation... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | cmhungsteve/SSTDA | DilatedResidualLayer | false | 15,045 | [
"MIT"
] | 154 | 9c5e1df952bd122ea474046d91e3ac6fa79ec312 | https://github.com/cmhungsteve/SSTDA/tree/9c5e1df952bd122ea474046d91e3ac6fa79ec312 |
MeanEmbedding | import torch
import torch.nn as nn
import torch.multiprocessing
import torch.utils.data
import torch.nn.modules.loss
class MeanEmbedding(nn.Module):
"""Mean embedding class."""
def __init__(self):
super(MeanEmbedding, self).__init__()
def forward(self, emb, len_):
"""Compute average embe... | 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.multiprocessing
import torch.utils.data
import torch.nn.modules.loss
assert_size_stride = torch._C._dynam... | cminusQAQ/graph4nlp | MeanEmbedding | false | 15,046 | [
"Apache-2.0"
] | 1,269 | d980e897131f1b9d3766750c06316d94749904fa | https://github.com/cminusQAQ/graph4nlp/tree/d980e897131f1b9d3766750c06316d94749904fa |
SoftDiceLoss | import torch
import torch.nn.functional as F
import torch.nn as nn
class SoftDiceLoss(nn.Module):
def __init__(self, weight=None, size_average=True):
super(SoftDiceLoss, self).__init__()
def forward(self, logits, targets):
num = targets.size(0)
probs = F.sigmoid(logits)
m1 = ... | 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... | cmarasinou/carvana-challenge | SoftDiceLoss | false | 15,047 | [
"MIT"
] | 93 | 4e1c43f306cfbef1df267acfce59bdcf19504850 | https://github.com/cmarasinou/carvana-challenge/tree/4e1c43f306cfbef1df267acfce59bdcf19504850 |
InnerProductDecoder | import torch
import torch.nn as nn
from torch.nn import functional as F
import torch.multiprocessing
import torch.utils.data
import torch.nn.modules.loss
class InnerProductDecoder(nn.Module):
"""Decoder for using inner product for prediction."""
def __init__(self, dropout, act=torch.sigmoid):
super(I... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
import torch.multiprocessing
import torch.utils.data
impor... | cminusQAQ/graph4nlp | InnerProductDecoder | false | 15,048 | [
"Apache-2.0"
] | 1,269 | d980e897131f1b9d3766750c06316d94749904fa | https://github.com/cminusQAQ/graph4nlp/tree/d980e897131f1b9d3766750c06316d94749904fa |
BCELoss2d | import torch
import torch.nn.functional as F
import torch.nn as nn
class BCELoss2d(nn.Module):
def __init__(self, weight=None, size_average=True):
super(BCELoss2d, self).__init__()
self.bce_loss = nn.BCELoss(weight, size_average)
def forward(self, logits, targets):
probs = F.sigmoid(... | 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... | cmarasinou/carvana-challenge | BCELoss2d | false | 15,049 | [
"MIT"
] | 93 | 4e1c43f306cfbef1df267acfce59bdcf19504850 | https://github.com/cmarasinou/carvana-challenge/tree/4e1c43f306cfbef1df267acfce59bdcf19504850 |
mlpblock | import torch
import torch.nn as nn
import torch.nn.functional as F
class linearblock(nn.Module):
def __init__(self, in_features, out_features, bias=True, dropout='none'):
super(linearblock, self).__init__()
self.conv = nn.Linear(in_features, out_features, bias=bias)
self.relu = nn.ReLU(in... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
import ... | coallaoh/WhitenBlackBox | mlpblock | false | 15,050 | [
"MIT"
] | 46 | 816363c59a11248e79ffed70f1a14510b0967dab | https://github.com/coallaoh/WhitenBlackBox/tree/816363c59a11248e79ffed70f1a14510b0967dab |
ShiftedSoftplus | import torch
import torch.nn.functional as F
from torch import nn
class ShiftedSoftplus(nn.Module):
__constants__ = ['beta', 'threshold']
beta: 'int'
threshold: 'int'
def __init__(self, beta: 'int'=1, threshold: 'int'=20) ->None:
super(ShiftedSoftplus, self).__init__()
self.beta = bet... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch import nn
assert_size_stride = torch._C._dynamo.gua... | cmusatyalab/mega-nerf | ShiftedSoftplus | false | 15,051 | [
"MIT"
] | 107 | 306e06cc316dd4f5c84d0610308bcbc208228fc3 | https://github.com/cmusatyalab/mega-nerf/tree/306e06cc316dd4f5c84d0610308bcbc208228fc3 |
Accuracy | import torch
from torch import nn
class Accuracy(nn.Module):
label = 'Accuracy'
def forward(self, prediction, truth):
prediction = prediction.argmax(dim=1)
correct = prediction == truth
accuracy = correct.float().mean()
return accuracy
def get_inputs():
return [torch.ran... | 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... | cms-flash/beauty-net | Accuracy | false | 15,052 | [
"MIT"
] | 155 | 668210a95ccb4462d7beff10505e4e83532682f2 | https://github.com/cms-flash/beauty-net/tree/668210a95ccb4462d7beff10505e4e83532682f2 |
ConvBlock | import torch
import torch.nn.functional as F
import torch.nn as nn
class ConvBlock(nn.Module):
def __init__(self):
super(ConvBlock, self).__init__()
self.conv1 = nn.Conv2d(3, 6, 5)
self.pool = nn.MaxPool2d(2, 2)
self.conv2 = nn.Conv2d(6, 16, 5)
def forward(self, x):
x... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | coasxu/FedMA | ConvBlock | false | 15,053 | [
"MIT"
] | 254 | 21f4d32338fd2563ebd97c737e3b9f4f470029d9 | https://github.com/coasxu/FedMA/tree/21f4d32338fd2563ebd97c737e3b9f4f470029d9 |
HirarchicalAttention | from torch.nn import Module
import torch
from typing import *
import torch.utils.data
import torch.nn as nn
import torch.onnx.operators
import torch.optim
class HirarchicalAttention(Module):
"""
ref: Hierarchical Attention Networks for Document Classification
"""
def __init__(self, hidden_size: 'int')... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | code-backdoor/code-backdoor | HirarchicalAttention | false | 15,054 | [
"MIT"
] | 71 | 1eeb3d79aa8a54c8f08e8d0156b569de5edd974e | https://github.com/code-backdoor/code-backdoor/tree/1eeb3d79aa8a54c8f08e8d0156b569de5edd974e |
ConvLayer | import torch
import torch.nn.functional as F
from typing import *
import torch.utils.data
import torch.nn as nn
import torch.onnx.operators
import torch.optim
class ConvLayer(nn.Module):
def __init__(self, in_channels, out_channels):
super(ConvLayer, self).__init__()
self.in_channels = in_channel... | 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 typing import *
i... | code-backdoor/code-backdoor | ConvLayer | false | 15,055 | [
"MIT"
] | 71 | 1eeb3d79aa8a54c8f08e8d0156b569de5edd974e | https://github.com/code-backdoor/code-backdoor/tree/1eeb3d79aa8a54c8f08e8d0156b569de5edd974e |
SimpleCNNContainerConvBlocks | import torch
import torch.nn.functional as F
import torch.nn as nn
class SimpleCNNContainerConvBlocks(nn.Module):
def __init__(self, input_channel, num_filters, kernel_size, output_dim=10):
super(SimpleCNNContainerConvBlocks, self).__init__()
"""
A testing cnn container, which allows init... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | coasxu/FedMA | SimpleCNNContainerConvBlocks | false | 15,056 | [
"MIT"
] | 254 | 21f4d32338fd2563ebd97c737e3b9f4f470029d9 | https://github.com/coasxu/FedMA/tree/21f4d32338fd2563ebd97c737e3b9f4f470029d9 |
UNet | import torch
import torch.nn as nn
import torch.nn.functional as F
class down(nn.Module):
"""
A class for creating neural network blocks containing layers:
Average Pooling --> Convlution + Leaky ReLU --> Convolution + Leaky ReLU
This is used in the UNet Class to create a UNet like NN archite... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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 ... | avinashpaliwal/Deep-SloMo | UNet | false | 15,057 | [
"MIT"
] | 76 | 93373aa3cb9fd384fbf905e235fe6eb4f9cac780 | https://github.com/avinashpaliwal/Deep-SloMo/tree/93373aa3cb9fd384fbf905e235fe6eb4f9cac780 |
NormMLP | import torch
import torch.nn as nn
import torch.nn.functional as F
class NormMLP(nn.Module):
def __init__(self, input_size, output_size):
super(NormMLP, self).__init__()
self.linear = nn.Linear(input_size, output_size)
self.layer_norm = nn.LayerNorm(output_size)
def forward(self, act... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | cogentlabs/apl | NormMLP | false | 15,058 | [
"MIT"
] | 50 | 78092b162e019a2df0ab5ea31d4db0b9860090d3 | https://github.com/cogentlabs/apl/tree/78092b162e019a2df0ab5ea31d4db0b9860090d3 |
SoftTargetCrossEntropyLoss | import torch
def _convert_to_one_hot(targets: 'torch.Tensor', classes: 'int'
) ->torch.Tensor:
"""
This function converts target class indices to one-hot vectors,
given the number of classes.
"""
if torch.max(targets).item() >= classes:
raise ValueError('Class Index must be less than ... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
assert_size_stride = t... | colin2328/recipes | SoftTargetCrossEntropyLoss | false | 15,059 | [
"BSD-3-Clause"
] | 161 | a6cd0e12c9fcb48749721a6548d0a02319d54bd1 | https://github.com/colin2328/recipes/tree/a6cd0e12c9fcb48749721a6548d0a02319d54bd1 |
LeakyReLU | import torch
import numpy as np
import torch.nn as nn
from numbers import Number
def keep_variance_fn(x):
return x + 0.001
def normcdf(value, mu=0.0, stddev=1.0):
sinv = 1.0 / stddev if isinstance(stddev, Number) else stddev.reciprocal()
return 0.5 * (1.0 + torch.erf((value - mu) * sinv / np.sqrt(2.0)))... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import numpy as np
import torch.nn as nn
from numbers import N... | collector-m/LiDAR-MOS | LeakyReLU | false | 15,060 | [
"MIT"
] | 268 | 7ccbb63b4ee7c40195b35dd0dddd71473fae25b1 | https://github.com/collector-m/LiDAR-MOS/tree/7ccbb63b4ee7c40195b35dd0dddd71473fae25b1 |
ReLU | import torch
import numpy as np
import torch.nn as nn
from numbers import Number
def keep_variance_fn(x):
return x + 0.001
def normcdf(value, mu=0.0, stddev=1.0):
sinv = 1.0 / stddev if isinstance(stddev, Number) else stddev.reciprocal()
return 0.5 * (1.0 + torch.erf((value - mu) * sinv / np.sqrt(2.0)))... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import numpy as np
import torch.nn as nn
from numbers import N... | collector-m/LiDAR-MOS | ReLU | false | 15,061 | [
"MIT"
] | 268 | 7ccbb63b4ee7c40195b35dd0dddd71473fae25b1 | https://github.com/collector-m/LiDAR-MOS/tree/7ccbb63b4ee7c40195b35dd0dddd71473fae25b1 |
SoftmaxFocalClassificationLoss | import torch
import torch.nn as nn
import torch.nn.functional as F
class SoftmaxFocalClassificationLoss(nn.Module):
"""Criterion that computes Focal loss.
According to [1], the Focal loss is computed as follows:
.. math::
\\text{FL}(p_t) = -\\alpha_t (1 - p_t)^{\\gamma} \\, \\text{log}(p_t)
wh... | 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
... | collector-m/BtcDet | SoftmaxFocalClassificationLoss | false | 15,062 | [
"Apache-2.0"
] | 108 | 80bee34f2f40931600f812a6edbcb27e51cb7ec3 | https://github.com/collector-m/BtcDet/tree/80bee34f2f40931600f812a6edbcb27e51cb7ec3 |
AvgPool2d | import torch
import torch.nn as nn
import torch.nn.functional as F
def keep_variance_fn(x):
return x + 0.001
class AvgPool2d(nn.Module):
def __init__(self, keep_variance_fn=None, kernel_size=2):
super(AvgPool2d, self).__init__()
self._keep_variance_fn = keep_variance_fn
self.kernel_... | 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... | collector-m/LiDAR-MOS | AvgPool2d | false | 15,063 | [
"MIT"
] | 268 | 7ccbb63b4ee7c40195b35dd0dddd71473fae25b1 | https://github.com/collector-m/LiDAR-MOS/tree/7ccbb63b4ee7c40195b35dd0dddd71473fae25b1 |
Conv | import torch
from torch import nn
class Conv(nn.Module):
"""
Convenience class that does padding and convolution for inputs in the format
[batch_size, sequence length, hidden size]
"""
def __init__(self, input_size, output_size, kernel_size, pad_type):
"""
Parameters:
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import 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... | colincen/coach | Conv | false | 15,064 | [
"MIT"
] | 72 | 2b1b543851cc7ba359f48dac6a5c72f1ced9b530 | https://github.com/colincen/coach/tree/2b1b543851cc7ba359f48dac6a5c72f1ced9b530 |
FCN8VGG16 | import torch
import numpy as np
from torch import nn
import torch.utils.model_zoo as model_zoo
def conv3x3(in_planes, out_planes, stride=1, padding=1):
"""3x3 convolution with padding"""
return nn.Conv2d(in_planes, out_planes, kernel_size=(3, 3), stride=(
stride, stride), padding=(padding, padding))
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import numpy as np
from torch... | alzayats/DeepFish | FCN8VGG16 | false | 15,065 | [
"MIT"
] | 48 | 4d9ebfb0474a7e9346c72e2a5411ab6f72e878e2 | https://github.com/alzayats/DeepFish/tree/4d9ebfb0474a7e9346c72e2a5411ab6f72e878e2 |
Softmax | import torch
import torch.nn as nn
def keep_variance_fn(x):
return x + 0.001
class Softmax(nn.Module):
def __init__(self, dim=1, keep_variance_fn=None):
super(Softmax, self).__init__()
self.dim = dim
self._keep_variance_fn = keep_variance_fn
def forward(self, features_mean, fea... | 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... | collector-m/LiDAR-MOS | Softmax | false | 15,066 | [
"MIT"
] | 268 | 7ccbb63b4ee7c40195b35dd0dddd71473fae25b1 | https://github.com/collector-m/LiDAR-MOS/tree/7ccbb63b4ee7c40195b35dd0dddd71473fae25b1 |
lovasz_hinge | import torch
import torch.nn.parallel
import torch.utils.data
from torchvision.transforms import functional as F
import torch.nn.functional as F
from torch.autograd import Variable
def flatten_binary_scores(scores, labels, ignore=255):
"""
Flattens predictions in the batch (binary case)
Remove labels equa... | 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.parallel
import torch.utils.data
from torchvision.transforms import functional as F
import torch.nn.functional as F
from tor... | clovaai/ext_portrait_segmentation | lovasz_hinge | false | 15,067 | [
"MIT"
] | 227 | 9bc1bada1cb7bd17a3a80a2964980f4b4befef5b | https://github.com/clovaai/ext_portrait_segmentation/tree/9bc1bada1cb7bd17a3a80a2964980f4b4befef5b |
Linear | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.parameter import Parameter
def keep_variance_fn(x):
return x + 0.001
class Linear(nn.Module):
def __init__(self, in_features, out_features, bias=True,
keep_variance_fn=None):
super(Linear, 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
import torch.nn as nn
from torch.nn.parameter import Parameter
assert_size_strid... | collector-m/LiDAR-MOS | Linear | false | 15,068 | [
"MIT"
] | 268 | 7ccbb63b4ee7c40195b35dd0dddd71473fae25b1 | https://github.com/collector-m/LiDAR-MOS/tree/7ccbb63b4ee7c40195b35dd0dddd71473fae25b1 |
Conv2d | import torch
import torch.nn.functional as F
from torch.nn.modules.conv import _ConvNd
from torch.nn.modules.utils import _pair
def keep_variance_fn(x):
return x + 0.001
class Conv2d(_ConvNd):
def __init__(self, in_channels, out_channels, kernel_size, stride=1,
padding=0, dilation=1, groups=1, bias... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch.nn.modules.conv import _ConvNd
from torch.nn.modules.utils import _pa... | collector-m/LiDAR-MOS | Conv2d | false | 15,069 | [
"MIT"
] | 268 | 7ccbb63b4ee7c40195b35dd0dddd71473fae25b1 | https://github.com/collector-m/LiDAR-MOS/tree/7ccbb63b4ee7c40195b35dd0dddd71473fae25b1 |
MaxPool2d | import torch
import numpy as np
import torch.nn as nn
from numbers import Number
def keep_variance_fn(x):
return x + 0.001
def normcdf(value, mu=0.0, stddev=1.0):
sinv = 1.0 / stddev if isinstance(stddev, Number) else stddev.reciprocal()
return 0.5 * (1.0 + torch.erf((value - mu) * sinv / np.sqrt(2.0)))... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import numpy as np
import torch.nn as nn
from numbers import N... | collector-m/LiDAR-MOS | MaxPool2d | false | 15,070 | [
"MIT"
] | 268 | 7ccbb63b4ee7c40195b35dd0dddd71473fae25b1 | https://github.com/collector-m/LiDAR-MOS/tree/7ccbb63b4ee7c40195b35dd0dddd71473fae25b1 |
TransformerEncoderLayer | import torch
import torch.utils.data
import torch.nn.functional as F
import torch.nn as nn
from torch.nn.init import xavier_uniform_
from torch.nn.init import constant_
from torch.nn.init import xavier_normal_
def _get_activation_fn(activation):
if activation == 'relu':
return F.relu
elif activation =... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | codeboy5/cvpr20-scatter-text-recognizer | TransformerEncoderLayer | false | 15,071 | [
"Apache-2.0"
] | 63 | 4bd6cfbd4d7f64ce11864514f6b6b0646267c285 | https://github.com/codeboy5/cvpr20-scatter-text-recognizer/tree/4bd6cfbd4d7f64ce11864514f6b6b0646267c285 |
_MLP_B | import torch
import torch.nn as nn
class _MLP_B(nn.Module):
"""MLP that only use age gender MMSE"""
def __init__(self, in_size, drop_rate, fil_num):
super(_MLP_B, self).__init__()
self.fc1 = nn.Linear(in_size, fil_num)
self.fc2 = nn.Linear(fil_num, 2)
self.do1 = nn.Dropout(dro... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | colorfulbrain/brain2020 | _MLP_B | false | 15,072 | [
"MIT"
] | 91 | 1dde5d34fd2ba1f38bcc38f2c973d167c8c3a168 | https://github.com/colorfulbrain/brain2020/tree/1dde5d34fd2ba1f38bcc38f2c973d167c8c3a168 |
Context2AnswerAttention | import torch
import torch.nn as nn
import torch.multiprocessing
import torch.utils.data
import torch.nn.modules.loss
class Context2AnswerAttention(nn.Module):
def __init__(self, dim, hidden_size):
super(Context2AnswerAttention, self).__init__()
self.linear_sim = nn.Linear(dim, hidden_size, bias=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 import triton_helpers
from torch._inductor.runtime.... | cminusQAQ/graph4nlp | Context2AnswerAttention | false | 15,073 | [
"Apache-2.0"
] | 1,269 | d980e897131f1b9d3766750c06316d94749904fa | https://github.com/cminusQAQ/graph4nlp/tree/d980e897131f1b9d3766750c06316d94749904fa |
HardMish | import torch
from torch import nn
class HardMish(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x):
return x / 2 * torch.clamp(x + 2, min=0, max=2)
def get_inputs():
return [torch.rand([4, 4, 4, 4])]
def get_init_inputs():
return [[], {}]
| import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empt... | cooked-sashimi/Yet-Another-YOLOv4-Pytorch | HardMish | false | 15,074 | [
"MIT"
] | 133 | c884ef8849987a75b0e17eba1b739c22d3782e90 | https://github.com/cooked-sashimi/Yet-Another-YOLOv4-Pytorch/tree/c884ef8849987a75b0e17eba1b739c22d3782e90 |
_MLP_C | import torch
import torch.nn as nn
class _MLP_C(nn.Module):
"""MLP that use DPMs from fcn and age, gender and MMSE"""
def __init__(self, in_size, drop_rate, fil_num):
super(_MLP_C, self).__init__()
self.fc1 = nn.Linear(in_size, fil_num)
self.fc2 = nn.Linear(fil_num, 2)
self.do... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | colorfulbrain/brain2020 | _MLP_C | false | 15,075 | [
"MIT"
] | 91 | 1dde5d34fd2ba1f38bcc38f2c973d167c8c3a168 | https://github.com/colorfulbrain/brain2020/tree/1dde5d34fd2ba1f38bcc38f2c973d167c8c3a168 |
DarknetMish | import torch
import torch.nn.functional as F
from torch import nn
class darknet_mish(torch.autograd.Function):
"""
We can implement our own custom autograd Functions by subclassing
torch.autograd.Function and implementing the forward and backward passes
which operate on Tensors.
"""
@staticme... | 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.functional as F
from torch import nn
assert_size_stride =... | cooked-sashimi/Yet-Another-YOLOv4-Pytorch | DarknetMish | false | 15,076 | [
"MIT"
] | 133 | c884ef8849987a75b0e17eba1b739c22d3782e90 | https://github.com/cooked-sashimi/Yet-Another-YOLOv4-Pytorch/tree/c884ef8849987a75b0e17eba1b739c22d3782e90 |
Tanh2 | import torch
import torch.utils.data
import torch.nn as nn
import torch.nn.parallel
import torch.optim
class Tanh2(nn.Module):
def __init__(self):
super(Tanh2, self).__init__()
self.tanh = nn.Tanh()
def forward(self, x):
return (self.tanh(x) + 1) / 2
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.utils.data
import torch.nn as nn
import torch.nn.parallel
import t... | csyxwei/FFWM | Tanh2 | false | 15,077 | [
"MIT"
] | 83 | d42c578cabe1b81c6b1bb0c3cb707b190fca3c68 | https://github.com/csyxwei/FFWM/tree/d42c578cabe1b81c6b1bb0c3cb707b190fca3c68 |
SAM | import torch
from torch import nn
class SAM(nn.Module):
def __init__(self, in_channels):
super().__init__()
self.conv = nn.Conv2d(in_channels, out_channels=1, kernel_size=1)
def forward(self, x):
spatial_features = self.conv(x)
attention = torch.sigmoid(spatial_features)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_st... | cooked-sashimi/Yet-Another-YOLOv4-Pytorch | SAM | false | 15,078 | [
"MIT"
] | 133 | c884ef8849987a75b0e17eba1b739c22d3782e90 | https://github.com/cooked-sashimi/Yet-Another-YOLOv4-Pytorch/tree/c884ef8849987a75b0e17eba1b739c22d3782e90 |
GlobalAttentionGeneral | import torch
import torch.nn as nn
import torch.nn.parallel
def conv1x1(in_planes, out_planes, bias=False):
"""1x1 convolution with padding"""
return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=1,
padding=0, bias=bias)
class GlobalAttentionGeneral(nn.Module):
def __init__(self, idf, ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | comtalyst/multi-gan-material-defects | GlobalAttentionGeneral | false | 15,079 | [
"MIT"
] | 112 | aa1c9d4b918b5b5ad7f5fe03fdceec91a66e1007 | https://github.com/comtalyst/multi-gan-material-defects/tree/aa1c9d4b918b5b5ad7f5fe03fdceec91a66e1007 |
Attention | import torch
from torch import nn
class Attention(nn.Module):
def __init__(self, in_channels):
super(Attention, self).__init__()
self.out_channels = int(in_channels / 2)
self.conv1 = nn.Conv2d(in_channels, self.out_channels, kernel_size=
3, padding=1, stride=1)
self.re... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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... | createnewdemo/SPANet | Attention | false | 15,080 | [
"BSD-3-Clause"
] | 177 | 86cfb05d1778cf30142ef30692e995a5b7b59bb8 | https://github.com/createnewdemo/SPANet/tree/86cfb05d1778cf30142ef30692e995a5b7b59bb8 |
Bottleneck | import torch
from torch import nn
from collections import OrderedDict
class Bottleneck(nn.Module):
def __init__(self, in_channels, out_channels):
super(Bottleneck, self).__init__()
m = OrderedDict()
m['conv1'] = nn.Conv2d(in_channels, out_channels, kernel_size=1,
bias=False)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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
from col... | createnewdemo/SPANet | Bottleneck | false | 15,081 | [
"BSD-3-Clause"
] | 177 | 86cfb05d1778cf30142ef30692e995a5b7b59bb8 | https://github.com/createnewdemo/SPANet/tree/86cfb05d1778cf30142ef30692e995a5b7b59bb8 |
FeatureExtractFF | import torch
import torch.utils.data
import torch.nn as nn
class FeatureExtractFF(nn.Module):
def __init__(self, input_dim, hidden_sizes=(15,), activation_fn=nn.ReLU,
**activation_args):
super(FeatureExtractFF, self).__init__()
self._in = input_dim
self._hidden_sizes = 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 import triton_helpers
import torch.utils.data
impor... | criteo-research/pytorch-ada | FeatureExtractFF | false | 15,082 | [
"Apache-2.0"
] | 68 | 4b8861ce1c12fc8a4391eb14a811459e3e8a074a | https://github.com/criteo-research/pytorch-ada/tree/4b8861ce1c12fc8a4391eb14a811459e3e8a074a |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.