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 |
|---|---|---|---|---|---|---|---|---|---|---|
Baseline | import torch
import torch.nn as nn
class Baseline(nn.Module):
"""Baseline
"""
def __init__(self, hid_dim, x_dim, binary_dim, inp_dim):
super(Baseline, self).__init__()
self.x_dim = x_dim
self.binary_dim = binary_dim
self.inp_dim = inp_dim
self.hid_dim = hid_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_... | nyu-dl/MultimodalGame | Baseline | false | 16,199 | [
"BSD-3-Clause"
] | 54 | 0782a7bf3cf5125cd7c35a243e97f0e9e016fca3 | https://github.com/nyu-dl/MultimodalGame/tree/0782a7bf3cf5125cd7c35a243e97f0e9e016fca3 |
TVLoss | import torch
from torch import nn
from torch.nn import functional as F
class TVLoss(nn.Module):
"""L2 total variation loss, as in Mahendran et al."""
def forward(self, input):
input = F.pad(input, (0, 1, 0, 1), 'replicate')
x_diff = input[..., :-1, 1:] - input[..., :-1, :-1]
y_diff = ... | 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... | olaviinha/style-transfer-pytorch | TVLoss | false | 16,200 | [
"MIT"
] | 290 | 9bdb2d932a31b6cf0ac7b651dc38b740c3e37fe8 | https://github.com/olaviinha/style-transfer-pytorch/tree/9bdb2d932a31b6cf0ac7b651dc38b740c3e37fe8 |
Conv3dMaxPool | import torch
from torch import nn
class Conv3dMaxPool(nn.Module):
def __init__(self, out_channels: 'int', in_channels: 'int'):
super().__init__()
self.sat_conv3d = nn.Conv3d(in_channels=in_channels, out_channels=
out_channels, kernel_size=(3, 3, 3), padding=(1, 1, 1))
self.sat... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import 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... | openclimatefix/predict_pv_yield | Conv3dMaxPool | false | 16,201 | [
"MIT"
] | 47 | 83f27bd392190f1771221e92bfebb879bf562f5d | https://github.com/openclimatefix/predict_pv_yield/tree/83f27bd392190f1771221e92bfebb879bf562f5d |
Conv2d | import torch
import torch.utils.data
import torch.nn as nn
class Conv2d(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride=1,
relu=True, same_padding=False):
super(Conv2d, self).__init__()
padding = int((kernel_size - 1) / 2) if same_padding else 0
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
import torch.utils.data
import torch.nn as nn
assert_size_stride = torch._C._dyn... | ojasjoshi/Selective_Deblur_GANs | Conv2d | false | 16,202 | [
"MIT"
] | 1,663 | 9ac256b41b62c50c8b967f7e6fa7ecb4c7305889 | https://github.com/ojasjoshi/Selective_Deblur_GANs/tree/9ac256b41b62c50c8b967f7e6fa7ecb4c7305889 |
PartitionLoss | import torch
import torch.nn as nn
class PartitionLoss(nn.Module):
def __init__(self):
super(PartitionLoss, self).__init__()
def forward(self, x):
num_head = x.size(1)
if num_head > 1:
var = x.var(dim=1).mean()
loss = torch.log(1 + num_head / var)
else... | 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... | orena1/DAN | PartitionLoss | false | 16,203 | [
"MIT"
] | 50 | 49247ad0cad2a67057d184fa92d15fe2e7bb2cb6 | https://github.com/orena1/DAN/tree/49247ad0cad2a67057d184fa92d15fe2e7bb2cb6 |
ActivationLoss | import torch
import torch.utils.data
from torch import nn
class ActivationLoss(nn.Module):
def __init__(self):
super(ActivationLoss, self).__init__()
def forward(self, zero, one, labels):
loss_act = torch.abs(one - labels.data) + torch.abs(zero - (1.0 -
labels.data))
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 import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.utils.dat... | nviable/ClassNSeg | ActivationLoss | false | 16,204 | [
"BSD-3-Clause"
] | 68 | 87e506fddb9f36ef14f9bd1f6496f86d7faef0fd | https://github.com/nviable/ClassNSeg/tree/87e506fddb9f36ef14f9bd1f6496f86d7faef0fd |
IPDFeature | import math
import torch
import torch as th
import torch.nn as nn
class IPDFeature(nn.Module):
"""
Compute inter-channel phase difference
"""
def __init__(self, ipd_index='1,0;2,0;3,0;4,0;5,0;6,0', cos=True, sin=False
):
super(IPDFeature, self).__init__()
def split_index(sstr... | 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... | oucxlw/ConferencingSpeech2021 | IPDFeature | false | 16,205 | [
"Apache-2.0"
] | 98 | 617df8116c0510b2addadb1de374d7b50eea4f2b | https://github.com/oucxlw/ConferencingSpeech2021/tree/617df8116c0510b2addadb1de374d7b50eea4f2b |
MDNLayer | import torch
from torch import nn
from torch.nn import functional as F
class MDNLayer(nn.Module):
""" Mixture Density Network layer
The input maps to the parameters of a Mixture of Gaussians (MoG) probability
distribution, where each Gaussian has out_dim dimensions and diagonal covariance.
If dim_wis... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | oatsu-gh/nnsvs | MDNLayer | false | 16,206 | [
"MIT"
] | 298 | 510f37bc1d1f15282646e4d34435b5d63686cf40 | https://github.com/oatsu-gh/nnsvs/tree/510f37bc1d1f15282646e4d34435b5d63686cf40 |
L1Norm | 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.init
class L1Norm(nn.Module):
def __init__(self):
super(L1Norm, self).__init__()
self.eps = 1e-10
def forward(self, x):
norm = 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.triton_helpers import math as tl_math
import torch.nn as nn
import torch.nn.parallel
import torch.optim
import ... | oskyhn/CNNs-Without-Borders | L1Norm | false | 16,207 | [
"BSD-3-Clause"
] | 74 | 4fae1d8fd64c3c917f5c78c3513a60572af961b1 | https://github.com/oskyhn/CNNs-Without-Borders/tree/4fae1d8fd64c3c917f5c78c3513a60572af961b1 |
TimeIntervalTransformerLayer | import torch
import numpy as np
import torch.nn as nn
import torch.distributions
class TimeIntervalMultiHeadAttention(nn.Module):
def __init__(self, d_model, n_heads, kq_same=False, bias=True):
super().__init__()
"""
It also needs position and interaction (time interval) key/value 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
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | nmrenyi/ReChorus | TimeIntervalTransformerLayer | false | 16,208 | [
"MIT"
] | 314 | 9ab632579d0464b0aaf365539f87b04866920b66 | https://github.com/nmrenyi/ReChorus/tree/9ab632579d0464b0aaf365539f87b04866920b66 |
SpatialSoftmax | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.parameter import Parameter
class SpatialSoftmax(nn.Module):
def __init__(self, temperature=1, device='cpu'):
super(SpatialSoftmax, self).__init__()
if temperature:
self.temperature = Parameter(torch.ones(... | 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
... | ozcell/ENet-SAD_Pytorch | SpatialSoftmax | false | 16,209 | [
"MIT"
] | 53 | aaa79b5e96316e1bf24d3c2147ee622d4f17bc24 | https://github.com/ozcell/ENet-SAD_Pytorch/tree/aaa79b5e96316e1bf24d3c2147ee622d4f17bc24 |
GoodDiscriminator | import torch
from torch import nn
class MyConvo2d(nn.Module):
def __init__(self, input_dim, output_dim, kernel_size, he_init=True,
stride=1, bias=True):
super(MyConvo2d, self).__init__()
self.he_init = he_init
self.padding = int((kernel_size - 1) / 2)
self.conv = nn.Conv2d... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | justaboutlola/improved-wgan-pytorch | GoodDiscriminator | false | 16,210 | [
"MIT"
] | 412 | 5bb0b729809152d9129ef72a9dd28b3ff83021a2 | https://github.com/justaboutlola/improved-wgan-pytorch/tree/5bb0b729809152d9129ef72a9dd28b3ff83021a2 |
DQNLoss | import torch
import numpy as np
import torch.nn.functional as F
from torch.nn.modules.loss import _Loss
class DQNLoss(_Loss):
def __init__(self, mode='huber', size_average=None, reduce=None,
reduction='mean'):
super().__init__(size_average, reduce, reduction)
self.mode = mode
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
import torch.nn.functional as F
from torch.nn.modules.loss import _Loss
a... | opium-sh/prl | DQNLoss | false | 16,211 | [
"MIT"
] | 51 | 3e21f8c7c87cfc7aee84d9e264c3a8b2bc549076 | https://github.com/opium-sh/prl/tree/3e21f8c7c87cfc7aee84d9e264c3a8b2bc549076 |
PositionwiseFeedForwardNet | import torch
import torch.nn as nn
class PositionwiseFeedForwardNet(nn.Module):
"""
It's position-wise because this feed forward net will be independently applied to every token's representation.
Representations batch is of the shape (batch size, max token sequence length, model dimension).
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | ozzieba/pytorch-original-transformer | PositionwiseFeedForwardNet | false | 16,212 | [
"MIT"
] | 654 | 4c1e17a701fae050e362e962284fb99547636f75 | https://github.com/ozzieba/pytorch-original-transformer/tree/4c1e17a701fae050e362e962284fb99547636f75 |
BertAttention | from _paritybench_helpers import _mock_config
import math
import torch
import torch.nn as nn
class BertLayerNorm(nn.Module):
def __init__(self, config, variance_epsilon=1e-12):
"""Construct a layernorm module in the TF style (epsilon inside the square root).
"""
super(BertLayerNorm, 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.... | GingerNg/SDNet | BertAttention | false | 16,213 | [
"MIT"
] | 112 | 48ad8cc57c9a02aaad10e34d0c91a174ac68f056 | https://github.com/GingerNg/SDNet/tree/48ad8cc57c9a02aaad10e34d0c91a174ac68f056 |
PolicyGradientLoss | import torch
import torch.nn.functional as F
from torch.nn.modules.loss import _Loss
class PolicyGradientLoss(_Loss):
def __init__(self, size_average=None, reduce=None, reduction='mean'):
super().__init__(size_average, reduce, reduction)
def forward(self, nn_outputs, actions, returns):
outpu... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
from torch.nn.modules.... | opium-sh/prl | PolicyGradientLoss | false | 16,214 | [
"MIT"
] | 51 | 3e21f8c7c87cfc7aee84d9e264c3a8b2bc549076 | https://github.com/opium-sh/prl/tree/3e21f8c7c87cfc7aee84d9e264c3a8b2bc549076 |
CorrelationPenaltyLoss | 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.init
class CorrelationPenaltyLoss(nn.Module):
def __init__(self):
super(CorrelationPenaltyLoss, self).__init__()
def forward(self, 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
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as ... | oskyhn/CNNs-Without-Borders | CorrelationPenaltyLoss | false | 16,215 | [
"BSD-3-Clause"
] | 74 | 4fae1d8fd64c3c917f5c78c3513a60572af961b1 | https://github.com/oskyhn/CNNs-Without-Borders/tree/4fae1d8fd64c3c917f5c78c3513a60572af961b1 |
mIoULoss | import torch
import torch.nn as nn
import torch.nn.functional as F
class mIoULoss(nn.Module):
def __init__(self, weight=None, size_average=True, n_classes=4):
super(mIoULoss, self).__init__()
self.classes = n_classes
def forward(self, inputs, target_oneHot):
"""
IoU Loss for ... | 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
... | ozcell/ENet-SAD_Pytorch | mIoULoss | false | 16,216 | [
"MIT"
] | 53 | aaa79b5e96316e1bf24d3c2147ee622d4f17bc24 | https://github.com/ozcell/ENet-SAD_Pytorch/tree/aaa79b5e96316e1bf24d3c2147ee622d4f17bc24 |
TransformerLayer | import torch
import numpy as np
import torch.nn as nn
import torch.distributions
class MultiHeadAttention(nn.Module):
def __init__(self, d_model, n_heads, kq_same=False, bias=True):
super().__init__()
"""
It has projection layer for getting keys, queries and values. Followed by attention.... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | nmrenyi/ReChorus | TransformerLayer | false | 16,217 | [
"MIT"
] | 314 | 9ab632579d0464b0aaf365539f87b04866920b66 | https://github.com/nmrenyi/ReChorus/tree/9ab632579d0464b0aaf365539f87b04866920b66 |
PositionEmbeddingLayer | import torch
import torch.nn as nn
import torch.utils.data
from typing import Dict
from typing import Tuple
from abc import ABC
from abc import abstractmethod
class BaseLayer(nn.Module, ABC):
"""
Base Layer for the torecsys module
"""
def __init__(self, **kwargs):
"""
Initializer for ... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
import torch.utils.data
from typing import Dict
from typing import Tuple
from abc import ABC
from abc import abstractm... | p768lwy3/torecsys | PositionEmbeddingLayer | false | 16,218 | [
"MIT"
] | 92 | 2251366268b4fbe6f8c3ab1628fa72a0db043dcd | https://github.com/p768lwy3/torecsys/tree/2251366268b4fbe6f8c3ab1628fa72a0db043dcd |
UniformBatchMiner | import torch
import torch.nn as nn
import torch.utils.data
from typing import Any
from typing import Dict
from typing import List
from typing import Tuple
from abc import ABC
from abc import abstractmethod
class BaseMiner(nn.Module, ABC):
def __init__(self, *args: List[Any], **kwargs: Dict[str, Any]):
su... | 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
import torch.nn as nn
import torch.utils.data
from typing import Any
from typing import Dict
from typing import Lis... | p768lwy3/torecsys | UniformBatchMiner | false | 16,219 | [
"MIT"
] | 92 | 2251366268b4fbe6f8c3ab1628fa72a0db043dcd | https://github.com/p768lwy3/torecsys/tree/2251366268b4fbe6f8c3ab1628fa72a0db043dcd |
ModulatedConv2d | import math
import torch
from torch import nn
from torch.nn import functional as F
def fused_leaky_relu(input, bias, negative_slope=0.2, scale=2 ** 0.5):
rest_dim = [1] * (input.ndim - bias.ndim - 1)
input = input
if input.ndim == 3:
return F.leaky_relu(input + bias.view(1, *rest_dim, bias.shape[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 math
from to... | ozmig77/StyleCLIP-1 | ModulatedConv2d | false | 16,220 | [
"MIT"
] | 2,732 | 57b887bba971ef86c107f4805785ce44fca3efef | https://github.com/ozmig77/StyleCLIP-1/tree/57b887bba971ef86c107f4805785ce44fca3efef |
Policy | import torch
import torch.nn as nn
import torch.nn.functional as F
class Policy(nn.Module):
def __init__(self):
super(Policy, self).__init__()
self.affine1 = nn.Linear(4, 128)
self.action_head = nn.Linear(128, 2)
self.value_head = nn.Linear(128, 1)
self.saved_actions = []
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | nosyndicate/PyTorchRL | Policy | false | 16,221 | [
"MIT"
] | 48 | c4fb69ffebaa7f56b4210388f9eea7d42ca853e4 | https://github.com/nosyndicate/PyTorchRL/tree/c4fb69ffebaa7f56b4210388f9eea7d42ca853e4 |
FieldEachTypeBilinear | import math
import torch
import torch.nn as nn
import torch.utils.data
from typing import Dict
from typing import Tuple
from abc import ABC
from abc import abstractmethod
class BaseLayer(nn.Module, ABC):
"""
Base Layer for the torecsys module
"""
def __init__(self, **kwargs):
"""
Init... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import math
import torch.nn as nn
import torch.utils.data
from typing import Dic... | p768lwy3/torecsys | FieldEachTypeBilinear | false | 16,222 | [
"MIT"
] | 92 | 2251366268b4fbe6f8c3ab1628fa72a0db043dcd | https://github.com/p768lwy3/torecsys/tree/2251366268b4fbe6f8c3ab1628fa72a0db043dcd |
ToRGB | import math
import torch
from torch import nn
from torch.nn import functional as F
def fused_leaky_relu(input, bias, negative_slope=0.2, scale=2 ** 0.5):
rest_dim = [1] * (input.ndim - bias.ndim - 1)
input = input
if input.ndim == 3:
return F.leaky_relu(input + bias.view(1, *rest_dim, bias.shape[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
import math
from torch import nn
from torch.nn import functional as F
assert_siz... | ozmig77/StyleCLIP-1 | ToRGB | false | 16,223 | [
"MIT"
] | 2,732 | 57b887bba971ef86c107f4805785ce44fca3efef | https://github.com/ozmig77/StyleCLIP-1/tree/57b887bba971ef86c107f4805785ce44fca3efef |
SelfAttention | import torch
import torch.nn as nn
import torch.nn.functional as F
def mask_(matrices, maskval=0.0, mask_diagonal=True):
_b, h, w = matrices.size()
indices = torch.triu_indices(h, w, offset=0 if mask_diagonal else 1)
matrices[:, indices[0], indices[1]] = maskval
class SelfAttention(nn.Module):
def ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | ouyangshixiong/UPDeT | SelfAttention | false | 16,224 | [
"MIT"
] | 90 | e6010ff8a8a3ce064900f3f040a9a34218c97e0e | https://github.com/ouyangshixiong/UPDeT/tree/e6010ff8a8a3ce064900f3f040a9a34218c97e0e |
BertOutput | from _paritybench_helpers import _mock_config
import torch
import torch.nn
import torch.nn as nn
class BertOutput(nn.Module):
"""BERT output layer.
Based on: BERT (pytorch-transformer)
https://github.com/huggingface/transformers
"""
def __init__(self, config) ->None:
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.triton_helpers import libdevice
import torch.nn
imp... | Project-MONAI/MONAI | BertOutput | false | 16,225 | [
"Apache-2.0"
] | 2,971 | 2bab12c67c3cc1d54a4847628ce1e879064be11c | https://github.com/Project-MONAI/MONAI/tree/2bab12c67c3cc1d54a4847628ce1e879064be11c |
StyledConv | import math
import torch
from torch import nn
from torch.nn import functional as F
def fused_leaky_relu(input, bias, negative_slope=0.2, scale=2 ** 0.5):
rest_dim = [1] * (input.ndim - bias.ndim - 1)
input = input
if input.ndim == 3:
return F.leaky_relu(input + bias.view(1, *rest_dim, bias.shape[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 math
from to... | ozmig77/StyleCLIP-1 | StyledConv | false | 16,226 | [
"MIT"
] | 2,732 | 57b887bba971ef86c107f4805785ce44fca3efef | https://github.com/ozmig77/StyleCLIP-1/tree/57b887bba971ef86c107f4805785ce44fca3efef |
FieldAllTypeBilinear | import math
import torch
import torch.nn as nn
import torch.utils.data
from typing import Dict
from typing import Tuple
from abc import ABC
from abc import abstractmethod
class BaseLayer(nn.Module, ABC):
"""
Base Layer for the torecsys module
"""
def __init__(self, **kwargs):
"""
Init... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import math
import torch.nn as nn
import torch.utils.data
from typing import Dic... | p768lwy3/torecsys | FieldAllTypeBilinear | false | 16,227 | [
"MIT"
] | 92 | 2251366268b4fbe6f8c3ab1628fa72a0db043dcd | https://github.com/p768lwy3/torecsys/tree/2251366268b4fbe6f8c3ab1628fa72a0db043dcd |
ComplexCnnQAHead | import torch
from torch import nn
class ComplexCnnQAHead(nn.Module):
def __init__(self, input_size):
super().__init__()
self.relu = nn.ReLU()
self.conv_1 = nn.Conv1d(in_channels=input_size, out_channels=256,
kernel_size=1, padding=0)
self.conv_3 = nn.Conv1d(in_channels... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch import nn
assert_s... | park-sungmoo/odqa_baseline_code | ComplexCnnQAHead | false | 16,228 | [
"Apache-2.0"
] | 67 | 45954be766e5f987bef18e5b8a2e47f1508742cd | https://github.com/park-sungmoo/odqa_baseline_code/tree/45954be766e5f987bef18e5b8a2e47f1508742cd |
GlobalDiscriminator | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim
class GlobalDiscriminator(nn.Module):
def __init__(self, y_size, M_channels):
super().__init__()
self.c0 = nn.Conv2d(M_channels, 64, kernel_size=3)
self.c1 = nn.Conv2d(64, 32, kernel_size=3)
self... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
import ... | neuralsyn/self-supervised-relational-reasoning | GlobalDiscriminator | false | 16,229 | [
"MIT"
] | 130 | 6ecfafcf4a36c2eacef7ddd5bd1b23c28fbb14c8 | https://github.com/neuralsyn/self-supervised-relational-reasoning/tree/6ecfafcf4a36c2eacef7ddd5bd1b23c28fbb14c8 |
AE | import torch
import torch.nn.functional as F
import torch.nn as nn
import torch.nn.modules.loss
class AE(nn.Module):
""" Autoencoder for dimensional reduction"""
def __init__(self, dim):
super(AE, self).__init__()
self.dim = dim
self.fc1 = nn.Linear(dim, 512)
self.fc2 = 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
import torch.nn.functional as... | peterfeifanchen/scGNN | AE | false | 16,230 | [
"MIT"
] | 60 | 4ef9013ad0f44f9f51708e9bb60e5138f5706593 | https://github.com/peterfeifanchen/scGNN/tree/4ef9013ad0f44f9f51708e9bb60e5138f5706593 |
MaskL1Loss | import torch
import torch.nn as nn
class MaskL1Loss(nn.Module):
"""
Loss from paper <Pose Guided Person Image Generation> Sec3.1 pose mask loss
"""
def __init__(self, ratio=1):
super(MaskL1Loss, self).__init__()
self.criterion = nn.L1Loss()
self.ratio = ratio
def 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 torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
... | pasan1992/Human-Pose-Transfer | MaskL1Loss | false | 16,231 | [
"MIT"
] | 64 | a7febc632d4fbf627ba05740d2048accb25575f2 | https://github.com/pasan1992/Human-Pose-Transfer/tree/a7febc632d4fbf627ba05740d2048accb25575f2 |
BertMixedLayer | from _paritybench_helpers import _mock_config
import math
import torch
import torch.nn
import torch.nn as nn
class BertAttention(nn.Module):
"""BERT attention layer.
Based on: BERT (pytorch-transformer)
https://github.com/huggingface/transformers
"""
def __init__(self, config) ->None:
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.... | Project-MONAI/MONAI | BertMixedLayer | false | 16,232 | [
"Apache-2.0"
] | 2,971 | 2bab12c67c3cc1d54a4847628ce1e879064be11c | https://github.com/Project-MONAI/MONAI/tree/2bab12c67c3cc1d54a4847628ce1e879064be11c |
CBOWClassifier | import torch
from torch import nn
class CBOWClassifier(nn.Module):
"""
Continuous bag of words classifier.
"""
def __init__(self, hidden_size, input_size, max_pool, dropout=0.5):
"""
:param hidden_size:
:param input_size:
:param max_pool: if true then max pool over wor... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | nyu-mll/CoLA-baselines | CBOWClassifier | false | 16,233 | [
"MIT"
] | 54 | dd095d3646ed05a315280aaa8ed4ec84ba435b3e | https://github.com/nyu-mll/CoLA-baselines/tree/dd095d3646ed05a315280aaa8ed4ec84ba435b3e |
DHead | import torch
import torch.nn as nn
from math import *
class DHead(nn.Module):
def __init__(self):
super().__init__()
self.conv = nn.Conv2d(256, 1, 4)
def forward(self, x):
output = torch.sigmoid(self.conv(x))
return output
def get_inputs():
return [torch.rand([4, 256, 6... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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 math import *
assert_size_stride = torch._C._dynamo.g... | pengyuzhang97/NIID-Bench | DHead | false | 16,234 | [
"MIT"
] | 124 | 235b6f5c2bf218a587f9effae346a2f616de1855 | https://github.com/pengyuzhang97/NIID-Bench/tree/235b6f5c2bf218a587f9effae346a2f616de1855 |
IcosahedronUnpool | import math
import torch
from torch import nn
import torch.nn.functional as F
class IcosahedronUnpool(nn.Module):
"""Isocahedron Unpooling, consists in adding 1 values to match the desired un pooling size
"""
def forward(self, x):
"""Forward calculates the subset of pixels that will result from 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 import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_str... | phil-hawkins/deepsphere-pytorch | IcosahedronUnpool | false | 16,235 | [
"MIT"
] | 99 | f23c531445b3ddf234c7e98cdadb010163051e6d | https://github.com/phil-hawkins/deepsphere-pytorch/tree/f23c531445b3ddf234c7e98cdadb010163051e6d |
MultiHeadedAttention | import math
import torch
from typing import Optional
from typing import Tuple
from torch import nn
class MultiHeadedAttention(nn.Module):
"""Multi-Head Attention layer.
Args:
n_head (int): The number of heads.
n_feat (int): The number of features.
dropout_rate (float): Dropout rate.
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | pengchengguo/wenet | MultiHeadedAttention | false | 16,236 | [
"Apache-2.0"
] | 1,166 | 940dc164e5cfa9b8c0131688f0f9457af9563892 | https://github.com/pengchengguo/wenet/tree/940dc164e5cfa9b8c0131688f0f9457af9563892 |
AppendCLSToken | import math
import torch
from torch import Tensor
import torch.nn as nn
class BaseEmbeddingLayer(nn.Module):
def _apply_initialization(self, x: 'Tensor', d: 'int', method: 'str'
) ->None:
d_sqrt_inv = 1 / math.sqrt(d)
if method == 'uniform':
nn.init.uniform_(x, a=-d_sqrt_inv, ... | 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 math
from torch import Tensor
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cud... | pfnet-research/deep-table | AppendCLSToken | false | 16,237 | [
"MIT"
] | 48 | a19c0c3048484017d5f24806604c3b3470bcf550 | https://github.com/pfnet-research/deep-table/tree/a19c0c3048484017d5f24806604c3b3470bcf550 |
CnnQAHead | import torch
from torch import nn
class CnnQAHead(nn.Module):
def __init__(self, input_size):
super().__init__()
self.conv_1 = nn.Conv1d(in_channels=input_size, out_channels=2,
kernel_size=1, padding=0)
self.conv_3 = nn.Conv1d(in_channels=input_size, out_channels=2,
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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... | park-sungmoo/odqa_baseline_code | CnnQAHead | false | 16,238 | [
"Apache-2.0"
] | 67 | 45954be766e5f987bef18e5b8a2e47f1508742cd | https://github.com/park-sungmoo/odqa_baseline_code/tree/45954be766e5f987bef18e5b8a2e47f1508742cd |
CoverageAttention | from _paritybench_helpers import _mock_config
import torch
from torch import nn
import torch.nn.functional as F
class CoverageAttention(nn.Module):
def __init__(self, config: 'SARGConfig'):
super(CoverageAttention, self).__init__()
self.linear_h = nn.Linear(config.hidden_size, 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 import triton_helpers
from torch._inductor.runtime.... | NetEase-GameAI/SARG | CoverageAttention | false | 16,239 | [
"BSD-3-Clause"
] | 53 | 037085794f10439c4e52f57ab0fa042f35d03f62 | https://github.com/NetEase-GameAI/SARG/tree/037085794f10439c4e52f57ab0fa042f35d03f62 |
HealpixAvgPool | import torch
from torch import nn
import torch.nn.functional as F
class HealpixAvgPool(nn.AvgPool1d):
"""Healpix Average pooling module
"""
def __init__(self):
"""initialization
"""
super().__init__(kernel_size=4)
def forward(self, x):
"""forward call the 1d Averagepo... | 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... | phil-hawkins/deepsphere-pytorch | HealpixAvgPool | false | 16,240 | [
"MIT"
] | 99 | f23c531445b3ddf234c7e98cdadb010163051e6d | https://github.com/phil-hawkins/deepsphere-pytorch/tree/f23c531445b3ddf234c7e98cdadb010163051e6d |
RBFExpansion | import torch
import numpy as np
import torch.nn as nn
class RBFExpansion(nn.Module):
"""Expand distances between nodes by radial basis functions.
.. math::
\\exp(- \\gamma * ||d - \\mu||^2)
where :math:`d` is the distance between two nodes and :math:`\\mu` helps centralizes
the distances. We... | 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 numpy as np
import torch.nn as nn
assert_size_stride = torch._C._d... | padr31/dgl-lifesci | RBFExpansion | false | 16,241 | [
"Apache-2.0"
] | 390 | 932581468b330862836c0f050077fa33d0eb9405 | https://github.com/padr31/dgl-lifesci/tree/932581468b330862836c0f050077fa33d0eb9405 |
InfoNCELoss | import torch
from torch import Tensor
from torch.nn.modules.loss import _Loss
def cos_sim_matrix(a: 'Tensor', b: 'Tensor', eps: 'float'=1e-08) ->Tensor:
a_n, b_n = a.norm(dim=1), b.norm(dim=1)
a_norm = a / torch.clamp(a_n.unsqueeze(1), min=eps)
b_norm = b / torch.clamp(b_n.unsqueeze(1), min=eps)
sim_m... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | pfnet-research/deep-table | InfoNCELoss | false | 16,242 | [
"MIT"
] | 48 | a19c0c3048484017d5f24806604c3b3470bcf550 | https://github.com/pfnet-research/deep-table/tree/a19c0c3048484017d5f24806604c3b3470bcf550 |
ChamferLoss | import torch
import torch.nn as nn
class ChamferLoss(nn.Module):
def __init__(self, input_channels, reduction='mean'):
super(ChamferLoss, self).__init__()
self.input_channels = input_channels
def forward(self, x, y):
x.shape[0]
num_points = x.shape[1]
x = x[:, :, :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 import triton_helpers
import torch.nn as nn
assert_... | pfe-everis/lcd | ChamferLoss | false | 16,243 | [
"BSD-3-Clause"
] | 76 | 25f3fe7dc7e0c8ba02fb380dbcbe7752747b3fb5 | https://github.com/pfe-everis/lcd/tree/25f3fe7dc7e0c8ba02fb380dbcbe7752747b3fb5 |
EquiangularAvgUnpool | import math
import torch
from torch import nn
import torch.nn.functional as F
def equiangular_bandwidth(nodes):
"""Calculate the equiangular bandwidth based on input nodes
Args:
nodes (int): the number of nodes should be a power of 4
Returns:
int: the corresponding bandwidth
"""
... | 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 math
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guard... | phil-hawkins/deepsphere-pytorch | EquiangularAvgUnpool | false | 16,244 | [
"MIT"
] | 99 | f23c531445b3ddf234c7e98cdadb010163051e6d | https://github.com/phil-hawkins/deepsphere-pytorch/tree/f23c531445b3ddf234c7e98cdadb010163051e6d |
HealpixMaxPool | import torch
from torch import nn
import torch.nn.functional as F
class HealpixMaxPool(nn.MaxPool1d):
"""Healpix Maxpooling module
"""
def __init__(self, return_indices=False):
"""Initialization
"""
super().__init__(kernel_size=4, return_indices=return_indices)
def forward(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 import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empt... | phil-hawkins/deepsphere-pytorch | HealpixMaxPool | false | 16,245 | [
"MIT"
] | 99 | f23c531445b3ddf234c7e98cdadb010163051e6d | https://github.com/phil-hawkins/deepsphere-pytorch/tree/f23c531445b3ddf234c7e98cdadb010163051e6d |
Normalization | import numbers
import torch
import torch.nn as nn
class Normalization(nn.Module):
"""A normalization layer."""
def __init__(self, eps: 'numbers.Real'=1e-15):
"""Creates a new instance of ``Normalization``.
Args:
eps (numbers.Real, optional): A tiny number to be added to t... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import numbers
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guar... | phohenecker/pytorch-transformer | Normalization | false | 16,246 | [
"BSD-2-Clause"
] | 50 | 211406d82ac04a7b473bcdebda77cc3c2e9af0cf | https://github.com/phohenecker/pytorch-transformer/tree/211406d82ac04a7b473bcdebda77cc3c2e9af0cf |
VAE | import torch
import torch.nn.functional as F
import torch.nn as nn
import torch.nn.modules.loss
class VAE(nn.Module):
""" Variational Autoencoder for dimensional reduction"""
def __init__(self, dim):
super(VAE, self).__init__()
self.dim = dim
self.fc1 = nn.Linear(dim, 400)
sel... | import torch
from torch import device
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from... | peterfeifanchen/scGNN | VAE | false | 16,247 | [
"MIT"
] | 60 | 4ef9013ad0f44f9f51708e9bb60e5138f5706593 | https://github.com/peterfeifanchen/scGNN/tree/4ef9013ad0f44f9f51708e9bb60e5138f5706593 |
HardTripletLoss | import torch
import torch.nn as nn
def _pairwise_distance_squared(x, y):
xx = torch.sum(torch.pow(x, 2), 1).view(-1, 1)
yy = torch.sum(torch.pow(y, 2), 1).view(1, -1)
pdist = xx + yy - 2.0 * torch.mm(x, torch.t(y))
return pdist
class HardTripletLoss(nn.Module):
def __init__(self, margin=0.2, ha... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | pfe-everis/lcd | HardTripletLoss | false | 16,248 | [
"BSD-3-Clause"
] | 76 | 25f3fe7dc7e0c8ba02fb380dbcbe7752747b3fb5 | https://github.com/pfe-everis/lcd/tree/25f3fe7dc7e0c8ba02fb380dbcbe7752747b3fb5 |
Normalize | import torch
import torch.nn as nn
class Normalize(nn.Module):
def __init__(self, dim):
super().__init__()
self.dim = dim
def forward(self, x):
norm = torch.norm(x, p=2, dim=self.dim, keepdim=True)
return x / norm
def get_inputs():
return [torch.rand([4, 4, 4, 4, 4])]
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_... | phuochieu212/PointGLR | Normalize | false | 16,249 | [
"MIT"
] | 104 | 37017b1af31486aa9d516a3762725a650dca9ad1 | https://github.com/phuochieu212/PointGLR/tree/37017b1af31486aa9d516a3762725a650dca9ad1 |
BertSelfOutput | from _paritybench_helpers import _mock_config
import torch
import torch.nn as nn
import torch.utils.checkpoint
class BertSelfOutput(nn.Module):
def __init__(self, config, twin=False, merge=False):
super().__init__()
self.LayerNorm = nn.LayerNorm(config.hidden_size, eps=config.
layer_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 ... | igor0/BLIP | BertSelfOutput | false | 16,250 | [
"BSD-3-Clause"
] | 473 | 6d8c3f1e381ed23acb84c55b4adb80e74c08117a | https://github.com/igor0/BLIP/tree/6d8c3f1e381ed23acb84c55b4adb80e74c08117a |
N0reparameterize | import torch
from torch import nn as nn
import torch.nn.functional as F
from torch.distributions import Normal
class N0reparameterize(nn.Module):
"""Reparametrize zero mean Gaussian Variable."""
def __init__(self, input_dim, z_dim, fixed_sigma=None):
super().__init__()
self.input_dim = 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
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
fr... | pimdh/lie-vae | N0reparameterize | false | 16,251 | [
"MIT"
] | 83 | 0e0cc4d533c064fcfc405e8a75449f8b2f6cf8cf | https://github.com/pimdh/lie-vae/tree/0e0cc4d533c064fcfc405e8a75449f8b2f6cf8cf |
ChamferLoss | import torch
import torch.nn as nn
class ChamferLoss(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x, y):
"""
:param x: (bs, np, 3)
:param y: (bs, np, 3)
:return: loss
"""
x = x.unsqueeze(1)
y = y.unsqueeze(2)
dis... | 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... | phuochieu212/PointGLR | ChamferLoss | false | 16,252 | [
"MIT"
] | 104 | 37017b1af31486aa9d516a3762725a650dca9ad1 | https://github.com/phuochieu212/PointGLR/tree/37017b1af31486aa9d516a3762725a650dca9ad1 |
QuaternionMean | import torch
from torch import nn as nn
def quaternions_to_group_matrix(q):
"""Normalises q and maps to group matrix."""
q = q / q.norm(p=2, dim=-1, keepdim=True)
r, i, j, k = q[..., 0], q[..., 1], q[..., 2], q[..., 3]
return torch.stack([r * r - i * i - j * j + k * k, 2 * (r * i + j * k),
2 *... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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... | pimdh/lie-vae | QuaternionMean | false | 16,253 | [
"MIT"
] | 83 | 0e0cc4d533c064fcfc405e8a75449f8b2f6cf8cf | https://github.com/pimdh/lie-vae/tree/0e0cc4d533c064fcfc405e8a75449f8b2f6cf8cf |
RelPositionMultiHeadedAttention | import math
import torch
from typing import Optional
from typing import Tuple
from torch import nn
class MultiHeadedAttention(nn.Module):
"""Multi-Head Attention layer.
Args:
n_head (int): The number of heads.
n_feat (int): The number of features.
dropout_rate (float): Dropout rate.
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | pengchengguo/wenet | RelPositionMultiHeadedAttention | false | 16,254 | [
"Apache-2.0"
] | 1,166 | 940dc164e5cfa9b8c0131688f0f9457af9563892 | https://github.com/pengchengguo/wenet/tree/940dc164e5cfa9b8c0131688f0f9457af9563892 |
ClampExp | import torch
import torch.utils.data
class ClampExp(torch.nn.Module):
"""
Nonlinearity min(exp(lam * x), 1)
"""
def __init__(self):
"""
Constructor
:param lam: Lambda parameter
"""
super(ClampExp, self).__init__()
def forward(self, x):
one = 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 import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.utils.dat... | pkulwj1994/normalizing-flows | ClampExp | false | 16,255 | [
"MIT"
] | 96 | 326321c4aea4a3f6ab703f82e21277a79cd7d9e4 | https://github.com/pkulwj1994/normalizing-flows/tree/326321c4aea4a3f6ab703f82e21277a79cd7d9e4 |
TVLoss | import torch
from typing import Tuple
from torch.nn.modules.loss import _Loss
from typing import List
from typing import Optional
def _reduce(x: 'torch.Tensor', reduction: 'str'='mean') ->torch.Tensor:
"""Reduce input in batch dimension if needed.
Args:
x: Tensor with shape (N, *).
reduction:... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
from typing import Tuple
from torch.nn.modules.loss import _Loss
from typing im... | photosynthesis-team/piq | TVLoss | false | 16,256 | [
"Apache-2.0"
] | 471 | 79cccf887dd28ce57dea461972cda3648a79165a | https://github.com/photosynthesis-team/piq/tree/79cccf887dd28ce57dea461972cda3648a79165a |
Nreparameterize | import torch
from torch import nn as nn
import torch.nn.functional as F
from torch.distributions import Normal
class Nreparameterize(nn.Module):
"""Reparametrize Gaussian variable."""
def __init__(self, input_dim, z_dim):
super().__init__()
self.input_dim = input_dim
self.z_dim = z_di... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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... | pimdh/lie-vae | Nreparameterize | false | 16,257 | [
"MIT"
] | 83 | 0e0cc4d533c064fcfc405e8a75449f8b2f6cf8cf | https://github.com/pimdh/lie-vae/tree/0e0cc4d533c064fcfc405e8a75449f8b2f6cf8cf |
MAPELoss | import torch
import torch.nn as nn
class MAPELoss(nn.Module):
def forward(self, estimation: 'torch.Tensor', target: 'torch.Tensor'):
AER = torch.abs((target - estimation) / (target + 1e-10))
MAPE = AER.mean() * 100
return MAPE
def get_inputs():
return [torch.rand([4, 4, 4, 4]), torc... | 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
... | pmq20/gde | MAPELoss | false | 16,258 | [
"MIT"
] | 131 | fa4d4dacbcf00727bef76c4a641c72b94d5f8126 | https://github.com/pmq20/gde/tree/fa4d4dacbcf00727bef76c4a641c72b94d5f8126 |
ContrastiveEmbeddingLoss | import torch
from torch.nn.modules.loss import *
import torch.nn as nn
from torch.nn import *
from torch.optim import *
from torch.optim.lr_scheduler import *
class ContrastiveEmbeddingLoss(nn.Module):
"""
Contrastive embedding loss
paper: http://yann.lecun.com/exdb/publis/pdf/hadsell-chopra-lecun-06.pdf... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
from torch.nn.modules.loss i... | pokidyshev/catalyst | ContrastiveEmbeddingLoss | false | 16,259 | [
"Apache-2.0"
] | 46 | bfe2cc2af7b02bd954fb0b4a0cae8b350f56789a | https://github.com/pokidyshev/catalyst/tree/bfe2cc2af7b02bd954fb0b4a0cae8b350f56789a |
Upsample | import torch
import torch.nn as nn
class Upsample(nn.Module):
"""PyTorch upsampling implementation.
This module upsamples by inserting <i-1> zeros in between samples in the time
dimension. It does not low pass filter after this and assumes that the filter is a
separate module if desired.
.. see... | 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... | plexixx/rfml | Upsample | false | 16,260 | [
"BSD-3-Clause"
] | 61 | c00633b2c2005d38f991c6b9e3fd855ca25166c4 | https://github.com/plexixx/rfml/tree/c00633b2c2005d38f991c6b9e3fd855ca25166c4 |
ChebConv | import math
import torch
def cheb_conv(laplacian, inputs, weight):
"""Chebyshev convolution.
Args:
laplacian (:obj:`torch.sparse.Tensor`): The laplacian corresponding to the current sampling of the sphere.
inputs (:obj:`torch.Tensor`): The current input data being forwarded.
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
import math
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empt... | phil-hawkins/deepsphere-pytorch | ChebConv | false | 16,261 | [
"MIT"
] | 99 | f23c531445b3ddf234c7e98cdadb010163051e6d | https://github.com/phil-hawkins/deepsphere-pytorch/tree/f23c531445b3ddf234c7e98cdadb010163051e6d |
RUM | import torch
import torch.nn.functional as F
import torch.nn as nn
def rotation_components(x, y, eps=1e-12):
size_batch = x.size()[0]
hidden_size = x.size()[1]
u = F.normalize(x, p=2, dim=1, eps=eps)
costh = torch.sum(u * F.normalize(y, p=2, dim=1, eps=eps), dim=1).view(
size_batch, 1)
sin... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | omri123/rotational-unit-of-memory | RUM | false | 16,262 | [
"MIT"
] | 82 | e796c841e1e837df09497ba77c3bc285db47d02d | https://github.com/omri123/rotational-unit-of-memory/tree/e796c841e1e837df09497ba77c3bc285db47d02d |
ContrastiveDistanceLoss | import torch
from torch.nn.modules.loss import *
import torch.nn as nn
from torch.nn import *
from torch.optim import *
from torch.optim.lr_scheduler import *
class ContrastiveDistanceLoss(nn.Module):
"""
Contrastive distance loss
"""
def __init__(self, margin=1.0, reduction='mean'):
"""
... | 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.nn.modules.loss import *
import torch.nn as nn
from torch.nn import *
from tor... | pokidyshev/catalyst | ContrastiveDistanceLoss | false | 16,263 | [
"Apache-2.0"
] | 46 | bfe2cc2af7b02bd954fb0b4a0cae8b350f56789a | https://github.com/pokidyshev/catalyst/tree/bfe2cc2af7b02bd954fb0b4a0cae8b350f56789a |
ContrastivePairwiseEmbeddingLoss | import torch
from torch.nn.modules.loss import *
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import *
from torch.optim import *
from torch.optim.lr_scheduler import *
class ContrastivePairwiseEmbeddingLoss(nn.Module):
"""
ContrastivePairwiseEmbeddingLoss – proof of concept criterion.
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | pokidyshev/catalyst | ContrastivePairwiseEmbeddingLoss | false | 16,264 | [
"Apache-2.0"
] | 46 | bfe2cc2af7b02bd954fb0b4a0cae8b350f56789a | https://github.com/pokidyshev/catalyst/tree/bfe2cc2af7b02bd954fb0b4a0cae8b350f56789a |
GCNModelVAE | from torch.nn import Module
import torch
import torch.nn.functional as F
from torch.nn.modules.module import Module
from torch.nn.parameter import Parameter
import torch.nn as nn
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... | peterfeifanchen/scGNN | GCNModelVAE | false | 16,265 | [
"MIT"
] | 60 | 4ef9013ad0f44f9f51708e9bb60e5138f5706593 | https://github.com/peterfeifanchen/scGNN/tree/4ef9013ad0f44f9f51708e9bb60e5138f5706593 |
Shared | from _paritybench_helpers import _mock_config
import torch
import torch.utils.data
import torch.optim
import torch.utils.data.distributed
class Shared(torch.nn.Module):
def __init__(self, args):
super(Shared, self).__init__()
ncha, self.size, _ = args.inputsize
self.taskcla = args.taskcla... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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... | Prathyusha-Akundi/Adversarial-Continual-Learning | Shared | false | 16,266 | [
"MIT"
] | 237 | edf4bbd2c4c61f1cc20818793702ef8c6cf4e0df | https://github.com/Prathyusha-Akundi/Adversarial-Continual-Learning/tree/edf4bbd2c4c61f1cc20818793702ef8c6cf4e0df |
LearnedPositionalEncoding | import torch
import torch.nn as nn
import torch.optim
class LearnedPositionalEncoding(nn.Module):
def __init__(self, max_position_embeddings, embedding_dim, seq_length):
super(LearnedPositionalEncoding, self).__init__()
self.position_embeddings = nn.Parameter(torch.zeros(1, seq_length, 512)
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
import torch.optim
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dyna... | potpov/TransBTS | LearnedPositionalEncoding | false | 16,267 | [
"Apache-2.0"
] | 163 | 658de5f1dde17d25db54fb07adf49370cc32d7c3 | https://github.com/potpov/TransBTS/tree/658de5f1dde17d25db54fb07adf49370cc32d7c3 |
Adder2D | from torch.autograd import Function
import math
import torch
import torch.nn as nn
from torch.autograd.function import Function
def adder2d_function(X, W, stride=1, padding=0):
n_filters, _d_filter, h_filter, w_filter = W.size()
n_x, _d_x, h_x, w_x = X.size()
h_out = (h_x - h_filter + 2 * padding) / strid... | 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.autograd import Function
import math
import torch.nn as nn
fro... | poppin-mice/ShiftAddNet | Adder2D | false | 16,268 | [
"MIT"
] | 55 | a17369a50da5bba6250fdeac7c065bd00f293f3c | https://github.com/poppin-mice/ShiftAddNet/tree/a17369a50da5bba6250fdeac7c065bd00f293f3c |
DeiTOutput | from _paritybench_helpers import _mock_config
import torch
from torch import nn
import torch.utils.checkpoint
class DeiTOutput(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.intermediate_size, config.hidden_size)
self.dropout = nn.Dropout(config.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 import nn
import torch.utils.checkpoint
assert_size_stride = torch._C... | jxhe/unify-parameter-efficient-tuning | DeiTOutput | false | 16,269 | [
"Apache-2.0"
] | 101 | 3222ce2c0079566a28043e22380eb4ab6ad14389 | https://github.com/jxhe/unify-parameter-efficient-tuning/tree/3222ce2c0079566a28043e22380eb4ab6ad14389 |
four_layer_conv | import torch
class four_layer_conv(torch.nn.Module):
def __init__(self):
super(four_layer_conv, self).__init__()
self.relu = torch.nn.ReLU(inplace=True)
self.fcn1 = torch.nn.Conv2d(256, 256, 3, stride=1, padding=1)
self.fcn2 = torch.nn.Conv2d(256, 256, 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
assert_size_stride = torch._C... | peckjon/detectorch | four_layer_conv | false | 16,270 | [
"Apache-2.0"
] | 627 | 69d31250d79a72b12b7419638ef59163f833bbba | https://github.com/peckjon/detectorch/tree/69d31250d79a72b12b7419638ef59163f833bbba |
ConcatSquashLinear | from torch.nn import Module
import torch
from torch.nn import Linear
import torch.utils.tensorboard
class ConcatSquashLinear(Module):
def __init__(self, dim_in, dim_out, dim_ctx):
super(ConcatSquashLinear, self).__init__()
self._layer = Linear(dim_in, dim_out)
self._hyper_bias = Linear(di... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch.nn import Module
from torch.nn import Linear
import torch.utils.tenso... | entc-17-fyp-05/diffusion-point-cloud | ConcatSquashLinear | false | 16,271 | [
"MIT"
] | 138 | cde2e501855dea31496ddffad16f40aa588e3af8 | https://github.com/entc-17-fyp-05/diffusion-point-cloud/tree/cde2e501855dea31496ddffad16f40aa588e3af8 |
S2S2Mean | import torch
from torch import nn as nn
def s2s2_gram_schmidt(v1, v2):
"""Normalise 2 3-vectors. Project second to orthogonal component.
Take cross product for third. Stack to form SO matrix."""
u1 = v1
e1 = u1 / u1.norm(p=2, dim=-1, keepdim=True).clamp(min=1e-05)
u2 = v2 - (e1 * v2).sum(-1, keepd... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | pimdh/lie-vae | S2S2Mean | false | 16,272 | [
"MIT"
] | 83 | 0e0cc4d533c064fcfc405e8a75449f8b2f6cf8cf | https://github.com/pimdh/lie-vae/tree/0e0cc4d533c064fcfc405e8a75449f8b2f6cf8cf |
CrossLayer | import torch
import torch.nn as nn
import torch.optim
class CrossLayer(nn.Module):
def __init__(self, d, dropout):
super().__init__()
self.linear = nn.Linear(d, d)
self.dropout = nn.Dropout(dropout)
def forward(self, x0, x):
return self.dropout(x0 * self.linear(x)) + x
def ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
import torch.optim
assert_size_stride = torch._C._dynamo.g... | ppmdatix/rtdl | CrossLayer | false | 16,273 | [
"Apache-2.0"
] | 298 | a01ecd9ae6b673f4e82e51f804ffd7031c7350a0 | https://github.com/ppmdatix/rtdl/tree/a01ecd9ae6b673f4e82e51f804ffd7031c7350a0 |
InitConv | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim
class InitConv(nn.Module):
def __init__(self, in_channels=4, out_channels=16, dropout=0.2):
super(InitConv, self).__init__()
self.conv = nn.Conv3d(in_channels, out_channels, kernel_size=3,
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
import torch.nn as nn
import torch.optim
assert_size_stride = torch._C._dynamo.g... | potpov/TransBTS | InitConv | false | 16,274 | [
"Apache-2.0"
] | 163 | 658de5f1dde17d25db54fb07adf49370cc32d7c3 | https://github.com/potpov/TransBTS/tree/658de5f1dde17d25db54fb07adf49370cc32d7c3 |
SimpleNet | import torch
import torch.nn as nn
import torch.nn.functional as F
class SimpleNet(nn.Module):
def __init__(self, ni):
super().__init__()
self.linear1 = nn.Linear(ni, 128)
self.linear2 = nn.Linear(128, 128)
self.linear3 = nn.Linear(128, 64)
self.linear4 = nn.Linear(64, 64)... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 ... | pranjukn/AI-Feynman | SimpleNet | false | 16,275 | [
"MIT"
] | 470 | 92e67b01fc2b00ed6ebcacc67edf6122b4219ac7 | https://github.com/pranjukn/AI-Feynman/tree/92e67b01fc2b00ed6ebcacc67edf6122b4219ac7 |
AlphaChooser | import torch
from torch import nn
class AlphaChooser(torch.nn.Module):
"""
It manages the alpha values in alpha-entmax
function.
"""
def __init__(self, head_count):
super(AlphaChooser, self).__init__()
self.pre_alpha = nn.Parameter(torch.randn(head_count))
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
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empt... | prajjwal1/fluence2 | AlphaChooser | false | 16,276 | [
"Apache-2.0"
] | 64 | f7353f4947ac4712ecd1df34e97df27d83060f13 | https://github.com/prajjwal1/fluence2/tree/f7353f4947ac4712ecd1df34e97df27d83060f13 |
GatedConv | import torch
from torch import nn
import torch.nn.init as init
class GatedConv(nn.Module):
"""GatedConv."""
def __init__(self, input_size, width=3, dropout=0.2, nopad=False):
"""init."""
super(GatedConv, self).__init__()
self.conv = nn.Conv2d(in_channels=input_size, out_channels=2 *
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
import torch.nn.init as init
assert_size_stride = torch._C.... | pppku/SVS_system | GatedConv | false | 16,277 | [
"Apache-2.0"
] | 78 | 95ef1076c51bfc0b74349b8058a9c918ff24c500 | https://github.com/pppku/SVS_system/tree/95ef1076c51bfc0b74349b8058a9c918ff24c500 |
FFN | import torch
from torch import nn
import torch as t
class Conv(nn.Module):
"""Convolution Module."""
def __init__(self, in_channels, out_channels, kernel_size=1, stride=1,
padding=0, dilation=1, bias=True, w_init='linear'):
"""init."""
super(Conv, self).__init__()
self.conv = ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | pppku/SVS_system | FFN | false | 16,278 | [
"Apache-2.0"
] | 78 | 95ef1076c51bfc0b74349b8058a9c918ff24c500 | https://github.com/pppku/SVS_system/tree/95ef1076c51bfc0b74349b8058a9c918ff24c500 |
visual_context | import torch
import torch.nn as nn
import torch.utils.data
class visual_context(nn.Module):
def __init__(self):
super(visual_context, self).__init__()
self.AdaptiveAvgPool = nn.AdaptiveAvgPool2d((None, 1))
def forward(self, visual_feature):
visual_feature = self.AdaptiveAvgPool(visua... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
import torch.utils.data
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C.... | prabhatrmishra/IDCardInfoExtr | visual_context | false | 16,279 | [
"Apache-2.0"
] | 66 | c59270f61a3251a6aff55bc7d81f2057c4663a37 | https://github.com/prabhatrmishra/IDCardInfoExtr/tree/c59270f61a3251a6aff55bc7d81f2057c4663a37 |
DispConv | import torch
import torch.nn as nn
class Conv3x3(nn.Module):
def __init__(self, in_channels, out_channels, use_refl=True):
super(Conv3x3, self).__init__()
if use_refl:
self.pad = nn.ReflectionPad2d(1)
else:
self.pad = nn.ZeroPad2d(1)
self.conv = nn.Conv2d(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.triton_helpers import math as tl_math
import torch.... | prstrive/EPCDepth | DispConv | false | 16,280 | [
"MIT"
] | 76 | 84119c806741334b652749ee953e3eab60a3718c | https://github.com/prstrive/EPCDepth/tree/84119c806741334b652749ee953e3eab60a3718c |
CosineAngularLoss | import torch
import torch.nn as nn
import torch.nn.parallel
class CosineAngularLoss(nn.Module):
def __init__(self):
super(CosineAngularLoss, self).__init__()
def forward(self, preds, truths):
preds_norm = torch.nn.functional.normalize(preds, p=2, dim=1)
truths_norm = torch.nn.functio... | 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... | princeton-vl/oasis | CosineAngularLoss | false | 16,281 | [
"BSD-3-Clause"
] | 59 | 5835d24c331d78e91becba29f7e4a53ccd3e376e | https://github.com/princeton-vl/oasis/tree/5835d24c331d78e91becba29f7e4a53ccd3e376e |
InfoLoss | import math
import torch
import torch.nn as nn
class InfoLoss(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x, eps=1e-08):
x = torch.mean(x, 0)
logN = math.log(float(x.shape[0]))
x = x * (x + eps).log() / logN
neg_entropy = x.sum()
retur... | 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... | pudumagico/deepproblog | InfoLoss | false | 16,282 | [
"Apache-2.0"
] | 54 | 6d38e783990551f4030780a1d69c7138fada2020 | https://github.com/pudumagico/deepproblog/tree/6d38e783990551f4030780a1d69c7138fada2020 |
EntropyLoss | import math
import torch
import torch.nn as nn
class EntropyLoss(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x, eps=1e-08):
logN = math.log(float(x.shape[0]))
x = x * (x + eps).log() / logN
neg_entropy = x.sum(1)
return -neg_entropy.mean()
d... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert... | pudumagico/deepproblog | EntropyLoss | false | 16,283 | [
"Apache-2.0"
] | 54 | 6d38e783990551f4030780a1d69c7138fada2020 | https://github.com/pudumagico/deepproblog/tree/6d38e783990551f4030780a1d69c7138fada2020 |
ConvElu | import torch
import torch.nn as nn
class ConvElu(nn.Module):
def __init__(self, in_ch=3, out_ch=3, dirate=1):
super(ConvElu, self).__init__()
self.conv_s1 = nn.Conv2d(in_ch, out_ch, 3, padding=1 * dirate,
dilation=1 * dirate, padding_mode='reflect')
self.elu = nn.ELU(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.triton_helpers import libdevice, math as tl_math
im... | prstrive/EPCDepth | ConvElu | false | 16,284 | [
"MIT"
] | 76 | 84119c806741334b652749ee953e3eab60a3718c | https://github.com/prstrive/EPCDepth/tree/84119c806741334b652749ee953e3eab60a3718c |
JSD | import math
import torch
import torch.nn as nn
class JSD(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x, eps=1e-08):
logN = math.log(float(x.shape[0]))
y = torch.mean(x, 0)
y = y * (y + eps).log() / logN
y = y.sum()
x = x * (x + eps).lo... | 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... | pudumagico/deepproblog | JSD | false | 16,285 | [
"Apache-2.0"
] | 54 | 6d38e783990551f4030780a1d69c7138fada2020 | https://github.com/pudumagico/deepproblog/tree/6d38e783990551f4030780a1d69c7138fada2020 |
Highway | import torch
from torch import nn
class Highway(nn.Module):
def __init__(self, in_size, out_size):
super(Highway, self).__init__()
self.H = nn.Linear(in_size, out_size)
self.H.bias.data.zero_()
self.T = nn.Linear(in_size, out_size)
self.T.bias.data.fill_(-1)
self.r... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch import nn
assert_s... | puppyapple/tacotron_pytorch | Highway | false | 16,286 | [
"MIT"
] | 278 | 800bf8b0538c91f1104e99d8e7c1b645bb6154d3 | https://github.com/puppyapple/tacotron_pytorch/tree/800bf8b0538c91f1104e99d8e7c1b645bb6154d3 |
UpConv | import torch
import torch.nn as nn
class Conv3x3(nn.Module):
def __init__(self, in_channels, out_channels, use_refl=True):
super(Conv3x3, self).__init__()
if use_refl:
self.pad = nn.ReflectionPad2d(1)
else:
self.pad = nn.ZeroPad2d(1)
self.conv = nn.Conv2d(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.triton_helpers import libdevice, math as tl_math
im... | prstrive/EPCDepth | UpConv | false | 16,287 | [
"MIT"
] | 76 | 84119c806741334b652749ee953e3eab60a3718c | https://github.com/prstrive/EPCDepth/tree/84119c806741334b652749ee953e3eab60a3718c |
SoftDiceLoss | import torch
from torch.nn.modules.loss import _Loss
class SoftDiceLoss(_Loss):
def __init__(self, size_average=None, reduce=None, reduction='mean'):
super(SoftDiceLoss, self).__init__(size_average, reduce, reduction)
def forward(self, y_pred, y_gt):
numerator = torch.sum(y_pred * y_gt)
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch.nn.modules.loss import _Loss
assert_size_stride = torch._C._dynamo.guards.asse... | purbayankar/pytorch-UNet | SoftDiceLoss | false | 16,288 | [
"MIT"
] | 91 | 63183199b1cf4e23a37869d30fc335e484c0c0fe | https://github.com/purbayankar/pytorch-UNet/tree/63183199b1cf4e23a37869d30fc335e484c0c0fe |
Attention | import math
import torch
from torch import nn
from torch.nn import Linear
import torch as t
from torch.autograd import Variable
class MultiheadAttention(nn.Module):
"""Multihead attention mechanism (dot attention)."""
def __init__(self, num_hidden_k):
""":param num_hidden_k: dimension of hidden."""
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | pppku/SVS_system | Attention | false | 16,290 | [
"Apache-2.0"
] | 78 | 95ef1076c51bfc0b74349b8058a9c918ff24c500 | https://github.com/pppku/SVS_system/tree/95ef1076c51bfc0b74349b8058a9c918ff24c500 |
BahdanauAttention | import torch
from torch import nn
class BahdanauAttention(nn.Module):
def __init__(self, dim):
super(BahdanauAttention, self).__init__()
self.query_layer = nn.Linear(dim, dim, bias=False)
self.tanh = nn.Tanh()
self.v = nn.Linear(dim, 1, bias=False)
def forward(self, query, pr... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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... | puppyapple/tacotron_pytorch | BahdanauAttention | false | 16,292 | [
"MIT"
] | 278 | 800bf8b0538c91f1104e99d8e7c1b645bb6154d3 | https://github.com/puppyapple/tacotron_pytorch/tree/800bf8b0538c91f1104e99d8e7c1b645bb6154d3 |
ClassWisePool | import sys
from torch.autograd import Function
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.optim
import torch.utils.data
class ClassWisePoolFunction(Function):
@staticmethod
def forward(ctx, input, num_maps):
batch_size, num_channels, h, w = input.size()
if num_ch... | 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 sys
from torch.autograd import Function
import torch.nn as nn
import torch.nn.parallel
import torch.optim
import torch.utils.data
ass... | pyushkevich/wildcat.pytorch | ClassWisePool | false | 16,293 | [
"MIT"
] | 273 | 2046cde4e4a350eb1172fe60035448aa8df632d5 | https://github.com/pyushkevich/wildcat.pytorch/tree/2046cde4e4a350eb1172fe60035448aa8df632d5 |
BertLayerNorm | import torch
import torch.nn as nn
import torch.cuda
import torch.onnx.utils
import torch.random
import torch.cuda.random
import torch.utils.cpp_extension
class BertLayerNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-12):
super(BertLayerNorm, self).__init__()
self.weight = nn.Parameter(t... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
import torch.cuda
import torch.onnx.utils
import torch.ra... | nict-wisdom/rannc | BertLayerNorm | false | 16,294 | [
"MIT"
] | 45 | a1708807e053e2d58b7f6d6ed925f03aa8504416 | https://github.com/nict-wisdom/rannc/tree/a1708807e053e2d58b7f6d6ed925f03aa8504416 |
ReLUDropout | import torch
import torch.utils.data
import torch.cuda
import torch.utils.checkpoint
def relu_dropout(x, p=0, training=False, variational=False, batch_first=False):
if not training or p == 0:
return x.clamp_(min=0)
p1m = 1 - p
if variational:
if batch_first:
mask = torch.rand_l... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.utils.data
import torch.cuda
import torch.utils.checkpoint
assert_size_strid... | quanpn90/NMTGMinor | ReLUDropout | false | 16,295 | [
"MIT"
] | 75 | 0e5f989c8bc01c6c8dc3a8c1ce7c05bfd884b796 | https://github.com/quanpn90/NMTGMinor/tree/0e5f989c8bc01c6c8dc3a8c1ce7c05bfd884b796 |
Invertible1x1Conv | import torch
import torch.utils.data
from torch import nn
class Flow(nn.Module):
"""
Generic class for flow functions
"""
def __init__(self):
super().__init__()
def forward(self, z):
"""
:param z: input variable, first dimension is batch dim
:return: transformed z... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.utils.data
from torch import nn
assert_size_stride = torch._C._dyna... | pkulwj1994/normalizing-flows | Invertible1x1Conv | false | 16,296 | [
"MIT"
] | 96 | 326321c4aea4a3f6ab703f82e21277a79cd7d9e4 | https://github.com/pkulwj1994/normalizing-flows/tree/326321c4aea4a3f6ab703f82e21277a79cd7d9e4 |
AttendNodeModule | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
class AttendNodeModule(nn.Module):
def forward(self, node_vectors, query):
"""
Args:
node_vectors [Tensor] (num_node, dim_v) : node feature vectors
query [Tensor] (dim_v, ) : query v... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | qiuyue1993/XNM-Net | AttendNodeModule | false | 16,297 | [
"MIT"
] | 95 | 1c4a16fd745d9e90e0d7a08b21e7efca4d2c6195 | https://github.com/qiuyue1993/XNM-Net/tree/1c4a16fd745d9e90e0d7a08b21e7efca4d2c6195 |
SmoothL1Loss | import torch
import torch.utils.data
def smooth_l1_loss(pred, target, weight, beta):
val = target - pred
abs_val = val.abs()
smooth_mask = abs_val < beta
return weight * torch.where(smooth_mask, 0.5 / beta * val ** 2, abs_val -
0.5 * beta).sum(dim=-1)
class SmoothL1Loss(torch.nn.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.triton_helpers import math as tl_math
import torch.utils.data
assert_size_stride = torch._C._dynamo.guards.asse... | qilei123/FreeAnchor | SmoothL1Loss | false | 16,298 | [
"MIT"
] | 495 | 80361a7addb7d84a50863a6b34734d28034c7256 | https://github.com/qilei123/FreeAnchor/tree/80361a7addb7d84a50863a6b34734d28034c7256 |
FillUpLuminance | import torch
class FillUpLuminance(torch.nn.Module):
def __init__(self):
super(FillUpLuminance, self).__init__()
def forward(self, color, luminance):
return color + (1 - color) * luminance
def get_inputs():
return [torch.rand([4, 4, 4, 4]), torch.rand([4, 4, 4, 4])]
def get_init_inpu... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
@triton.j... | qway/nerfmeshes | FillUpLuminance | false | 16,299 | [
"MIT"
] | 113 | d983dcbbcfec1337c9f2040969213c6d1ea0c39e | https://github.com/qway/nerfmeshes/tree/d983dcbbcfec1337c9f2040969213c6d1ea0c39e |
CmapPafHead | import torch
import torch.utils.data
import torch.nn
import torch.optim
class UpsampleCBR(torch.nn.Sequential):
def __init__(self, input_channels, output_channels, count=1, num_flat=0):
layers = []
for i in range(count):
if i == 0:
inch = input_channels
els... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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
import torch.optim
assert_size_stride = ... | quantd2/trt_pose | CmapPafHead | false | 16,300 | [
"MIT"
] | 738 | 44c5e826977f20c8dad2d9725313a18cb2189853 | https://github.com/quantd2/trt_pose/tree/44c5e826977f20c8dad2d9725313a18cb2189853 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.