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 |
|---|---|---|---|---|---|---|---|---|---|---|
AsymmetricLoss | import torch
import torch.nn as nn
import torch.nn.functional as F
def reduce_loss(loss, reduction):
"""Reduce loss as specified.
Args:
loss (Tensor): Elementwise loss tensor.
reduction (str): Options are "none", "mean" and "sum".
Return:
Tensor: Reduced loss tensor.
"""
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import torc... | colinski/mmclassification | AsymmetricLoss | false | 6,465 | [
"Apache-2.0"
] | 1 | 447c8291bc2e2abda6f3eafe2e6d0f13d65843cb | https://github.com/colinski/mmclassification/tree/447c8291bc2e2abda6f3eafe2e6d0f13d65843cb |
ChannelAttentionBlock | import torch
import torch.nn as nn
class ChannelAttentionBlock(nn.Module):
def __init__(self, in_channels):
super(ChannelAttentionBlock, self).__init__()
self.gamma = nn.Parameter(torch.zeros(1))
self.softmax = nn.Softmax(dim=-1)
def forward(self, x):
"""
:param x: 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.... | cnuzh/CSNet | ChannelAttentionBlock | false | 6,466 | [
"MIT"
] | 1 | a6c3163624f55dc294ec2e5a6de020d77bd4ff91 | https://github.com/cnuzh/CSNet/tree/a6c3163624f55dc294ec2e5a6de020d77bd4ff91 |
DGCNLayer | from _paritybench_helpers import _mock_config
from torch.nn import Module
import math
import torch
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.modules.module import Module
class GraphConvolution(Module):
def __init__(self, in_features, out_features, bias=True):
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch.nn import Module
i... | cjx96/CDRIB | DGCNLayer | false | 6,467 | [
"MIT"
] | 1 | e0d2d2b70ec195a76b479b94fb7758d286350c39 | https://github.com/cjx96/CDRIB/tree/e0d2d2b70ec195a76b479b94fb7758d286350c39 |
GeneralizedMeanPooling | import torch
from torch import Tensor
import torch.nn as nn
from torch.functional import Tensor
import torch.nn.functional as F
from torch import Tensor
from torch.nn.parameter import Parameter
def gem(x: 'Tensor', p: 'Parameter', eps: 'float'=1e-06, clamp=True) ->Tensor:
if clamp:
x = x.clamp(min=eps)
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch ... | colinski/mmclassification | GeneralizedMeanPooling | false | 6,468 | [
"Apache-2.0"
] | 1 | 447c8291bc2e2abda6f3eafe2e6d0f13d65843cb | https://github.com/colinski/mmclassification/tree/447c8291bc2e2abda6f3eafe2e6d0f13d65843cb |
BasicBlock | import torch
import torch.nn as nn
def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1):
return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride,
padding=dilation, groups=groups, bias=True, dilation=dilation)
class BasicBlock(nn.Module):
expansion = 1
def __init__(sel... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | columbia-robovision/SSCNav | BasicBlock | false | 6,469 | [
"MIT"
] | 1 | 0e781a350cddb68c499402d6468ad1adcfb1759d | https://github.com/columbia-robovision/SSCNav/tree/0e781a350cddb68c499402d6468ad1adcfb1759d |
InnerProductDecoder | import torch
import torch.nn.functional as F
import torch.nn as nn
import torch.nn.modules.loss
class InnerProductDecoder(nn.Module):
"""Decoder for using inner product for prediction."""
def __init__(self, dropout, act=torch.sigmoid):
super(InnerProductDecoder, self).__init__()
self.dropout ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
import torch.nn.modules.loss
assert_size_stride = torch._C... | conf20/Egg | InnerProductDecoder | false | 6,470 | [
"MIT"
] | 1 | 6bd35903d1d7a7430b336545a9ee2b0a7f0e10f3 | https://github.com/conf20/Egg/tree/6bd35903d1d7a7430b336545a9ee2b0a7f0e10f3 |
GCNModelVAE | from torch.nn import Module
import torch
import torch.nn.functional as F
import torch.nn as nn
from torch.nn.modules.module import Module
from torch.nn.parameter import Parameter
import torch.nn.modules.loss
class GraphConvolution(Module):
"""
Simple GCN layer, similar to https://arxiv.org/abs/1609.02907
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch.nn import Module
i... | conf20/Egg | GCNModelVAE | false | 6,471 | [
"MIT"
] | 1 | 6bd35903d1d7a7430b336545a9ee2b0a7f0e10f3 | https://github.com/conf20/Egg/tree/6bd35903d1d7a7430b336545a9ee2b0a7f0e10f3 |
PSNRLoss | import torch
import torch.nn as nn
from torch.nn.functional import mse_loss
def psnr_loss(input: 'torch.Tensor', target: 'torch.Tensor', max_val: 'float'
) ->torch.Tensor:
"""Function that computes PSNR
See :class:`~kornia.losses.PSNRLoss` for details.
"""
if not torch.is_tensor(input) or not tor... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
from t... | connorlee77/kornia | PSNRLoss | false | 6,472 | [
"ECL-2.0",
"Apache-2.0"
] | 1 | af5b1f76bedf2a7fc0e0da2386b1be3032b6534f | https://github.com/connorlee77/kornia/tree/af5b1f76bedf2a7fc0e0da2386b1be3032b6534f |
RgbaToRgb | import torch
import torch.nn as nn
def rgba_to_rgb(image: 'torch.Tensor') ->torch.Tensor:
"""Convert image from RGBA to RGB.
See :class:`~kornia.color.RgbaToRgb` for details.
Args:
image (torch.Tensor): RGBA Image to be converted to RGB.
Returns:
torch.Tensor: RGB version of the ima... | 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... | connorlee77/kornia | RgbaToRgb | false | 6,473 | [
"ECL-2.0",
"Apache-2.0"
] | 1 | af5b1f76bedf2a7fc0e0da2386b1be3032b6534f | https://github.com/connorlee77/kornia/tree/af5b1f76bedf2a7fc0e0da2386b1be3032b6534f |
MLP | from _paritybench_helpers import _mock_config
import math
import torch
import torch.nn as nn
from torch.nn.parameter import Parameter
def gelu(x):
return 0.5 * x * (1 + torch.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 *
torch.pow(x, 3))))
class Conv1D(nn.Module):
def __init__(self, nf, nx):
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 ... | ExamDay/NeuralGREWT | MLP | false | 6,474 | [
"MIT"
] | 1 | 2256eb8c88f410bf5a229911f299b216153c96ba | https://github.com/ExamDay/NeuralGREWT/tree/2256eb8c88f410bf5a229911f299b216153c96ba |
AFMLayer | import itertools
import torch
import torch.nn as nn
import torch.nn.functional as F
from sklearn.metrics import *
class AFMLayer(nn.Module):
"""Attentonal Factorization Machine models pairwise (order-2) feature
interactions without linear term and bias.
Input shape
- A list of 3D tensor with sha... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | chenkkkk/DeepCTR-PyTorch | AFMLayer | false | 6,475 | [
"Apache-2.0"
] | 1 | a10a3ace4ad79171e7fb182407b3e4d22bf753e7 | https://github.com/chenkkkk/DeepCTR-PyTorch/tree/a10a3ace4ad79171e7fb182407b3e4d22bf753e7 |
Rot180 | import torch
import torch.nn as nn
def rot180(input: 'torch.Tensor') ->torch.Tensor:
"""Rotate a tensor image or a batch of tensor images
180 degrees. Input must be a tensor of shape (C, H, W)
or a batch of tensors :math:`(*, C, H, W)`.
Args:
input (torch.Tensor): input tensor
Returns:
... | 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... | connorlee77/kornia | Rot180 | false | 6,476 | [
"ECL-2.0",
"Apache-2.0"
] | 1 | af5b1f76bedf2a7fc0e0da2386b1be3032b6534f | https://github.com/connorlee77/kornia/tree/af5b1f76bedf2a7fc0e0da2386b1be3032b6534f |
AbsModel | from torch.nn import Module
import torch
from torch import Tensor
from torch.nn import Identity
from torch.nn.modules import Module
import torch.optim.lr_scheduler
class AbsLayer(Module):
def forward(self, x: 'Tensor') ->Tensor:
return torch.abs(x).reshape((-1, 1))
class AbsModel(Module):
"""Fake m... | 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 import Module
from torch import Tensor
from torch.nn import... | coreylowman/avalanche | AbsModel | false | 6,477 | [
"MIT"
] | 1 | 9c1e7765f1577c400ec0c57260221bcffd9566a2 | https://github.com/coreylowman/avalanche/tree/9c1e7765f1577c400ec0c57260221bcffd9566a2 |
RgbaToBgr | import torch
import torch.nn as nn
def bgr_to_rgb(image: 'torch.Tensor') ->torch.Tensor:
"""Convert a BGR image to RGB.
See :class:`~kornia.color.BgrToRgb` for details.
Args:
image (torch.Tensor): BGR Image to be converted to RGB.
Returns:
torch.Tensor: RGB version of the image.
... | 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... | connorlee77/kornia | RgbaToBgr | false | 6,478 | [
"ECL-2.0",
"Apache-2.0"
] | 1 | af5b1f76bedf2a7fc0e0da2386b1be3032b6534f | https://github.com/connorlee77/kornia/tree/af5b1f76bedf2a7fc0e0da2386b1be3032b6534f |
Vflip | import torch
import torch.nn as nn
def vflip(input: 'torch.Tensor') ->torch.Tensor:
"""Vertically flip a tensor image or a batch of tensor images. Input must
be a tensor of shape (C, H, W) or a batch of tensors :math:`(*, C, H, W)`.
Args:
input (torch.Tensor): input tensor
Returns:
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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | connorlee77/kornia | Vflip | false | 6,479 | [
"ECL-2.0",
"Apache-2.0"
] | 1 | af5b1f76bedf2a7fc0e0da2386b1be3032b6534f | https://github.com/connorlee77/kornia/tree/af5b1f76bedf2a7fc0e0da2386b1be3032b6534f |
ResNetDownsampleA | import torch
import torch.nn as nn
import torch.nn.functional as F
class ResNetDownsampleA(nn.Module):
def __init__(self, planes):
super(ResNetDownsampleA, self).__init__()
self._planes = planes
def forward(self, x):
return F.pad(input=x[:, :, ::2, ::2], pad=(0, 0, 0, 0, self._planes... | 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... | corypaik/pytorch-lightning-pbt | ResNetDownsampleA | false | 6,480 | [
"Apache-2.0"
] | 1 | ad25e472fe59ca22bc400023d2589f4bedd37e30 | https://github.com/corypaik/pytorch-lightning-pbt/tree/ad25e472fe59ca22bc400023d2589f4bedd37e30 |
TotalVariation | import torch
import torch.nn as nn
def total_variation(img: 'torch.Tensor') ->torch.Tensor:
"""Function that computes Total Variation.
See :class:`~kornia.losses.TotalVariation` for details.
"""
if not torch.is_tensor(img):
raise TypeError(f'Input type is not a torch.Tensor. Got {type(img)}')... | 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... | connorlee77/kornia | TotalVariation | false | 6,481 | [
"ECL-2.0",
"Apache-2.0"
] | 1 | af5b1f76bedf2a7fc0e0da2386b1be3032b6534f | https://github.com/connorlee77/kornia/tree/af5b1f76bedf2a7fc0e0da2386b1be3032b6534f |
CNN | import torch
import torch.nn as nn
import torch.utils.data
class CNN(nn.Module):
def __init__(self):
super(CNN, self).__init__()
self.Conv1 = nn.Conv2d(1, 15, 9, 1, 0)
self.Relu1 = nn.ReLU()
self.MaxPool1 = nn.MaxPool2d(2)
self.Conv2 = nn.Conv2d(15, 20, 5, 1, 0)
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
import torch.nn as nn
import ... | clapmyhands/cz4042 | CNN | false | 6,482 | [
"MIT"
] | 1 | 8869bacfb5a49566ae9fcce464187035093ed22d | https://github.com/clapmyhands/cz4042/tree/8869bacfb5a49566ae9fcce464187035093ed22d |
L2Normalization | from torch.nn import Module
import torch
from torch import Tensor
from torch.nn.modules import Module
import torch.optim.lr_scheduler
class L2Normalization(Module):
"""Module to L2-normalize the input. Typically used in last layer to
normalize the embedding."""
def __init__(self):
super().__init_... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
from torch.nn import Module
... | coreylowman/avalanche | L2Normalization | false | 6,483 | [
"MIT"
] | 1 | 9c1e7765f1577c400ec0c57260221bcffd9566a2 | https://github.com/coreylowman/avalanche/tree/9c1e7765f1577c400ec0c57260221bcffd9566a2 |
CatImgs | import torch
from torch import nn
class CatImgs(nn.Module):
def forward(self, img1, img2, img3):
return torch.cat((img1, img2, img3), 3)
def get_inputs():
return [torch.rand([4, 4, 4, 4]), 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 import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_str... | crisdeodates/AI-depthai-experiments | CatImgs | false | 6,484 | [
"MIT"
] | 1 | 74b8b84a03cb637d20a7fcd091cce11add78bd2c | https://github.com/crisdeodates/AI-depthai-experiments/tree/74b8b84a03cb637d20a7fcd091cce11add78bd2c |
Quadratic | import torch
import torch.nn as nn
class Quadratic(nn.Module):
def __init__(self):
super(Quadratic, self).__init__()
def forward(self, x):
return x ** 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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | craigxchen/Reinforcement-Learning-Function-Approximation | Quadratic | false | 6,485 | [
"MIT"
] | 1 | 09c4df1dd44c6a76a3f574bebc959a19b141f3fe | https://github.com/craigxchen/Reinforcement-Learning-Function-Approximation/tree/09c4df1dd44c6a76a3f574bebc959a19b141f3fe |
PLU | import torch
import torch.nn as nn
class PLU(nn.Module):
def __init__(self):
super(PLU, self).__init__()
self.w1 = torch.nn.Parameter(torch.ones(1))
self.w2 = torch.nn.Parameter(torch.ones(1))
def forward(self, x):
return self.w1 * torch.max(x, torch.zeros_like(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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
emp... | craigxchen/Reinforcement-Learning-Function-Approximation | PLU | false | 6,486 | [
"MIT"
] | 1 | 09c4df1dd44c6a76a3f574bebc959a19b141f3fe | https://github.com/craigxchen/Reinforcement-Learning-Function-Approximation/tree/09c4df1dd44c6a76a3f574bebc959a19b141f3fe |
Spike | import torch
import torch.nn as nn
class Spike(nn.Module):
def __init__(self, center=1, width=1):
super(Spike, self).__init__()
self.c = center
self.w = width
self.alpha = torch.nn.Parameter(torch.ones(1))
self.beta = torch.nn.Parameter(torch.ones(1))
def forward(self... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
emp... | craigxchen/Reinforcement-Learning-Function-Approximation | Spike | false | 6,487 | [
"MIT"
] | 1 | 09c4df1dd44c6a76a3f574bebc959a19b141f3fe | https://github.com/craigxchen/Reinforcement-Learning-Function-Approximation/tree/09c4df1dd44c6a76a3f574bebc959a19b141f3fe |
XOR | import torch
import torch.utils.data.distributed
import torch.nn as nn
import torch.utils.data
class XOR(nn.Module):
def __init__(self, input_dim, output_dim):
super(XOR, self).__init__()
self.lin1 = nn.Linear(input_dim, 8)
self.lin2 = nn.Linear(8, output_dim)
def forward(self, featu... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | csh-tech/horovod | XOR | false | 6,488 | [
"Apache-2.0"
] | 1 | 2a3f43f35c840d7e8cfa9674a051ffa53be9918d | https://github.com/csh-tech/horovod/tree/2a3f43f35c840d7e8cfa9674a051ffa53be9918d |
Model | import torch
from torch import nn
def depth_to_3d(depth: 'torch.Tensor', xyz: 'torch.Tensor') ->torch.Tensor:
points_depth: 'torch.Tensor' = depth.permute(0, 2, 3, 1)
points_3d: 'torch.Tensor' = xyz * points_depth
return points_3d.permute(0, 3, 1, 2)
class Model(nn.Module):
def forward(self, xyz, d... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_str... | crisdeodates/AI-depthai-experiments | Model | false | 6,489 | [
"MIT"
] | 1 | 74b8b84a03cb637d20a7fcd091cce11add78bd2c | https://github.com/crisdeodates/AI-depthai-experiments/tree/74b8b84a03cb637d20a7fcd091cce11add78bd2c |
DrugDrugAttentionLayer | import torch
import torch.nn.functional
import torch.cuda
class DrugDrugAttentionLayer(torch.nn.Module):
"""Co-attention layer for drug pairs."""
def __init__(self, feature_number: 'int'):
"""Initialize the co-attention layer.
:param feature_number: Number of input features.
"""
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn.fun... | cthoyt/chemicalx | DrugDrugAttentionLayer | false | 6,490 | [
"Apache-2.0"
] | 1 | f48d70bc88e89e9605a5b1c2f006fb8d37b42922 | https://github.com/cthoyt/chemicalx/tree/f48d70bc88e89e9605a5b1c2f006fb8d37b42922 |
NetModel | import torch
import torch.nn as nn
import torch.utils.data
class NetModel(nn.Module):
def __init__(self, n1, n2):
super(NetModel, self).__init__()
self.layer1 = nn.Conv2d(1, n1, kernel_size=9, stride=1, padding=4,
bias=True)
self.relu1 = nn.ReLU(inplace=True)
self.laye... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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 ... | crazywiden/SRCNN | NetModel | false | 6,491 | [
"MIT"
] | 1 | 872e495397101222f6732ee0129587b6f893aea2 | https://github.com/crazywiden/SRCNN/tree/872e495397101222f6732ee0129587b6f893aea2 |
CriticNet | import torch
import torch.nn as nn
import torch.nn.functional as F
class CriticNet(nn.Module):
def __init__(self, num_state, num_action):
super(CriticNet, self).__init__()
self.num_state = num_state
self.num_action = num_action
self.fc1 = nn.Linear(num_state, 100)
self.fc2... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | cugzj/Adaptive-B | CriticNet | false | 6,492 | [
"Apache-2.0"
] | 1 | cebc965b1dbad93332ae371bfef8640259d940c4 | https://github.com/cugzj/Adaptive-B/tree/cebc965b1dbad93332ae371bfef8640259d940c4 |
Projection | from _paritybench_helpers import _mock_config
import torch
import torch.nn as nn
class TimeDistributed(nn.Module):
def __init__(self, layer, activation='relu'):
super().__init__()
self.layer = layer
self.activation = self.select_activation(activation)
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
from torch._inductor.runtime.... | crystal-k7/chatspace | Projection | false | 6,493 | [
"Apache-2.0"
] | 1 | b63861eab74e1b85f0233f689cf97a13dff873e4 | https://github.com/crystal-k7/chatspace/tree/b63861eab74e1b85f0233f689cf97a13dff873e4 |
CCAMDec | from torch.nn import Module
import torch
from torchvision.datasets import *
from torch.nn import Parameter
from torch.nn import Softmax
from torchvision.transforms import *
class CCAMDec(Module):
"""
CCAM decoding module
"""
def __init__(self):
super(CCAMDec, self).__init__()
self.sof... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | coolgrasshopper/amodal_road_segmentation | CCAMDec | false | 6,494 | [
"MIT"
] | 1 | 462209242973815055f085ada99772af32082f5c | https://github.com/coolgrasshopper/amodal_road_segmentation/tree/462209242973815055f085ada99772af32082f5c |
Highway | import torch
from torch import nn
from torch.nn import functional as F
import torch.nn.functional
import torch.cuda
class Highway(nn.Module):
"""The Highway update layer from [srivastava2015]_.
.. [srivastava2015] Srivastava, R. K., *et al.* (2015).
`Highway Networks <http://arxiv.org/abs/1505.00387>`... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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... | cthoyt/chemicalx | Highway | false | 6,495 | [
"Apache-2.0"
] | 1 | f48d70bc88e89e9605a5b1c2f006fb8d37b42922 | https://github.com/cthoyt/chemicalx/tree/f48d70bc88e89e9605a5b1c2f006fb8d37b42922 |
EmbeddingLayer | import torch
import torch.nn.functional
import torch.cuda
class EmbeddingLayer(torch.nn.Module):
"""Attention layer."""
def __init__(self, feature_number: 'int'):
"""Initialize the relational embedding layer.
:param feature_number: Number of features.
"""
super().__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.... | cthoyt/chemicalx | EmbeddingLayer | false | 6,496 | [
"Apache-2.0"
] | 1 | f48d70bc88e89e9605a5b1c2f006fb8d37b42922 | https://github.com/cthoyt/chemicalx/tree/f48d70bc88e89e9605a5b1c2f006fb8d37b42922 |
ActorNet | import torch
import torch.nn as nn
import torch.nn.functional as F
class ActorNet(nn.Module):
def __init__(self, num_state, num_action):
super(ActorNet, self).__init__()
self.num_state = num_state
self.num_action = num_action
self.fc1 = nn.Linear(self.num_state, 100)
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.... | cugzj/Adaptive-B | ActorNet | false | 6,497 | [
"Apache-2.0"
] | 1 | cebc965b1dbad93332ae371bfef8640259d940c4 | https://github.com/cugzj/Adaptive-B/tree/cebc965b1dbad93332ae371bfef8640259d940c4 |
InverseDepthSmoothnessLoss | import torch
import torch.nn as nn
def _gradient_x(img: 'torch.Tensor') ->torch.Tensor:
assert len(img.shape) == 4, img.shape
return img[:, :, :, :-1] - img[:, :, :, 1:]
def _gradient_y(img: 'torch.Tensor') ->torch.Tensor:
assert len(img.shape) == 4, img.shape
return img[:, :, :-1, :] - img[:, :, 1:... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert... | connorlee77/kornia | InverseDepthSmoothnessLoss | false | 6,498 | [
"ECL-2.0",
"Apache-2.0"
] | 1 | af5b1f76bedf2a7fc0e0da2386b1be3032b6534f | https://github.com/connorlee77/kornia/tree/af5b1f76bedf2a7fc0e0da2386b1be3032b6534f |
Critic | import torch
import torch.nn as nn
import torch.nn.functional as F
class Critic(nn.Module):
def __init__(self, num_state, num_action):
super(Critic, self).__init__()
self.num_state = num_state
self.num_action = num_action
self.fc1 = nn.Linear(self.num_state, 512)
self.stat... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | cugzj/Adaptive-B | Critic | false | 6,499 | [
"Apache-2.0"
] | 1 | cebc965b1dbad93332ae371bfef8640259d940c4 | https://github.com/cugzj/Adaptive-B/tree/cebc965b1dbad93332ae371bfef8640259d940c4 |
RMSELoss | import torch
class RMSELoss(torch.nn.Module):
def __init__(self, eps=1e-08):
super(RMSELoss, self).__init__()
self.eps = eps
self.criterion = torch.nn.MSELoss()
def forward(self, y_hat, y):
return torch.sqrt(self.criterion(y_hat, y) + self.eps)
def get_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 libdevice
assert_size_stride = torch._... | cvpr22sub7201/SpeechDrivenTongueAnimation | RMSELoss | false | 6,500 | [
"MIT"
] | 1 | 82caf9d7f4331e039e3b2f0d31df6393d24ccb1c | https://github.com/cvpr22sub7201/SpeechDrivenTongueAnimation/tree/82caf9d7f4331e039e3b2f0d31df6393d24ccb1c |
ShrinkageLoss | import torch
import torch.nn as nn
class ShrinkageLoss(nn.Module):
""" ShrinkageLoss class.
Modified version of shrinkage loss tailored to images:
http://openaccess.thecvf.com/content_ECCV_2018/papers/Xiankai_Lu_Deep_Regression_Tracking_ECCV_2018_paper.pdf
It basically computes a point-wis... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import torch.nn as nn
assert_size_stride = torch._C._dynamo.gu... | cvpr22sub7201/SpeechDrivenTongueAnimation | ShrinkageLoss | false | 6,501 | [
"MIT"
] | 1 | 82caf9d7f4331e039e3b2f0d31df6393d24ccb1c | https://github.com/cvpr22sub7201/SpeechDrivenTongueAnimation/tree/82caf9d7f4331e039e3b2f0d31df6393d24ccb1c |
HuberLoss | import torch
class HuberLoss(torch.nn.Module):
def __init__(self, delta=1.0):
super(HuberLoss, self).__init__()
self.l2_criterion = torch.nn.MSELoss()
self.l1_criterion = torch.nn.L1Loss()
self.delta = delta
def forward(self, y_hat, y):
l2_loss = self.l2_criterion(y_h... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
assert_size_stride = t... | cvpr22sub7201/SpeechDrivenTongueAnimation | HuberLoss | false | 6,502 | [
"MIT"
] | 1 | 82caf9d7f4331e039e3b2f0d31df6393d24ccb1c | https://github.com/cvpr22sub7201/SpeechDrivenTongueAnimation/tree/82caf9d7f4331e039e3b2f0d31df6393d24ccb1c |
DiceLoss | import torch
from torch import nn
import torch.backends.cudnn
class DiceLoss(nn.Module):
def __init__(self, smooth=0, eps=1e-07):
super(DiceLoss, self).__init__()
self.smooth = smooth
self.eps = eps
def forward(self, output, target):
return 1 - (2 * torch.sum(output * target)... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch import nn
import torch.backends.cudnn
assert_size_stride = torch._C._dynamo.gu... | cxz/tgs-salt-identification-challenge | DiceLoss | false | 6,503 | [
"MIT"
] | 1 | 859f3d7f2d3184532c42c34444500eec3b03b1c8 | https://github.com/cxz/tgs-salt-identification-challenge/tree/859f3d7f2d3184532c42c34444500eec3b03b1c8 |
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... | cuulee/mega-nerf | ShiftedSoftplus | false | 6,504 | [
"MIT"
] | 1 | b38ea40b6ca53ae4423fcfb354ac13cd794827a4 | https://github.com/cuulee/mega-nerf/tree/b38ea40b6ca53ae4423fcfb354ac13cd794827a4 |
BiInteractionPooling | import torch
import torch.nn as nn
from sklearn.metrics import *
class BiInteractionPooling(nn.Module):
"""Bi-Interaction Layer used in Neural FM,compress the
pairwise element-wise product of features into one single vector.
Input shape
- A 3D tensor with shape:``(batch_size,field_size,embeddi... | 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
from sklearn.metrics import *
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = tor... | chenkkkk/DeepCTR-PyTorch | BiInteractionPooling | false | 6,505 | [
"Apache-2.0"
] | 1 | a10a3ace4ad79171e7fb182407b3e4d22bf753e7 | https://github.com/chenkkkk/DeepCTR-PyTorch/tree/a10a3ace4ad79171e7fb182407b3e4d22bf753e7 |
ArgMax | import torch
import torch.sparse
import torch.nn as nn
class ArgMax(nn.Module):
def __init__(self, dim=None):
super().__init__()
self.dim = dim
def forward(self, x):
return torch.argmax(x, dim=self.dim)
def get_inputs():
return [torch.rand([4, 4, 4, 4])]
def get_init_inputs()... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.sparse
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.as... | cwerner/deadtrees | ArgMax | false | 6,506 | [
"Apache-2.0"
] | 1 | 15ddfec58c4a40f22f9c1e2424fb535df4d29b03 | https://github.com/cwerner/deadtrees/tree/15ddfec58c4a40f22f9c1e2424fb535df4d29b03 |
HGCN | import torch
import torch.nn as nn
class HGCN(nn.Module):
def __init__(self, n_edges, in_feature, out_feature, n_agents):
super(HGCN, self).__init__()
None
self.W_line = nn.Parameter(torch.ones(n_edges))
self.W = None
def forward(self, node_features, hyper_graph):
sel... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
im... | cugbbaiyun/HGCN-MIX | HGCN | false | 6,507 | [
"Apache-2.0"
] | 1 | 82b5c22a3cb2dabc2b86c54f23fa314477d92b63 | https://github.com/cugbbaiyun/HGCN-MIX/tree/82b5c22a3cb2dabc2b86c54f23fa314477d92b63 |
UpBlock | import torch
import torch.nn as nn
import torch.nn.functional as F
class UpBlock(nn.Module):
""" Encoder - From pyramid bottom to op
"""
def __init__(self, in_channels, out_channels, sz=1):
super(UpBlock, self).__init__()
self.c1 = nn.Conv3d(in_channels, out_channels, kernel_size=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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | cwood1967/Seg3D | UpBlock | false | 6,508 | [
"Apache-2.0"
] | 1 | dd3ae11fbd89fcfb98d3c00089515a336f2a24e9 | https://github.com/cwood1967/Seg3D/tree/dd3ae11fbd89fcfb98d3c00089515a336f2a24e9 |
Generator | import torch
import torch.nn as nn
import torch.nn.functional as F
class Decoder(nn.Module):
def __init__(self):
super(Decoder, self).__init__()
self.conv6_1 = nn.Conv2d(512, 512, kernel_size=3, stride=1, padding=1)
self.conv6_2 = nn.Conv2d(512, 512, kernel_size=3, stride=1, padding=1)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
import ... | bigabig/saliency | Generator | false | 6,509 | [
"Apache-2.0"
] | 1 | 83618c90ea419ee05fbed116e8ad7bb2b331ecf5 | https://github.com/bigabig/saliency/tree/83618c90ea419ee05fbed116e8ad7bb2b331ecf5 |
MultiHeadAttention | 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.... | csyhhu/attention-is-all-you-need-pytorch | MultiHeadAttention | false | 6,510 | [
"MIT"
] | 1 | 5792c9714295b1a33d1ca074206ec223f436b954 | https://github.com/csyhhu/attention-is-all-you-need-pytorch/tree/5792c9714295b1a33d1ca074206ec223f436b954 |
MS_Block | import torch
import torch.nn as nn
import torch.multiprocessing
import torch.onnx
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... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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.onnx
assert_size... | cvmlarun/RANet | MS_Block | false | 6,511 | [
"Apache-2.0"
] | 1 | 3f67a3f36aaacd9cc7fb98ec79f77db8f1ebdc60 | https://github.com/cvmlarun/RANet/tree/3f67a3f36aaacd9cc7fb98ec79f77db8f1ebdc60 |
EqualLinear | from torch.autograd import Function
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import init as init
from torchvision.models import vgg as vgg
from torch import autograd as autograd
def fused_leaky_relu(input, bias, negative_slope=0.2, scale=2 ** 0.5):
return FusedL... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch.autograd import Function
import math
import torch.nn as nn
from torch... | cyysc1998/EDVRDarts | EqualLinear | false | 6,512 | [
"MIT"
] | 1 | 201badbc8c6469b519647a8869c3782ebe1176cf | https://github.com/cyysc1998/EDVRDarts/tree/201badbc8c6469b519647a8869c3782ebe1176cf |
CharbonnierLoss | import functools
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import init as init
from torchvision.models import vgg as vgg
from torch import autograd as autograd
def reduce_loss(loss, reduction):
"""Reduce loss as specified.
Args:
loss (Tensor): Elementwise loss t... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
import functools
import torc... | cyysc1998/EDVRDarts | CharbonnierLoss | false | 6,513 | [
"MIT"
] | 1 | 201badbc8c6469b519647a8869c3782ebe1176cf | https://github.com/cyysc1998/EDVRDarts/tree/201badbc8c6469b519647a8869c3782ebe1176cf |
ResBlock2 | import torch
import torch.nn as nn
import torch.multiprocessing
import torch.onnx
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, grou... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | cvmlarun/RANet | ResBlock2 | false | 6,514 | [
"Apache-2.0"
] | 1 | 3f67a3f36aaacd9cc7fb98ec79f77db8f1ebdc60 | https://github.com/cvmlarun/RANet/tree/3f67a3f36aaacd9cc7fb98ec79f77db8f1ebdc60 |
JaccardLoss | import torch
from torch import nn
import torch.backends.cudnn
def jaccard(preds, trues, weight=None, is_average=True, eps=1e-06):
num = preds.size(0)
preds = preds.view(num, -1)
trues = trues.view(num, -1)
if weight is not None:
w = torch.autograd.Variable(weight).view(num, -1)
preds =... | 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
import torch.backends.cudnn
assert_size_stride = torch._C._dynamo.gu... | cxz/tgs-salt-identification-challenge | JaccardLoss | false | 6,515 | [
"MIT"
] | 1 | 859f3d7f2d3184532c42c34444500eec3b03b1c8 | https://github.com/cxz/tgs-salt-identification-challenge/tree/859f3d7f2d3184532c42c34444500eec3b03b1c8 |
FocalLoss | import torch
from torch.nn import functional as F
from torch import nn
import torch.backends.cudnn
class FocalLoss(nn.Module):
def __init__(self, gamma):
super().__init__()
self.gamma = gamma
def forward(self, input, target):
if not target.size() == input.size():
raise Va... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch ... | cxz/tgs-salt-identification-challenge | FocalLoss | false | 6,516 | [
"MIT"
] | 1 | 859f3d7f2d3184532c42c34444500eec3b03b1c8 | https://github.com/cxz/tgs-salt-identification-challenge/tree/859f3d7f2d3184532c42c34444500eec3b03b1c8 |
BasicBlock_ins | import torch
import torch.nn as nn
import torch.multiprocessing
import torch.onnx
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):
expansi... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | cvmlarun/RANet | BasicBlock_ins | false | 6,517 | [
"Apache-2.0"
] | 1 | 3f67a3f36aaacd9cc7fb98ec79f77db8f1ebdc60 | https://github.com/cvmlarun/RANet/tree/3f67a3f36aaacd9cc7fb98ec79f77db8f1ebdc60 |
UNetModule | import torch
from torch import nn
import torch.backends.cudnn
def conv3x3(num_in, num_out):
"""Creates a 3x3 convolution building block module.
Args:
num_in: number of input feature maps
num_out: number of output feature maps
Returns:
The 3x3 convolution module.
"""
return nn.C... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch import nn
import t... | cxz/tgs-salt-identification-challenge | UNetModule | false | 6,518 | [
"MIT"
] | 1 | 859f3d7f2d3184532c42c34444500eec3b03b1c8 | https://github.com/cxz/tgs-salt-identification-challenge/tree/859f3d7f2d3184532c42c34444500eec3b03b1c8 |
Actor | import torch
import torch.nn as nn
import torch.nn.functional as F
class Actor(nn.Module):
def __init__(self, num_state, num_action):
super(Actor, self).__init__()
self.num_state = num_state
self.num_action = num_action
self.fc1 = nn.Linear(self.num_state, 512)
self.action... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | cugzj/Adaptive-B | Actor | false | 6,519 | [
"Apache-2.0"
] | 1 | cebc965b1dbad93332ae371bfef8640259d940c4 | https://github.com/cugzj/Adaptive-B/tree/cebc965b1dbad93332ae371bfef8640259d940c4 |
EncoderLayer | 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.... | csyhhu/attention-is-all-you-need-pytorch | EncoderLayer | false | 6,520 | [
"MIT"
] | 1 | 5792c9714295b1a33d1ca074206ec223f436b954 | https://github.com/csyhhu/attention-is-all-you-need-pytorch/tree/5792c9714295b1a33d1ca074206ec223f436b954 |
ModulatedConv2d | from torch.autograd import Function
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import init as init
from torchvision.models import vgg as vgg
from torch import autograd as autograd
def make_resample_kernel(k):
"""Make resampling kernel for UpFirDn.
Args:
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
from torch.autograd... | cyysc1998/EDVRDarts | ModulatedConv2d | false | 6,521 | [
"MIT"
] | 1 | 201badbc8c6469b519647a8869c3782ebe1176cf | https://github.com/cyysc1998/EDVRDarts/tree/201badbc8c6469b519647a8869c3782ebe1176cf |
OneMinusCosThetaByThetaSq | import torch
from torch import cos
from torch import sin
def get_small_and_large_angle_inds(theta: 'torch.Tensor', eps: 'float'=0.001):
"""Returns the indices of small and non-small (large) angles, given
a tensor of angles, and the threshold below (exclusive) which angles
are considered 'small'.
Args... | 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 cos
from torch import sin
assert_size_stride = torch._C... | darkmatter08/dfa-scales-to-modern-deep-learning | OneMinusCosThetaByThetaSq | false | 6,522 | [
"MIT"
] | 1 | 72bf8a045b4bb7eb81736d8ec1d671c4949fb01e | https://github.com/darkmatter08/dfa-scales-to-modern-deep-learning/tree/72bf8a045b4bb7eb81736d8ec1d671c4949fb01e |
ToRGB | from torch.autograd import Function
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import init as init
from torchvision.models import vgg as vgg
from torch import autograd as autograd
def make_resample_kernel(k):
"""Make resampling kernel for UpFirDn.
Args:
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch.autograd import Function
import math
import torch.nn as nn
import tor... | cyysc1998/EDVRDarts | ToRGB | false | 6,523 | [
"MIT"
] | 1 | 201badbc8c6469b519647a8869c3782ebe1176cf | https://github.com/cyysc1998/EDVRDarts/tree/201badbc8c6469b519647a8869c3782ebe1176cf |
TotalVariationLoss | import torch
from typing import Optional
class TotalVariationLoss(torch.nn.Module):
"""
Calculates the total variation loss of a tensor.
"""
loss: 'Optional[torch.Tensor]'
def __init__(self):
super().__init__()
self.loss = None
def forward(self, x):
b, _c, h, w = x.sh... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
from typing import Optional
assert_size_stride = torch._C._dynamo.guards.assert... | daniilgaltsev/Neural-Style-Transfer | TotalVariationLoss | false | 6,524 | [
"MIT"
] | 1 | c781c34a591973afae1a6b7a40c7b31c43af63f7 | https://github.com/daniilgaltsev/Neural-Style-Transfer/tree/c781c34a591973afae1a6b7a40c7b31c43af63f7 |
DecoderLayer | 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.... | csyhhu/attention-is-all-you-need-pytorch | DecoderLayer | false | 6,525 | [
"MIT"
] | 1 | 5792c9714295b1a33d1ca074206ec223f436b954 | https://github.com/csyhhu/attention-is-all-you-need-pytorch/tree/5792c9714295b1a33d1ca074206ec223f436b954 |
SEModule | import torch
import torch.utils.data
import torch
import torch.nn.functional as F
import torch.nn as nn
import torch.nn
class SEModule(nn.Module):
def __init__(self, planes, compress_rate):
super(SEModule, self).__init__()
self.conv1 = nn.Conv2d(planes, planes // compress_rate, kernel_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... | dakotahawkins/impersonator | SEModule | false | 6,526 | [
"MIT"
] | 1 | 87d59167a10fd70aaa95be4fafbf4c8a32eb1a37 | https://github.com/dakotahawkins/impersonator/tree/87d59167a10fd70aaa95be4fafbf4c8a32eb1a37 |
TwoLayer | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.onnx
class TwoLayer(nn.Module):
def __init__(self, inputSize, hiddenSize, outputSize):
super(TwoLayer, self).__init__()
self.fc1 = nn.Linear(inputSize, hiddenSize)
self.fc2 = nn.Linear(hiddenSize, outputSize)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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 ... | dashesy/ELL | TwoLayer | false | 6,527 | [
"MIT"
] | 1 | b4a2b852fc0479d8f0854b1133ee324e14c66bf8 | https://github.com/dashesy/ELL/tree/b4a2b852fc0479d8f0854b1133ee324e14c66bf8 |
ZonoConv | import torch
from typing import Tuple
from typing import Union
import torch.utils.data
class ZonoConv(torch.nn.Module):
"""
Wrapper around pytorch's convolutional layer.
We only add the bias to the zeroth element of the zonotope
"""
def __init__(self, in_channels: 'int', out_channels: 'int', kern... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from typing import Tuple
from typing import Union
import torch.utils.data
assert... | david-shmailov/adversarial-robustness-toolbox | ZonoConv | false | 6,528 | [
"MIT"
] | 1 | ad8b94d3928abe218cd6ab2eed1c5c21f1d6e420 | https://github.com/david-shmailov/adversarial-robustness-toolbox/tree/ad8b94d3928abe218cd6ab2eed1c5c21f1d6e420 |
ZonoDenseLayer | import torch
import torch.utils.data
class ZonoDenseLayer(torch.nn.Module):
"""
Class implementing a dense layer on a zonotope.
Bias is only added to the zeroth term.
"""
def __init__(self, in_features: 'int', out_features: 'int'):
super().__init__()
self.weight = torch.nn.Paramet... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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
assert_size_stride = torch._C._dynamo.guards.assert_size... | david-shmailov/adversarial-robustness-toolbox | ZonoDenseLayer | false | 6,529 | [
"MIT"
] | 1 | ad8b94d3928abe218cd6ab2eed1c5c21f1d6e420 | https://github.com/david-shmailov/adversarial-robustness-toolbox/tree/ad8b94d3928abe218cd6ab2eed1c5c21f1d6e420 |
Actor | import torch
import numpy as np
import torch.nn.functional as F
import torch.nn as nn
def hidden_init(layer):
fan_in = layer.weight.data.size()[0]
lim = 1.0 / np.sqrt(fan_in)
return -lim, lim
class Actor(nn.Module):
def __init__(self, actor_in, actor_out, seed, fc1_units=256, fc2_units=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.... | davidhtf/drlnd | Actor | false | 6,530 | [
"MIT"
] | 1 | 221601f38659055824763ce41c6d9edd3d476fd4 | https://github.com/davidhtf/drlnd/tree/221601f38659055824763ce41c6d9edd3d476fd4 |
QNetwork | import torch
import torch.nn.functional as F
import torch.nn as nn
class QNetwork(nn.Module):
"""Actor (Policy) Model."""
def __init__(self, state_size, action_size, seed, fc1_units=64,
fc2_units=32):
"""Initialize parameters and build model.
Params
======
state_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 import triton_helpers
import torch.nn as nn
assert_... | davidhtf/drlnd | QNetwork | false | 6,531 | [
"MIT"
] | 1 | 221601f38659055824763ce41c6d9edd3d476fd4 | https://github.com/davidhtf/drlnd/tree/221601f38659055824763ce41c6d9edd3d476fd4 |
CosAttention | import torch
import torch.nn as nn
class CosAttention(nn.Module):
def __init__(self):
super(CosAttention, self).__init__()
def forward(self, title_output, attr_output):
"""
title_output (batchsize, seqlen, hidden_dim)
attr_output (batchsize, hidden_dim)
"""
se... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
assert... | deepframwork/TorchBlocks | CosAttention | false | 6,532 | [
"MIT"
] | 1 | 35f6e1bb83d2b9b05ba914a21fd365cb26ac4a32 | https://github.com/deepframwork/TorchBlocks/tree/35f6e1bb83d2b9b05ba914a21fd365cb26ac4a32 |
AttentionModule | import torch
from torch import nn
class AttentionModule(nn.Module):
def __init__(self, feat_chans: 'int', state_chans: 'int',
attention_units: 'int') ->None:
super().__init__()
self.feat_conv = nn.Conv2d(feat_chans, attention_units, 3, padding=1)
self.state_conv = nn.Conv2d(state_... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | das-projects/deepOCR | AttentionModule | false | 6,533 | [
"Apache-2.0"
] | 1 | ffc6db691605b7b4837da9619ab6e918fa1c18de | https://github.com/das-projects/deepOCR/tree/ffc6db691605b7b4837da9619ab6e918fa1c18de |
CPAMDec | from torch.nn import Module
import torch
from torchvision.datasets import *
from torch.nn import Conv2d
from torch.nn import Parameter
from torch.nn import Linear
from torch.nn import Softmax
from torchvision.transforms import *
class CPAMDec(Module):
"""
CPAM decoding module
"""
def __init__(self, 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.... | coolgrasshopper/amodal_road_segmentation | CPAMDec | false | 6,534 | [
"MIT"
] | 1 | 462209242973815055f085ada99772af32082f5c | https://github.com/coolgrasshopper/amodal_road_segmentation/tree/462209242973815055f085ada99772af32082f5c |
NoNorm | import torch
import torch.nn as nn
class NoNorm(nn.Module):
def __init__(self, feat_size):
super(NoNorm, self).__init__()
self.bias = nn.Parameter(torch.zeros(feat_size))
self.weight = nn.Parameter(torch.ones(feat_size))
def forward(self, input_tensor):
return input_tensor * ... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | deepframwork/TorchBlocks | NoNorm | false | 6,535 | [
"MIT"
] | 1 | 35f6e1bb83d2b9b05ba914a21fd365cb26ac4a32 | https://github.com/deepframwork/TorchBlocks/tree/35f6e1bb83d2b9b05ba914a21fd365cb26ac4a32 |
ConvAutoencoder | import torch
import torch.nn.functional as F
from torch import nn
import torch.utils.data
class ConvAutoencoder(nn.Module):
def __init__(self):
super(ConvAutoencoder, self).__init__()
self.conv1 = nn.Conv2d(12, 16, 3)
self.conv2 = nn.Conv2d(16, 4, 3)
self.t_conv1 = nn.ConvTranspos... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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... | dedbox/TOAD-GAN | ConvAutoencoder | false | 6,536 | [
"MIT"
] | 1 | 8a0a84d10f9c5975ae4b1c54f7da99567c8ffd67 | https://github.com/dedbox/TOAD-GAN/tree/8a0a84d10f9c5975ae4b1c54f7da99567c8ffd67 |
Critic | import torch
import numpy as np
import torch.nn.functional as F
import torch.nn as nn
def hidden_init(layer):
fan_in = layer.weight.data.size()[0]
lim = 1.0 / np.sqrt(fan_in)
return -lim, lim
class Critic(nn.Module):
def __init__(self, critic_in, action_size, seed, fc1_units=512,
fc2_units=... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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
import tor... | davidhtf/drlnd | Critic | false | 6,537 | [
"MIT"
] | 1 | 221601f38659055824763ce41c6d9edd3d476fd4 | https://github.com/davidhtf/drlnd/tree/221601f38659055824763ce41c6d9edd3d476fd4 |
DenseSynthesizer | import torch
import torch.nn as nn
class DenseSynthesizer(nn.Module):
def __init__(self, head_dim, n_heads, n_tokens, big=True):
super().__init__()
h = max(head_dim, n_tokens) if big else min(head_dim, n_tokens)
w1 = torch.empty(n_heads, head_dim, h)
b1 = torch.empty(n_heads, h)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | darkmatter08/dfa-scales-to-modern-deep-learning | DenseSynthesizer | false | 6,538 | [
"MIT"
] | 1 | 72bf8a045b4bb7eb81736d8ec1d671c4949fb01e | https://github.com/darkmatter08/dfa-scales-to-modern-deep-learning/tree/72bf8a045b4bb7eb81736d8ec1d671c4949fb01e |
MaskUpdate | import torch
from torch import nn
class MaskUpdate(nn.Module):
def __init__(self, alpha):
super(MaskUpdate, self).__init__()
self.updateFunc = nn.ReLU(True)
self.alpha = alpha
def forward(self, inputMaskMap):
return torch.pow(self.updateFunc(inputMaskMap), self.alpha)
def g... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empt... | delldu/ImagePatch | MaskUpdate | false | 6,539 | [
"MIT"
] | 1 | aaeadba9fe9f40e9bf900468f100a06bafc8231f | https://github.com/delldu/ImagePatch/tree/aaeadba9fe9f40e9bf900468f100a06bafc8231f |
decoder3 | import torch
import torch.nn as nn
class decoder3(nn.Module):
def __init__(self):
super(decoder3, self).__init__()
self.reflecPad7 = nn.ReflectionPad2d((1, 1, 1, 1))
self.conv7 = nn.Conv2d(256, 128, 3, 1, 0)
self.relu7 = nn.ReLU(inplace=True)
self.unpool = nn.UpsamplingNea... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | cy-xu/LinearStyleTransfer | decoder3 | false | 6,540 | [
"BSD-2-Clause"
] | 1 | a07ab32db037f60a122e252588d6bd504b7d70d7 | https://github.com/cy-xu/LinearStyleTransfer/tree/a07ab32db037f60a122e252588d6bd504b7d70d7 |
JointL2Loss | import torch
import torch.nn as nn
import torch.utils.data
class JointL2Loss(nn.Module):
def __init__(self):
super(JointL2Loss, self).__init__()
def forward(self, joint_pred, joint_gt):
batch_size, joint_num, _ = joint_gt.shape
joint_pred = joint_pred.view(batch_size * joint_num, -1)... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
import... | dejianwei/HigherA2J | JointL2Loss | false | 6,541 | [
"MIT"
] | 1 | 655d993d4b835ec58396887a85b68ef506b5df9e | https://github.com/dejianwei/HigherA2J/tree/655d993d4b835ec58396887a85b68ef506b5df9e |
Attention | import torch
import torch.nn as nn
class Attention(nn.Module):
def __init__(self, feature_dim, maxlen=70):
super().__init__()
self.attention_fc = nn.Linear(feature_dim, 1)
self.bias = nn.Parameter(torch.zeros(1, maxlen, 1, requires_grad=True))
def forward(self, rnn_output):
"... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
im... | deepframwork/TorchBlocks | Attention | false | 6,542 | [
"MIT"
] | 1 | 35f6e1bb83d2b9b05ba914a21fd365cb26ac4a32 | https://github.com/deepframwork/TorchBlocks/tree/35f6e1bb83d2b9b05ba914a21fd365cb26ac4a32 |
FocalLoss | import torch
import torch.nn as nn
class FocalLoss(nn.Module):
def __init__(self, gamma=2, eps=1e-07):
super(FocalLoss, self).__init__()
self.gamma = gamma
self.eps = eps
self.ce = nn.CrossEntropyLoss(reduction='none')
def forward(self, input, target):
logp = self.ce(... | 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
... | delldu/EQFace | FocalLoss | false | 6,543 | [
"MIT"
] | 1 | a088e80709c1e31a57e302cabfa85ab96f2c0aa5 | https://github.com/delldu/EQFace/tree/a088e80709c1e31a57e302cabfa85ab96f2c0aa5 |
GaussActivation | import torch
from torch import nn
from torch.nn.parameter import Parameter
class GaussActivation(nn.Module):
def __init__(self, a, mu, sigma1, sigma2):
super(GaussActivation, self).__init__()
self.a = Parameter(torch.tensor(a, dtype=torch.float32))
self.mu = Parameter(torch.tensor(mu, dty... | 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
f... | delldu/ImagePatch | GaussActivation | false | 6,544 | [
"MIT"
] | 1 | aaeadba9fe9f40e9bf900468f100a06bafc8231f | https://github.com/delldu/ImagePatch/tree/aaeadba9fe9f40e9bf900468f100a06bafc8231f |
MultiHeadedAttentionBlock | import torch
import torch.nn as nn
from typing import Callable
class MLP(nn.Module):
"""Multi Layer Perceptron class"""
def __init__(self, in_feats: 'int', hidden_feats: 'int'=None, out_feats:
'int'=None, act_layer: 'Callable[[torch.Tensor], torch.Tensor]'=nn.
GELU, drop_rate: 'float'=0.0):
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | cvpr22sub7201/SpeechDrivenTongueAnimation | MultiHeadedAttentionBlock | false | 6,545 | [
"MIT"
] | 1 | 82caf9d7f4331e039e3b2f0d31df6393d24ccb1c | https://github.com/cvpr22sub7201/SpeechDrivenTongueAnimation/tree/82caf9d7f4331e039e3b2f0d31df6393d24ccb1c |
TransformerEncoderLayer | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import TransformerEncoderLayer
from typing import Optional
from torch.nn.init import xavier_uniform_
class TransformerEncoderLayer(nn.Module):
def __init__(self, dim_model, nhead, dim_feedforward=2048, dropout=0.1,
activatio... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | d-michele/Graph-MPNN-transformer | TransformerEncoderLayer | false | 6,546 | [
"MIT"
] | 1 | 1aafc44e1433a61d1a6a7c9e35564635bb9f8afc | https://github.com/d-michele/Graph-MPNN-transformer/tree/1aafc44e1433a61d1a6a7c9e35564635bb9f8afc |
FusedLeakyReLU | import torch
from torch import nn
from torch.nn import functional as F
class FusedLeakyReLU(nn.Module):
def __init__(self, channel):
super().__init__()
self.bias = nn.Parameter(torch.zeros(channel))
self.scale = 1.414
def forward(self, input):
shape = 1, self.bias.shape[0], 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 import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_str... | delldu/StyleGAN2 | FusedLeakyReLU | false | 6,547 | [
"MIT",
"BSD-2-Clause",
"Apache-2.0"
] | 1 | 4bcba4673d3dc32ac3a67f6b5d5e24b490cdfbb3 | https://github.com/delldu/StyleGAN2/tree/4bcba4673d3dc32ac3a67f6b5d5e24b490cdfbb3 |
ResidualBlockNoBN | import torch
import torch.nn as nn
from torch.nn import init as init
from torch.nn.modules.batchnorm import _BatchNorm
from torchvision.models import vgg as vgg
from torch import autograd as autograd
@torch.no_grad()
def default_init_weights(module_list, scale=1, bias_fill=0, **kwargs):
"""Initialize network weig... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
from to... | cyysc1998/EDVRDarts | ResidualBlockNoBN | false | 6,548 | [
"MIT"
] | 1 | 201badbc8c6469b519647a8869c3782ebe1176cf | https://github.com/cyysc1998/EDVRDarts/tree/201badbc8c6469b519647a8869c3782ebe1176cf |
HDRLoss | import torch
from torch import nn
from numpy import *
from math import sqrt as sqrt
from itertools import product as product
class HDRLoss(nn.Module):
"""High dynamic range loss."""
def __init__(self, eps=0.01):
"""Initializes loss with numerical stability epsilon."""
super(HDRLoss, self).__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
from torch._inductor.runtime import triton_helpers
from torch import nn
from numpy import *
from math import sqrt as sqrt
from itertools imp... | davidpqc1231/AnnotatedNetworkModelGit | HDRLoss | false | 6,549 | [
"MIT"
] | 1 | 419e6c9ef31f1efe7fd63d693b12c08a7d8c0f33 | https://github.com/davidpqc1231/AnnotatedNetworkModelGit/tree/419e6c9ef31f1efe7fd63d693b12c08a7d8c0f33 |
EqualLinearWithLeakyRelu | import math
import torch
from torch import nn
from torch.nn import functional as F
class EqualLinearWithLeakyRelu(nn.Module):
"""Add this class for onnx -- data driven flow is difficult tracing."""
def __init__(self, in_dim, out_dim, lr_mul=0.01):
super().__init__()
self.weight = nn.Parameter... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import math
from torch import nn
assert_size_stride = torch._C._dynamo.guards.as... | delldu/StyleGAN2 | EqualLinearWithLeakyRelu | false | 6,550 | [
"MIT",
"BSD-2-Clause",
"Apache-2.0"
] | 1 | 4bcba4673d3dc32ac3a67f6b5d5e24b490cdfbb3 | https://github.com/delldu/StyleGAN2/tree/4bcba4673d3dc32ac3a67f6b5d5e24b490cdfbb3 |
GatedConv2d | import torch
import torch.nn as nn
from torch.nn import Parameter
def l2normalize(v, eps=1e-12):
return v / (v.norm() + eps)
class SpectralNorm(nn.Module):
def __init__(self, module, name='weight', power_iterations=1):
super(SpectralNorm, self).__init__()
self.module = module
self.n... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as ... | delldu/DeepFillv2 | GatedConv2d | false | 6,551 | [
"MIT"
] | 1 | a564b9589c1b42bcdddd3d7601f4059c4594a439 | https://github.com/delldu/DeepFillv2/tree/a564b9589c1b42bcdddd3d7601f4059c4594a439 |
CNN | import torch
from torch.nn import functional as F
from torch import nn
class CNN(nn.Module):
"""Regularization for sparse-data CT and XPCI CT.
* The CNN has 3 layers:
inChannels -> Layer 1 -> n_cnn -> Layer 2 ->
n_cnn -> Layer_3 -> 1 channel
Args:
n_cnn (int): Number of output channels 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 import nn
assert_s... | dennis-j-lee/AirNet-SNL | CNN | false | 6,552 | [
"BSD-3-Clause"
] | 1 | c35b84b50b7f1351a450a5970b19d8a8b83053d1 | https://github.com/dennis-j-lee/AirNet-SNL/tree/c35b84b50b7f1351a450a5970b19d8a8b83053d1 |
ContourDTConsistency | import torch
from typing import Optional
import torch.utils.data
import torch.nn as nn
import torch.nn.parallel
class ContourDTConsistency(nn.Module):
"""Consistency regularization between the instance contour map and
signed distance transform.
Args:
pred1 (torch.Tensor): contour logits.
... | 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... | devaansh100/pytorch_connectomics | ContourDTConsistency | false | 6,553 | [
"MIT"
] | 1 | b1e4b16b0480546ea806d14876208080815ed964 | https://github.com/devaansh100/pytorch_connectomics/tree/b1e4b16b0480546ea806d14876208080815ed964 |
ReverseMaskConv | import torch
from torch import nn
from torch.nn.parameter import Parameter
def weights_init():
"""
Gaussian init.
"""
def init_fun(m):
classname = m.__class__.__name__
if (classname.find('Conv') == 0 or classname.find('Linear') == 0
) and hasattr(m, 'weight'):
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | delldu/ImagePatch | ReverseMaskConv | false | 6,554 | [
"MIT"
] | 1 | aaeadba9fe9f40e9bf900468f100a06bafc8231f | https://github.com/delldu/ImagePatch/tree/aaeadba9fe9f40e9bf900468f100a06bafc8231f |
BinaryReg | import torch
from typing import Optional
import torch.utils.data
import torch.nn as nn
import torch.nn.parallel
class BinaryReg(nn.Module):
"""Regularization for encouraging the outputs to be binary.
Args:
pred (torch.Tensor): foreground logits.
mask (Optional[torch.Tensor], optional): weight... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.utils.dat... | devaansh100/pytorch_connectomics | BinaryReg | false | 6,555 | [
"MIT"
] | 1 | b1e4b16b0480546ea806d14876208080815ed964 | https://github.com/devaansh100/pytorch_connectomics/tree/b1e4b16b0480546ea806d14876208080815ed964 |
NonoverlapReg | import torch
import torch.utils.data
import torch.nn as nn
import torch.nn.parallel
class NonoverlapReg(nn.Module):
"""Regularization to prevent overlapping prediction of pre- and post-synaptic
masks in synaptic polarity prediction ("1" in MODEL.TARGET_OPT).
Args:
fg_masked (bool): mask the regul... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.utils.data
import torch.nn as nn
import torch.nn.parallel
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty... | devaansh100/pytorch_connectomics | NonoverlapReg | false | 6,556 | [
"MIT"
] | 1 | b1e4b16b0480546ea806d14876208080815ed964 | https://github.com/devaansh100/pytorch_connectomics/tree/b1e4b16b0480546ea806d14876208080815ed964 |
WeightedBCEFocalLoss | import torch
import torch.utils.data
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.parallel
class WeightedBCEFocalLoss(nn.Module):
"""Weighted binary focal loss with logits.
"""
def __init__(self, gamma=2.0, alpha=0.25, eps=0.0):
super().__init__()
self.eps = eps
... | 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... | devaansh100/pytorch_connectomics | WeightedBCEFocalLoss | false | 6,557 | [
"MIT"
] | 1 | b1e4b16b0480546ea806d14876208080815ed964 | https://github.com/devaansh100/pytorch_connectomics/tree/b1e4b16b0480546ea806d14876208080815ed964 |
DiceLoss | import torch
import torch.utils.data
import torch.nn as nn
import torch.nn.parallel
class DiceLoss(nn.Module):
"""DICE loss.
"""
def __init__(self, reduce=True, smooth=100.0, power=1):
super(DiceLoss, self).__init__()
self.smooth = smooth
self.reduce = reduce
self.power = ... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.utils.data
import torch.nn as nn
import torch.nn.parallel
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty... | devaansh100/pytorch_connectomics | DiceLoss | false | 6,558 | [
"MIT"
] | 1 | b1e4b16b0480546ea806d14876208080815ed964 | https://github.com/devaansh100/pytorch_connectomics/tree/b1e4b16b0480546ea806d14876208080815ed964 |
NoiseInjection | import torch
from torch import nn
class NoiseInjection(nn.Module):
def __init__(self):
super().__init__()
self.weight = nn.Parameter(torch.zeros(1))
def forward(self, image):
noise = torch.randn_like(image[:, 0:1, :, :])
return image + self.weight * noise * 0.9
def get_inpu... | import torch
from torch import device
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C.... | delldu/StyleGAN2 | NoiseInjection | false | 6,559 | [
"MIT",
"BSD-2-Clause",
"Apache-2.0"
] | 1 | 4bcba4673d3dc32ac3a67f6b5d5e24b490cdfbb3 | https://github.com/delldu/StyleGAN2/tree/4bcba4673d3dc32ac3a67f6b5d5e24b490cdfbb3 |
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-feed-forward-layer module """
def __init__(self, d_in, d_hid, dropout=0.1):
super()... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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... | desmarg/ehr_ml | PositionwiseFeedForward | false | 6,560 | [
"MIT"
] | 1 | 48a385fe2ebdbef655bd4c6b6dd9a73a4e3f76b4 | https://github.com/desmarg/ehr_ml/tree/48a385fe2ebdbef655bd4c6b6dd9a73a4e3f76b4 |
WeightedBCEWithLogitsLoss | import torch
import torch.utils.data
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.parallel
class WeightedBCEWithLogitsLoss(nn.Module):
"""Weighted binary cross-entropy with logits.
"""
def __init__(self, size_average=True, reduce=True, eps=0.0):
super().__init__()
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import torc... | devaansh100/pytorch_connectomics | WeightedBCEWithLogitsLoss | false | 6,561 | [
"MIT"
] | 1 | b1e4b16b0480546ea806d14876208080815ed964 | https://github.com/devaansh100/pytorch_connectomics/tree/b1e4b16b0480546ea806d14876208080815ed964 |
ForegroundDTConsistency | import torch
from typing import Optional
import torch.utils.data
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.parallel
class ForegroundDTConsistency(nn.Module):
"""Consistency regularization between the binary foreground mask and
signed distance transform.
Args:
pred1 (to... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import torc... | devaansh100/pytorch_connectomics | ForegroundDTConsistency | false | 6,562 | [
"MIT"
] | 1 | b1e4b16b0480546ea806d14876208080815ed964 | https://github.com/devaansh100/pytorch_connectomics/tree/b1e4b16b0480546ea806d14876208080815ed964 |
HSwish | import torch
import torch.nn as nn
import torch.quantization
class HSigmoid(nn.Module):
"""Hard Sigmoid."""
def __init__(self, inplace: 'bool'=True) ->None:
"""Initialize."""
super(HSigmoid, self).__init__()
self.relu6 = nn.ReLU6(inplace=inplace)
def forward(self, x: 'torch.Tenso... | 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.quantization
assert_size_stride = torch._C._dynamo.gua... | dhlee347/model_compression | HSwish | false | 6,563 | [
"MIT"
] | 1 | 274b85ff56d81f0b7cf6907cbc1bd10e16cdb956 | https://github.com/dhlee347/model_compression/tree/274b85ff56d81f0b7cf6907cbc1bd10e16cdb956 |
encoder3 | import torch
import torch.nn as nn
class encoder3(nn.Module):
def __init__(self):
super(encoder3, self).__init__()
self.conv1 = nn.Conv2d(3, 3, 1, 1, 0)
self.reflecPad1 = nn.ReflectionPad2d((1, 1, 1, 1))
self.conv2 = nn.Conv2d(3, 64, 3, 1, 0)
self.relu2 = nn.ReLU(inplace=T... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | cy-xu/LinearStyleTransfer | encoder3 | false | 6,564 | [
"BSD-2-Clause"
] | 1 | a07ab32db037f60a122e252588d6bd504b7d70d7 | https://github.com/cy-xu/LinearStyleTransfer/tree/a07ab32db037f60a122e252588d6bd504b7d70d7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.