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 |
|---|---|---|---|---|---|---|---|---|---|---|
CausalConv2d | import torch
from torch import nn
import torch.utils.data
class WNConv2d(nn.Module):
def __init__(self, in_channel, out_channel, kernel_size, stride=1,
padding=0, bias=True, activation=None):
super().__init__()
self.conv = nn.utils.weight_norm(nn.Conv2d(in_channel, 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
from torch._inductor.runtime.triton_helpers import libdevice
from torch import n... | Shivanshu-Gupta/KaoKore-VQ-VAE2 | CausalConv2d | false | 1,075 | [
"MIT"
] | 0 | 38a88ba312dee3c0e2c1aaf02e1c1754ba19ac0c | https://github.com/Shivanshu-Gupta/KaoKore-VQ-VAE2/tree/38a88ba312dee3c0e2c1aaf02e1c1754ba19ac0c |
FastGRNNCell | import torch
import torch.nn as nn
import torch.onnx
from itertools import product as product
def gen_nonlinearity(A, nonlinearity):
"""
Returns required activation for a tensor based on the inputs
nonlinearity is either a callable or a value in
['tanh', 'sigmoid', 'relu', 'quantTanh', 'quantSigm... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 ... | ShishirPatil/EdgeML-1 | FastGRNNCell | false | 1,076 | [
"MIT"
] | 0 | cbba9f8b989e545788427c004eb8450e7e4c1a21 | https://github.com/ShishirPatil/EdgeML-1/tree/cbba9f8b989e545788427c004eb8450e7e4c1a21 |
ResidualConvUnit | import torch
import torch.nn as nn
class ResidualConvUnit(nn.Module):
"""Residual convolution module.
"""
def __init__(self, features):
"""Init.
Args:
features (int): number of features
"""
super().__init__()
self.conv1 = nn.Conv2d(features, features, ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | ShiraLightricks/3d-photo-inpainting | ResidualConvUnit | false | 1,077 | [
"MIT"
] | 0 | c42ac41576690b765e50f5281ddbfb58439ff36d | https://github.com/ShiraLightricks/3d-photo-inpainting/tree/c42ac41576690b765e50f5281ddbfb58439ff36d |
LayerNorm | import torch
import numpy as np
class BaseModule(torch.nn.Module):
def __init__(self):
super(BaseModule, self).__init__()
@property
def nparams(self):
"""
Returns number of trainable parameters of the module.
"""
num_params = 0
for name, param in self.name... | 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 numpy as np
assert_size_stride = torch._C._dynamo.guards.assert_size_str... | Sobsz/uberduck-ml-dev | LayerNorm | false | 1,078 | [
"Apache-2.0"
] | 0 | f099238f6f2e3f600d72d89dea3c883c59d91387 | https://github.com/Sobsz/uberduck-ml-dev/tree/f099238f6f2e3f600d72d89dea3c883c59d91387 |
Loss | import torch
import torch as t
import torch.nn as nn
def indicator(K):
"""
@K: number of users
"""
return t.eye(5 * K)
class Loss(nn.Module):
def __init__(self, K, Nt, Vartheta):
super(Loss, self).__init__()
self.K = K
self.Nt = Nt
self.Delta = indica... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | SoulVen/USRMNet-HWGCN | Loss | false | 1,079 | [
"Apache-2.0"
] | 0 | 2f99f53150335be26270bd408ce59dc51c8435cc | https://github.com/SoulVen/USRMNet-HWGCN/tree/2f99f53150335be26270bd408ce59dc51c8435cc |
AttNet | import torch
import torch.nn as nn
import torch.nn.functional as F
class AttNet(nn.Module):
def __init__(self, num_input_ch):
super(AttNet, self).__init__()
self.num_input_ch = num_input_ch
self.conv1 = nn.Conv2d(self.num_input_ch, 64, 3, padding=1, bias=True)
self.conv2 = nn.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.... | SionHu/LP-MOT | AttNet | false | 1,080 | [
"MIT"
] | 0 | 90e6a1d51ebe1a948ac5c018a5ee560654e824f1 | https://github.com/SionHu/LP-MOT/tree/90e6a1d51ebe1a948ac5c018a5ee560654e824f1 |
Net | import torch
import torch.nn as nn
class FcCat(nn.Module):
def __init__(self, nIn, nOut):
super(FcCat, self).__init__()
self.fc = nn.Linear(nIn, nOut, bias=False)
def forward(self, x):
out = torch.cat((x, self.fc(x)), 1)
return out
class Net(nn.Module):
def __init__(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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | Sreehari-S/Tiramisu_DigestPath | Net | false | 1,081 | [
"Apache-2.0"
] | 0 | a884ee911bc60ce997996e0ec2e6036600ffcffa | https://github.com/Sreehari-S/Tiramisu_DigestPath/tree/a884ee911bc60ce997996e0ec2e6036600ffcffa |
DecoderLayer | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
class ScaledDotProductAttention(nn.Module):
def __init__(self):
super(ScaledDotProductAttention, self).__init__()
def forward(self, query, key, value, mask=None):
_1, _2, query_sequence_length, _3 = query.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.... | SeungoneKim/Transformer_implementation | DecoderLayer | false | 1,082 | [
"Apache-2.0"
] | 0 | a52bf552eb645fc9bfb812cc26842fc147d6c008 | https://github.com/SeungoneKim/Transformer_implementation/tree/a52bf552eb645fc9bfb812cc26842fc147d6c008 |
TransitionUp | import torch
import torch.nn as nn
def center_crop(layer, max_height, max_width):
_, _, h, w = layer.size()
xy1 = (w - max_width) // 2
xy2 = (h - max_height) // 2
return layer[:, :, xy2:xy2 + max_height, xy1:xy1 + max_width]
class TransitionUp(nn.Module):
def __init__(self, in_channels, out_cha... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | Sreehari-S/Tiramisu_DigestPath | TransitionUp | false | 1,083 | [
"Apache-2.0"
] | 0 | a884ee911bc60ce997996e0ec2e6036600ffcffa | https://github.com/Sreehari-S/Tiramisu_DigestPath/tree/a884ee911bc60ce997996e0ec2e6036600ffcffa |
ConvBlock | import torch
import torch.nn as nn
import torch.utils.data
class WSConv2d(nn.Module):
"""
Weight scaled Conv2d (Equalized Learning Rate)
Note that input is multiplied rather than changing weights
this will have the same result.
Inspired by:
https://github.com/nvnbny/progressive_growing_of_gan... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 ... | SongsLearning/Machine-Learning-Collection | ConvBlock | false | 1,084 | [
"MIT"
] | 0 | a8dff83969f67d37f70a89db06b851057d2da539 | https://github.com/SongsLearning/Machine-Learning-Collection/tree/a8dff83969f67d37f70a89db06b851057d2da539 |
FcCat | import torch
import torch.nn as nn
class FcCat(nn.Module):
def __init__(self, nIn, nOut):
super(FcCat, self).__init__()
self.fc = nn.Linear(nIn, nOut, bias=False)
def forward(self, x):
out = torch.cat((x, self.fc(x)), 1)
return out
def get_inputs():
return [torch.rand([... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | Sreehari-S/Tiramisu_DigestPath | FcCat | false | 1,086 | [
"Apache-2.0"
] | 0 | a884ee911bc60ce997996e0ec2e6036600ffcffa | https://github.com/Sreehari-S/Tiramisu_DigestPath/tree/a884ee911bc60ce997996e0ec2e6036600ffcffa |
WSConv2d | import torch
import torch.nn as nn
import torch.utils.data
class WSConv2d(nn.Module):
"""
Weight scaled Conv2d (Equalized Learning Rate)
Note that input is multiplied rather than changing weights
this will have the same result.
Inspired by:
https://github.com/nvnbny/progressive_growing_of_gan... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | SongsLearning/Machine-Learning-Collection | WSConv2d | false | 1,087 | [
"MIT"
] | 0 | a8dff83969f67d37f70a89db06b851057d2da539 | https://github.com/SongsLearning/Machine-Learning-Collection/tree/a8dff83969f67d37f70a89db06b851057d2da539 |
Standardscaler | import torch
class Standardscaler(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, input_batch):
std, mean = torch.std_mean(input_batch.type(torch.float32),
unbiased=False)
total = (input_batch - mean) / std
return total
def get_inputs(... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
assert_size_stride = torch._... | Stuksus/StandardScaler_for_pytorch | Standardscaler | false | 1,088 | [
"MIT"
] | 0 | 27da9afd111007f20a615bee9a5a7ac272adb241 | https://github.com/Stuksus/StandardScaler_for_pytorch/tree/27da9afd111007f20a615bee9a5a7ac272adb241 |
FeatureResizer | import torch
import torch.utils.data
import torch
from torch import nn
class FeatureResizer(nn.Module):
"""
This class takes as input a set of embeddings of dimension C1 and outputs a set of
embedding of dimension C2, after a linear transformation, dropout and normalization (LN).
"""
def __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.utils.... | Sudhir11292rt/DefVisTR | FeatureResizer | false | 1,089 | [
"Apache-2.0"
] | 0 | d52b2d88c10c6239de1c1ff851a743c58b708b75 | https://github.com/Sudhir11292rt/DefVisTR/tree/d52b2d88c10c6239de1c1ff851a743c58b708b75 |
UGRNNLRCell | import torch
import torch.nn as nn
import torch.onnx
from itertools import product as product
def gen_nonlinearity(A, nonlinearity):
"""
Returns required activation for a tensor based on the inputs
nonlinearity is either a callable or a value in
['tanh', 'sigmoid', 'relu', 'quantTanh', 'quantSigm... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 ... | ShishirPatil/EdgeML-1 | UGRNNLRCell | false | 1,090 | [
"MIT"
] | 0 | cbba9f8b989e545788427c004eb8450e7e4c1a21 | https://github.com/ShishirPatil/EdgeML-1/tree/cbba9f8b989e545788427c004eb8450e7e4c1a21 |
FCLayer | import torch
import torch.nn as nn
class FCLayer(nn.Module):
def __init__(self, input_dim, output_dim, dropout_rate=0.0,
use_activation=True):
super(FCLayer, self).__init__()
self.use_activation = use_activation
self.dropout = nn.Dropout(dropout_rate)
self.linear = nn.Line... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as ... | StevenChaoo/R-BERT-DDI | FCLayer | false | 1,091 | [
"MIT"
] | 0 | 6d9666e0bc61397ca942ffad53653690c1e8a899 | https://github.com/StevenChaoo/R-BERT-DDI/tree/6d9666e0bc61397ca942ffad53653690c1e8a899 |
MultiHeadAttention | import math
import torch
import numpy as np
def convert_pad_shape(pad_shape):
"""Reverse, then flatten a list of lists."""
l = pad_shape[::-1]
pad_shape = [item for sublist in l for item in sublist]
return pad_shape
class BaseModule(torch.nn.Module):
def __init__(self):
super(BaseModule... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | Sobsz/uberduck-ml-dev | MultiHeadAttention | false | 1,092 | [
"Apache-2.0"
] | 0 | f099238f6f2e3f600d72d89dea3c883c59d91387 | https://github.com/Sobsz/uberduck-ml-dev/tree/f099238f6f2e3f600d72d89dea3c883c59d91387 |
WNConv2d | import torch
from torch import nn
import torch.utils.data
class WNConv2d(nn.Module):
def __init__(self, in_channel, out_channel, kernel_size, stride=1,
padding=0, bias=True, activation=None):
super().__init__()
self.conv = nn.utils.weight_norm(nn.Conv2d(in_channel, 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
from torch._inductor.runtime.triton_helpers import libdevice
from torch import n... | Shivanshu-Gupta/KaoKore-VQ-VAE2 | WNConv2d | false | 1,093 | [
"MIT"
] | 0 | 38a88ba312dee3c0e2c1aaf02e1c1754ba19ac0c | https://github.com/Shivanshu-Gupta/KaoKore-VQ-VAE2/tree/38a88ba312dee3c0e2c1aaf02e1c1754ba19ac0c |
DisparityRegression | import torch
import torch.nn as nn
import torch.utils.data
class DisparityRegression(nn.Module):
def __init__(self, maxdisp, win_size):
super(DisparityRegression, self).__init__()
self.max_disp = maxdisp
self.win_size = win_size
def forward(self, x):
disp = torch.arange(0, 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
import torch.nn as nn
import torch.utils.data
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C.... | SpadeLiu/Graft-PSMNet | DisparityRegression | false | 1,094 | [
"MIT"
] | 0 | 1f2950d5afd85237f8d3604caab20dd47a8c9889 | https://github.com/SpadeLiu/Graft-PSMNet/tree/1f2950d5afd85237f8d3604caab20dd47a8c9889 |
Message_Passing_Unit_v1 | import torch
from torchvision.transforms import functional as F
import torch.utils.data
from torch import nn
import torch.nn.functional as F
class Message_Passing_Unit_v1(nn.Module):
def __init__(self, fea_size, filter_size=128):
super(Message_Passing_Unit_v1, self).__init__()
self.w = nn.Linear(... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.utils.data
from ... | SpartaG117/scene_graph_benchmark | Message_Passing_Unit_v1 | false | 1,095 | [
"MIT"
] | 0 | e2e49940dd2f752b1faf9ae26707435ba3441bcb | https://github.com/SpartaG117/scene_graph_benchmark/tree/e2e49940dd2f752b1faf9ae26707435ba3441bcb |
ExpModule | import torch
import torch.nn as nn
class ExpModule(nn.Module):
def __init__(self):
super(ExpModule, self).__init__()
def forward(self, x):
return torch.exp(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.triton_helpers import math as tl_math
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert... | SimonTreu/sdvae | ExpModule | false | 1,096 | [
"MIT"
] | 0 | e0270b9b2acf2d66eec93870f1c5633c8f04d9ab | https://github.com/SimonTreu/sdvae/tree/e0270b9b2acf2d66eec93870f1c5633c8f04d9ab |
EncoderLayer | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
class ScaledDotProductAttention(nn.Module):
def __init__(self):
super(ScaledDotProductAttention, self).__init__()
def forward(self, query, key, value, mask=None):
_1, _2, query_sequence_length, _3 = query.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.... | SeungoneKim/Transformer_implementation | EncoderLayer | false | 1,097 | [
"Apache-2.0"
] | 0 | a52bf552eb645fc9bfb812cc26842fc147d6c008 | https://github.com/SeungoneKim/Transformer_implementation/tree/a52bf552eb645fc9bfb812cc26842fc147d6c008 |
Residual_Covolution | import torch
import torch.nn as nn
class Residual_Covolution(nn.Module):
def __init__(self, icol, ocol, num_classes):
super(Residual_Covolution, self).__init__()
self.conv1 = nn.Conv2d(icol, ocol, kernel_size=3, stride=1, padding
=12, dilation=12, bias=True)
self.conv2 = nn.Co... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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_... | SultanAbuGhazal/CGNet | Residual_Covolution | false | 1,098 | [
"MIT"
] | 0 | f10b976b984ba09be26b902ed4da97cd1311cf17 | https://github.com/SultanAbuGhazal/CGNet/tree/f10b976b984ba09be26b902ed4da97cd1311cf17 |
ResidualBlockNoBN | import torch
from torch import nn
class ResidualBlockNoBN(nn.Module):
def __init__(self, in_channels, out_channels, stride=1):
super(ResidualBlockNoBN, self).__init__()
self.conv1 = nn.Conv2d(in_channels=in_channels, out_channels=
out_channels, kernel_size=(3, 3), stride=stride, paddi... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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... | Suvapna/ArtificialLaughter | ResidualBlockNoBN | false | 1,100 | [
"MIT"
] | 0 | a7114134b698f829e05e74cac30052e18b260f85 | https://github.com/Suvapna/ArtificialLaughter/tree/a7114134b698f829e05e74cac30052e18b260f85 |
SpatialAttention | import torch
import torch.nn as nn
class SpatialAttention(nn.Module):
def __init__(self, kernel_size=7, bias=True):
super(SpatialAttention, self).__init__()
assert kernel_size in (3, 7), 'kernel size must be 3 or 7'
padding = 3 if kernel_size == 7 else 1
self.conv1 = nn.Conv2d(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
import torch.nn as nn
assert_... | SuzaKrish/mmdetection | SpatialAttention | false | 1,101 | [
"Apache-2.0"
] | 0 | 31c16891d7493252262e738bcbf05326dba866b2 | https://github.com/SuzaKrish/mmdetection/tree/31c16891d7493252262e738bcbf05326dba866b2 |
Message_Passing_Unit_v2 | import torch
from torchvision.transforms import functional as F
import torch.utils.data
from torch import nn
import torch.nn.functional as F
class Message_Passing_Unit_v2(nn.Module):
def __init__(self, fea_size, filter_size=128):
super(Message_Passing_Unit_v2, self).__init__()
self.w = nn.Linear(... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.utils.data
from ... | SpartaG117/scene_graph_benchmark | Message_Passing_Unit_v2 | false | 1,102 | [
"MIT"
] | 0 | e2e49940dd2f752b1faf9ae26707435ba3441bcb | https://github.com/SpartaG117/scene_graph_benchmark/tree/e2e49940dd2f752b1faf9ae26707435ba3441bcb |
PositionalEmbedding | import math
import torch
class PositionalEmbedding(torch.nn.Module):
def __init__(self):
super(PositionalEmbedding, self).__init__()
def forward(self, inputs):
if inputs.dim() != 3:
raise ValueError('The rank of input must be 3.')
length = inputs.shape[1]
channels... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import math as tl_math
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_str... | THUNLP-MT/PLM4MT | PositionalEmbedding | false | 1,103 | [
"BSD-3-Clause"
] | 0 | 85bd2ee9d96b07ac827e14d4b3e5b0d0924c3401 | https://github.com/THUNLP-MT/PLM4MT/tree/85bd2ee9d96b07ac827e14d4b3e5b0d0924c3401 |
MaxPool | import torch
import torch.nn as nn
class MaxPool(nn.Module):
def __init__(self, dim=1):
super(MaxPool, self).__init__()
self.dim = dim
def forward(self, input):
return torch.max(input, self.dim)[0]
def __repr__(self):
return self.__class__.__name__ + ' (' + 'dim=' + str(... | 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... | SwaggyZhang/Geometry-aware | MaxPool | false | 1,104 | [
"Apache-2.0"
] | 0 | a750c00aa2f0bda5160dfdeee2eef5230fd9d993 | https://github.com/SwaggyZhang/Geometry-aware/tree/a750c00aa2f0bda5160dfdeee2eef5230fd9d993 |
Transpose | import torch
import torch.nn as nn
class Transpose(nn.Module):
def __init__(self, dim1=0, dim2=1):
super(Transpose, self).__init__()
self.dim1 = dim1
self.dim2 = dim2
def forward(self, input):
return input.transpose(self.dim1, self.dim2).contiguous()
def __repr__(self):
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | SwaggyZhang/Geometry-aware | Transpose | false | 1,105 | [
"Apache-2.0"
] | 0 | a750c00aa2f0bda5160dfdeee2eef5230fd9d993 | https://github.com/SwaggyZhang/Geometry-aware/tree/a750c00aa2f0bda5160dfdeee2eef5230fd9d993 |
GraphConv | import torch
from torch import nn
import torch.nn
import torch.autograd
def sparse_bmm(sparse_matrix, dense_matrix_batch):
"""
Perform torch.bmm on an unbatched sparse matrix and a batched dense matrix.
Args:
sparse_matrix (torch.sparse.FloatTensor): Shape = (m, n)
dense_matrix_batch (tor... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import 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
import torch.autograd
assert_size_stride = ... | T0mt0mp/kaolin | GraphConv | false | 1,106 | [
"ECL-2.0",
"Apache-2.0"
] | 0 | 57d1e1478eec8df49dc7cc492f25637cec40399f | https://github.com/T0mt0mp/kaolin/tree/57d1e1478eec8df49dc7cc492f25637cec40399f |
Align | import torch
import torch.nn.functional as F
class Align(torch.nn.Module):
def __init__(self, p):
super(Align, self).__init__()
self.p = p
def forward(self, e1, e2):
pred = -torch.norm(e1 - e2, p=self.p, dim=1)
return pred
def only_pos_loss(self, e1, r, e2):
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.functional as F
assert_size_stride = torch._C._dynamo.guards.as... | TMUITLab/EAFR | Align | false | 1,108 | [
"MIT"
] | 0 | dadb6485d48711ccb8aa2f03760aeb437645f1ff | https://github.com/TMUITLab/EAFR/tree/dadb6485d48711ccb8aa2f03760aeb437645f1ff |
MNISTGenerator | import torch
from torch import nn as nn
from torch import optim as optim
from torchvision import transforms as transforms
class MNISTGenerator(nn.Module):
def __init__(self, latent_dim):
super(MNISTGenerator, self).__init__()
self.image_shape = 1, 28, 28
self.latent_dim = latent_dim
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch import nn as nn
fr... | RobinMaas95/GTSRB_Visualization | MNISTGenerator | false | 1,109 | [
"MIT"
] | 0 | fa837ff94e089a936ef4f4418970d262b35f70b6 | https://github.com/RobinMaas95/GTSRB_Visualization/tree/fa837ff94e089a936ef4f4418970d262b35f70b6 |
Conv2d | import torch
import torch.nn as nn
import torch.nn.parallel
import torch.nn.functional as F
class Conv2d(nn.Conv2d):
def __init__(self, in_channels, out_channels, kernel_size, stride=1,
padding=0, dilation=1, groups=1, bias=True):
super(Conv2d, self).__init__(in_channels, out_channels, kernel_siz... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 ... | T1anZhenYu/pytorch-classification | Conv2d | false | 1,110 | [
"MIT"
] | 0 | ad68e09f20a98541bcb437a7df8e7d14e8c21636 | https://github.com/T1anZhenYu/pytorch-classification/tree/ad68e09f20a98541bcb437a7df8e7d14e8c21636 |
lovasz_hinge | import torch
import torch.nn.parallel
import torch.utils.data
from torchvision.transforms import functional as F
import torch.nn.functional as F
from torch.autograd import Variable
def flatten_binary_scores(scores, labels, ignore=255):
"""
Flattens predictions in the batch (binary case)
Remove labels equa... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn.parallel
import torch.utils.data
from torchvision.transforms import functional as F
import torch.nn.functional as F
from tor... | PhillipHuang2017/ext_portrait_segmentation | lovasz_hinge | false | 1,111 | [
"MIT"
] | 0 | 6d0cec0a953dacbc94a01ea8b719feb687b7c029 | https://github.com/PhillipHuang2017/ext_portrait_segmentation/tree/6d0cec0a953dacbc94a01ea8b719feb687b7c029 |
AlignEA | import torch
import torch.nn.functional as F
class AlignEA(torch.nn.Module):
def __init__(self, p, feat_drop, params):
super(AlignEA, self).__init__()
self.params = params
def forward(self, e1, r, e2):
return torch.sum(torch.pow(e1 + r - e2, 2), 1)
def only_pos_loss(self, e1, r,... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn.functional as F
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards... | TMUITLab/EAFR | AlignEA | false | 1,112 | [
"MIT"
] | 0 | dadb6485d48711ccb8aa2f03760aeb437645f1ff | https://github.com/TMUITLab/EAFR/tree/dadb6485d48711ccb8aa2f03760aeb437645f1ff |
fpn_module | import torch
import torch.nn.functional as F
import torch.nn as nn
class fpn_module(nn.Module):
def __init__(self, numClass):
super(fpn_module, self).__init__()
self.toplayer = nn.Conv2d(2048, 256, kernel_size=1, stride=1, padding=0
)
self.smooth1_1 = nn.Conv2d(256, 256, kerne... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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... | LOUEY233/CPS3320_python | fpn_module | false | 1,113 | [
"MIT"
] | 0 | 3cc1733d91c3a8f680eeb984348e2a52ae3285ec | https://github.com/LOUEY233/CPS3320_python/tree/3cc1733d91c3a8f680eeb984348e2a52ae3285ec |
Bilinear | import torch
import torch.nn as nn
class Bilinear(nn.Module):
def __init__(self, size):
super(Bilinear, self).__init__()
self.size = size
self.mat = nn.Parameter(torch.FloatTensor(self.size, self.size))
self.reset_parameters()
def reset_parameters(self):
params = [p 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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | TRUMANCFY/VL-DIORA | Bilinear | false | 1,114 | [
"Apache-2.0"
] | 0 | cef398e05842d4a30345260d8e27d1c362671834 | https://github.com/TRUMANCFY/VL-DIORA/tree/cef398e05842d4a30345260d8e27d1c362671834 |
N_TransE | import torch
import torch.nn.functional as F
class N_TransE(torch.nn.Module):
def __init__(self, p, params):
super(N_TransE, self).__init__()
self.p = p
self.params = params
def forward(self, e1, r, e2):
pred = -torch.norm(e1 + r - e2, p=self.p, dim=1)
return pred
... | 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.functional as F
assert_size_stride = torch._C._dynamo.guards.as... | TMUITLab/EAFR | N_TransE | false | 1,115 | [
"MIT"
] | 0 | dadb6485d48711ccb8aa2f03760aeb437645f1ff | https://github.com/TMUITLab/EAFR/tree/dadb6485d48711ccb8aa2f03760aeb437645f1ff |
FM | import torch
import torch.nn as nn
from sklearn.metrics import *
class FM(nn.Module):
"""Factorization Machine models pairwise (order-2) feature interactions
without linear term and bias.
Input shape
- 3D tensor with shape: ``(batch_size,field_size,embedding_size)``.
Output shape
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
from sklearn.metrics import *
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = tor... | Sunmyunghan/Final_Project | FM | false | 1,117 | [
"MIT"
] | 0 | 28cde293dc6d07521b2e1c5613b20444aea91d21 | https://github.com/Sunmyunghan/Final_Project/tree/28cde293dc6d07521b2e1c5613b20444aea91d21 |
VertexDirectEmbedder | import torch
import torch.utils.data
from torch import nn
def normalize_embeddings(embeddings: 'torch.Tensor', epsilon: 'float'=1e-06
) ->torch.Tensor:
"""
Normalize N D-dimensional embedding vectors arranged in a tensor [N, D]
Args:
embeddings (tensor [N, D]): N D-dimensional embedding vecto... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
import torch.utils.data
from... | TWJianNuo/detectron2 | VertexDirectEmbedder | false | 1,118 | [
"Apache-2.0"
] | 0 | 091bc43e85b8f7cefdccebf8d85afb7cfff2a3f0 | https://github.com/TWJianNuo/detectron2/tree/091bc43e85b8f7cefdccebf8d85afb7cfff2a3f0 |
HighWay | import torch
import torch.nn as nn
from torch.nn import Parameter
class HighWay(torch.nn.Module):
def __init__(self, f_in, f_out, bias=True):
super(HighWay, self).__init__()
self.w = Parameter(torch.Tensor(f_in, f_out))
nn.init.xavier_uniform_(self.w)
if bias:
self.bia... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
from torch.nn import Parameter
assert_size_stride = torch.... | TMUITLab/EAFR | HighWay | false | 1,119 | [
"MIT"
] | 0 | dadb6485d48711ccb8aa2f03760aeb437645f1ff | https://github.com/TMUITLab/EAFR/tree/dadb6485d48711ccb8aa2f03760aeb437645f1ff |
Network | import torch
import torch.nn as nn
from torch.nn.functional import relu
from torch.nn.functional import softmax
class Network(nn.Module):
def __init__(self, input_size, output_size):
super().__init__()
self.input_size = input_size
self.output_size = output_size
self.fc1 = nn.Linea... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | THE-RAF/Reinforcement-Learning | Network | false | 1,120 | [
"MIT"
] | 0 | 36b4c5330740b533fb8170263f995afb91a1d021 | https://github.com/THE-RAF/Reinforcement-Learning/tree/36b4c5330740b533fb8170263f995afb91a1d021 |
SpatialCrossMapLRN | import torch
import torch.nn as nn
import torch.nn.parallel
import torch.optim
import torch.utils.data
class SpatialCrossMapLRN(nn.Module):
def __init__(self, local_size=1, alpha=1.0, beta=0.75, k=1,
ACROSS_CHANNELS=True):
super(SpatialCrossMapLRN, self).__init__()
self.ACROSS_CHANNELS = ... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
import torch.nn.parallel
import torch.optim
import torch.... | Tagussan/pretrained-models.pytorch | SpatialCrossMapLRN | false | 1,121 | [
"BSD-3-Clause"
] | 0 | 854e6c153c2534dd7cf76a5ec102307ea5171167 | https://github.com/Tagussan/pretrained-models.pytorch/tree/854e6c153c2534dd7cf76a5ec102307ea5171167 |
MLPBase | import torch
from torch import nn
import torch.nn.functional as F
class MLPBase(nn.Module):
def __init__(self, num_inputs, num_outputs):
super(MLPBase, self).__init__()
self.l1 = nn.Linear(num_inputs, 400)
self.l2 = nn.Linear(400, 300)
self.l3 = nn.Linear(300, num_outputs)
de... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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... | TachikakaMin/dreamer-torch | MLPBase | false | 1,122 | [
"MIT"
] | 0 | 3c99526f4507e28cf8b34ada0321001adcf8ae1f | https://github.com/TachikakaMin/dreamer-torch/tree/3c99526f4507e28cf8b34ada0321001adcf8ae1f |
N_R_Align | import torch
import torch.nn as nn
class N_R_Align(torch.nn.Module):
def __init__(self, params):
super(N_R_Align, self).__init__()
self.params = params
self.cos_sim = nn.CosineSimilarity(dim=1, eps=1e-06)
def forward(self, e1, e2, n1, n2):
return self.params * torch.sigmoid(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 import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
assert... | TMUITLab/EAFR | N_R_Align | false | 1,123 | [
"MIT"
] | 0 | dadb6485d48711ccb8aa2f03760aeb437645f1ff | https://github.com/TMUITLab/EAFR/tree/dadb6485d48711ccb8aa2f03760aeb437645f1ff |
FC | import torch
import torch.nn as nn
import torch.nn.functional as F
class FC(nn.Module):
def __init__(self, in_channels, out_channels, use_bias=False,
activation='LR', gain=2 ** 0.5):
super(FC, self).__init__()
self.he_std = in_channels * -0.5 * gain
self.weight = torch.nn.Paramete... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | TOMeoww/STGAN | FC | false | 1,124 | [
"MIT"
] | 0 | 090a4024999e68f017140312ecfdd0d4dc3dc425 | https://github.com/TOMeoww/STGAN/tree/090a4024999e68f017140312ecfdd0d4dc3dc425 |
Mean | import torch
class Mean(torch.nn.Module):
def __init__(self, dim):
super().__init__()
self.dim = dim
def forward(self, x):
_std, mean = torch.std_mean(x, self.dim)
return mean
def get_inputs():
return [torch.rand([4, 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
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
reinterpret... | Tahlor/glom-pytorch | Mean | false | 1,125 | [
"MIT"
] | 0 | 45b2fc52af5288cd53611e497a70d53ffa303410 | https://github.com/Tahlor/glom-pytorch/tree/45b2fc52af5288cd53611e497a70d53ffa303410 |
LinearModel | import torch
class LinearModel(torch.nn.Module):
def __init__(self, input_size: 'int', output_size: 'int', dropout: 'float'
):
super().__init__()
self.linear = torch.nn.Linear(input_size, output_size)
self.dropout = torch.nn.Dropout(dropout)
def forward(self, data):
d... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cu... | TDteach/SEAM | LinearModel | false | 1,126 | [
"MIT"
] | 0 | 231447dad15403e7620adcf6629b6e7fccc4b809 | https://github.com/TDteach/SEAM/tree/231447dad15403e7620adcf6629b6e7fccc4b809 |
GeometricMean | import torch
import torch.nn.functional as F
class GeometricMean(torch.nn.Module):
def __init__(self, dim):
super().__init__()
self.dim = dim
def forward(self, x):
log_x = torch.log(F.relu(x))
return torch.exp(torch.mean(log_x, dim=self.dim))
def get_inputs():
return [t... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
assert_size_stride = t... | Tahlor/glom-pytorch | GeometricMean | false | 1,127 | [
"MIT"
] | 0 | 45b2fc52af5288cd53611e497a70d53ffa303410 | https://github.com/Tahlor/glom-pytorch/tree/45b2fc52af5288cd53611e497a70d53ffa303410 |
MinibatchStd | import torch
import torch.nn as nn
class MinibatchStd(nn.Module):
"""
calculate minibatch std to avoid mode collapse
"""
def __init__(self):
super(MinibatchStd, self).__init__()
def forward(self, x):
size = list(x.size())
size[1] = 1
std = torch.std(x, dim=0)
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_... | Tak-jae-ho/RGBD-GAN-pytorch | MinibatchStd | false | 1,128 | [
"MIT"
] | 0 | 4fb1bc1de7b7807fd4f2d346d9b688a2d257eedb | https://github.com/Tak-jae-ho/RGBD-GAN-pytorch/tree/4fb1bc1de7b7807fd4f2d346d9b688a2d257eedb |
PixelwiseNorm | import torch
import torch.nn as nn
class PixelwiseNorm(nn.Module):
"""
layer pixelwise normalization
"""
def __init__(self, eps=1e-07):
super(PixelwiseNorm, self).__init__()
self.eps = eps
def forward(self, x):
return x / torch.sqrt(torch.sum(x ** 2, dim=1, keepdim=True) ... | 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_... | Tak-jae-ho/RGBD-GAN-pytorch | PixelwiseNorm | false | 1,129 | [
"MIT"
] | 0 | 4fb1bc1de7b7807fd4f2d346d9b688a2d257eedb | https://github.com/Tak-jae-ho/RGBD-GAN-pytorch/tree/4fb1bc1de7b7807fd4f2d346d9b688a2d257eedb |
ConsensusAttention | import torch
import torch.nn.functional as F
from torch import nn
from torch import einsum
class ConsensusAttention(nn.Module):
def __init__(self, num_patches_side, attend_self=True,
local_consensus_radius=0):
super().__init__()
self.attend_self = attend_self
self.local_consensus_... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | Tahlor/glom-pytorch | ConsensusAttention | false | 1,130 | [
"MIT"
] | 0 | 45b2fc52af5288cd53611e497a70d53ffa303410 | https://github.com/Tahlor/glom-pytorch/tree/45b2fc52af5288cd53611e497a70d53ffa303410 |
DenseCrossEntropy | import torch
import torch.nn as nn
import torch.utils.data
import torch.nn.parallel
class DenseCrossEntropy(nn.Module):
def forward(self, x, target):
x = x.float()
target = target.float()
logprobs = torch.nn.functional.log_softmax(x, dim=-1)
loss = -logprobs * target
loss ... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
... | Tanmengxuan/Google-Landmark-Recognition-2020-3rd-Place-Solution | DenseCrossEntropy | false | 1,131 | [
"Apache-2.0"
] | 0 | 8e2d9056d5c88c6415827086809e73522b336fbb | https://github.com/Tanmengxuan/Google-Landmark-Recognition-2020-3rd-Place-Solution/tree/8e2d9056d5c88c6415827086809e73522b336fbb |
HalfMSELoss | import torch
from torch.nn.modules.loss import MSELoss
class HalfMSELoss(MSELoss):
def __init__(self, reduction='mean'):
super().__init__(reduction=reduction)
def forward(self, input, target):
return super().forward(input, target) / 2
def get_inputs():
return [torch.rand([4, 4, 4, 4]),... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch.nn.modules.loss import MSELoss
assert_size_stride = torch._C._dynamo.guards.as... | ThayaFluss/candle | HalfMSELoss | false | 1,132 | [
"MIT"
] | 0 | 4a12fde60ffbbf0cb688617fee81aded94c0b613 | https://github.com/ThayaFluss/candle/tree/4a12fde60ffbbf0cb688617fee81aded94c0b613 |
EqualLinear | import torch
from torch import nn
import torch.nn.functional as F
class EqualLinear(nn.Module):
def __init__(self, in_dim, out_dim, lr_mul=1, bias=True):
super().__init__()
self.weight = nn.Parameter(torch.randn(out_dim, in_dim))
if bias:
self.bias = nn.Parameter(torch.zeros(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 import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_st... | TheSignPainter/AGGAN | EqualLinear | false | 1,133 | [
"Apache-2.0"
] | 0 | d75144f81df3f5a0a761d48c6285c38e74002be3 | https://github.com/TheSignPainter/AGGAN/tree/d75144f81df3f5a0a761d48c6285c38e74002be3 |
SuperPointNet | import torch
import torch.optim
import torch.utils.data
class SuperPointNet(torch.nn.Module):
""" Pytorch definition of SuperPoint Network. """
def __init__(self):
super(SuperPointNet, self).__init__()
self.relu = torch.nn.ReLU(inplace=True)
self.pool = torch.nn.MaxPool2d(kernel_size=... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | Sunny-Qin-0314/pytorch-superpoint | SuperPointNet | false | 1,134 | [
"MIT"
] | 0 | 5c5325a1e5917afcc7469e137206990a8cd33725 | https://github.com/Sunny-Qin-0314/pytorch-superpoint/tree/5c5325a1e5917afcc7469e137206990a8cd33725 |
ArcMarginProduct_subcenter | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
import torch.nn.parallel
class ArcMarginProduct_subcenter(nn.Module):
def __init__(self, in_features, out_features, k=3):
super().__init__()
self.weight = nn.Parameter(torch.FloatTensor(out_feat... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | Tanmengxuan/Google-Landmark-Recognition-2020-3rd-Place-Solution | ArcMarginProduct_subcenter | false | 1,135 | [
"Apache-2.0"
] | 0 | 8e2d9056d5c88c6415827086809e73522b336fbb | https://github.com/Tanmengxuan/Google-Landmark-Recognition-2020-3rd-Place-Solution/tree/8e2d9056d5c88c6415827086809e73522b336fbb |
ChannelMixer | import torch
import torch.nn as nn
class ChannelMixer(nn.Module):
def __init__(self, input_size, hidden_size, dropout=None):
super(ChannelMixer, self).__init__()
self.fc1 = nn.Linear(input_size, hidden_size)
self.fc2 = nn.Linear(hidden_size, input_size)
self.dropout = None
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 ... | TheRealMarVin/mlp-mixer | ChannelMixer | false | 1,136 | [
"MIT"
] | 0 | 2124cb5c5adfc7af473cab535095471d4943adab | https://github.com/TheRealMarVin/mlp-mixer/tree/2124cb5c5adfc7af473cab535095471d4943adab |
Net | import torch
from torch import nn
from torch.nn import functional as F
class Net(nn.Module):
def __init__(self, obs_dim, act_dim):
super(Net, self).__init__()
self.fc0 = nn.Linear(obs_dim, 128)
self.fc1 = nn.Linear(128, act_dim)
def forward(self, x):
x = x.type_as(self.fc0.bi... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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... | TommeyChang/CS294-Homework | Net | false | 1,137 | [
"MIT"
] | 0 | 17b525bf4366034b45c4febd89f1053d44550237 | https://github.com/TommeyChang/CS294-Homework/tree/17b525bf4366034b45c4febd89f1053d44550237 |
ActorDownAction | import torch
from torch import nn
import torch.nn.functional as F
class MLPBase(nn.Module):
def __init__(self, num_inputs, num_outputs):
super(MLPBase, self).__init__()
self.l1 = nn.Linear(num_inputs, 400)
self.l2 = nn.Linear(400, 300)
self.l3 = nn.Linear(300, num_outputs)
de... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | TachikakaMin/dreamer-torch | ActorDownAction | false | 1,138 | [
"MIT"
] | 0 | 3c99526f4507e28cf8b34ada0321001adcf8ae1f | https://github.com/TachikakaMin/dreamer-torch/tree/3c99526f4507e28cf8b34ada0321001adcf8ae1f |
UpsampleConvLayer | import torch
import torch.nn as nn
class UpsampleConvLayer(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride,
scale_factor):
super(UpsampleConvLayer, self).__init__()
self._scale_factor = scale_factor
self._reflection_pad = nn.ReflectionPad2d(kernel_siz... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | ThomasRanvier/cnn_style_transfer | UpsampleConvLayer | false | 1,139 | [
"MIT"
] | 0 | 90b6c76c20263c22f4e45184d572284726ecbd7b | https://github.com/ThomasRanvier/cnn_style_transfer/tree/90b6c76c20263c22f4e45184d572284726ecbd7b |
StructuralProbe | import torch
import torch.nn as nn
import torch.utils.data.dataloader
class StructuralProbe(nn.Module):
""" Computes squared L2 distance after projection by a matrix.
For a batch of sentences, computes all n^2 pairs of distances
for each sentence in the batch.
"""
def __init__(self, model_dim, ra... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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.dataloader
assert_size_stride = to... | TimO96/NLP2 | StructuralProbe | false | 1,140 | [
"MIT"
] | 0 | 83f65a385457f68397c641f38b53df0110282578 | https://github.com/TimO96/NLP2/tree/83f65a385457f68397c641f38b53df0110282578 |
Pooling | import torch
import torch.nn as nn
class Pooling(nn.Module):
"""
Implementation of pooling for PoolFormer
--pool_size: pooling size
"""
def __init__(self, pool_size=3):
super().__init__()
self.pool = nn.AvgPool2d(pool_size, stride=1, padding=pool_size //
2, count_incl... | 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... | TranNhiem/MA_SSRL_Pytorch | Pooling | false | 1,141 | [
"MIT"
] | 0 | 87d946461850240fdd54de761603f13ef3710c2b | https://github.com/TranNhiem/MA_SSRL_Pytorch/tree/87d946461850240fdd54de761603f13ef3710c2b |
TwoWordBilinearLabelProbe | import torch
import torch.nn as nn
import torch.utils.data.dataloader
class TwoWordBilinearLabelProbe(nn.Module):
""" Computes a bilinear function of pairs of vectors.
For a batch of sentences, computes all n^2 pairs of scores
for each sentence in the batch.
"""
def __init__(self, model_dim, rank... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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.dataloader
assert_size_stride = to... | TimO96/NLP2 | TwoWordBilinearLabelProbe | false | 1,142 | [
"MIT"
] | 0 | 83f65a385457f68397c641f38b53df0110282578 | https://github.com/TimO96/NLP2/tree/83f65a385457f68397c641f38b53df0110282578 |
Policy | import torch
from torch import nn
from torch.nn import functional as F
class Policy(nn.Module):
def __init__(self, act_dim, obs_dim):
super(Policy, self).__init__()
self.fc0 = nn.Linear(act_dim, 128)
self.fc1 = nn.Linear(128, obs_dim)
def forward(self, x):
x = x.type_as(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 import nn
assert_s... | TommeyChang/CS294-Homework | Policy | false | 1,143 | [
"MIT"
] | 0 | 17b525bf4366034b45c4febd89f1053d44550237 | https://github.com/TommeyChang/CS294-Homework/tree/17b525bf4366034b45c4febd89f1053d44550237 |
CrossEntropyLoss | import torch
import torch.nn as nn
import torch.utils.data.dataloader
class CrossEntropyLoss(nn.Module):
"""Custom cross-entropy loss"""
def __init__(self):
super(CrossEntropyLoss, self).__init__()
self.pytorch_ce_loss = torch.nn.CrossEntropyLoss(ignore_index=-1,
reduction='sum')
... | 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
... | TimO96/NLP2 | CrossEntropyLoss | false | 1,144 | [
"MIT"
] | 0 | 83f65a385457f68397c641f38b53df0110282578 | https://github.com/TimO96/NLP2/tree/83f65a385457f68397c641f38b53df0110282578 |
GlobalAttentionGeneral | import torch
import torch.nn as nn
import torch.nn.parallel
import torch.onnx
def conv1x1(in_planes, out_planes, bias=False):
"""1x1 convolution with padding"""
return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=1,
padding=0, bias=bias)
class GlobalAttentionGeneral(nn.Module):
def __... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | Thesis-02F/Style-Attn | GlobalAttentionGeneral | false | 1,145 | [
"MIT"
] | 0 | 55f78de4858e395ebf9750a23923fd772600290f | https://github.com/Thesis-02F/Style-Attn/tree/55f78de4858e395ebf9750a23923fd772600290f |
Mlp | import math
import torch
import warnings
import torch.nn as nn
def _no_grad_trunc_normal_(tensor, mean, std, a, b):
"""Copy & paste from PyTorch official master until it's in a few official releases - RW
Method based on https://people.sc.fsu.edu/~jburkardt/presentations/truncated_normal.pdf
"""
def 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 math
import ... | TranNhiem/solo-learn | Mlp | false | 1,146 | [
"MIT"
] | 0 | 7539732b68d153087d09a26a23e1edfdc49bc086 | https://github.com/TranNhiem/solo-learn/tree/7539732b68d153087d09a26a23e1edfdc49bc086 |
TokenMixer | import torch
import torch.nn as nn
class TokenMixer(nn.Module):
def __init__(self, input_size, hidden_size, dropout=None):
super(TokenMixer, self).__init__()
self.fc1 = nn.Linear(input_size, hidden_size)
self.fc2 = nn.Linear(hidden_size, input_size)
self.dropout = None
if ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 ... | TheRealMarVin/mlp-mixer | TokenMixer | false | 1,147 | [
"MIT"
] | 0 | 2124cb5c5adfc7af473cab535095471d4943adab | https://github.com/TheRealMarVin/mlp-mixer/tree/2124cb5c5adfc7af473cab535095471d4943adab |
SelfAttention | import torch
import numpy as np
import torch.nn as nn
class SelfAttention(nn.Module):
""" Scaled Dot-Product Attention """
def __init__(self, dropout=0.1):
super(SelfAttention, self).__init__()
self.dropout = nn.Dropout(dropout)
def forward(self, query, key, value, mask=None):
ke... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | TranQuocTrinh/image_captioning | SelfAttention | false | 1,148 | [
"MIT"
] | 0 | 4c2d77426ba3b9fe9151a15a958320d5298aa190 | https://github.com/TranQuocTrinh/image_captioning/tree/4c2d77426ba3b9fe9151a15a958320d5298aa190 |
AveragePoolingLayer | import torch
import torch.nn as nn
import torch.nn.functional as F
class AveragePoolingLayer(nn.Module):
"""Implements the average pooling layer.
Basically, this layer can be used to downsample feature maps from spatial
domain.
"""
def __init__(self, scale_factor=2):
super().__init__()
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | Twizwei/idinvert_pytorch | AveragePoolingLayer | false | 1,149 | [
"MIT"
] | 0 | 11f1126aab517fbe32b488d92f6fdea339463d04 | https://github.com/Twizwei/idinvert_pytorch/tree/11f1126aab517fbe32b488d92f6fdea339463d04 |
LayerNormChannel | import torch
import torch.nn as nn
class LayerNormChannel(nn.Module):
"""
LayerNorm only for Channel Dimension.
Input: tensor in shape [B, C, H, W]
"""
def __init__(self, num_channels, eps=1e-05):
super().__init__()
self.weight = nn.Parameter(torch.ones(num_channels))
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 libdevice
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_... | TranNhiem/MA_SSRL_Pytorch | LayerNormChannel | false | 1,150 | [
"MIT"
] | 0 | 87d946461850240fdd54de761603f13ef3710c2b | https://github.com/TranNhiem/MA_SSRL_Pytorch/tree/87d946461850240fdd54de761603f13ef3710c2b |
Whitening2d | import torch
import torch.nn as nn
from torch.cuda.amp import custom_fwd
from torch.nn.functional import conv2d
class Whitening2d(nn.Module):
def __init__(self, output_dim: 'int', eps: 'float'=0.0):
"""Layer that computes hard whitening for W-MSE using the Cholesky decomposition.
Args:
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | TranNhiem/solo-learn | Whitening2d | false | 1,151 | [
"MIT"
] | 0 | 7539732b68d153087d09a26a23e1edfdc49bc086 | https://github.com/TranNhiem/solo-learn/tree/7539732b68d153087d09a26a23e1edfdc49bc086 |
ClassificationModel | import torch
import torch.nn as nn
class ClassificationModel(nn.Module):
def __init__(self, num_features_in, num_anchors=9, num_classes=80,
prior=0.01, feature_size=256, dropout1=0.25, dropout2=0.25):
super(ClassificationModel, self).__init__()
self.num_classes = num_classes
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
assert_... | TobyChen0106/DeepQ_Final_B05901170 | ClassificationModel | false | 1,152 | [
"Apache-2.0"
] | 0 | 808a224c01272726a051eb7b7bb9e1b28887716e | https://github.com/TobyChen0106/DeepQ_Final_B05901170/tree/808a224c01272726a051eb7b7bb9e1b28887716e |
ContrastiveLoss | import torch
from torch import nn
import torch.nn.functional as F
class ContrastiveLoss(nn.Module):
"""
contrastive loss
L2 distance:
L(a1,a2,y) = y * d(a1, a2) + (1-y)*max(0, m - d(a1, a2))
cosine distance:
L(a1, a2, y) = y * (1 - d(a1,a2)) + (1-y) * max(0, d(a1,a2) -m)
where y=1 if (a1,... | 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... | TuBui/deep_image_comparator | ContrastiveLoss | false | 1,153 | [
"MIT"
] | 0 | 2dea7738d794b91a960ee9f41461a4e3ffcd5e44 | https://github.com/TuBui/deep_image_comparator/tree/2dea7738d794b91a960ee9f41461a4e3ffcd5e44 |
GreedyHashLoss | import torch
class GreedyHashLoss(torch.nn.Module):
def __init__(self):
super(GreedyHashLoss, self).__init__()
def forward(self, u):
b = GreedyHashLoss.Hash.apply(u)
loss = (u.abs() - 1).pow(3).abs().mean()
return b, loss
class Hash(torch.autograd.Function):
@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 import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
assert_size_stride = t... | TuBui/deep_image_comparator | GreedyHashLoss | false | 1,154 | [
"MIT"
] | 0 | 2dea7738d794b91a960ee9f41461a4e3ffcd5e44 | https://github.com/TuBui/deep_image_comparator/tree/2dea7738d794b91a960ee9f41461a4e3ffcd5e44 |
MultiHeadAttention | import torch
import numpy as np
import torch.nn as nn
class SelfAttention(nn.Module):
""" Scaled Dot-Product Attention """
def __init__(self, dropout=0.1):
super(SelfAttention, self).__init__()
self.dropout = nn.Dropout(dropout)
def forward(self, query, key, value, mask=None):
ke... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | TranQuocTrinh/image_captioning | MultiHeadAttention | false | 1,155 | [
"MIT"
] | 0 | 4c2d77426ba3b9fe9151a15a958320d5298aa190 | https://github.com/TranQuocTrinh/image_captioning/tree/4c2d77426ba3b9fe9151a15a958320d5298aa190 |
LastBlock | import torch
import numpy as np
import torch.nn as nn
class BatchNormLayer(nn.Module):
"""Implements batch normalization layer."""
def __init__(self, channels, gamma=False, beta=True, decay=0.9, epsilon
=1e-05):
"""Initializes with basic settings.
Args:
channels: Number of 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
import numpy as np
import torch.nn as nn
assert_size_stride = torch._C._dynamo.g... | Twizwei/idinvert_pytorch | LastBlock | false | 1,156 | [
"MIT"
] | 0 | 11f1126aab517fbe32b488d92f6fdea339463d04 | https://github.com/Twizwei/idinvert_pytorch/tree/11f1126aab517fbe32b488d92f6fdea339463d04 |
SineODE | import math
import torch
class SineODE(torch.nn.Module):
def forward(self, t, y):
return 2 * y / t + t ** 4 * torch.sin(2 * t) - t ** 2 + 4 * t ** 3
def y_exact(self, t):
return -0.5 * t ** 4 * torch.cos(2 * t) + 0.5 * t ** 3 * torch.sin(
2 * t) + 0.25 * t ** 2 * torch.cos(2 * 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 math as tl_math
import math
assert_size_stride = torch._C._dynamo.guards.assert_size_stri... | TylerChoi1224/torchdiffeq | SineODE | false | 1,157 | [
"MIT"
] | 0 | 72f74d9651a58ab11cdadd60682f1b61e625ef53 | https://github.com/TylerChoi1224/torchdiffeq/tree/72f74d9651a58ab11cdadd60682f1b61e625ef53 |
ObjectClassifier | import torch
from torch import nn
class ObjectClassifier(nn.Module):
"""
perform log likelihood over sequence data ie. log(softmax), permute dimension
accordingly to meet NLLLoss requirement
Input: [seq_len, bsz, d_input]
Output: [bsz, num_classes, seq_len]
Usage:
bsz=5; seq=16; d_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.... | TuBui/deep_image_comparator | ObjectClassifier | false | 1,158 | [
"MIT"
] | 0 | 2dea7738d794b91a960ee9f41461a4e3ffcd5e44 | https://github.com/TuBui/deep_image_comparator/tree/2dea7738d794b91a960ee9f41461a4e3ffcd5e44 |
ResidualBlock | import torch
import torch.nn as nn
class GenericLayer(nn.Module):
def __init__(self, layer, out_channels, padding=(0, 0, 0, 0),
activation=None):
super(GenericLayer, self).__init__()
self._act = activation
self._layer = layer
self._norm = nn.InstanceNorm2d(out_channels, af... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | ThomasRanvier/cnn_style_transfer | ResidualBlock | false | 1,159 | [
"MIT"
] | 0 | 90b6c76c20263c22f4e45184d572284726ecbd7b | https://github.com/ThomasRanvier/cnn_style_transfer/tree/90b6c76c20263c22f4e45184d572284726ecbd7b |
FirstBlock | import torch
import numpy as np
import torch.nn as nn
class BatchNormLayer(nn.Module):
"""Implements batch normalization layer."""
def __init__(self, channels, gamma=False, beta=True, decay=0.9, epsilon
=1e-05):
"""Initializes with basic settings.
Args:
channels: Number of 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
import numpy as np
import torch.nn as nn
assert_size_stride = torch._C._dynamo.g... | Twizwei/idinvert_pytorch | FirstBlock | false | 1,160 | [
"MIT"
] | 0 | 11f1126aab517fbe32b488d92f6fdea339463d04 | https://github.com/Twizwei/idinvert_pytorch/tree/11f1126aab517fbe32b488d92f6fdea339463d04 |
HR2O_NL | import torch
import torch.nn as nn
class HR2O_NL(nn.Module):
def __init__(self, hidden_dim=512, kernel_size=3, mlp_1x1=False):
super(HR2O_NL, self).__init__()
self.hidden_dim = hidden_dim
padding = kernel_size // 2
self.conv_q = nn.Conv2d(hidden_dim, hidden_dim, kernel_size,
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | StephenStorm/ACAR | HR2O_NL | false | 1,161 | [
"Apache-2.0"
] | 0 | 21ef3eca7330bd62eccb645018c8e48d9fc52153 | https://github.com/StephenStorm/ACAR/tree/21ef3eca7330bd62eccb645018c8e48d9fc52153 |
Gated_Recurrent_Unit | import torch
from torchvision.transforms import functional as F
import torch.utils.data
from torch import nn
import torch.nn.functional as F
class Gated_Recurrent_Unit(nn.Module):
def __init__(self, fea_size, dropout):
super(Gated_Recurrent_Unit, self).__init__()
self.wih = nn.Linear(fea_size, 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 import triton_helpers
import torch.utils.data
from ... | SpartaG117/scene_graph_benchmark | Gated_Recurrent_Unit | false | 1,162 | [
"MIT"
] | 0 | e2e49940dd2f752b1faf9ae26707435ba3441bcb | https://github.com/SpartaG117/scene_graph_benchmark/tree/e2e49940dd2f752b1faf9ae26707435ba3441bcb |
ConstantODE | import torch
class ConstantODE(torch.nn.Module):
def __init__(self):
super(ConstantODE, self).__init__()
self.a = torch.nn.Parameter(torch.tensor(0.2))
self.b = torch.nn.Parameter(torch.tensor(3.0))
def forward(self, t, y):
return self.a + (y - (self.a * t + self.b)) ** 5
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
@triton.j... | TylerChoi1224/torchdiffeq | ConstantODE | false | 1,163 | [
"MIT"
] | 0 | 72f74d9651a58ab11cdadd60682f1b61e625ef53 | https://github.com/TylerChoi1224/torchdiffeq/tree/72f74d9651a58ab11cdadd60682f1b61e625ef53 |
GradientReversal | from torch.autograd import Function
import torch
class GradientReversalFunction(Function):
"""
Gradient Reversal Layer from:
Unsupervised Domain Adaptation by Backpropagation (Ganin & Lempitsky, 2015)
Forward pass is the identity function. In the backward pass,
the upstream gradients are multipli... | 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.autograd import Function
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.gu... | TheElderMindseeker/pytorch-domain-adaptation | GradientReversal | false | 1,164 | [
"MIT"
] | 0 | 70ca862708bd6e59b5eee5d7c8bd808ef3457dc8 | https://github.com/TheElderMindseeker/pytorch-domain-adaptation/tree/70ca862708bd6e59b5eee5d7c8bd808ef3457dc8 |
Decoder | import torch
import torch.nn as nn
class Decoder(nn.Module):
def __init__(self, latent_dim=4, obs_dim=2, nhidden=20):
super(Decoder, self).__init__()
self.relu = nn.ReLU(inplace=True)
self.fc1 = nn.Linear(latent_dim, nhidden)
self.fc2 = nn.Linear(nhidden, obs_dim)
def forward... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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_... | TylerChoi1224/torchdiffeq | Decoder | false | 1,165 | [
"MIT"
] | 0 | 72f74d9651a58ab11cdadd60682f1b61e625ef53 | https://github.com/TylerChoi1224/torchdiffeq/tree/72f74d9651a58ab11cdadd60682f1b61e625ef53 |
WeighedMSELoss | import torch
from torch import Tensor
from torch.nn import MSELoss
class WeighedMSELoss(MSELoss):
def __init__(self, weights):
super().__init__(reduction='none')
self.weights = weights
def forward(self, input: 'Tensor', target: 'Tensor') ->Tensor:
loss = super().forward(input, target... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch.nn import MSELoss
assert_size_stride = torch._C._dynamo.guards.assert_size_str... | UT-ADL/lidar-as-camera | WeighedMSELoss | false | 1,166 | [
"Apache-2.0"
] | 0 | daccb2ae21b4899ecfd8611b7a27f91681617383 | https://github.com/UT-ADL/lidar-as-camera/tree/daccb2ae21b4899ecfd8611b7a27f91681617383 |
LanguageModelCriterion | import torch
import torch.nn as nn
from torch.autograd import *
class LanguageModelCriterion(nn.Module):
def __init__(self):
super(LanguageModelCriterion, self).__init__()
def forward(self, input, target, mask):
if target.ndim == 3:
target = target.reshape(-1, target.shape[2])
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
from torch.autograd import *
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torc... | VISLANG-Lab/MGCL | LanguageModelCriterion | false | 1,167 | [
"MIT"
] | 0 | 22da06ffa7410d9632bfda8eefb1b79e4f660de0 | https://github.com/VISLANG-Lab/MGCL/tree/22da06ffa7410d9632bfda8eefb1b79e4f660de0 |
PoolFormerBlock | import math
import torch
import warnings
import torch.nn as nn
def _no_grad_trunc_normal_(tensor, mean, std, a, b):
"""Copy & paste from PyTorch official master until it's in a few official releases - RW
Method based on https://people.sc.fsu.edu/~jburkardt/presentations/truncated_normal.pdf
"""
def 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 math
import ... | TranNhiem/solo-learn | PoolFormerBlock | false | 1,168 | [
"MIT"
] | 0 | 7539732b68d153087d09a26a23e1edfdc49bc086 | https://github.com/TranNhiem/solo-learn/tree/7539732b68d153087d09a26a23e1edfdc49bc086 |
SelfAttn | import torch
from torch import nn
import torch.nn.functional as F
class SelfAttn(nn.Module):
"""
Self attention layer: aggreagating a sequence into a single vector.
This implementation uses the attention formula proposed by Sukhbaatar etal. 2015
https://papers.nips.cc/paper/5846-end-to-end-memory-net... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | TuBui/deep_image_comparator | SelfAttn | false | 1,169 | [
"MIT"
] | 0 | 2dea7738d794b91a960ee9f41461a4e3ffcd5e44 | https://github.com/TuBui/deep_image_comparator/tree/2dea7738d794b91a960ee9f41461a4e3ffcd5e44 |
SinkhornKnopp | import torch
import torch.distributed as dist
class SinkhornKnopp(torch.nn.Module):
def __init__(self, num_iters: 'int'=3, epsilon: 'float'=0.05,
world_size: 'int'=1):
"""Approximates optimal transport using the Sinkhorn-Knopp algorithm.
A simple iterative method to approach the double 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
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_str... | TranNhiem/solo-learn | SinkhornKnopp | false | 1,170 | [
"MIT"
] | 0 | 7539732b68d153087d09a26a23e1edfdc49bc086 | https://github.com/TranNhiem/solo-learn/tree/7539732b68d153087d09a26a23e1edfdc49bc086 |
RewardCriterion | import torch
import torch.nn as nn
from torch.autograd import *
class RewardCriterion(nn.Module):
def __init__(self):
super(RewardCriterion, self).__init__()
def forward(self, input, seq, reward):
input = input.gather(2, seq.unsqueeze(2)).squeeze(2)
input = input.reshape(-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
import torch.nn as nn
from torch.autograd import *
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torc... | VISLANG-Lab/MGCL | RewardCriterion | false | 1,171 | [
"MIT"
] | 0 | 22da06ffa7410d9632bfda8eefb1b79e4f660de0 | https://github.com/VISLANG-Lab/MGCL/tree/22da06ffa7410d9632bfda8eefb1b79e4f660de0 |
ResBlock | import torch
import torch.nn as nn
def conv3x3(in_planes, out_planes, stride=1):
"""3x3 convolution with padding"""
return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride,
padding=1, bias=False)
def norm(dim):
return nn.GroupNorm(min(32, dim), dim)
class ResBlock(nn.Module):
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | TylerChoi1224/torchdiffeq | ResBlock | false | 1,172 | [
"MIT"
] | 0 | 72f74d9651a58ab11cdadd60682f1b61e625ef53 | https://github.com/TylerChoi1224/torchdiffeq/tree/72f74d9651a58ab11cdadd60682f1b61e625ef53 |
MultiheadAttention | import torch
import torch.nn as nn
class MultiheadAttention(nn.Module):
"""A warpper for torch.nn.MultiheadAttention.
This module implements MultiheadAttention with residual connection,
and positional encoding used in DETR is also passed as input.
Args:
embed_dims (int): The embedding dimens... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | VIRC-lab-csust/AGMNet | MultiheadAttention | false | 1,173 | [
"Apache-2.0"
] | 0 | ead95466da343cf9436774138c642d2ca12da4e4 | https://github.com/VIRC-lab-csust/AGMNet/tree/ead95466da343cf9436774138c642d2ca12da4e4 |
Model | import torch
import numpy as np
import torch.nn.functional as F
import torch.nn as nn
class Model(nn.Module):
def __init__(self, input_size, action_dim, conv=False, conv_size=16,
fc_size=32, K=2):
super(Model, self).__init__()
self.input_size = input_size
self.input_h = int(np.sqr... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import numpy as np
import tor... | VashishtMadhavan/pytorch-maml-rl | Model | false | 1,174 | [
"MIT"
] | 0 | d8821b8374d973869bb6a1393f1b2c369c9a664b | https://github.com/VashishtMadhavan/pytorch-maml-rl/tree/d8821b8374d973869bb6a1393f1b2c369c9a664b |
SoftClDiceLoss | import torch
import numpy as np
from torch import nn
import torch.jit
import torch.nn.functional as F
import torch.nn.functional
def sum_tensor(inp, axes, keepdim=False):
axes = np.unique(axes).astype(int)
if keepdim:
for ax in axes:
inp = inp.sum(int(ax), keepdim=True)
else:
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
import numpy as np
from torch import nn
import torch.jit
import torch.nn.functional as F
... | CamilaGL/nnUNet | SoftClDiceLoss | false | 1,175 | [
"Apache-2.0"
] | 0 | 471ab73a6e4f67fc72d476183b5344be4cccf7ca | https://github.com/CamilaGL/nnUNet/tree/471ab73a6e4f67fc72d476183b5344be4cccf7ca |
ConvLayer | import torch
import torch.nn as nn
import torch.nn.functional as F
class ConvLayer(nn.Module):
"""A Convolutional Layer"""
def __init__(self, in_channels=1, out_channels=256, kernel_size=9, stride=1
):
super(ConvLayer, self).__init__()
self.conv = nn.Conv2d(in_channels, out_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
import torch.nn as nn
assert_... | VIVelev/capsnets | ConvLayer | false | 1,176 | [
"MIT"
] | 0 | dca4bfcd4007977a6bc3534a4676880326fcf94a | https://github.com/VIVelev/capsnets/tree/dca4bfcd4007977a6bc3534a4676880326fcf94a |
MultiHeadAttention | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
class MultiHeadAttention(nn.Module):
"""Multi-headed Attention for input Query, Key, Value
Multi-headed Attention is a module for attention mechanisms which runs through attention in several times in
parallel, then the multiple... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | UdbhavPrasad072300/Kaggle-Competition-Templates | MultiHeadAttention | false | 1,177 | [
"MIT"
] | 0 | f3c93ff60ae33af9b6c6d79d30c5099eb250396c | https://github.com/UdbhavPrasad072300/Kaggle-Competition-Templates/tree/f3c93ff60ae33af9b6c6d79d30c5099eb250396c |
WeighedL1Loss | import torch
from torch import Tensor
from torch.nn import L1Loss
class WeighedL1Loss(L1Loss):
def __init__(self, weights):
super().__init__(reduction='none')
self.weights = weights
def forward(self, input: 'Tensor', target: 'Tensor') ->Tensor:
loss = super().forward(input, target)
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
from torch.nn import L... | UT-ADL/lidar-as-camera | WeighedL1Loss | false | 1,178 | [
"Apache-2.0"
] | 0 | daccb2ae21b4899ecfd8611b7a27f91681617383 | https://github.com/UT-ADL/lidar-as-camera/tree/daccb2ae21b4899ecfd8611b7a27f91681617383 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.