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 |
|---|---|---|---|---|---|---|---|---|---|---|
EqualConv2d | import math
import torch
from torch import nn
import torch.nn.functional as F
class EqualConv2d(nn.Module):
def __init__(self, in_channel, out_channel, kernel_size, groups=1,
stride=1, padding=0, bias=True, lr_mul=1):
super().__init__()
self.weight = nn.Parameter(torch.randn(out_channel, ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | Tiamat-Tech/RetrieveInStyle | EqualConv2d | false | 14,479 | [
"MIT"
] | 53 | c5714b9c3c219c9ba463f3e162083458702038c1 | https://github.com/Tiamat-Tech/RetrieveInStyle/tree/c5714b9c3c219c9ba463f3e162083458702038c1 |
HuberLoss | import torch
import torch.nn as nn
import torch.utils.data
class HuberLoss(nn.Module):
def __init__(self, delta=1):
super().__init__()
self.huber_loss_delta1 = nn.SmoothL1Loss()
self.delta = delta
def forward(self, x, x_hat):
loss = self.huber_loss_delta1(x / self.delta, x_ha... | 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
... | Thibaud-Ardoin/d4rl_evaluations | HuberLoss | false | 14,480 | [
"Apache-2.0"
] | 123 | 135b23d3aecc234aacaeaaa019fbc7101d9b87ec | https://github.com/Thibaud-Ardoin/d4rl_evaluations/tree/135b23d3aecc234aacaeaaa019fbc7101d9b87ec |
CNormalized_Linear | import math
import torch
import torch as th
class CNormalized_Linear(th.nn.Module):
"""Linear layer with column-wise normalized input matrix."""
def __init__(self, in_features, out_features, bias=False):
"""Initialize the layer."""
super(CNormalized_Linear, self).__init__()
self.in_fe... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 ... | TheSignPainter/CausalDiscoveryToolbox | CNormalized_Linear | false | 14,481 | [
"MIT"
] | 528 | 33eae18184905e505be978b08003b9477bf38e0c | https://github.com/TheSignPainter/CausalDiscoveryToolbox/tree/33eae18184905e505be978b08003b9477bf38e0c |
MultiHead | import math
import torch
from torch.nn import functional as F
from torch import nn
def matmul(x, y):
if x.dim() == y.dim():
return torch.matmul(x, y)
if x.dim() == y.dim() - 1:
return torch.matmul(x.unsqueeze(-2), y).squeeze(-2)
return torch.matmul(x, y.unsqueeze(-2)).squeeze(-2)
class 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._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | TheShadow29/vognet-pytorch | MultiHead | false | 14,482 | [
"MIT"
] | 70 | 238e93c37cf9f03a2fd376a14760bb3d334a113d | https://github.com/TheShadow29/vognet-pytorch/tree/238e93c37cf9f03a2fd376a14760bb3d334a113d |
Value | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
class Value(nn.Module):
def __init__(self, state_dim, action_dim):
super(Value, self).__init__()
self.l1 = nn.Linear(state_dim, 400)
self.l2 = nn.Linear(400, 300)
self.l3 = nn.Linear(300, 1)... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
import ... | Thibaud-Ardoin/d4rl_evaluations | Value | false | 14,483 | [
"Apache-2.0"
] | 123 | 135b23d3aecc234aacaeaaa019fbc7101d9b87ec | https://github.com/Thibaud-Ardoin/d4rl_evaluations/tree/135b23d3aecc234aacaeaaa019fbc7101d9b87ec |
LayerNorm | import torch
import torch.nn as nn
import torch.utils.data
class LayerNorm(nn.Module):
"""
Simple 1D LayerNorm.
"""
def __init__(self, features, center=True, scale=False, eps=1e-06):
super().__init__()
self.center = center
self.scale = scale
self.eps = eps
if s... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
import torch.utils.data
assert_size_stride = torch._C._dy... | Thibaud-Ardoin/d4rl_evaluations | LayerNorm | false | 14,484 | [
"Apache-2.0"
] | 123 | 135b23d3aecc234aacaeaaa019fbc7101d9b87ec | https://github.com/Thibaud-Ardoin/d4rl_evaluations/tree/135b23d3aecc234aacaeaaa019fbc7101d9b87ec |
Downsample | import torch
import torch.utils.data
import torch
import torch.nn as nn
class Downsample(nn.Module):
def __init__(self, dim):
super().__init__()
self.conv = nn.Conv2d(dim, dim, 3, 2, 1)
def forward(self, x):
return self.conv(x)
def get_inputs():
return [torch.rand([4, 4, 4, 4])... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.utils.data
import torch
import torch.nn as nn
assert_size_stride = ... | Tiamat-Tech/Image-Super-Resolution-via-Iterative-Refinement | Downsample | false | 14,485 | [
"Apache-2.0"
] | 1,764 | ef9b943b573328d7a5ddb1a0c2abd168b91610dc | https://github.com/Tiamat-Tech/Image-Super-Resolution-via-Iterative-Refinement/tree/ef9b943b573328d7a5ddb1a0c2abd168b91610dc |
FusedLeakyReLU | import torch
import torch.utils.data
import torch
import torch.nn as nn
import torch.nn.functional as F
def fused_leaky_relu(input, bias, negative_slope=0.2, scale=2 ** 0.5):
return F.leaky_relu(input + bias, negative_slope) * scale
class FusedLeakyReLU(nn.Module):
def __init__(self, channel, negative_slop... | 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
import torch.nn as nn
import torch.nn.functional as F
assert_size_stride = torch._C._dynamo.guards.asse... | Theomat/colorization-av-enseirb-2020 | FusedLeakyReLU | false | 14,486 | [
"Apache-2.0"
] | 1,422 | c54c2388ea39a62289fa2f1c51b4757bf55d3c4f | https://github.com/Theomat/colorization-av-enseirb-2020/tree/c54c2388ea39a62289fa2f1c51b4757bf55d3c4f |
GetGradient | import torch
import torch.nn as nn
import torch.nn.functional as F
class GetGradient(nn.Module):
""" generate the gradient map
"""
def __init__(self):
super(GetGradient, self).__init__()
kernel_v = [[0, -1, 0], [0, 0, 0], [0, 1, 0]]
kernel_h = [[0, 0, 0], [-1, 0, 1], [0, 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.triton_helpers import libdevice
import torch.nn as ... | TencentARC/FAIG | GetGradient | false | 14,487 | [
"Apache-2.0"
] | 74 | 14f856a87e3696953304029532e2f84997d12278 | https://github.com/TencentARC/FAIG/tree/14f856a87e3696953304029532e2f84997d12278 |
ToRGB | import math
import torch
import torch.utils.data
import torch
import torch.nn as nn
import torch.nn.functional as F
def make_kernel(k):
k = torch.tensor(k, dtype=torch.float32)
if len(k.shape) == 1:
k = k[None, :] * k[:, None]
k /= k.sum()
return k
def upfirdn2d_native(input, kernel, up_x, u... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import math
import torch.utils.data
import torch
import torch.nn as nn
import to... | Theomat/colorization-av-enseirb-2020 | ToRGB | false | 14,488 | [
"Apache-2.0"
] | 1,422 | c54c2388ea39a62289fa2f1c51b4757bf55d3c4f | https://github.com/Theomat/colorization-av-enseirb-2020/tree/c54c2388ea39a62289fa2f1c51b4757bf55d3c4f |
SpatialTemporalConv3D | import torch
import torch.nn as nn
class SpatialTemporalConv3D(nn.Module):
"""
Apply 3D conv. over an input signal composed of several input planes with distinct spatial and time axes, by performing 3D convolution over the spatiotemporal axes
args:
in_channels (int): number of channels in the inp... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | Tencent/DVQA | SpatialTemporalConv3D | false | 14,489 | [
"BSD-3-Clause"
] | 408 | 21727333a6b41d54ad1a8beca1fcbe00a69ed347 | https://github.com/Tencent/DVQA/tree/21727333a6b41d54ad1a8beca1fcbe00a69ed347 |
ReshapeF | import torch
import torch.utils.data
import torch
import torch.nn as nn
class Normalize(nn.Module):
def __init__(self, power=2):
super(Normalize, self).__init__()
self.power = power
def forward(self, x):
norm = x.pow(self.power).sum(1, keepdim=True).pow(1.0 / self.power)
out ... | 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
import torch.nn as nn
assert_size_stride =... | Theomat/colorization-av-enseirb-2020 | ReshapeF | false | 14,490 | [
"Apache-2.0"
] | 1,422 | c54c2388ea39a62289fa2f1c51b4757bf55d3c4f | https://github.com/Theomat/colorization-av-enseirb-2020/tree/c54c2388ea39a62289fa2f1c51b4757bf55d3c4f |
Swish | import torch
import torch.nn as nn
class Swish(nn.Module):
"""The swish activation function: :math:`\\mathrm{swish}(x)=x\\sigma(\\beta x)=\\frac{x}{1+e^{-\\beta x}}`.
:param beta: The :math:`\\beta` parameter in the swish activation.
:type beta: float
:param trainable: Whether scalar :math:`\\beta` c... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | Tiamat-Tech/neurodiffeq | Swish | false | 14,491 | [
"MIT"
] | 202 | 622827e5b9b65d285ebe36614fbdae68ba07f4dc | https://github.com/Tiamat-Tech/neurodiffeq/tree/622827e5b9b65d285ebe36614fbdae68ba07f4dc |
SelfGating | import torch
import torch as th
import torch.nn as nn
class SelfGating(nn.Module):
def __init__(self, input_dim):
super(SelfGating, self).__init__()
self.fc = nn.Linear(input_dim, input_dim)
def forward(self, input_tensor):
"""Feature gating as used in S3D-G."""
spatiotempora... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | Tiamat-Tech/just-ask | SelfGating | false | 14,492 | [
"Apache-2.0"
] | 59 | 80725161e12ad0682b4c2091f61a5889a335ba21 | https://github.com/Tiamat-Tech/just-ask/tree/80725161e12ad0682b4c2091f61a5889a335ba21 |
InvertibleLinearFlow | import torch
import numpy as np
import torch.nn as nn
from typing import Tuple
class Flow(nn.Module):
def __init__(self):
super(Flow, self).__init__()
def forward(self, *inputs, **kwargs) ->Tuple[torch.Tensor, torch.Tensor]:
"""
Args:
*inputs: input [batch, *input_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
import numpy as np
import torch.nn as nn
from typing import Tuple
assert_size_st... | Tiamat-Tech/VAENAR-TTS | InvertibleLinearFlow | false | 14,493 | [
"MIT"
] | 62 | 69b6b5be1ab5168cfd3c6ab902075638e76a3b8d | https://github.com/Tiamat-Tech/VAENAR-TTS/tree/69b6b5be1ab5168cfd3c6ab902075638e76a3b8d |
EqualLinear | from torch.autograd import Function
import math
import torch
from torch import nn
from torch.nn import functional as F
def fused_leaky_relu(input, bias=None, negative_slope=0.2, scale=2 ** 0.5):
if input.device.type == 'cpu':
if bias is not None:
rest_dim = [1] * (input.ndim - bias.ndim - 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.autograd import Function
import math
from torch import nn
from torch.... | Tiamat-Tech/alias-free-gan-pytorch | EqualLinear | false | 14,494 | [
"MIT"
] | 485 | f14d54ce2d973880b0c352614b2d63088c9026ae | https://github.com/Tiamat-Tech/alias-free-gan-pytorch/tree/f14d54ce2d973880b0c352614b2d63088c9026ae |
MonomialNN | import torch
import torch.nn as nn
from warnings import warn
class MonomialNN(nn.Module):
"""A network that expands its input to a given list of monomials.
Its output shape will be (n_samples, n_input_units * n_degrees)
:param degrees: max degree to be included, or a list of degrees that will be used
... | 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 warnings import warn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._... | Tiamat-Tech/neurodiffeq | MonomialNN | false | 14,495 | [
"MIT"
] | 202 | 622827e5b9b65d285ebe36614fbdae68ba07f4dc | https://github.com/Tiamat-Tech/neurodiffeq/tree/622827e5b9b65d285ebe36614fbdae68ba07f4dc |
Actor | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
class Actor(nn.Module):
def __init__(self, state_dim, action_dim, max_action):
super(Actor, self).__init__()
self.l1 = nn.Linear(state_dim + action_dim, 400)
self.l2 = nn.Linear(400, 300)
se... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | Thibaud-Ardoin/d4rl_evaluations | Actor | false | 14,496 | [
"Apache-2.0"
] | 123 | 135b23d3aecc234aacaeaaa019fbc7101d9b87ec | https://github.com/Thibaud-Ardoin/d4rl_evaluations/tree/135b23d3aecc234aacaeaaa019fbc7101d9b87ec |
InstanceSimilarity | import torch
import torch.nn.functional as F
import torch.nn as nn
class InstanceSimilarity(nn.Module):
"""
Instance Similarity based loss
"""
def __init__(self, mse=True):
super(InstanceSimilarity, self).__init__()
self.mse = mse
def _loss(self, fm_s, fm_t):
fm_s = fm_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.... | Tiamat-Tech/ZAQ-code | InstanceSimilarity | false | 14,497 | [
"MIT"
] | 55 | e7e9f55791e36c6784d58c356d3ced76a7583369 | https://github.com/Tiamat-Tech/ZAQ-code/tree/e7e9f55791e36c6784d58c356d3ced76a7583369 |
VNLinear | import torch
import torch.nn as nn
import torch.utils.data
import torch
import torch.nn.parallel
class VNLinear(nn.Module):
def __init__(self, in_channels, out_channels):
super(VNLinear, self).__init__()
self.map_to_feat = nn.Linear(in_channels, out_channels, bias=False)
def forward(self, x)... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
import torch.utils.data
import torch
import torch.nn.paral... | Tiamat-Tech/vnn | VNLinear | false | 14,498 | [
"MIT"
] | 280 | f3197e210022b5f0015e0da6456adf66bd0cd73e | https://github.com/Tiamat-Tech/vnn/tree/f3197e210022b5f0015e0da6456adf66bd0cd73e |
FC_Q | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
class FC_Q(nn.Module):
def __init__(self, state_dim, num_actions):
super(FC_Q, self).__init__()
self.q1 = nn.Linear(state_dim, 256)
self.q2 = nn.Linear(256, 256)
self.q3 = nn.Linear(256, num... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | Thibaud-Ardoin/d4rl_evaluations | FC_Q | false | 14,499 | [
"Apache-2.0"
] | 123 | 135b23d3aecc234aacaeaaa019fbc7101d9b87ec | https://github.com/Thibaud-Ardoin/d4rl_evaluations/tree/135b23d3aecc234aacaeaaa019fbc7101d9b87ec |
MultiNonLinearClassifier | import torch
import torch.nn as nn
class MultiNonLinearClassifier(nn.Module):
def __init__(self, hidden_size, num_label):
super(MultiNonLinearClassifier, self).__init__()
self.num_label = num_label
self.classifier1 = nn.Linear(hidden_size, int(hidden_size / 2))
self.classifier2 = ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | TimSYQQX/glyce | MultiNonLinearClassifier | false | 14,500 | [
"Apache-2.0"
] | 396 | 1542ed30ce104c25aa5c69ffcc9cc5ef2fcda975 | https://github.com/TimSYQQX/glyce/tree/1542ed30ce104c25aa5c69ffcc9cc5ef2fcda975 |
Sentence_Maxpool | import torch
import torch.nn as nn
import torch.nn.functional as F
class Sentence_Maxpool(nn.Module):
""" Utilitary for the answer module """
def __init__(self, word_dimension, output_dim, relu=True):
super(Sentence_Maxpool, self).__init__()
self.fc = nn.Linear(word_dimension, output_dim)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | Tiamat-Tech/just-ask | Sentence_Maxpool | false | 14,501 | [
"Apache-2.0"
] | 59 | 80725161e12ad0682b4c2091f61a5889a335ba21 | https://github.com/Tiamat-Tech/just-ask/tree/80725161e12ad0682b4c2091f61a5889a335ba21 |
AbsLayer | from torch.nn import Module
import torch
from torch import Tensor
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))
def get_inputs():
return [torch.rand([4, 4, 4, 4])]
def get_i... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import math as tl_math
from torch.nn import Module
from torch.nn.modules import Module
import to... | TomVeniat/avalanche | AbsLayer | false | 14,502 | [
"MIT"
] | 810 | 6e89f9945cf40c14471406a4cf4830a8d95c5705 | https://github.com/TomVeniat/avalanche/tree/6e89f9945cf40c14471406a4cf4830a8d95c5705 |
ActNormFlow | import torch
import torch.nn as nn
from typing import Tuple
class Flow(nn.Module):
def __init__(self):
super(Flow, self).__init__()
def forward(self, *inputs, **kwargs) ->Tuple[torch.Tensor, torch.Tensor]:
"""
Args:
*inputs: input [batch, *input_size]
Returns: out... | 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
from typing import Tuple
assert_size_stride = torch... | Tiamat-Tech/VAENAR-TTS | ActNormFlow | false | 14,503 | [
"MIT"
] | 62 | 69b6b5be1ab5168cfd3c6ab902075638e76a3b8d | https://github.com/Tiamat-Tech/VAENAR-TTS/tree/69b6b5be1ab5168cfd3c6ab902075638e76a3b8d |
MetaBilinear | import re
import torch
import warnings
from torch import nn
import torch.nn.functional as F
from collections import OrderedDict
class MetaModule(nn.Module):
"""
Base class for PyTorch meta-learning modules. These modules accept an
additional argument `params` in their `forward` method.
Notes
----... | 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 re
import warnings
from torch import nn
from collections import OrderedDict
assert_size_stride = torch._C._dynamo.guards.assert_size_... | Timothy102/light-field-networks | MetaBilinear | false | 14,504 | [
"MIT"
] | 95 | 0d2d6099ea1df4332b173fab47e5606d579b4293 | https://github.com/Timothy102/light-field-networks/tree/0d2d6099ea1df4332b173fab47e5606d579b4293 |
EncoderLayer | import math
import torch
from torch.nn import functional as F
from torch import nn
def matmul(x, y):
if x.dim() == y.dim():
return torch.matmul(x, y)
if x.dim() == y.dim() - 1:
return torch.matmul(x.unsqueeze(-2), y).squeeze(-2)
return torch.matmul(x, y.unsqueeze(-2)).squeeze(-2)
class 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.... | TheShadow29/vognet-pytorch | EncoderLayer | false | 14,505 | [
"MIT"
] | 70 | 238e93c37cf9f03a2fd376a14760bb3d334a113d | https://github.com/TheShadow29/vognet-pytorch/tree/238e93c37cf9f03a2fd376a14760bb3d334a113d |
HighwayCNN | import torch
import torch.nn as nn
class HighwayCNN(nn.Module):
def __init__(self, input_size, gate_bias=-1, activation_function=nn.
functional.relu, gate_activation=nn.functional.softmax):
super(HighwayCNN, self).__init__()
self.activation_function = activation_function
self.gate... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | TimSYQQX/glyce | HighwayCNN | false | 14,506 | [
"Apache-2.0"
] | 396 | 1542ed30ce104c25aa5c69ffcc9cc5ef2fcda975 | https://github.com/TimSYQQX/glyce/tree/1542ed30ce104c25aa5c69ffcc9cc5ef2fcda975 |
BatchLinear | import re
import torch
import warnings
from torch import nn
from collections import OrderedDict
class MetaModule(nn.Module):
"""
Base class for PyTorch meta-learning modules. These modules accept an
additional argument `params` in their `forward` method.
Notes
-----
Objects inherited from `Me... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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 re
import warnings
from torch import nn
from collections import OrderedDi... | Timothy102/light-field-networks | BatchLinear | false | 14,507 | [
"MIT"
] | 95 | 0d2d6099ea1df4332b173fab47e5606d579b4293 | https://github.com/Timothy102/light-field-networks/tree/0d2d6099ea1df4332b173fab47e5606d579b4293 |
VNMaxPool | import torch
import torch.nn as nn
import torch.utils.data
import torch
import torch.nn.parallel
class VNMaxPool(nn.Module):
def __init__(self, in_channels):
super(VNMaxPool, self).__init__()
self.map_to_dir = nn.Linear(in_channels, in_channels, bias=False)
def forward(self, x):
"""
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
import torch.utils.data
import torch
import torch.nn.paral... | Tiamat-Tech/vnn | VNMaxPool | false | 14,508 | [
"MIT"
] | 280 | f3197e210022b5f0015e0da6456adf66bd0cd73e | https://github.com/Tiamat-Tech/vnn/tree/f3197e210022b5f0015e0da6456adf66bd0cd73e |
SoftL1 | import torch
class SoftL1(torch.nn.Module):
def __init__(self):
super(SoftL1, self).__init__()
def forward(self, input, target, eps=0.0):
l1 = torch.abs(input - target)
ret = l1 - eps
ret = torch.clamp(ret, min=0.0, max=100.0)
return ret, torch.mean(l1.detach())
def... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
assert_size_stride = t... | Tiamat-Tech/npms | SoftL1 | false | 14,509 | [
"MIT"
] | 96 | 2d1bce8c98b0f24aa69273975c52b2fbdb101c29 | https://github.com/Tiamat-Tech/npms/tree/2d1bce8c98b0f24aa69273975c52b2fbdb101c29 |
Correlation | import torch
from torch import nn
class Correlation(nn.Module):
"""Correlation Congruence for Knowledge Distillation, ICCV 2019.
The authors nicely shared the code with me. I restructured their code to be
compatible with my running framework. Credits go to the original author"""
def __init__(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.triton_helpers import math as tl_math
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_... | UBCDingXin/RepDistiller | Correlation | false | 14,510 | [
"BSD-2-Clause"
] | 1,347 | dcc043277f2820efafd679ffb82b8e8195b7e222 | https://github.com/UBCDingXin/RepDistiller/tree/dcc043277f2820efafd679ffb82b8e8195b7e222 |
HighwayMLP | import torch
import torch.nn as nn
class HighwayMLP(nn.Module):
def __init__(self, input_size, gate_bias=-2, activation_function=nn.
functional.relu, gate_activation=nn.functional.softmax):
super(HighwayMLP, self).__init__()
self.activation_function = activation_function
self.gate... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | TimSYQQX/glyce | HighwayMLP | false | 14,511 | [
"Apache-2.0"
] | 396 | 1542ed30ce104c25aa5c69ffcc9cc5ef2fcda975 | https://github.com/TimSYQQX/glyce/tree/1542ed30ce104c25aa5c69ffcc9cc5ef2fcda975 |
DeConv | import torch
from torch import nn
import torch.onnx
class DeConv(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size=3,
upsampl_scale=2):
super().__init__()
self.upsampling = nn.UpsamplingNearest2d(scale_factor=upsampl_scale)
padding_size = int((kernel_size - 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 import nn
import torch.onnx
assert_size_stride = torch._C._dynamo.gua... | TriceHelix/ASMAGAN | DeConv | false | 14,512 | [
"Apache-2.0"
] | 121 | 6e2b5b587f88f641fdcc05a81cf5f0b4d6a9f3e1 | https://github.com/TriceHelix/ASMAGAN/tree/6e2b5b587f88f641fdcc05a81cf5f0b4d6a9f3e1 |
CustomizeLayer | import torch
import torch.nn as nn
class CustomizeLayer(nn.Module):
def __init__(self, in_dim):
super().__init__()
self.in_dim = in_dim
self.scale = nn.Parameter(torch.Tensor(self.in_dim))
self.bias = nn.Parameter(torch.Tensor(self.in_dim))
def forward(self, x):
norm ... | 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_... | Trouble404/Torch-Pruning | CustomizeLayer | false | 14,513 | [
"MIT"
] | 468 | 80e07f66c220ac0ec52f0e19a4a71e8865d28952 | https://github.com/Trouble404/Torch-Pruning/tree/80e07f66c220ac0ec52f0e19a4a71e8865d28952 |
MultiHeadSelfAttention | from torch.nn import Module
import torch
from torch.nn import Dropout
from torch.nn import Linear
from torch.nn.modules import Dropout
def masked_softmax(vector: 'torch.Tensor', mask: 'torch.Tensor', dim: 'int'=-1
) ->torch.Tensor:
"""
``torch.nn.functional.softmax(vector)`` does not work if some elements... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | TimSYQQX/glyce | MultiHeadSelfAttention | false | 14,514 | [
"Apache-2.0"
] | 396 | 1542ed30ce104c25aa5c69ffcc9cc5ef2fcda975 | https://github.com/TimSYQQX/glyce/tree/1542ed30ce104c25aa5c69ffcc9cc5ef2fcda975 |
TestNet | import torch
from torch import nn
class TestNet(nn.Module):
def __init__(self):
super().__init__()
self.conv = nn.Conv1d(1, 1, 1)
def forward(self, x):
x_len = x.shape[-1]
return self.conv(x.view(-1, 1, x_len)).view(x.shape)
def get_inputs():
return [torch.rand([4, 4, 4... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_st... | TuZehai/pytorch_stoi | TestNet | false | 14,515 | [
"MIT"
] | 45 | ae58e3ef4d608fc367e522150f48c58f122716fd | https://github.com/TuZehai/pytorch_stoi/tree/ae58e3ef4d608fc367e522150f48c58f122716fd |
SimulatorReward | import torch
import torch.nn.functional as F
class SimulatorReward(torch.nn.Module):
def __init__(self):
super(SimulatorReward, self).__init__()
self.conv1 = torch.nn.Conv2d(4, 8, kernel_size=3, padding=1)
self.conv2 = torch.nn.Conv2d(8, 16, kernel_size=3, padding=1)
self.conv3 = ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | Tuantrung/DeepReinforcementLearningInAction | SimulatorReward | false | 14,516 | [
"MIT"
] | 474 | 8afda00a8211326c540b5de5a964d62a7f29a70c | https://github.com/Tuantrung/DeepReinforcementLearningInAction/tree/8afda00a8211326c540b5de5a964d62a7f29a70c |
Conv_Q | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
class Conv_Q(nn.Module):
def __init__(self, frames, num_actions):
super(Conv_Q, self).__init__()
self.c1 = nn.Conv2d(frames, 32, kernel_size=8, stride=4)
self.c2 = nn.Conv2d(32, 64, kernel_size=4, 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.... | Thibaud-Ardoin/d4rl_evaluations | Conv_Q | false | 14,517 | [
"Apache-2.0"
] | 123 | 135b23d3aecc234aacaeaaa019fbc7101d9b87ec | https://github.com/Thibaud-Ardoin/d4rl_evaluations/tree/135b23d3aecc234aacaeaaa019fbc7101d9b87ec |
LayerNorm | import torch
from torch import nn
class LayerNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-06):
"""
Construct a layernorm module in the T5 style No bias and no subtraction of mean.
"""
super().__init__()
self.weight = nn.Parameter(torch.ones(hidden_size))
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | TsinghuaAI/CPM-2-Pretrain | LayerNorm | false | 14,518 | [
"MIT"
] | 54 | 33003865239e7ba13a12aabf9ec2735cef66bf3b | https://github.com/TsinghuaAI/CPM-2-Pretrain/tree/33003865239e7ba13a12aabf9ec2735cef66bf3b |
PKT | import torch
from torch import nn
class PKT(nn.Module):
"""Probabilistic Knowledge Transfer for deep representation learning
Code from author: https://github.com/passalis/probabilistic_kt"""
def __init__(self):
super(PKT, self).__init__()
def forward(self, f_s, f_t):
return self.cosi... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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... | UBCDingXin/RepDistiller | PKT | false | 14,519 | [
"BSD-2-Clause"
] | 1,347 | dcc043277f2820efafd679ffb82b8e8195b7e222 | https://github.com/UBCDingXin/RepDistiller/tree/dcc043277f2820efafd679ffb82b8e8195b7e222 |
LogSoftmax | import torch
import torch.nn.functional as F
class LogSoftmax(torch.nn.Module):
def __init__(self, dim):
super(LogSoftmax, self).__init__()
self.dim = dim
def forward(self, x, a):
nll = -F.log_softmax(x, self.dim, _stacklevel=5)
return (nll * a / a.sum(1, keepdim=True).clamp(... | 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... | Tiamat-Tech/just-ask | LogSoftmax | false | 14,520 | [
"Apache-2.0"
] | 59 | 80725161e12ad0682b4c2091f61a5889a335ba21 | https://github.com/Tiamat-Tech/just-ask/tree/80725161e12ad0682b4c2091f61a5889a335ba21 |
GlobalAvgPool2d | import torch
from torch import nn
from torch.nn import functional as F
class GlobalAvgPool2d(nn.Module):
def __init__(self):
"""
Global Average pooling module
"""
super(GlobalAvgPool2d, self).__init__()
def forward(self, x):
"""
The forward function of the Glo... | 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... | UniSerj/ai-research | GlobalAvgPool2d | false | 14,521 | [
"Apache-2.0"
] | 46 | 79f0093c93408cc5dd7d3f56aafd7dc1f901421c | https://github.com/UniSerj/ai-research/tree/79f0093c93408cc5dd7d3f56aafd7dc1f901421c |
LogSumExpPooling1d | import torch
from torch import nn as nn
class LogSumExpPooling1d(nn.Module):
"""Applies a 1D LogSumExp pooling over an input signal composed of several input planes.
LogSumExp is a smooth approximation of the max function.
Examples:
>>> m = LogSumExpPooling1d()
>>> input = autograd.Variable(torch... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import math as tl_math
from torch import nn as nn
assert_size_stride = torch._C._dynamo.guards.a... | UKPLab/coling2018-graph-neural-networks-question-answering | LogSumExpPooling1d | false | 14,522 | [
"Apache-2.0"
] | 164 | 389558d6570195debea570834944507de4f21d65 | https://github.com/UKPLab/coling2018-graph-neural-networks-question-answering/tree/389558d6570195debea570834944507de4f21d65 |
CircleLoss | import torch
from torch import Tensor
from torch import nn
from torchvision.transforms import *
class CircleLoss(nn.Module):
def __init__(self, m: 'float', gamma: 'float') ->None:
super(CircleLoss, self).__init__()
self.m = m
self.gamma = gamma
self.soft_plus = nn.Softplus()
... | 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 ... | TxuanYu/Person_reID_baseline_pytorch | CircleLoss | false | 14,523 | [
"MIT"
] | 3,358 | 10574b17cc8fd1fc8ade88f134679e281fdb01cc | https://github.com/TxuanYu/Person_reID_baseline_pytorch/tree/10574b17cc8fd1fc8ade88f134679e281fdb01cc |
LatentDecoder | import torch
from torch import nn
class LatentDecoder(nn.Module):
def __init__(self, hidden_size):
super(LatentDecoder, self).__init__()
self.dense = nn.Linear(hidden_size, hidden_size)
self.dense_mu = nn.Linear(hidden_size, hidden_size)
self.LayerNorm = nn.LayerNorm(hidden_size, ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
from torch import n... | UKPLab/MMT-Retrieval | LatentDecoder | false | 14,524 | [
"MIT"
] | 98 | a31caaeb0da680131bf39dc855e38fdda949f38e | https://github.com/UKPLab/MMT-Retrieval/tree/a31caaeb0da680131bf39dc855e38fdda949f38e |
Project3D | import torch
import torch.nn as nn
import torch.utils.data
class Project3D(nn.Module):
"""Layer which projects 3D points into a camera with intrinsics K and at position T
"""
def __init__(self, batch_size, height, width, eps=1e-07):
super(Project3D, self).__init__()
self.batch_size = batc... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
import torch.utils.data
assert_size_stride = torch._C._dyn... | Uehwan/SimVODIS | Project3D | false | 14,525 | [
"MIT"
] | 117 | 288ae6f3bf37336f2c829b3a6371793990b23214 | https://github.com/Uehwan/SimVODIS/tree/288ae6f3bf37336f2c829b3a6371793990b23214 |
KLD | import torch
import torch.nn as nn
import torch.nn.parallel
import torch.optim
import torch.utils.data
import torch.utils.data.distributed
import torch.nn.functional as F
class KLD(nn.Module):
def forward(self, targets, inputs):
targets = F.softmax(targets, dim=1)
inputs = F.log_softmax(inputs, d... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import torc... | UMBCvision/CompReSS | KLD | false | 14,526 | [
"MIT"
] | 61 | c5e57edce75da96482fd36eac484c5aca9676945 | https://github.com/UMBCvision/CompReSS/tree/c5e57edce75da96482fd36eac484c5aca9676945 |
HSwish | import torch
from torch import nn
class HSwish(nn.Module):
def __init__(self):
"""
An HSwish module
:param inplace: A boolean stating if the operation is inplace
"""
super(HSwish, self).__init__()
self.relu6 = nn.ReLU6()
def forward(self, x):
"""
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empt... | UniSerj/ai-research | HSwish | false | 14,527 | [
"Apache-2.0"
] | 46 | 79f0093c93408cc5dd7d3f56aafd7dc1f901421c | https://github.com/UniSerj/ai-research/tree/79f0093c93408cc5dd7d3f56aafd7dc1f901421c |
FreqEncoder | import torch
import torch.nn as nn
class FreqEncoder(nn.Module):
def __init__(self, input_dim, max_freq_log2, N_freqs, log_sampling=True,
include_input=True, periodic_fns=(torch.sin, torch.cos)):
super().__init__()
self.input_dim = input_dim
self.include_input = include_input
... | 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... | VCAT19/torch-ngp | FreqEncoder | false | 14,528 | [
"MIT"
] | 262 | dcbfe061b30808875a80f12a10a383b51b35f121 | https://github.com/VCAT19/torch-ngp/tree/dcbfe061b30808875a80f12a10a383b51b35f121 |
RKDLoss | import torch
from torch import nn
import torch.nn.functional as F
class RKDLoss(nn.Module):
"""Relational Knowledge Disitllation, CVPR2019"""
def __init__(self, w_d=25, w_a=50):
super(RKDLoss, self).__init__()
self.w_d = w_d
self.w_a = w_a
def forward(self, f_s, f_t):
stu... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | UBCDingXin/RepDistiller | RKDLoss | false | 14,529 | [
"BSD-2-Clause"
] | 1,347 | dcc043277f2820efafd679ffb82b8e8195b7e222 | https://github.com/UBCDingXin/RepDistiller/tree/dcc043277f2820efafd679ffb82b8e8195b7e222 |
FactorTransfer | import torch
from torch import nn
import torch.nn.functional as F
class FactorTransfer(nn.Module):
"""Paraphrasing Complex Network: Network Compression via Factor Transfer, NeurIPS 2018"""
def __init__(self, p1=2, p2=1):
super(FactorTransfer, self).__init__()
self.p1 = p1
self.p2 = p2... | 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 ... | UBCDingXin/RepDistiller | FactorTransfer | false | 14,530 | [
"BSD-2-Clause"
] | 1,347 | dcc043277f2820efafd679ffb82b8e8195b7e222 | https://github.com/UBCDingXin/RepDistiller/tree/dcc043277f2820efafd679ffb82b8e8195b7e222 |
BertAttention | from _paritybench_helpers import _mock_config
import math
import torch
from torch import nn
from torch.nn import LayerNorm
class BertSelfAttention(nn.Module):
def __init__(self, config):
super(BertSelfAttention, self).__init__()
if config.hidden_size % config.num_attention_heads != 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.... | UKPLab/MMT-Retrieval | BertAttention | false | 14,531 | [
"MIT"
] | 98 | a31caaeb0da680131bf39dc855e38fdda949f38e | https://github.com/UKPLab/MMT-Retrieval/tree/a31caaeb0da680131bf39dc855e38fdda949f38e |
EfficientBaseQuantization | import torch
import numpy as np
from torch import nn
class _EfficientBaseQuantizationFunction(torch.autograd.Function):
@staticmethod
def clip(x, min_value, max_value):
x = torch.min(x, max_value)
x = torch.max(x, min_value)
return x
@staticmethod
def forward(ctx, x, delta, q... | 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 numpy as np
from torc... | UniSerj/ai-research | EfficientBaseQuantization | false | 14,532 | [
"Apache-2.0"
] | 46 | 79f0093c93408cc5dd7d3f56aafd7dc1f901421c | https://github.com/UniSerj/ai-research/tree/79f0093c93408cc5dd7d3f56aafd7dc1f901421c |
ScaledLeakyReLUSin | import math
import torch
from torch import nn
import torch.nn.functional as F
class ScaledLeakyReLUSin(nn.Module):
def __init__(self, negative_slope=0.2):
super().__init__()
self.negative_slope = negative_slope
def forward(self, input):
out_lr = F.leaky_relu(input[:, ::2], negative_s... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import math as tl_math
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_... | Ugness/CIPS_SR | ScaledLeakyReLUSin | false | 14,533 | [
"MIT"
] | 172 | abce872f5bc1b84afb9634a7dd1991e8c74d7616 | https://github.com/Ugness/CIPS_SR/tree/abce872f5bc1b84afb9634a7dd1991e8c74d7616 |
SReLU | import torch
import torch.nn as nn
from torch.nn.parameter import Parameter
class SReLU(nn.Module):
"""
SReLU (S-shaped Rectified Linear Activation Unit): a combination of three linear functions, which perform mapping R → R with the following formulation:
.. math::
h(x_i) = \\left\\{\\begin{matrix... | 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 torch.nn.parameter import Parameter
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided... | VITA-Group/SViTE | SReLU | false | 14,534 | [
"MIT"
] | 50 | b0c62fd153c8b0b99917ab935ee76925c9de1149 | https://github.com/VITA-Group/SViTE/tree/b0c62fd153c8b0b99917ab935ee76925c9de1149 |
MultiHeadAttention | import torch
import torch.nn as nn
def scaled_dot_product_attention(q, k, v, mask=None):
"""Calculate the attention weights.
q, k, v must have matching leading dimensions.
k, v must have matching penultimate dimension, i.e.: seq_len_k = seq_len_v.
The mask has different shapes depending on its type(pa... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | ULTR-Community/ULTRA_Pytorch | MultiHeadAttention | false | 14,535 | [
"Apache-2.0"
] | 46 | ec4fe329e4239b588a940cb4bcdd6a321aade679 | https://github.com/ULTR-Community/ULTRA_Pytorch/tree/ec4fe329e4239b588a940cb4bcdd6a321aade679 |
BaseQuantization | import torch
from torch import nn
class Clipping(nn.Module):
def __init__(self):
"""
This module perform element-wise clipping.
"""
super(Clipping, self).__init__()
def forward(self, x, max_value, min_value):
"""
The forward function of the clipping module
... | 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
assert_... | UniSerj/ai-research | BaseQuantization | false | 14,536 | [
"Apache-2.0"
] | 46 | 79f0093c93408cc5dd7d3f56aafd7dc1f901421c | https://github.com/UniSerj/ai-research/tree/79f0093c93408cc5dd7d3f56aafd7dc1f901421c |
AdaIN | import torch
import torch.nn as nn
import torch.optim
import torch.utils.data
def calc_mean_std(feat, eps=1e-05):
size = feat.size()
assert len(size) == 4
N, C = size[:2]
feat_var = feat.view(N, C, -1).var(dim=2) + eps
feat_std = feat_var.sqrt().view(N, C, 1, 1)
feat_mean = feat.view(N, C, -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 libdevice
import torch.nn as nn
import torch.optim
import torch.utils.data
assert_size_st... | VITA-Group/Sandwich-Batch-Normalization | AdaIN | false | 14,537 | [
"MIT"
] | 46 | 25e7df6e64a67cebd7e70b911f874cfc1bd19df0 | https://github.com/VITA-Group/Sandwich-Batch-Normalization/tree/25e7df6e64a67cebd7e70b911f874cfc1bd19df0 |
SCRM | import torch
import torch.nn.functional as F
import torch.nn as nn
class SCRM(nn.Module):
"""
spatial & channel wise relation loss
"""
def __init__(self, gamma=0.1):
super(SCRM, self).__init__()
self.softmax = nn.Softmax(dim=-1)
self.gamma = gamma
def spatial_wise(self, x... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | Tiamat-Tech/ZAQ-code | SCRM | false | 14,538 | [
"MIT"
] | 55 | e7e9f55791e36c6784d58c356d3ced76a7583369 | https://github.com/Tiamat-Tech/ZAQ-code/tree/e7e9f55791e36c6784d58c356d3ced76a7583369 |
LFF | import torch
import numpy as np
from torch import nn
class SinActivation(nn.Module):
def __init__(self):
super(SinActivation, self).__init__()
def forward(self, x):
return torch.sin(x)
class ConLinear(nn.Module):
def __init__(self, ch_in, ch_out, is_first=False, bias=True):
su... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import math as tl_math
import numpy ... | Ugness/CIPS_SR | LFF | false | 14,539 | [
"MIT"
] | 172 | abce872f5bc1b84afb9634a7dd1991e8c74d7616 | https://github.com/Ugness/CIPS_SR/tree/abce872f5bc1b84afb9634a7dd1991e8c74d7616 |
Clipping | import torch
from torch import nn
class Clipping(nn.Module):
def __init__(self):
"""
This module perform element-wise clipping.
"""
super(Clipping, self).__init__()
def forward(self, x, max_value, min_value):
"""
The forward function of the clipping module
... | 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... | UniSerj/ai-research | Clipping | false | 14,540 | [
"Apache-2.0"
] | 46 | 79f0093c93408cc5dd7d3f56aafd7dc1f901421c | https://github.com/UniSerj/ai-research/tree/79f0093c93408cc5dd7d3f56aafd7dc1f901421c |
SaAdaIN | import torch
import torch.nn as nn
import torch.optim
import torch.utils.data
def calc_mean_std(feat, eps=1e-05):
size = feat.size()
assert len(size) == 4
N, C = size[:2]
feat_var = feat.view(N, C, -1).var(dim=2) + eps
feat_std = feat_var.sqrt().view(N, C, 1, 1)
feat_mean = feat.view(N, C, -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 libdevice
import torch.nn as nn
import torch.optim
import torch.utils.data
assert_size_st... | VITA-Group/Sandwich-Batch-Normalization | SaAdaIN | false | 14,541 | [
"MIT"
] | 46 | 25e7df6e64a67cebd7e70b911f874cfc1bd19df0 | https://github.com/VITA-Group/Sandwich-Batch-Normalization/tree/25e7df6e64a67cebd7e70b911f874cfc1bd19df0 |
DenoisingNet | import torch
import torch.nn as nn
class DenoisingNet(nn.Module):
def __init__(self, input_vec_size):
super(DenoisingNet, self).__init__()
self.linear_layer = nn.Linear(input_vec_size, 1)
self.elu_layer = nn.ELU()
self.propensity_net = nn.Sequential(self.linear_layer, self.elu_lay... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 ... | ULTR-Community/ULTRA_Pytorch | DenoisingNet | false | 14,542 | [
"Apache-2.0"
] | 46 | ec4fe329e4239b588a940cb4bcdd6a321aade679 | https://github.com/ULTR-Community/ULTRA_Pytorch/tree/ec4fe329e4239b588a940cb4bcdd6a321aade679 |
AdaptiveConcatPool2d | import torch
import torch.nn as nn
class AdaptiveConcatPool2d(nn.Module):
"""
Pools with AdaptiveMaxPool2d AND AdaptiveAvgPool2d and concatenates both
results.
Args:
target_size: the target output size (single integer or
double-integer tuple)
"""
def __init__(self, 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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | Vermeille/Torchelie | AdaptiveConcatPool2d | false | 14,543 | [
"MIT"
] | 117 | 43957d83238372ae6436aac90127865c2040b76c | https://github.com/Vermeille/Torchelie/tree/43957d83238372ae6436aac90127865c2040b76c |
MLP_CIFAR10 | import torch
import torch.nn as nn
import torch.nn.functional as F
class MLP_CIFAR10(nn.Module):
def __init__(self, save_features=None, bench_model=False):
super(MLP_CIFAR10, self).__init__()
self.fc1 = nn.Linear(3 * 32 * 32, 1024)
self.fc2 = nn.Linear(1024, 512)
self.fc3 = nn.Lin... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | VITA-Group/SViTE | MLP_CIFAR10 | false | 14,544 | [
"MIT"
] | 50 | b0c62fd153c8b0b99917ab935ee76925c9de1149 | https://github.com/VITA-Group/SViTE/tree/b0c62fd153c8b0b99917ab935ee76925c9de1149 |
OrthoLoss | import torch
import torch.nn as nn
def ortho(w: 'torch.Tensor') ->torch.Tensor:
"""
Returns the orthogonal loss for weight matrix `m`, from Big GAN.
https://arxiv.org/abs/1809.11096
:math:`R_{\\beta}(W)= ||W^T W \\odot (1 - I)||_F^2`
"""
cosine = torch.einsum('ij,ji->ij', w, w)
no_diag ... | 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... | Vermeille/Torchelie | OrthoLoss | false | 14,545 | [
"MIT"
] | 117 | 43957d83238372ae6436aac90127865c2040b76c | https://github.com/Vermeille/Torchelie/tree/43957d83238372ae6436aac90127865c2040b76c |
Model | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self, n_input_features):
super(Model, self).__init__()
self.linear = nn.Linear(n_input_features, 1)
def forward(self, x):
y_pred = torch.sigmoid(self.linear(x))
return y_pred
def get_inputs():
retur... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | ValerioMessina/Logistic-Regression | Model | false | 14,546 | [
"MIT"
] | 832 | 7cd3223b5ddfc228f9eae1adabaa5de5fa8f26e9 | https://github.com/ValerioMessina/Logistic-Regression/tree/7cd3223b5ddfc228f9eae1adabaa5de5fa8f26e9 |
RoundSTE | import torch
from torch import nn
class RoundSTE(nn.Module):
def __init__(self):
"""
This module perform element-wise rounding with straight through estimator (STE).
"""
super(RoundSTE, self).__init__()
def forward(self, x):
"""
The forward function of the rou... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | UniSerj/ai-research | RoundSTE | false | 14,547 | [
"Apache-2.0"
] | 46 | 79f0093c93408cc5dd7d3f56aafd7dc1f901421c | https://github.com/UniSerj/ai-research/tree/79f0093c93408cc5dd7d3f56aafd7dc1f901421c |
HardSigmoid | import torch
import torch.nn as nn
class HardSigmoid(nn.Module):
"""
Hard Sigmoid
"""
def forward(self, x: 'torch.Tensor') ->torch.Tensor:
return x.add_(0.5).clamp_(min=0, max=1)
def get_inputs():
return [torch.rand([4, 4, 4, 4])]
def get_init_inputs():
return [[], {}]
| import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
@... | Vermeille/Torchelie | HardSigmoid | false | 14,548 | [
"MIT"
] | 117 | 43957d83238372ae6436aac90127865c2040b76c | https://github.com/Vermeille/Torchelie/tree/43957d83238372ae6436aac90127865c2040b76c |
StyledConv | from torch.autograd import Function
import math
import torch
from torch import nn
import torch.nn.functional as F
def make_kernel(k):
k = torch.tensor(k, dtype=torch.float32)
if k.ndim == 1:
k = k[None, :] * k[:, None]
k /= k.sum()
return k
def upfirdn2d(input, kernel, up=1, down=1, pad=(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.triton_helpers import libdevice
from torch.autograd... | Ugness/CIPS_SR | StyledConv | false | 14,549 | [
"MIT"
] | 172 | abce872f5bc1b84afb9634a7dd1991e8c74d7616 | https://github.com/Ugness/CIPS_SR/tree/abce872f5bc1b84afb9634a7dd1991e8c74d7616 |
FocalLoss | import torch
import torch.nn as nn
from typing import Optional
def focal_loss(input: 'torch.Tensor', target: 'torch.Tensor', gamma:
'float'=0, weight: 'Optional[torch.Tensor]'=None) ->torch.Tensor:
"""
Returns the focal loss between `target` and `input`
:math:`\\text{FL}(p_t)=-(1-p_t)^\\gamma\\log(p_... | 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
... | Vermeille/Torchelie | FocalLoss | false | 14,550 | [
"MIT"
] | 117 | 43957d83238372ae6436aac90127865c2040b76c | https://github.com/Vermeille/Torchelie/tree/43957d83238372ae6436aac90127865c2040b76c |
HardSwish | import torch
import torch.nn as nn
class HardSwish(nn.Module):
"""
Hard Swish
"""
def forward(self, x: 'torch.Tensor') ->torch.Tensor:
return x.add(0.5).clamp_(min=0, max=1).mul_(x)
def get_inputs():
return [torch.rand([4, 4, 4, 4])]
def get_init_inputs():
return [[], {}]
| import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
emp... | Vermeille/Torchelie | HardSwish | false | 14,551 | [
"MIT"
] | 117 | 43957d83238372ae6436aac90127865c2040b76c | https://github.com/Vermeille/Torchelie/tree/43957d83238372ae6436aac90127865c2040b76c |
PixelNorm | import torch
class PixelNorm(torch.nn.Module):
"""
PixelNorm from ProgressiveGAN
"""
def forward(self, x):
return x / (x.mean(dim=1, keepdim=True).sqrt() + 1e-08)
def get_inputs():
return [torch.rand([4, 4, 4, 4])]
def get_init_inputs():
return [[], {}]
| import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_c... | Vermeille/Torchelie | PixelNorm | false | 14,552 | [
"MIT"
] | 117 | 43957d83238372ae6436aac90127865c2040b76c | https://github.com/Vermeille/Torchelie/tree/43957d83238372ae6436aac90127865c2040b76c |
LeNet_300_100 | import torch
import torch.nn as nn
import torch.nn.functional as F
class LeNet_300_100(nn.Module):
"""Simple NN with hidden layers [300, 100]
Based on https://github.com/mi-lad/snip/blob/master/train.py
by Milad Alizadeh.
"""
def __init__(self, save_features=None, bench_model=False):
sup... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | VITA-Group/SViTE | LeNet_300_100 | false | 14,553 | [
"MIT"
] | 50 | b0c62fd153c8b0b99917ab935ee76925c9de1149 | https://github.com/VITA-Group/SViTE/tree/b0c62fd153c8b0b99917ab935ee76925c9de1149 |
RobertaClassificationHead | from _paritybench_helpers import _mock_config
import torch
import torch.nn as nn
class RobertaClassificationHead(nn.Module):
"""Head for sentence-level classification tasks."""
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size * 2, config.hidden_size)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as ... | AlexShypula/CodeGen | RobertaClassificationHead | false | 14,554 | [
"MIT"
] | 241 | 2e5f8090c4369fd3f0ebec4a867503edc1362d5d | https://github.com/AlexShypula/CodeGen/tree/2e5f8090c4369fd3f0ebec4a867503edc1362d5d |
MinibatchStddev | import torch
import torch.nn as nn
class MinibatchStddev(nn.Module):
"""Minibatch Stddev layer from Progressive GAN"""
def forward(self, x: 'torch.Tensor') ->torch.Tensor:
stddev_map = torch.sqrt(x.var(dim=0) + 1e-08).mean()
stddev = stddev_map.expand(x.shape[0], 1, *x.shape[2:])
retu... | 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_... | Vermeille/Torchelie | MinibatchStddev | false | 14,555 | [
"MIT"
] | 117 | 43957d83238372ae6436aac90127865c2040b76c | https://github.com/Vermeille/Torchelie/tree/43957d83238372ae6436aac90127865c2040b76c |
Copy | import torch
import torch.nn as nn
class Copy(nn.Module):
def __init__(self, hidden_size, copy_weight=1.0):
super().__init__()
self.Wcopy = nn.Linear(hidden_size, hidden_size)
self.copy_weight = copy_weight
def forward(self, enc_out_hs, dec_hs):
"""
get unnormalized 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.triton_helpers import libdevice
import torch.nn as ... | Verylovenlp/MinTL-SKKU | Copy | false | 14,556 | [
"MIT"
] | 60 | 15b5cb870c7d6dcd0f5d895aac2806539cc5101f | https://github.com/Verylovenlp/MinTL-SKKU/tree/15b5cb870c7d6dcd0f5d895aac2806539cc5101f |
ChannelPool | import torch
from torch import nn
class ChannelPool(nn.Module):
def forward(self, x):
return torch.mean(x, 1).unsqueeze(1)
def get_inputs():
return [torch.rand([4, 4, 4, 4])]
def get_init_inputs():
return [[], {}]
| import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_str... | VictorSuciu/ICCV2019_MirrorNet | ChannelPool | false | 14,557 | [
"BSD-3-Clause"
] | 48 | e7ce3c269feaf33a0b156091beebbaebdabf6155 | https://github.com/VictorSuciu/ICCV2019_MirrorNet/tree/e7ce3c269feaf33a0b156091beebbaebdabf6155 |
FFN | import torch
import torch.utils.data
import torchvision.transforms.functional as F
import torch.nn as nn
import torch.nn.functional as F
class FFN(nn.Module):
def __init__(self, d_model, d_ffn, dropout=0):
super().__init__()
self.linear1 = nn.Linear(d_model, d_ffn)
self.activation = F.rel... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | Tarandro/MOTR | FFN | false | 14,558 | [
"MIT"
] | 191 | f2bcc2df0b3bd959208e78c54a3e9d8a3434f9f4 | https://github.com/Tarandro/MOTR/tree/f2bcc2df0b3bd959208e78c54a3e9d8a3434f9f4 |
MaskUpdate | import torch
import torch.nn as 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):
""" self.alpha.data = torch.clamp(self.alpha.data, 0.6, 0.8)
... | 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... | Vious/LBAM_Pytorch | MaskUpdate | false | 14,559 | [
"MIT"
] | 112 | b9292440e7a7559c027f48d6fd061dcabc41a6bf | https://github.com/Vious/LBAM_Pytorch/tree/b9292440e7a7559c027f48d6fd061dcabc41a6bf |
PONO | import torch
import torch.nn as nn
def pono(x, epsilon=1e-05):
"""Positional normalization"""
mean = x.mean(dim=1, keepdim=True)
std = x.var(dim=1, keepdim=True).add(epsilon).sqrt()
output = (x - mean) / std
return output, mean, std
class PONO(nn.Module):
def forward(self, x, mask=None):
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_... | Warvito/lmconv | PONO | false | 14,560 | [
"MIT"
] | 69 | 01adba51e3fff1e7da99324dc64a9fc9cd38621e | https://github.com/Warvito/lmconv/tree/01adba51e3fff1e7da99324dc64a9fc9cd38621e |
CORblock_Z | import torch
import torch.nn as nn
import torch.utils.model_zoo
class Identity(nn.Module):
"""
Helper module that stores the current tensor. Useful for accessing by name
"""
def forward(self, x):
return x
class CORblock_Z(nn.Module):
def __init__(self, in_channels, out_channels, kernel... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
import ... | ViCCo-Group/THINGSvision | CORblock_Z | false | 14,561 | [
"MIT"
] | 45 | 27273564631605639287f9b3bd3c57ba8cdb720f | https://github.com/ViCCo-Group/THINGSvision/tree/27273564631605639287f9b3bd3c57ba8cdb720f |
Block | import torch
import torch.nn as nn
import torch.utils.data
class Mlp(nn.Module):
def __init__(self, in_features, hidden_features=None, out_features=None,
act_layer=nn.GELU, drop=0.0):
super().__init__()
out_features = out_features or in_features
hidden_features = hidden_features o... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | Vegetebird/MHFormer | Block | false | 14,562 | [
"MIT"
] | 83 | 68d793414e13c256249431a45ac49949930c8e7f | https://github.com/Vegetebird/MHFormer/tree/68d793414e13c256249431a45ac49949930c8e7f |
SymLinear | import math
import torch
import torch.utils.data
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.parameter import Parameter
import torch.nn.init as init
class SymLinear(nn.Module):
"""Linear with symmetric weight matrices"""
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
import math
import torch.utils.data
import torch.nn as nn
from torch.nn.paramete... | Waasem/graph2nn | SymLinear | false | 14,563 | [
"MIT"
] | 133 | b112eb6c6805a1813e433442b0b1f5cabb4ad1a2 | https://github.com/Waasem/graph2nn/tree/b112eb6c6805a1813e433442b0b1f5cabb4ad1a2 |
PositionwiseFeedForward | import torch
import torch.nn as nn
import torch.nn.functional as F
class PositionwiseFeedForward(nn.Module):
"""Implements FFN equation."""
def __init__(self, d_model, d_ff, dropout=0.1):
super(PositionwiseFeedForward, self).__init__()
self.w_1 = nn.Linear(d_model, d_ff)
self.w_2 = 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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | WangYueFt/prnet | PositionwiseFeedForward | false | 14,564 | [
"MIT"
] | 105 | ffceaf1a891286f5ac8a452fca737dd3c44202fd | https://github.com/WangYueFt/prnet/tree/ffceaf1a891286f5ac8a452fca737dd3c44202fd |
BilinearUpsample | import torch
from typing import Union
from typing import List
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
class BilinearUpsample(nn.Module):
"""
Overview:
Upsamples the input to the given member varible scale_factor using mode biliner
Interface:
forward
... | 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 typing import Union
from typing import List
import torch.nn as nn
import torch.utils... | Weiyuhong-1998/DI-engine | BilinearUpsample | false | 14,565 | [
"Apache-2.0"
] | 464 | 88658ea358298c6e61e95a454284b8853a3e9484 | https://github.com/Weiyuhong-1998/DI-engine/tree/88658ea358298c6e61e95a454284b8853a3e9484 |
Attn | import torch
import torch.nn as nn
import torch.nn.functional as F
class Attn(nn.Module):
def __init__(self, hidden_size):
super().__init__()
self.hidden_size = hidden_size
self.attn = nn.Linear(self.hidden_size * 2, hidden_size)
self.v = nn.Linear(hidden_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._inductor.runtime.... | Verylovenlp/MinTL-SKKU | Attn | false | 14,566 | [
"MIT"
] | 60 | 15b5cb870c7d6dcd0f5d895aac2806539cc5101f | https://github.com/Verylovenlp/MinTL-SKKU/tree/15b5cb870c7d6dcd0f5d895aac2806539cc5101f |
FRN | import torch
from torch import nn
class FRN(nn.Module):
def __init__(self, num_features, eps=1e-06):
super(FRN, self).__init__()
self.eps = eps
self.gamma = nn.Parameter(torch.ones(1, num_features, 1, 1))
self.beta = nn.Parameter(torch.zeros(1, num_features, 1, 1))
self.t ... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
from torch import nn
assert_... | WangGodder/deep-cross-modal-hashing | FRN | false | 14,567 | [
"MIT"
] | 65 | 9784397c1076c81b43ebd856cb24b8a67cf8f41e | https://github.com/WangGodder/deep-cross-modal-hashing/tree/9784397c1076c81b43ebd856cb24b8a67cf8f41e |
RobertaClassificationHead | from _paritybench_helpers import _mock_config
import torch
import torch.nn as nn
class RobertaClassificationHead(nn.Module):
"""Head for sentence-level classification tasks."""
def __init__(self, config):
super(RobertaClassificationHead, self).__init__()
self.dense = nn.Linear(config.hidden_s... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as ... | AkariAsai/logic_guided_qa | RobertaClassificationHead | false | 14,568 | [
"MIT"
] | 69 | 96ae70f01b7267ef0b472b8497c903035d052fd9 | https://github.com/AkariAsai/logic_guided_qa/tree/96ae70f01b7267ef0b472b8497c903035d052fd9 |
LabelSmoothCELoss | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
def one_hot(val: 'torch.LongTensor', num: 'int', num_first: 'bool'=False
) ->torch.FloatTensor:
"""
Overview:
Convert a ``torch.LongTensor`` to one hot encoding.
This implementation can be slightly f... | 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
... | Weiyuhong-1998/DI-engine | LabelSmoothCELoss | false | 14,569 | [
"Apache-2.0"
] | 464 | 88658ea358298c6e61e95a454284b8853a3e9484 | https://github.com/Weiyuhong-1998/DI-engine/tree/88658ea358298c6e61e95a454284b8853a3e9484 |
nin | import torch
import torch.nn as nn
from torch.nn.utils import weight_norm as wn
class nin(nn.Module):
def __init__(self, dim_in, dim_out, weight_norm=True):
super(nin, self).__init__()
if weight_norm:
self.lin_a = wn(nn.Linear(dim_in, dim_out))
else:
self.lin_a = 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 ... | Warvito/lmconv | nin | false | 14,570 | [
"MIT"
] | 69 | 01adba51e3fff1e7da99324dc64a9fc9cd38621e | https://github.com/Warvito/lmconv/tree/01adba51e3fff1e7da99324dc64a9fc9cd38621e |
Encoder | import torch
import torch.nn as nn
import torch.utils.data
class Conv(nn.Module):
def __init__(self, filters0, filters1, kernel_size, bn, bias=True):
super().__init__()
if bn:
bias = False
self.conv = nn.Conv2d(filters0, filters1, kernel_size, stride=1,
padding=ker... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
import torch.utils.data
assert_size_stride = torch._C._dyn... | Weiyuhong-1998/DI-engine | Encoder | false | 14,571 | [
"Apache-2.0"
] | 464 | 88658ea358298c6e61e95a454284b8853a3e9484 | https://github.com/Weiyuhong-1998/DI-engine/tree/88658ea358298c6e61e95a454284b8853a3e9484 |
GaussActivation | import torch
import torch.nn as 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, dt... | 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
... | Vious/LBAM_Pytorch | GaussActivation | false | 14,572 | [
"MIT"
] | 112 | b9292440e7a7559c027f48d6fd061dcabc41a6bf | https://github.com/Vious/LBAM_Pytorch/tree/b9292440e7a7559c027f48d6fd061dcabc41a6bf |
ResidualBlock | import torch
import torch.nn as nn
import torch.utils.data
class ResidualBlock(nn.Module):
def __init__(self, in_channels, out_channels, activation='relu'):
super().__init__()
self.in_channels, self.out_channels, self.activation = (in_channels,
out_channels, activation)
self.b... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
import torch.utils.data
assert_size_stride = torch._C._dynamo.guard... | Weiyuhong-1998/DI-engine | ResidualBlock | false | 14,573 | [
"Apache-2.0"
] | 464 | 88658ea358298c6e61e95a454284b8853a3e9484 | https://github.com/Weiyuhong-1998/DI-engine/tree/88658ea358298c6e61e95a454284b8853a3e9484 |
EnsembleFC | import torch
import torch.nn as nn
import torch.utils.data
class EnsembleFC(nn.Module):
__constants__ = ['in_features', 'out_features']
in_features: 'int'
out_features: 'int'
ensemble_size: 'int'
weight: 'torch.Tensor'
def __init__(self, in_features: 'int', out_features: 'int',
ensemb... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
import torch.utils.data
assert_size_stride = torch._C._dyn... | Weiyuhong-1998/DI-engine | EnsembleFC | false | 14,574 | [
"Apache-2.0"
] | 464 | 88658ea358298c6e61e95a454284b8853a3e9484 | https://github.com/Weiyuhong-1998/DI-engine/tree/88658ea358298c6e61e95a454284b8853a3e9484 |
GLU | import torch
import torch.nn as nn
import torch.utils.data
class GLU(nn.Module):
"""
Overview:
Gating Linear Unit.
This class does a thing like this:
.. code:: python
# Inputs: input, context, output_size
# The gate value is a learnt function of the input.
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
import torch.utils.data
assert_size_stride = torch._C._dyn... | Weiyuhong-1998/DI-engine | GLU | false | 14,575 | [
"Apache-2.0"
] | 464 | 88658ea358298c6e61e95a454284b8853a3e9484 | https://github.com/Weiyuhong-1998/DI-engine/tree/88658ea358298c6e61e95a454284b8853a3e9484 |
HardSigmoid | import torch
from torch import nn
from torch.nn import functional as F
class HardSigmoid(nn.Module):
def __init__(self, slope=0.2, offset=0.5):
super().__init__()
self.slope = slope
self.offset = offset
def forward(self, x):
x = self.slope * x + self.offset
x = F.thre... | 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... | WenmuZhou/crnn.pytorch | HardSigmoid | false | 14,576 | [
"Apache-2.0"
] | 46 | bf7a7c62376eee93943ca7c68e88e3d563c09aa8 | https://github.com/WenmuZhou/crnn.pytorch/tree/bf7a7c62376eee93943ca7c68e88e3d563c09aa8 |
Head | import torch
import torch.nn as nn
import torch.utils.data
class Conv(nn.Module):
def __init__(self, filters0, filters1, kernel_size, bn, bias=True):
super().__init__()
if bn:
bias = False
self.conv = nn.Conv2d(filters0, filters1, kernel_size, stride=1,
padding=ker... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
import torch.utils.data
assert_size_stride = torch._C._dyn... | Weiyuhong-1998/DI-engine | Head | false | 14,577 | [
"Apache-2.0"
] | 464 | 88658ea358298c6e61e95a454284b8853a3e9484 | https://github.com/Weiyuhong-1998/DI-engine/tree/88658ea358298c6e61e95a454284b8853a3e9484 |
RewardModelNetwork | import torch
import torch.nn as nn
import torch.utils.data
class RewardModelNetwork(nn.Module):
def __init__(self, input_size: 'int', hidden_size: 'int', output_size:
'int') ->None:
super(RewardModelNetwork, self).__init__()
self.l1 = nn.Linear(input_size, hidden_size)
self.l2 = 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 ... | Weiyuhong-1998/DI-engine | RewardModelNetwork | false | 14,578 | [
"Apache-2.0"
] | 464 | 88658ea358298c6e61e95a454284b8853a3e9484 | https://github.com/Weiyuhong-1998/DI-engine/tree/88658ea358298c6e61e95a454284b8853a3e9484 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.