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 |
|---|---|---|---|---|---|---|---|---|---|---|
NetRVlad | import torch
import torch.nn as nn
def _moveaxis(tensor: 'torch.Tensor', source: 'int', destination: 'int'
) ->torch.Tensor:
dim = tensor.dim()
perm = list(range(dim))
if destination < 0:
destination += dim
perm.pop(source)
perm.insert(destination, source)
return tensor.permute(*pe... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | TheoMoutakanni/hcrn-videoqa | NetRVlad | false | 2,905 | [
"Apache-2.0"
] | 0 | 03a0fb1f24d756e7cd61d519f92925b610a91a29 | https://github.com/TheoMoutakanni/hcrn-videoqa/tree/03a0fb1f24d756e7cd61d519f92925b610a91a29 |
Swish | import torch
import torch.nn as nn
import torch.distributed
class Swish(nn.Module):
def __init__(self):
super(Swish, self).__init__()
self.beta = nn.Parameter(torch.tensor(1.0))
def forward(self, x):
return x * torch.sigmoid(self.beta * x)
def get_inputs():
return [torch.rand([... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
import torch.distributed
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C... | Ugness/PointFlow | Swish | false | 2,906 | [
"MIT"
] | 0 | 238489c70b0332526cb2d506ab3e076fae20685d | https://github.com/Ugness/PointFlow/tree/238489c70b0332526cb2d506ab3e076fae20685d |
MultiHeadedAttention | import math
import torch
from torch import Tensor
import torch.nn as nn
class MultiHeadedAttention(nn.Module):
"""
Multi-Head Attention module from "Attention is All You Need"
Implementation modified from OpenNMT-py.
https://github.com/OpenNMT/OpenNMT-py
"""
def __init__(self, num_heads: 'in... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | Tim-blo/ACTOR | MultiHeadedAttention | false | 2,907 | [
"MIT"
] | 0 | f10d7534a34fa557ab6b1739217649ae4f654505 | https://github.com/Tim-blo/ACTOR/tree/f10d7534a34fa557ab6b1739217649ae4f654505 |
EntityLayer | import torch
import torch.nn as nn
class EntityLayer(nn.Module):
def __init__(self, initial_size, layer_size, device='cpu'):
super(EntityLayer, self).__init__()
self.weights_ent = nn.Linear(initial_size, layer_size, bias=False)
self.init_params()
self
def init_params(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.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | TraianVidrascu/DGAT | EntityLayer | false | 2,908 | [
"Apache-2.0"
] | 0 | 8855634d6262dec867512880442429918a9ee4b4 | https://github.com/TraianVidrascu/DGAT/tree/8855634d6262dec867512880442429918a9ee4b4 |
MyNetwork | from torch.nn import Module
import random
import torch
import torch.nn as nn
import torch.optim as optim
from torch.utils.data import DataLoader
from torch.utils.data import TensorDataset
class MyNetwork(Module):
def __init__(self, size_input, size_hidden, size_output):
"""Create simple network"""
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | Thijsvanede/torch-train | MyNetwork | false | 2,909 | [
"MIT"
] | 0 | e10c64b1d61f9cdfb84b2645a196be4379851a1a | https://github.com/Thijsvanede/torch-train/tree/e10c64b1d61f9cdfb84b2645a196be4379851a1a |
MergeLayer | import torch
import torch.nn as nn
class MergeLayer(nn.Module):
def __init__(self, h_size, device='cpu'):
super(MergeLayer, self).__init__()
self.weight_inbound = nn.Linear(h_size, h_size, bias=True)
self.weight_outbound = nn.Linear(h_size, h_size, bias=True)
self.lambda_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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | TraianVidrascu/DGAT | MergeLayer | false | 2,910 | [
"Apache-2.0"
] | 0 | 8855634d6262dec867512880442429918a9ee4b4 | https://github.com/TraianVidrascu/DGAT/tree/8855634d6262dec867512880442429918a9ee4b4 |
LayerNormAVG | import torch
import torch.nn as nn
import torch.cuda
import torch.distributed
class LayerNormAVG(nn.Module):
"""
Layer Normalization class inspired by Transformer normalization, but here we normalize to given average
to preserve magnitue of USE
"""
def __init__(self, features, desired_avg... | 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.distributed
assert_size_st... | USE-sum/usesum | LayerNormAVG | false | 2,911 | [
"MIT"
] | 0 | eaf6dae0c451459551f728c0a8866777c20ed707 | https://github.com/USE-sum/usesum/tree/eaf6dae0c451459551f728c0a8866777c20ed707 |
PreProcess | import torch
import torch.nn as nn
class PreProcess(nn.Module):
def __init__(self):
"""
Blocco di pre-processing delle immagini. Prende il tensore in ingresso nella forma
(batch, width, height, channel), lo permuta e lo normalizza tra 0 e 1.
"""
super(PreProcess, self).__i... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | UnibsMatt/NN | PreProcess | false | 2,912 | [
"MIT"
] | 0 | 25eaddc079cd08227a52fdebd95453473fcd3b29 | https://github.com/UnibsMatt/NN/tree/25eaddc079cd08227a52fdebd95453473fcd3b29 |
CrossEntropyLossWithSoftLabel | import torch
from torch.nn import *
from torch.optim import *
from torch.optim.lr_scheduler import *
class CrossEntropyLossWithSoftLabel(torch.nn.Module):
def __init__(self, reduction='mean'):
super().__init__()
self.reduction = reduction
self.logsoftmax = torch.nn.LogSoftmax(dim=1)
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
from torch.nn import *... | UNIST-LIM-Lab/NeuBoots | CrossEntropyLossWithSoftLabel | false | 2,913 | [
"MIT"
] | 0 | 196adf9e1ece2abc145f69966504bac2676e5b5e | https://github.com/UNIST-LIM-Lab/NeuBoots/tree/196adf9e1ece2abc145f69966504bac2676e5b5e |
Accuracy | import torch
from torch.nn import *
from torch.optim import *
from torch.optim.lr_scheduler import *
class Accuracy(torch.nn.Module):
def __init__(self, reduction='mean', nlabels=5):
super().__init__()
self.reduction = reduction
self.nlabels = nlabels
def forward(self, 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 *
from torch.optim import *
from torch.optim.lr_scheduler import *
a... | UNIST-LIM-Lab/NeuBoots | Accuracy | false | 2,914 | [
"MIT"
] | 0 | 196adf9e1ece2abc145f69966504bac2676e5b5e | https://github.com/UNIST-LIM-Lab/NeuBoots/tree/196adf9e1ece2abc145f69966504bac2676e5b5e |
NextSentencePrediction | import torch
import torch.nn as nn
import torch.cuda
import torch.distributed
class NextSentencePrediction(nn.Module):
"""
2-class classification model : is_next, is_random_next
Args:
hidden_size (int): BERT model output size
"""
def __init__(self, hidden_size):
super(NextSen... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | SivilTaram/dialogue-utterance-rewriter-pytorch | NextSentencePrediction | false | 2,915 | [
"MIT"
] | 0 | 92c2254958b7a1ee9199836f7f2236575270983f | https://github.com/SivilTaram/dialogue-utterance-rewriter-pytorch/tree/92c2254958b7a1ee9199836f7f2236575270983f |
IoULoss | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.parallel
import torch.optim
import torch.utils.data.distributed
class IoULoss(nn.Module):
"""
Creates a criterion that computes the Intersection over Union (IoU)
between a segmentation mask and its ground truth.
Rahman... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
import torch.nn.parallel
import torch.optim
import torch.utils.data... | TransformersWsz/onestage_grounding | IoULoss | false | 2,916 | [
"MIT"
] | 0 | c939a7d5d7c7f9e1bfa8df2e6269397b8f840b5a | https://github.com/TransformersWsz/onestage_grounding/tree/c939a7d5d7c7f9e1bfa8df2e6269397b8f840b5a |
GELU | import math
import torch
import torch.nn as nn
import torch.cuda
import torch.distributed
class GELU(nn.Module):
""" Implementation of the gelu activation function
:cite:`DBLP:journals/corr/HendrycksG16`
For information: OpenAI GPT's gelu is slightly different
(and gives slightly differen... | 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.distributed
assert_size_st... | SivilTaram/dialogue-utterance-rewriter-pytorch | GELU | false | 2,917 | [
"MIT"
] | 0 | 92c2254958b7a1ee9199836f7f2236575270983f | https://github.com/SivilTaram/dialogue-utterance-rewriter-pytorch/tree/92c2254958b7a1ee9199836f7f2236575270983f |
BertPredictionTransform | import math
import torch
import torch.nn as nn
import torch.cuda
import torch.distributed
def get_activation_fn(activation):
"""Return an activation function Module according to its name."""
if activation == 'gelu':
fn = GELU()
elif activation == 'relu':
fn = nn.ReLU()
elif activation ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import math
import ... | SivilTaram/dialogue-utterance-rewriter-pytorch | BertPredictionTransform | false | 2,918 | [
"MIT"
] | 0 | 92c2254958b7a1ee9199836f7f2236575270983f | https://github.com/SivilTaram/dialogue-utterance-rewriter-pytorch/tree/92c2254958b7a1ee9199836f7f2236575270983f |
CrossEntropyLossSoft | import torch
import torch.nn.parallel
import torch.optim
import torch.utils.data
import torch.utils.data.distributed
import torch.utils
class CrossEntropyLossSoft(torch.nn.modules.loss._Loss):
""" inplace distillation for image classification """
def forward(self, output, target):
output_log_prob = t... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | Ren-Research/maestro | CrossEntropyLossSoft | false | 2,919 | [
"MIT"
] | 0 | b89e171d51ec910b165b9b01dd8373848a6207f7 | https://github.com/Ren-Research/maestro/tree/b89e171d51ec910b165b9b01dd8373848a6207f7 |
ActionApproximation | import torch
class ActionApproximation(torch.nn.Module):
def __init__(self, state_observations_count, action_count, hidden_count=512
):
super(ActionApproximation, self).__init__()
self.ReLU = torch.nn.ReLU()
self.dense0 = torch.nn.Linear(state_observations_count, hidden_count)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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... | Unn20/achtung_die_kurve | ActionApproximation | false | 2,920 | [
"MIT"
] | 0 | e2dbb1752c070cfc398e415d5a427384c0230f3c | https://github.com/Unn20/achtung_die_kurve/tree/e2dbb1752c070cfc398e415d5a427384c0230f3c |
AsymmetricLoss | import torch
from torchvision import datasets as datasets
import torch.nn as nn
import torch.nn.parallel
import torch.optim
import torch.utils.data.distributed
class AsymmetricLoss(nn.Module):
def __init__(self, gamma_neg=4, gamma_pos=1, clip=0.05, eps=1e-08,
disable_torch_grad_focal_loss=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 import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torchv... | MinliangLin/ASL | AsymmetricLoss | false | 2,921 | [
"MIT"
] | 0 | beda0989a8e30ac51a7ce9f9e247a12bbe84ec96 | https://github.com/MinliangLin/ASL/tree/beda0989a8e30ac51a7ce9f9e247a12bbe84ec96 |
AverageAttention | import math
import torch
import torch.nn as nn
import torch.cuda
import torch.distributed
def get_activation_fn(activation):
"""Return an activation function Module according to its name."""
if activation == 'gelu':
fn = GELU()
elif activation == 'relu':
fn = nn.ReLU()
elif activation ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import math
import torch.nn as nn
import torch.cuda
import torch.distributed
ass... | SivilTaram/dialogue-utterance-rewriter-pytorch | AverageAttention | false | 2,922 | [
"MIT"
] | 0 | 92c2254958b7a1ee9199836f7f2236575270983f | https://github.com/SivilTaram/dialogue-utterance-rewriter-pytorch/tree/92c2254958b7a1ee9199836f7f2236575270983f |
MaskedLanguageModel | import math
import torch
import torch.nn as nn
import torch.cuda
import torch.distributed
def get_activation_fn(activation):
"""Return an activation function Module according to its name."""
if activation == 'gelu':
fn = GELU()
elif activation == 'relu':
fn = nn.ReLU()
elif activation ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | SivilTaram/dialogue-utterance-rewriter-pytorch | MaskedLanguageModel | false | 2,923 | [
"MIT"
] | 0 | 92c2254958b7a1ee9199836f7f2236575270983f | https://github.com/SivilTaram/dialogue-utterance-rewriter-pytorch/tree/92c2254958b7a1ee9199836f7f2236575270983f |
CNN_decoder_attention | import torch
import torch.nn as nn
import torch.nn.init as init
class CNN_decoder_attention(nn.Module):
def __init__(self, input_size, output_size, stride=2):
super(CNN_decoder_attention, self).__init__()
self.input_size = input_size
self.output_size = output_size
self.relu = nn.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._inductor.runtime.... | Qin-Folks/graph-generation | CNN_decoder_attention | false | 2,924 | [
"MIT"
] | 0 | afe1b697272b0e683b4551918de36f57f714e70b | https://github.com/Qin-Folks/graph-generation/tree/afe1b697272b0e683b4551918de36f57f714e70b |
Model | import torch
import torch.nn as nn
import torch.hub
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self):
super(Model, self).__init__()
self.conv1 = nn.Conv2d(1, 20, 5)
self.conv2 = nn.Conv2d(20, 20, 5)
def forward(self, x):
x = F.relu(self.conv1(x))
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
import ... | UoA-CARES/BuilT-NLP | Model | false | 2,925 | [
"MIT"
] | 0 | 761798cbce51d91ec24171e9159413e51c0e0e62 | https://github.com/UoA-CARES/BuilT-NLP/tree/761798cbce51d91ec24171e9159413e51c0e0e62 |
Decoder | import torch
import torch.nn as nn
class Decoder(nn.Module):
def __init__(self, h_dim, n_chan, out_dim):
super(Decoder, self).__init__()
self.h_dim = h_dim
self.n_chan = n_chan
self.decoding = nn.Linear(h_dim, out_dim)
def forward(self, x):
x = torch.stack([self.decod... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | VDelv/Spatio-Temporal-EEG-Analysis | Decoder | false | 2,926 | [
"BSD-3-Clause"
] | 0 | 7207e642da013e19dfd4316a22b597a93ce59581 | https://github.com/VDelv/Spatio-Temporal-EEG-Analysis/tree/7207e642da013e19dfd4316a22b597a93ce59581 |
PositionwiseFeedForward | import math
import torch
import torch.nn as nn
import torch.cuda
import torch.distributed
def get_activation_fn(activation):
"""Return an activation function Module according to its name."""
if activation == 'gelu':
fn = GELU()
elif activation == 'relu':
fn = nn.ReLU()
elif activation ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | SivilTaram/dialogue-utterance-rewriter-pytorch | PositionwiseFeedForward | false | 2,927 | [
"MIT"
] | 0 | 92c2254958b7a1ee9199836f7f2236575270983f | https://github.com/SivilTaram/dialogue-utterance-rewriter-pytorch/tree/92c2254958b7a1ee9199836f7f2236575270983f |
ContrastiveLoss | import torch
class ContrastiveLoss(torch.nn.Module):
"""
Contrastive loss function.
Based on: http://yann.lecun.com/exdb/publis/pdf/hadsell-chopra-lecun-06.pdf
"""
def __init__(self, margin=2.0):
super(ContrastiveLoss, self).__init__()
self.margin = margin
def forward(self, d... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torc... | VictorCallejas/FB-Similarity-Challenge | ContrastiveLoss | false | 2,928 | [
"MIT"
] | 0 | 0092071f29d5d8fab055d27a1e542e2e64e9cdab | https://github.com/VictorCallejas/FB-Similarity-Challenge/tree/0092071f29d5d8fab055d27a1e542e2e64e9cdab |
CaricatureLoss | import torch
import torch.nn as nn
import torch.nn.functional as F
def resize_4d_tensor_by_size(x, height, width):
res = F.interpolate(x, size=(height, width), mode='bilinear')
return res
class CaricatureLoss(nn.Module):
def __init__(self, power=1.0):
super().__init__()
self.power = pow... | 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... | Tiamat-Tech/torch-dreams | CaricatureLoss | false | 2,929 | [
"MIT"
] | 0 | e1c1795f0a0007f54293c474de5d2b80ee829ab8 | https://github.com/Tiamat-Tech/torch-dreams/tree/e1c1795f0a0007f54293c474de5d2b80ee829ab8 |
BertPreTrainingHeads | import math
import torch
import torch.nn as nn
import torch.cuda
import torch.distributed
def get_activation_fn(activation):
"""Return an activation function Module according to its name."""
if activation == 'gelu':
fn = GELU()
elif activation == 'relu':
fn = nn.ReLU()
elif activation ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | SivilTaram/dialogue-utterance-rewriter-pytorch | BertPreTrainingHeads | false | 2,930 | [
"MIT"
] | 0 | 92c2254958b7a1ee9199836f7f2236575270983f | https://github.com/SivilTaram/dialogue-utterance-rewriter-pytorch/tree/92c2254958b7a1ee9199836f7f2236575270983f |
TripletLoss | import torch
import torch.nn as nn
class TripletLoss(torch.nn.Module):
"""
Triplet loss function.
"""
def __init__(self, margin=2.0):
super(TripletLoss, self).__init__()
self.margin = margin
def forward(self, anchor, positive, negative):
squarred_distance_1 = (anchor - po... | 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
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torc... | VictorCallejas/FB-Similarity-Challenge | TripletLoss | false | 2,931 | [
"MIT"
] | 0 | 0092071f29d5d8fab055d27a1e542e2e64e9cdab | https://github.com/VictorCallejas/FB-Similarity-Challenge/tree/0092071f29d5d8fab055d27a1e542e2e64e9cdab |
QuadrupletLoss | import torch
import torch.nn as nn
class QuadrupletLoss(torch.nn.Module):
"""
Quadruplet loss function.
Builds on the Triplet Loss and takes 4 data input: one anchor, one positive and two negative examples. The negative examples needs not to be matching the anchor, the positive and each other.
"""
... | 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
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torc... | VictorCallejas/FB-Similarity-Challenge | QuadrupletLoss | false | 2,932 | [
"MIT"
] | 0 | 0092071f29d5d8fab055d27a1e542e2e64e9cdab | https://github.com/VictorCallejas/FB-Similarity-Challenge/tree/0092071f29d5d8fab055d27a1e542e2e64e9cdab |
CatDotProdAttention | import torch
import torch.nn as nn
import torch.nn.functional as F
class CatDotProdAttention(nn.Module):
"""Dot-Production Attention concatenated with query values
Attribute:
linear (nn.Linear): linear layer to compress output
"""
def __init__(self, dim):
super().__init__()
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | Tzu-An/ml_seq2seq_attn | CatDotProdAttention | false | 2,933 | [
"Apache-2.0"
] | 0 | 1f29b1156c5e66e2bb5255c6d214c70162c91528 | https://github.com/Tzu-An/ml_seq2seq_attn/tree/1f29b1156c5e66e2bb5255c6d214c70162c91528 |
TorchFlattenNet | import torch
class TorchFlattenNet(torch.nn.Module):
def __init__(self):
super(TorchFlattenNet, self).__init__()
self.conv1 = torch.nn.Conv2d(1, 32, 3, 1)
def forward(self, x):
x = self.conv1(x)
return torch.flatten(x, 1)
def get_inputs():
return [torch.rand([4, 1, 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
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
reinterpret_tens... | TomokiHirose/convert_diff_fw_params | TorchFlattenNet | false | 2,934 | [
"MIT"
] | 0 | ba574ea52ae5574c9fbaabd340b8ccd0bf9ab5c5 | https://github.com/TomokiHirose/convert_diff_fw_params/tree/ba574ea52ae5574c9fbaabd340b8ccd0bf9ab5c5 |
BahdanauAttention | import torch
import torch.nn as nn
class BahdanauAttention(nn.Module):
"""
Bahdanau Attention.
Reference:
https://blog.floydhub.com/attention-mechanism/#bahdanau-att-step1 --> Attention Mechanism
https://github.com/sgrvinod/a-PyTorch-Tutorial-to-Image-Captioning --> PyTorch Image Captioning
""... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | Ventu012/P2_Image_Captioning | BahdanauAttention | false | 2,935 | [
"MIT"
] | 0 | 320e620145205efbc9222ad0f840469c0ec8d091 | https://github.com/Ventu012/P2_Image_Captioning/tree/320e620145205efbc9222ad0f840469c0ec8d091 |
Actor | import torch
import torch.nn as nn
import torch.nn.functional as F
class Actor(nn.Module):
def __init__(self, state_dim, action_dim, max_action):
super(Actor, self).__init__()
self.l1 = nn.Linear(state_dim, 400)
self.l2 = nn.Linear(400, 300)
self.l3 = nn.Linear(300, action_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._inductor.runtime.... | VasaKiDD/TD3-deep-rl-research | Actor | false | 2,936 | [
"Apache-2.0"
] | 0 | f75b2f86f3b7969a82fc4b7f9ea2b62de3616217 | https://github.com/VasaKiDD/TD3-deep-rl-research/tree/f75b2f86f3b7969a82fc4b7f9ea2b62de3616217 |
PositionalEncoding | import torch
import numpy as np
import torch.nn as nn
class PositionalEncoding(nn.Module):
def __init__(self, module_dim=512, dropout=0.1, max_len=5000):
super(PositionalEncoding, self).__init__()
self.dropout = nn.Dropout(p=dropout)
pe = torch.zeros(max_len, module_dim)
position ... | 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 numpy as np
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dyna... | TheoMoutakanni/hcrn-videoqa | PositionalEncoding | false | 2,937 | [
"Apache-2.0"
] | 0 | 03a0fb1f24d756e7cd61d519f92925b610a91a29 | https://github.com/TheoMoutakanni/hcrn-videoqa/tree/03a0fb1f24d756e7cd61d519f92925b610a91a29 |
SolutionModel | import torch
import torch.nn as nn
import torch.nn.functional as F
class SolutionModel(nn.Module):
def __init__(self, input_size, output_size):
super(SolutionModel, self).__init__()
self.input_size = input_size
self.hidden_size = 32
self.linear1 = nn.Linear(input_size, self.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
import torch.nn as nn
assert_... | VVKot/mlinseconds-vote-prediction | SolutionModel | false | 2,938 | [
"MIT"
] | 0 | c869ae428fb8d5e83f0a47468722da968aed28c6 | https://github.com/VVKot/mlinseconds-vote-prediction/tree/c869ae428fb8d5e83f0a47468722da968aed28c6 |
Curiosity | import torch
import torch.nn as nn
import torch.nn.functional as F
class Curiosity(nn.Module):
def __init__(self, state_dim):
super(Curiosity, self).__init__()
self.l1 = nn.Linear(state_dim, 400)
self.l2 = nn.Linear(400, 300)
self.l3 = nn.Linear(300, 1)
self.sigmoid = nn.S... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | VasaKiDD/TD3-deep-rl-research | Curiosity | false | 2,939 | [
"Apache-2.0"
] | 0 | f75b2f86f3b7969a82fc4b7f9ea2b62de3616217 | https://github.com/VasaKiDD/TD3-deep-rl-research/tree/f75b2f86f3b7969a82fc4b7f9ea2b62de3616217 |
LinearModel | import torch
import torch.nn as nn
class LinearModel(nn.Module):
def __init__(self, input_size, output_size, hidden_size):
super(LinearModel, self).__init__()
self.linear1 = nn.Linear(input_size, hidden_size)
self.linear2 = nn.Linear(hidden_size, hidden_size)
self.linear3 = 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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | VVKot/mlinseconds-vote-prediction | LinearModel | false | 2,940 | [
"MIT"
] | 0 | c869ae428fb8d5e83f0a47468722da968aed28c6 | https://github.com/VVKot/mlinseconds-vote-prediction/tree/c869ae428fb8d5e83f0a47468722da968aed28c6 |
Net | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch import save as save
from torch import load as load
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.l1 = nn.Linear(784, 520)
self.l2 = nn.Linear(520, 320)
self.l3 = nn.Linear(32... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
from to... | UoA-sjer215/2021-python-41 | Net | false | 2,941 | [
"Apache-2.0"
] | 0 | b27094f5915395636fa85ad6a4a9751c7224c345 | https://github.com/UoA-sjer215/2021-python-41/tree/b27094f5915395636fa85ad6a4a9751c7224c345 |
down_right_shifted_conv2d | import torch
import torch.nn as nn
from torch.nn.utils import weight_norm as wn
def right_shift(x, pad=None):
xs = [int(y) for y in x.size()]
x = x[:, :, :, :xs[3] - 1]
pad = nn.ZeroPad2d((1, 0, 0, 0)) if pad is None else pad
return pad(x)
class down_right_shifted_conv2d(nn.Module):
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.nn as ... | VahidZee/PixelCnnPP | down_right_shifted_conv2d | false | 2,942 | [
"MIT"
] | 0 | b0d7bffb3cc18263e55d7851f60f5682ba09e5c2 | https://github.com/VahidZee/PixelCnnPP/tree/b0d7bffb3cc18263e55d7851f60f5682ba09e5c2 |
ConvolModel | import torch
import torch.nn as nn
import torch.nn.functional as F
class ConvolModel(nn.Module):
def __init__(self):
super(ConvolModel, self).__init__()
self.conv1 = nn.Conv2d(1, 5, 2)
self.conv2 = nn.Conv2d(5, 10, 2)
self.conv3 = nn.Conv2d(10, 10, 2)
def forward(self, x):
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | VVKot/mlinseconds-vote-prediction | ConvolModel | false | 2,943 | [
"MIT"
] | 0 | c869ae428fb8d5e83f0a47468722da968aed28c6 | https://github.com/VVKot/mlinseconds-vote-prediction/tree/c869ae428fb8d5e83f0a47468722da968aed28c6 |
nin | import torch
import torch.nn as nn
from torch.nn.utils import weight_norm as wn
class nin(nn.Module):
def __init__(self, dim_in, dim_out):
super(nin, self).__init__()
self.lin_a = wn(nn.Linear(dim_in, dim_out))
self.dim_out = dim_out
def forward(self, x):
""" a network in 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.triton_helpers import libdevice
import torch.nn as ... | VahidZee/PixelCnnPP | nin | false | 2,944 | [
"MIT"
] | 0 | b0d7bffb3cc18263e55d7851f60f5682ba09e5c2 | https://github.com/VahidZee/PixelCnnPP/tree/b0d7bffb3cc18263e55d7851f60f5682ba09e5c2 |
SELayer | import torch
import torch.nn as nn
import torch.nn.parallel
import torch.optim
import torch.utils.data
import torch.utils.data.distributed
import torchvision.transforms.functional as F
import torch.nn.functional as F
from collections import OrderedDict
import torch.utils
def make_divisible(v, divisor=8, min_value=1):... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
import ... | Ren-Research/maestro | SELayer | false | 2,945 | [
"MIT"
] | 0 | b89e171d51ec910b165b9b01dd8373848a6207f7 | https://github.com/Ren-Research/maestro/tree/b89e171d51ec910b165b9b01dd8373848a6207f7 |
KnowledgeDistillationLoss | import torch
import torch.nn as nn
class KnowledgeDistillationLoss(nn.Module):
def __init__(self, reduction='mean', alpha=1.0):
super().__init__()
self.reduction = reduction
self.alpha = alpha
def forward(self, inputs, targets, mask=None):
inputs = inputs.narrow(1, 0, targets... | 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
... | VitoPalmisano/MiB_BiSeNet_SEAM_test | KnowledgeDistillationLoss | false | 2,946 | [
"MIT"
] | 0 | 7b74beb69f135c0bb843ee24c90c3097ce448eec | https://github.com/VitoPalmisano/MiB_BiSeNet_SEAM_test/tree/7b74beb69f135c0bb843ee24c90c3097ce448eec |
down_shifted_conv2d | import torch
import torch.nn as nn
from torch.nn.utils import weight_norm as wn
def down_shift(x, pad=None):
xs = [int(y) for y in x.size()]
x = x[:, :, :xs[2] - 1, :]
pad = nn.ZeroPad2d((0, 0, 1, 0)) if pad is None else pad
return pad(x)
class down_shifted_conv2d(nn.Module):
def __init__(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.triton_helpers import libdevice
import torch.nn as ... | VahidZee/PixelCnnPP | down_shifted_conv2d | false | 2,947 | [
"MIT"
] | 0 | b0d7bffb3cc18263e55d7851f60f5682ba09e5c2 | https://github.com/VahidZee/PixelCnnPP/tree/b0d7bffb3cc18263e55d7851f60f5682ba09e5c2 |
MyConv1dPadSame | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
from itertools import product as product
from math import sqrt as sqrt
class MyConv1dPadSame(nn.Module):
"""
extend nn.Conv1d to support SAME padding
"""
def __init__(self, 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
import torch.nn as nn
import torch.utils.data
from itertools import product as p... | WFDetector/WFDetection | MyConv1dPadSame | false | 2,949 | [
"Apache-2.0"
] | 0 | b16d35b3a3a5de62de9e0bac83eccd21b6358b53 | https://github.com/WFDetector/WFDetection/tree/b16d35b3a3a5de62de9e0bac83eccd21b6358b53 |
ClassificationCircleLoss | import torch
import torch.nn as nn
from typing import Tuple
import torch.utils.data
from torch.nn.functional import cross_entropy
from itertools import product as product
from math import sqrt as sqrt
class ClassificationCircleLoss(nn.Module):
"""Circle loss for class-level labels as described in the paper
`"... | 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
... | WFDetector/WFDetection | ClassificationCircleLoss | false | 2,950 | [
"Apache-2.0"
] | 0 | b16d35b3a3a5de62de9e0bac83eccd21b6358b53 | https://github.com/WFDetector/WFDetection/tree/b16d35b3a3a5de62de9e0bac83eccd21b6358b53 |
SEModule | import torch
import torch.nn.functional as F
import torch.nn as nn
import torch.utils.data
from collections import OrderedDict
def make_divisible(v, divisor, min_val=None):
"""
This function is taken from the original tf repo.
It ensures that all layers have a channel number that is divisible by 8
It ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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... | WOODchen7/XNAS | SEModule | false | 2,951 | [
"MIT"
] | 0 | cc3d5cadfb4f755b4b4004dc368a102cdc68e6f6 | https://github.com/WOODchen7/XNAS/tree/cc3d5cadfb4f755b4b4004dc368a102cdc68e6f6 |
SoftmaxAttention | import torch
import torch.nn as nn
def masked_softmax(tensor, mask, kb_mask):
"""
Apply a masked softmax on the last dimension of a tensor.
The input tensor and mask should be of size (batch, *, sequence_length).
Args:
tensor: The tensor on which the softmax function must be applied along
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | TripuraPriyanka/ekmimn | SoftmaxAttention | false | 2,952 | [
"Apache-2.0"
] | 0 | 389c2249369e5b0f09498d79034634ac1db4ff68 | https://github.com/TripuraPriyanka/ekmimn/tree/389c2249369e5b0f09498d79034634ac1db4ff68 |
AdaIN2d | import torch
import torch.nn as nn
class AdaIN2d(nn.Module):
def __init__(self, in_channels, in_features):
super(AdaIN2d, self).__init__()
self.norm = nn.InstanceNorm2d(in_channels, affine=False,
track_running_stats=False)
self.net = nn.Linear(in_features, 2 * 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.triton_helpers import libdevice
import torch.nn as ... | TRUMANCFY/wolf | AdaIN2d | false | 2,953 | [
"Apache-2.0"
] | 0 | 1a21479256e4f51885e2d2fdd449b1faa61277a6 | https://github.com/TRUMANCFY/wolf/tree/1a21479256e4f51885e2d2fdd449b1faa61277a6 |
SingleHead | import torch
import torch.nn as nn
import torch.utils.data
from itertools import product as product
from math import sqrt as sqrt
class SingleHead(nn.Module):
"""
Single head used in CenterNet Head.
"""
def __init__(self, in_channel, out_channel, bias_fill=False, bias_value=0):
super(SingleHe... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 ... | WFDetector/WFDetection | SingleHead | false | 2,954 | [
"Apache-2.0"
] | 0 | b16d35b3a3a5de62de9e0bac83eccd21b6358b53 | https://github.com/WFDetector/WFDetection/tree/b16d35b3a3a5de62de9e0bac83eccd21b6358b53 |
PositionalEmbedding | import torch
import numpy as np
from torch import nn
class PositionalEmbedding(nn.Module):
def __init__(self, embed_dim, max_seq_len):
super(PositionalEmbedding, self).__init__()
position_encodings = np.array([[(pos / np.power(10000, 2.0 * (i //
2) / embed_dim)) for i in range(embed_... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import numpy as np
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynam... | WangDaYeeeeee/BERT-With-KnowledgeBase | PositionalEmbedding | false | 2,955 | [
"Apache-2.0"
] | 0 | 5f205295ce9b69ab0f813ef34409fdf2de3a14ca | https://github.com/WangDaYeeeeee/BERT-With-KnowledgeBase/tree/5f205295ce9b69ab0f813ef34409fdf2de3a14ca |
MatrixTree | import torch
import torch.nn as nn
import torch.cuda
import torch.distributed
class MatrixTree(nn.Module):
"""Implementation of the matrix-tree theorem for computing marginals
of non-projective dependency parsing. This attention layer is used
in the paper "Learning Structured Text Representations"
:ci... | 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.cuda
import torch.distributed
assert_s... | SivilTaram/dialogue-utterance-rewriter-pytorch | MatrixTree | false | 2,956 | [
"MIT"
] | 0 | 92c2254958b7a1ee9199836f7f2236575270983f | https://github.com/SivilTaram/dialogue-utterance-rewriter-pytorch/tree/92c2254958b7a1ee9199836f7f2236575270983f |
SeparableConvBlock | import math
import torch
import torch.nn.functional as F
import torch.utils.data
from itertools import product as product
from math import sqrt as sqrt
class Conv2dSamePadding(torch.nn.Conv2d):
"""
A wrapper around :class:`torch.nn.Conv2d` to support "SAME" padding mode and more features.
"""
def __i... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import math
import torch.nn.functional as F
import torch.utils.data
from itertoo... | WFDetector/WFDetection | SeparableConvBlock | false | 2,957 | [
"Apache-2.0"
] | 0 | b16d35b3a3a5de62de9e0bac83eccd21b6358b53 | https://github.com/WFDetector/WFDetection/tree/b16d35b3a3a5de62de9e0bac83eccd21b6358b53 |
complex_relu_layer | import torch
import torch.nn as nn
class complex_relu_layer(nn.Module):
"""The complex ReLU layer from the `MagNet: A Neural Network for Directed Graphs. <https://arxiv.org/pdf/2102.11391.pdf>`_ paper.
"""
def __init__(self):
super(complex_relu_layer, self).__init__()
def complex_relu(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... | XitongZhang1994/pytorch_geometric_signed_directed | complex_relu_layer | false | 2,958 | [
"MIT"
] | 0 | 2507c2c8496c4d48ddbc960781b21ea69bb1cfdd | https://github.com/XitongZhang1994/pytorch_geometric_signed_directed/tree/2507c2c8496c4d48ddbc960781b21ea69bb1cfdd |
Attention | import math
import torch
from torch import nn
import torch.nn.functional as F
class Attention(nn.Module):
"""
score_i = f(Q, K_i), i = 1, 2, ..., t
dot: f(Q, K_i) = Q.transpose · K_i
scaled_dot: f(Q, K_i) = Q.transpose · K_i / √(key_dim)
general: f(Q, K_i) = Q.transpose · W ·... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | WangDaYeeeeee/BERT-With-KnowledgeBase | Attention | false | 2,959 | [
"Apache-2.0"
] | 0 | 5f205295ce9b69ab0f813ef34409fdf2de3a14ca | https://github.com/WangDaYeeeeee/BERT-With-KnowledgeBase/tree/5f205295ce9b69ab0f813ef34409fdf2de3a14ca |
SummaryNet | import torch
import torch.nn as nn
import torch.nn.functional as F
class SummaryNet(nn.Module):
def __init__(self):
super().__init__()
self.conv1 = nn.Conv1d(in_channels=1, out_channels=6, kernel_size=5,
padding=2)
self.pool = nn.MaxPool1d(kernel_size=10, stride=10)
se... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | Wrede/BNN-LFI | SummaryNet | false | 2,960 | [
"MIT"
] | 0 | 8c5094f01c1eef286bdd84613c7259d534d2eb7e | https://github.com/Wrede/BNN-LFI/tree/8c5094f01c1eef286bdd84613c7259d534d2eb7e |
DeResNetBlockGroupNorm | import torch
import torch.nn as nn
def deconv3x3(in_planes, out_planes, stride=1, output_padding=0):
"""3x3 deconvolution with padding"""
return nn.ConvTranspose2d(in_planes, out_planes, kernel_size=3, stride=
stride, padding=1, output_padding=output_padding, bias=False)
class DeResNetBlockGroupNorm... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | TRUMANCFY/wolf | DeResNetBlockGroupNorm | false | 2,961 | [
"Apache-2.0"
] | 0 | 1a21479256e4f51885e2d2fdd449b1faa61277a6 | https://github.com/TRUMANCFY/wolf/tree/1a21479256e4f51885e2d2fdd449b1faa61277a6 |
LeNet5 | import torch
import torch.nn as nn
import torch.nn.functional as F
class LeNet5(nn.Module):
def __init__(self):
super(LeNet5, self).__init__()
self.conv1 = nn.Conv2d(1, 6, (5, 5), padding=0)
self.conv2 = nn.Conv2d(6, 16, (5, 5))
self.fc1 = nn.Linear(16 * 5 * 5, 120)
self.f... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | SuhangGeongyu/2019_SNUST_DEEPLEARNING_HW | LeNet5 | false | 2,962 | [
"MIT"
] | 0 | e6eb119483ab905f558f63341922a56ebee9b5c6 | https://github.com/SuhangGeongyu/2019_SNUST_DEEPLEARNING_HW/tree/e6eb119483ab905f558f63341922a56ebee9b5c6 |
MyMaxPool1dPadSame | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
from itertools import product as product
from math import sqrt as sqrt
class MyMaxPool1dPadSame(nn.Module):
"""
extend nn.MaxPool1d to support SAME padding
"""
def __init__(self, kernel_size, stride_size):
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
import torch.utils.data
from itertools import product as product
fr... | WFDetector/WFDetection | MyMaxPool1dPadSame | false | 2,963 | [
"Apache-2.0"
] | 0 | b16d35b3a3a5de62de9e0bac83eccd21b6358b53 | https://github.com/WFDetector/WFDetection/tree/b16d35b3a3a5de62de9e0bac83eccd21b6358b53 |
PrimaryCaps | import torch
from torch import nn
def squash(x, dim=-1):
squared_norm = (x ** 2).sum(dim=dim, keepdim=True)
scale = squared_norm / (1 + squared_norm)
return scale * x / (squared_norm.sqrt() + 1e-08)
class PrimaryCaps(nn.Module):
"""Primary capsule layer."""
def __init__(self, num_conv_units, in... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
from torch import n... | Xiangs18/CapsNet | PrimaryCaps | false | 2,964 | [
"MIT"
] | 0 | 79cd0ed1e726750968cd8658370f78aa86a62170 | https://github.com/Xiangs18/CapsNet/tree/79cd0ed1e726750968cd8658370f78aa86a62170 |
ResNetBlockGroupNorm | 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)
class ResNetBlockGroupNorm(nn.Module):
def __init__(self, inplanes, planes, num_groups... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | TRUMANCFY/wolf | ResNetBlockGroupNorm | false | 2,965 | [
"Apache-2.0"
] | 0 | 1a21479256e4f51885e2d2fdd449b1faa61277a6 | https://github.com/TRUMANCFY/wolf/tree/1a21479256e4f51885e2d2fdd449b1faa61277a6 |
ResidualBlock | import torch
from torch import nn
import torch.utils.data
class ResidualBlock(nn.Module):
def __init__(self, channels, reduction):
super(ResidualBlock, self).__init__()
self.conv1 = nn.Conv2d(channels, channels, kernel_size=3, padding=1)
self.prelu = nn.PReLU(num_parameters=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 import nn
import torch.utils.data
assert_size_stride = torch._C._dyna... | Wulfsta/SuperResolution | ResidualBlock | false | 2,966 | [
"MIT"
] | 0 | ced152e57da001074856b0c085d499c2825358d6 | https://github.com/Wulfsta/SuperResolution/tree/ced152e57da001074856b0c085d499c2825358d6 |
CapsuleLoss | import torch
from torch import nn
class CapsuleLoss(nn.Module):
"""Combine margin loss & reconstruction loss of capsule network."""
def __init__(self, upper_bound=0.9, lower_bound=0.1, lmda=0.5):
super(CapsuleLoss, self).__init__()
self.upper = upper_bound
self.lower = lower_bound
... | 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... | Xiangs18/CapsNet | CapsuleLoss | false | 2,967 | [
"MIT"
] | 0 | 79cd0ed1e726750968cd8658370f78aa86a62170 | https://github.com/Xiangs18/CapsNet/tree/79cd0ed1e726750968cd8658370f78aa86a62170 |
ScaledDotProductAttention | import torch
import numpy as np
import torch.nn as nn
class ScaledDotProductAttention(nn.Module):
""" Scaled Dot-Product Attention """
def __init__(self, temperature, attn_dropout=0.1):
super(ScaledDotProductAttention, self).__init__()
self.temperature = temperature
self.dropout = nn.... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | Xlinford/TDNet | ScaledDotProductAttention | false | 2,968 | [
"MIT"
] | 0 | e7cb59c40b8751b6dab9691d26ad224fd61c24d1 | https://github.com/Xlinford/TDNet/tree/e7cb59c40b8751b6dab9691d26ad224fd61c24d1 |
ConvCompress | import torch
from torch import nn
class ConvCompress(nn.Module):
def __init__(self, d_model, ratio=4, groups=1):
super().__init__()
self.conv = nn.Conv1d(d_model, d_model, ratio, stride=ratio, groups
=groups)
def forward(self, mem):
mem = mem.transpose(1, 2)
compr... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import 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... | Xinxinatg/DM-Count | ConvCompress | false | 2,969 | [
"MIT"
] | 0 | 9ac3327e26c0ede219bd44cb5a4ae6db9fded045 | https://github.com/Xinxinatg/DM-Count/tree/9ac3327e26c0ede219bd44cb5a4ae6db9fded045 |
NICEMLPBlock | import torch
import torch.nn as nn
class LinearWeightNorm(nn.Module):
def __init__(self, in_features, out_features, bias=True):
super(LinearWeightNorm, self).__init__()
self.linear = nn.Linear(in_features, out_features, bias=bias)
self.reset_parameters()
def reset_parameters(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.... | TRUMANCFY/wolf | NICEMLPBlock | false | 2,970 | [
"Apache-2.0"
] | 0 | 1a21479256e4f51885e2d2fdd449b1faa61277a6 | https://github.com/TRUMANCFY/wolf/tree/1a21479256e4f51885e2d2fdd449b1faa61277a6 |
SummaryNet_large | import torch
import torch.nn as nn
import torch.nn.functional as F
class SummaryNet_large(nn.Module):
def __init__(self):
super().__init__()
self.conv1 = nn.Conv1d(in_channels=2, out_channels=20, kernel_size=
3, padding=2)
self.pool = nn.MaxPool1d(kernel_size=5, stride=5)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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_... | Wrede/BNN-LFI | SummaryNet_large | false | 2,971 | [
"MIT"
] | 0 | 8c5094f01c1eef286bdd84613c7259d534d2eb7e | https://github.com/Wrede/BNN-LFI/tree/8c5094f01c1eef286bdd84613c7259d534d2eb7e |
ResidualBlock | import torch
from torch import nn
class ResidualBlock(nn.Module):
def __init__(self, channels):
super().__init__()
self.conv0 = nn.Conv2d(in_channels=channels, out_channels=channels,
kernel_size=3, padding=1)
self.conv1 = nn.Conv2d(in_channels=channels, out_channels=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... | Thaigun/Griddly | ResidualBlock | false | 2,972 | [
"MIT"
] | 0 | de5972a608a2928172510a0ac81a977c48af6b1f | https://github.com/Thaigun/Griddly/tree/de5972a608a2928172510a0ac81a977c48af6b1f |
FPNOutput | import torch
import torch.nn as nn
class ConvBNReLU(nn.Module):
def __init__(self, in_chan, out_chan, ks=1, stride=1, padding=0,
norm_layer=None, bias=True, *args, **kwargs):
super(ConvBNReLU, self).__init__()
self.conv = nn.Conv2d(in_chan, out_chan, kernel_size=ks, stride=
st... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | Xlinford/TDNet | FPNOutput | false | 2,974 | [
"MIT"
] | 0 | e7cb59c40b8751b6dab9691d26ad224fd61c24d1 | https://github.com/Xlinford/TDNet/tree/e7cb59c40b8751b6dab9691d26ad224fd61c24d1 |
Net_Tran | import torch
import torch.nn as nn
import torch.nn.parallel
import torch.optim
import torch.utils.data
import torch.utils.data.distributed
class Net_Tran(nn.Module):
def __init__(self):
super(Net_Tran, self).__init__()
self.conv1 = nn.Conv2d(3, 16, 3, stride=2, padding=1)
self.deconv1 = 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
import torch.nn as nn
import torch.nn.parallel
import torch.optim
import torch.u... | YibinXie/Pose_Estimation | Net_Tran | false | 2,975 | [
"MIT"
] | 0 | 5849140bf842bf3aeaad75827f5e7b7f2999c9ee | https://github.com/YibinXie/Pose_Estimation/tree/5849140bf842bf3aeaad75827f5e7b7f2999c9ee |
FlatCat | import torch
class FlatCat(torch.nn.Module):
def __init__(self):
super(FlatCat, self).__init__()
def forward(self, x, y):
x = x.view(x.shape[0], -1, 1, 1)
y = y.view(y.shape[0], -1, 1, 1)
return torch.cat([x, y], 1)
def get_inputs():
return [torch.rand([4, 4, 4, 4]), 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
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
@triton.j... | YirongMao/torch2trt | FlatCat | false | 2,976 | [
"MIT"
] | 0 | 7635051998a9cd6b9483da1569814031c04a1b52 | https://github.com/YirongMao/torch2trt/tree/7635051998a9cd6b9483da1569814031c04a1b52 |
MagnitudeTestModel | import torch
from torch import nn
from torchvision import models as models
import torch.nn.parallel
import torch.optim
import torch.utils.data
import torch.utils.data.distributed
import torch.onnx
def fill_bias(module, value):
module.bias.data.fill_(value)
def fill_conv_weight(conv, value):
conv.weight.data... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import 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
from torchvision import models as models
import torch.nn.pa... | JinYAnGHe/openvino_training_extensions | MagnitudeTestModel | false | 2,977 | [
"Apache-2.0"
] | 0 | a0b4456a3c9fe6c1b7eabc9d5eb4e74d01453dee | https://github.com/JinYAnGHe/openvino_training_extensions/tree/a0b4456a3c9fe6c1b7eabc9d5eb4e74d01453dee |
ResidualBlock | import torch
import torch.utils.data
from torch import nn
class ResidualBlock(nn.Module):
def __init__(self, in_channels, hidden, out_channels):
super().__init__()
self.conv1 = nn.Conv2d(in_channels=in_channels, out_channels=hidden,
kernel_size=3, stride=1, padding=1)
self.rel... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.utils.data
from ... | YigitGunduc/self-driving-car | ResidualBlock | false | 2,978 | [
"MIT"
] | 0 | 2be31f6473c911cf004236ce0874cb2da8fe8ad1 | https://github.com/YigitGunduc/self-driving-car/tree/2be31f6473c911cf004236ce0874cb2da8fe8ad1 |
FusedLeakyReLU | 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
return F.leaky_relu(input + bias.view(1, bias.shape[0], *rest_dim),
negative_slope=negative_slop... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
from torch.nn import functional as F
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda... | YotamNitzan/pixel2style2pixel | FusedLeakyReLU | false | 2,979 | [
"MIT"
] | 0 | b943f9e6de046a54b901eea1d8714cb02a71605f | https://github.com/YotamNitzan/pixel2style2pixel/tree/b943f9e6de046a54b901eea1d8714cb02a71605f |
GAT | import torch
import torch.nn as nn
import torch.nn.functional as F
class GraphAttentionLayer(nn.Module):
"""
Simple GAT layer, similar to https://arxiv.org/abs/1710.10903
"""
def __init__(self, in_features, out_features, dropout, alpha, concat=True):
super(GraphAttentionLayer, self).__init__(... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | XiangwenNing/pyGAT | GAT | false | 2,980 | [
"MIT"
] | 0 | c4bd8e2be044c6c7481d484875b3c318271cca9c | https://github.com/XiangwenNing/pyGAT/tree/c4bd8e2be044c6c7481d484875b3c318271cca9c |
GraphLevelAttentionLayer | import torch
import torch.nn.functional as F
import torch.nn as nn
class GraphLevelAttentionLayer(nn.Module):
"""
Simple GAT layer, similar to https://arxiv.org/abs/1710.10903
"""
def __init__(self, in_features, out_features):
super(GraphLevelAttentionLayer, self).__init__()
self.in_f... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | Yonggie/HsCTRD | GraphLevelAttentionLayer | false | 2,981 | [
"Apache-2.0"
] | 0 | d4541f13630a6abd0e17b116ad6aeeab74f54f1c | https://github.com/Yonggie/HsCTRD/tree/d4541f13630a6abd0e17b116ad6aeeab74f54f1c |
UpsampleBlock | import torch
import torch.nn as nn
class PixelShuffle1d(nn.Module):
def __init__(self, upscale_factor):
super().__init__()
self.upscale_factor = upscale_factor
def forward(self, x):
batch_size = x.shape[0]
short_channel_len = x.shape[1]
short_width = x.shape[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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | Yotsuyubi/drumgan | UpsampleBlock | false | 2,982 | [
"MIT"
] | 0 | eb6a9aa8b5c0d64bad65e4dbd14d444b7a859a29 | https://github.com/Yotsuyubi/drumgan/tree/eb6a9aa8b5c0d64bad65e4dbd14d444b7a859a29 |
Generator | import torch
import torch.nn as nn
import torch.nn.functional as F
class Generator(nn.Module):
"""Define standard linear + softmax generation step."""
def __init__(self, hidden_size, vocab_size):
super(Generator, self).__init__()
self.proj = nn.Linear(hidden_size, vocab_size, bias=False)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | Yixuan-Lee/yixuan-lee.github.io | Generator | false | 2,983 | [
"MIT"
] | 0 | 139dd141544302ca1802a6104f7db7aeb1ace825 | https://github.com/Yixuan-Lee/yixuan-lee.github.io/tree/139dd141544302ca1802a6104f7db7aeb1ace825 |
SamePaddingConv1d | import torch
import torch.nn as nn
class SamePaddingConv1d(nn.Module):
def __init__(self, in_dim, out_dim, kernel_size):
super().__init__()
self.conv = nn.Conv1d(in_dim, out_dim, kernel_size, padding=int((
kernel_size - 1) / 2))
def forward(self, x):
return self.conv(x)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | Yotsuyubi/drumgan | SamePaddingConv1d | false | 2,984 | [
"MIT"
] | 0 | eb6a9aa8b5c0d64bad65e4dbd14d444b7a859a29 | https://github.com/Yotsuyubi/drumgan/tree/eb6a9aa8b5c0d64bad65e4dbd14d444b7a859a29 |
MultiHeadAttention | 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.... | Yingting-dev/ReChorus | MultiHeadAttention | false | 2,985 | [
"MIT"
] | 0 | a16bc1e42f3e90e889133d7476c52ada44db573b | https://github.com/Yingting-dev/ReChorus/tree/a16bc1e42f3e90e889133d7476c52ada44db573b |
LNN | import math
import torch
import torch.nn.functional as F
import torch.utils.data
class LNN(torch.nn.Module):
"""
A pytorch implementation of LNN layer
Input shape
- A 3D tensor with shape: ``(batch_size,field_size,embedding_size)``.
Output shape
- 2D tensor with shape:``(batch_size,LNN... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | ZEKAICHEN/RecSys | LNN | false | 2,986 | [
"MIT"
] | 0 | 7ab66b4a6cee620cc4baeb00f916ff329834f903 | https://github.com/ZEKAICHEN/RecSys/tree/7ab66b4a6cee620cc4baeb00f916ff329834f903 |
FirstStage | import torch
import torch.nn as nn
import torch.nn.parallel
import torch.optim
import torch.utils.data
import torch.utils.data.distributed
def conv1x1(in_planes, out_planes, stride=1):
"""1x1 convolution with padding"""
return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=stride,
padding=0, b... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 ... | YibinXie/Pose_Estimation | FirstStage | false | 2,987 | [
"MIT"
] | 0 | 5849140bf842bf3aeaad75827f5e7b7f2999c9ee | https://github.com/YibinXie/Pose_Estimation/tree/5849140bf842bf3aeaad75827f5e7b7f2999c9ee |
Actor | import torch
import numpy as np
import torch.nn.functional as F
import torch.nn as nn
def hidden_init(layer):
fan_in = layer.weight.data.size()[0]
lim = 1.0 / np.sqrt(fan_in)
return -lim, lim
class Actor(nn.Module):
"""Actor (Policy) Model."""
def __init__(self, state_size, action_size, seed, f... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | YufengJin/deep-reinforcement-learning | Actor | false | 2,988 | [
"MIT"
] | 0 | 141cf00f169b46aa492c9e7520429bfdaab0117d | https://github.com/YufengJin/deep-reinforcement-learning/tree/141cf00f169b46aa492c9e7520429bfdaab0117d |
ResBlock | import torch
import torch.utils.data
import torch
import torch.nn as nn
class ResBlock(nn.Module):
def __init__(self, inFe):
super(ResBlock, self).__init__()
self.conv1 = nn.Conv2d(inFe, inFe, 3, 1, 1)
self.relu = nn.ReLU()
self.conv2 = nn.Conv2d(inFe, inFe, 3, 1, 1)
def forw... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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... | ZhibingLai/MSFN | ResBlock | false | 2,989 | [
"Apache-2.0"
] | 0 | eb650c351edf27270bc32b50b60842a9fe40308e | https://github.com/ZhibingLai/MSFN/tree/eb650c351edf27270bc32b50b60842a9fe40308e |
AvgReducePool1d | import torch
from torch import nn
class AvgReducePool1d(nn.Module):
"""A subclass of :torch_nn:`Module`.
Avg Pool layer for 1D inputs. The same as :torch_nn:`AvgPool1d` except that
the pooling dimension is entirely reduced (i.e., `pool_size=input_length`).
"""
def forward(self, input: 'torch.Tens... | 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... | ZhitingHu/texar-pytorch | AvgReducePool1d | false | 2,990 | [
"Apache-2.0"
] | 0 | 72ea115013ced8a5a2b004eacf6271184d3572a8 | https://github.com/ZhitingHu/texar-pytorch/tree/72ea115013ced8a5a2b004eacf6271184d3572a8 |
FeatureAssembler | import torch
from typing import Optional
import torch.nn as nn
class FeatureAssembler(nn.Module):
def __init__(self, T: 'int', embed_static: 'Optional[FeatureEmbedder]'=
None, embed_dynamic: 'Optional[FeatureEmbedder]'=None) ->None:
super().__init__()
self.T = T
self.embeddings = ... | 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 typing import Optional
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch... | ZhuangweiKang/pytorch-ts | FeatureAssembler | false | 2,991 | [
"Apache-2.0",
"MIT"
] | 0 | 076d456358fd1bac96becba4f1ba38ec5a5fcf4d | https://github.com/ZhuangweiKang/pytorch-ts/tree/076d456358fd1bac96becba4f1ba38ec5a5fcf4d |
TimeIntervalMultiHeadAttention | 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.... | Yingting-dev/ReChorus | TimeIntervalMultiHeadAttention | false | 2,992 | [
"MIT"
] | 0 | a16bc1e42f3e90e889133d7476c52ada44db573b | https://github.com/Yingting-dev/ReChorus/tree/a16bc1e42f3e90e889133d7476c52ada44db573b |
CondUpsampler | import torch
import torch.nn.functional as F
import torch.nn as nn
class CondUpsampler(nn.Module):
def __init__(self, cond_length, target_dim):
super().__init__()
self.linear1 = nn.Linear(cond_length, target_dim // 2)
self.linear2 = nn.Linear(target_dim // 2, target_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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | ZhuangweiKang/pytorch-ts | CondUpsampler | false | 2,993 | [
"Apache-2.0",
"MIT"
] | 0 | 076d456358fd1bac96becba4f1ba38ec5a5fcf4d | https://github.com/ZhuangweiKang/pytorch-ts/tree/076d456358fd1bac96becba4f1ba38ec5a5fcf4d |
GatedLinearUnit | import torch
import torch.nn as nn
class GatedLinearUnit(nn.Module):
def __init__(self, dim: 'int'=-1, nonlinear: 'bool'=True):
super().__init__()
self.dim = dim
self.nonlinear = nonlinear
def forward(self, x: 'torch.Tensor') ->torch.Tensor:
val, gate = torch.chunk(x, 2, dim=... | 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_... | ZhuangweiKang/pytorch-ts | GatedLinearUnit | false | 2,994 | [
"Apache-2.0",
"MIT"
] | 0 | 076d456358fd1bac96becba4f1ba38ec5a5fcf4d | https://github.com/ZhuangweiKang/pytorch-ts/tree/076d456358fd1bac96becba4f1ba38ec5a5fcf4d |
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
return F.leaky_relu(input + bias.view(1, bias.shape[0], *rest_dim),
negative_slope=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
from to... | YotamNitzan/pixel2style2pixel | StyledConv | false | 2,995 | [
"MIT"
] | 0 | b943f9e6de046a54b901eea1d8714cb02a71605f | https://github.com/YotamNitzan/pixel2style2pixel/tree/b943f9e6de046a54b901eea1d8714cb02a71605f |
Critic | import torch
import numpy as np
import torch.nn.functional as F
import torch.nn as nn
def hidden_init(layer):
fan_in = layer.weight.data.size()[0]
lim = 1.0 / np.sqrt(fan_in)
return -lim, lim
class Critic(nn.Module):
"""Critic (Value) Model."""
def __init__(self, state_size, action_size, seed, ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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... | YufengJin/deep-reinforcement-learning | Critic | false | 2,996 | [
"MIT"
] | 0 | 141cf00f169b46aa492c9e7520429bfdaab0117d | https://github.com/YufengJin/deep-reinforcement-learning/tree/141cf00f169b46aa492c9e7520429bfdaab0117d |
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.... | Yingting-dev/ReChorus | TimeIntervalTransformerLayer | false | 2,997 | [
"MIT"
] | 0 | a16bc1e42f3e90e889133d7476c52ada44db573b | https://github.com/Yingting-dev/ReChorus/tree/a16bc1e42f3e90e889133d7476c52ada44db573b |
GeneralizedMeanPooling | import torch
from torchvision.transforms import *
from torch import nn
class GeneralizedMeanPooling(nn.Module):
"""Applies a 2D power-average adaptive pooling over an input signal composed of several input planes.
The function computed is: :math:`f(X) = pow(sum(pow(X, p)), 1/p)`
- At p = infinity, one... | 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 torchvision.transforms ... | ZoRoronoa/Camera-Aware-Proxy | GeneralizedMeanPooling | false | 2,998 | [
"Apache-2.0"
] | 0 | 352f900bbae330f18c2bfe2b3f2516fb4e31adea | https://github.com/ZoRoronoa/Camera-Aware-Proxy/tree/352f900bbae330f18c2bfe2b3f2516fb4e31adea |
SpatialGather_Module | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch._utils
class SpatialGather_Module(nn.Module):
"""
Aggregate the context features according to the initial
predicted probability distribution.
Employ the soft-weighted method to aggregate the context.
O... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | Zhoushanglin100/Cityscape-model | SpatialGather_Module | false | 2,999 | [
"BSD-3-Clause"
] | 0 | 62b3d25712f16f01d951d5168d0f11e3133cd06b | https://github.com/Zhoushanglin100/Cityscape-model/tree/62b3d25712f16f01d951d5168d0f11e3133cd06b |
ToLongTensor | import torch
from torch import Tensor
from typing import List
import torch.nn as nn
class ToLongTensor(nn.Module):
"""Convert a list of integers to long tensor
"""
def __init__(self):
super(ToLongTensor, self).__init__()
def forward(self, tokens: 'List[List[int]]') ->Tensor:
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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | ZongHR/text | ToLongTensor | false | 3,000 | [
"BSD-3-Clause"
] | 0 | 856607154be7c784505869f10ae578346868b121 | https://github.com/ZongHR/text/tree/856607154be7c784505869f10ae578346868b121 |
SirenLayer | import math
import torch
import torch.nn as nn
class Sine(nn.Module):
def __init__(self, w0=30.0):
super().__init__()
self.w0 = w0
def forward(self, x):
return torch.sin(self.w0 * x)
class SirenLayer(nn.Module):
def __init__(self, input_dim, hidden_dim, use_bias=True, w0=1.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 math as tl_math
import math
i... | ZixiuHuang/nex-code | SirenLayer | false | 3,001 | [
"MIT"
] | 0 | c9432fb675914391b4de4786220351a0dc35aecb | https://github.com/ZixiuHuang/nex-code/tree/c9432fb675914391b4de4786220351a0dc35aecb |
Biaffine | import torch
from typing import Callable
from typing import Optional
from torch import nn
class Biaffine(nn.Module):
def __init__(self, in1_features: 'int', in2_features: 'int',
out_features: 'int', init_func: 'Optional[Callable]'=None) ->None:
super(Biaffine, self).__init__()
self.in1_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 typing import Callable
from typing import Optional
from torch import nn
ass... | Zzoay/dependency_representations | Biaffine | false | 3,002 | [
"Apache-2.0"
] | 0 | 7f4726629878aaf9bfee645fe1b11032df05c82e | https://github.com/Zzoay/dependency_representations/tree/7f4726629878aaf9bfee645fe1b11032df05c82e |
RobertaClassificationHead | import torch
import torch.nn as nn
from typing import Optional
class RobertaClassificationHead(nn.Module):
def __init__(self, num_classes, input_dim, inner_dim: 'Optional[int]'=
None, dropout: 'float'=0.1, activation=nn.ReLU):
super().__init__()
if not inner_dim:
inner_dim = i... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
from ty... | ZongHR/text | RobertaClassificationHead | false | 3,003 | [
"BSD-3-Clause"
] | 0 | 856607154be7c784505869f10ae578346868b121 | https://github.com/ZongHR/text/tree/856607154be7c784505869f10ae578346868b121 |
RobertaMaskLeanerHead | import torch
import torch.nn.functional as F
import torch.nn as nn
import torch.utils.data
import torch.onnx.operators
import torch.optim
import torch.optim.lr_scheduler
class RobertaMaskLeanerHead(nn.Module):
"""
Head for mask leaner.
input: (batch, src_lens, embed_dim)
output: (batch, src_lens,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
from torch._inductor.runtime.... | a1600012888/fairseq | RobertaMaskLeanerHead | false | 3,004 | [
"MIT"
] | 0 | dbd2cd08fc396f919d2e737513095fcb966896c0 | https://github.com/a1600012888/fairseq/tree/dbd2cd08fc396f919d2e737513095fcb966896c0 |
Block | import torch
import torch.nn as nn
import torch.nn.functional as F
class LayerNorm(nn.Module):
""" LayerNorm that supports two data formats: channels_last (default) or channels_first.
The ordering of the dimensions in the inputs. channels_last corresponds to inputs with
shape (batch_size, height, width, c... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as ... | ZhijieXiao-0624/CNXA | Block | false | 3,005 | [
"MIT"
] | 0 | a63b3561010cf87f696a005f8ea252e7cdaa7ca2 | https://github.com/ZhijieXiao-0624/CNXA/tree/a63b3561010cf87f696a005f8ea252e7cdaa7ca2 |
LinearWeightNorm | import torch
import torch.nn as nn
class LinearWeightNorm(nn.Module):
def __init__(self, in_features, out_features, bias=True):
super(LinearWeightNorm, self).__init__()
self.linear = nn.Linear(in_features, out_features, bias=bias)
self.reset_parameters()
def reset_parameters(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.triton_helpers import libdevice
import torch.nn as ... | TRUMANCFY/wolf | LinearWeightNorm | false | 3,006 | [
"Apache-2.0"
] | 0 | 1a21479256e4f51885e2d2fdd449b1faa61277a6 | https://github.com/TRUMANCFY/wolf/tree/1a21479256e4f51885e2d2fdd449b1faa61277a6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.