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 |
|---|---|---|---|---|---|---|---|---|---|---|
ResidualBlock | import torch
import torch.nn as nn
class ResidualBlock(nn.Module):
def __init__(self, in_planes, planes, norm_layer=nn.InstanceNorm2d,
stride=1, dilation=1):
super(ResidualBlock, self).__init__()
self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=3, dilation=
dilation, padd... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | haofeixu/gmflow | ResidualBlock | false | 15,489 | [
"Apache-2.0"
] | 58 | d304e5e516c11df378d63808d6679aea43bc564a | https://github.com/haofeixu/gmflow/tree/d304e5e516c11df378d63808d6679aea43bc564a |
ConvReLUNorm | import torch
import torch.cuda
import torch.distributed
import torch.utils.data
import torch.optim
class ConvReLUNorm(torch.nn.Module):
def __init__(self, in_channels, out_channels, kernel_size=1, dropout=0.0):
super(ConvReLUNorm, self).__init__()
self.conv = torch.nn.Conv1d(in_channels, out_chan... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | hamjam/NeMo | ConvReLUNorm | false | 15,490 | [
"Apache-2.0"
] | 4,145 | b3484d32e1317666151f931bfa39867d88ed8658 | https://github.com/hamjam/NeMo/tree/b3484d32e1317666151f931bfa39867d88ed8658 |
PermEqui1_mean | import torch
import torch.nn as nn
class PermEqui1_mean(nn.Module):
def __init__(self, in_dim, out_dim):
super(PermEqui1_mean, self).__init__()
self.Gamma = nn.Linear(in_dim, out_dim)
def forward(self, x):
xm = x.mean(1, keepdim=True)
x = self.Gamma(x - xm)
return 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... | haoruilee/DeepSets | PermEqui1_mean | false | 15,491 | [
"Apache-2.0"
] | 213 | b405dd6b51a34fb1ef622e25e6685b417b7b7cbb | https://github.com/haoruilee/DeepSets/tree/b405dd6b51a34fb1ef622e25e6685b417b7b7cbb |
PermEqui2_max | import torch
import torch.nn as nn
class PermEqui2_max(nn.Module):
def __init__(self, in_dim, out_dim):
super(PermEqui2_max, self).__init__()
self.Gamma = nn.Linear(in_dim, out_dim)
self.Lambda = nn.Linear(in_dim, out_dim, bias=False)
def forward(self, x):
xm, _ = x.max(1, 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
import torch.nn as nn
assert_... | haoruilee/DeepSets | PermEqui2_max | false | 15,492 | [
"Apache-2.0"
] | 213 | b405dd6b51a34fb1ef622e25e6685b417b7b7cbb | https://github.com/haoruilee/DeepSets/tree/b405dd6b51a34fb1ef622e25e6685b417b7b7cbb |
AttentionSelf | import torch
class AttentionSelf(torch.nn.Module):
def __init__(self, input_size, hidden_size, device=torch.device('cpu')):
"""
implementation of self-attention.
"""
super().__init__()
self.ff1 = torch.nn.Linear(input_size, hidden_size)
self.ff2 = torch.nn.Linear(h... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | haophancs/TREQS | AttentionSelf | false | 15,493 | [
"MIT"
] | 149 | 49e354ce2a08cf963ec139d99936020e0f80ced8 | https://github.com/haophancs/TREQS/tree/49e354ce2a08cf963ec139d99936020e0f80ced8 |
PermEqui2_mean | import torch
import torch.nn as nn
class PermEqui2_mean(nn.Module):
def __init__(self, in_dim, out_dim):
super(PermEqui2_mean, self).__init__()
self.Gamma = nn.Linear(in_dim, out_dim)
self.Lambda = nn.Linear(in_dim, out_dim, bias=False)
def forward(self, x):
xm = x.mean(1, 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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | haoruilee/DeepSets | PermEqui2_mean | false | 15,495 | [
"Apache-2.0"
] | 213 | b405dd6b51a34fb1ef622e25e6685b417b7b7cbb | https://github.com/haoruilee/DeepSets/tree/b405dd6b51a34fb1ef622e25e6685b417b7b7cbb |
CrossAttention | import torch
class CrossAttention(torch.nn.Module):
"""
Implement of Co-attention.
"""
def __init__(self):
super().__init__()
def forward(self, inputA, inputB, maskA=None, maskB=None):
"""
Input: embedding.
"""
inputA.size(0)
assert inputA.size(-1)... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | haophancs/TREQS | CrossAttention | false | 15,496 | [
"MIT"
] | 149 | 49e354ce2a08cf963ec139d99936020e0f80ced8 | https://github.com/haophancs/TREQS/tree/49e354ce2a08cf963ec139d99936020e0f80ced8 |
PermEqui1_max | import torch
import torch.nn as nn
class PermEqui1_max(nn.Module):
def __init__(self, in_dim, out_dim):
super(PermEqui1_max, self).__init__()
self.Gamma = nn.Linear(in_dim, out_dim)
def forward(self, x):
xm, _ = x.max(1, keepdim=True)
x = self.Gamma(x - xm)
return 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_... | haoruilee/DeepSets | PermEqui1_max | false | 15,497 | [
"Apache-2.0"
] | 213 | b405dd6b51a34fb1ef622e25e6685b417b7b7cbb | https://github.com/haoruilee/DeepSets/tree/b405dd6b51a34fb1ef622e25e6685b417b7b7cbb |
CompressionFM | import torch
class CompressionFM(torch.nn.Module):
"""
FM layer
"""
def __init__(self, input_size, fm_size):
super(CompressionFM, self).__init__()
self.LW = torch.nn.Linear(input_size, 1)
self.QV = torch.nn.Parameter(torch.randn(input_size, fm_size))
def forward(self, inp... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cu... | haophancs/TREQS | CompressionFM | false | 15,498 | [
"MIT"
] | 149 | 49e354ce2a08cf963ec139d99936020e0f80ced8 | https://github.com/haophancs/TREQS/tree/49e354ce2a08cf963ec139d99936020e0f80ced8 |
GateLayer | import torch
from torch import nn
class GateLayer(nn.Module):
def __init__(self, input_dim):
super(GateLayer, self).__init__()
self._norm_layer1 = nn.Linear(input_dim * 2, input_dim)
self._norm_layer2 = nn.Linear(input_dim, 1)
def forward(self, input1, input2):
norm_input = 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 import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_st... | hcmus-nlp-chatbot/CRSLab | GateLayer | false | 15,499 | [
"MIT"
] | 315 | b3ab262a4ad93cbae98fe66541eb735377768a35 | https://github.com/hcmus-nlp-chatbot/CRSLab/tree/b3ab262a4ad93cbae98fe66541eb735377768a35 |
compressedSigmoid | import torch
import torch.nn as nn
import torch._utils
class compressedSigmoid(nn.Module):
def __init__(self, para=2.0, bias=0.2):
super(compressedSigmoid, self).__init__()
self.para = para
self.bias = bias
def forward(self, x):
output = 1.0 / (self.para + torch.exp(-x)) + se... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
import torch._utils
assert_size_stride = torch._C._... | henbucuoshanghai/crowed-count- | compressedSigmoid | false | 15,500 | [
"MIT"
] | 81 | 3353c0a8011b6b83e6e0392258a88706378b443b | https://github.com/henbucuoshanghai/crowed-count-/tree/3353c0a8011b6b83e6e0392258a88706378b443b |
MultiHeadedAttention | import math
import torch
import torch.nn.functional as F
class MultiHeadedAttention(torch.nn.Module):
"""
Implement of multi-head attention.
"""
def __init__(self, n_heads, hidden_size, drop_rate):
super().__init__()
assert hidden_size % n_heads == 0
self.n_dk = hidden_size //... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | haophancs/TREQS | MultiHeadedAttention | false | 15,501 | [
"MIT"
] | 149 | 49e354ce2a08cf963ec139d99936020e0f80ced8 | https://github.com/haophancs/TREQS/tree/49e354ce2a08cf963ec139d99936020e0f80ced8 |
MultiHeadAttention | import math
import torch
import torch.cuda
from torch import nn
import torch.distributed
import torch.utils.data
import torch.optim
class MultiHeadAttention(nn.Module):
"""
Multi-head scaled dot-product attention layer.
Args:
hidden_size: size of the embeddings in the model, also known as d_model... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | hamjam/NeMo | MultiHeadAttention | false | 15,502 | [
"Apache-2.0"
] | 4,145 | b3484d32e1317666151f931bfa39867d88ed8658 | https://github.com/hamjam/NeMo/tree/b3484d32e1317666151f931bfa39867d88ed8658 |
RankingLoss | import torch
import torch.nn.functional as F
from abc import abstractmethod
import torch.utils.data.dataloader
import torch.nn as nn
import torch.nn
class SimilarityLoss(nn.Module):
def __init__(self):
super(SimilarityLoss, self).__init__()
@abstractmethod
def forward(self, inputs, 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 abc import abstractmethod
import torch.utils.data.dataloader
import torch.nn as nn
i... | helloMLWo/daga | RankingLoss | false | 15,503 | [
"MIT"
] | 46 | 88c7a1776ff36bd1abe1026103454e23ec77b552 | https://github.com/helloMLWo/daga/tree/88c7a1776ff36bd1abe1026103454e23ec77b552 |
CNN | import torch
import torch.nn as nn
import torch._utils
class CNN(nn.Module):
def __init__(self):
super(CNN, self).__init__()
self.cnn = nn.Conv2d(1, 1, 3, stride=1, padding=1)
def forward(self, input):
output = self.cnn(input)
return output
def get_inputs():
return [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
import torch.nn as nn
import torch._utils
assert_size_stride = torch._C._dynamo.... | henbucuoshanghai/crowed-count- | CNN | false | 15,504 | [
"MIT"
] | 81 | 3353c0a8011b6b83e6e0392258a88706378b443b | https://github.com/henbucuoshanghai/crowed-count-/tree/3353c0a8011b6b83e6e0392258a88706378b443b |
ScaledDotProductAttention | import torch
import numpy as np
import torch.utils.data
class ScaledDotProductAttention(torch.nn.Module):
"""
Scaled, softmax attention module for Transformer as defined by
Attention(Q, K, V) on pg 4. Returns the final attention vectors as well as
the attention matrices (pairwise scores). """
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.... | hengwei-chan/protein_transformer | ScaledDotProductAttention | false | 15,505 | [
"BSD-3-Clause"
] | 77 | 988bb0fcbb94b37e5a02071bd345ea073ad605f8 | https://github.com/hengwei-chan/protein_transformer/tree/988bb0fcbb94b37e5a02071bd345ea073ad605f8 |
CMVN | import torch
import torch.nn as nn
class CMVN(nn.Module):
__constants__ = ['mode', 'dim', 'eps']
def __init__(self, mode='global', dim=2, eps=1e-10):
super(CMVN, self).__init__()
if mode != 'global':
raise NotImplementedError(
'Only support global mean variance nor... | 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_... | hhhaaahhhaa/s3prl | CMVN | false | 15,506 | [
"Apache-2.0"
] | 856 | a469787f05c42196c4d989555082f5fd9dcbe8a6 | https://github.com/hhhaaahhhaa/s3prl/tree/a469787f05c42196c4d989555082f5fd9dcbe8a6 |
CAM | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch._utils
class CAM(nn.Module):
def __init__(self, in_dim):
super(CAM, self).__init__()
self.para_mu = nn.Parameter(torch.zeros(1))
def forward(self, x):
N, C, H, W = x.size()
proj_query = x.view(N, ... | 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
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dyn... | henbucuoshanghai/crowed-count- | CAM | false | 15,507 | [
"MIT"
] | 81 | 3353c0a8011b6b83e6e0392258a88706378b443b | https://github.com/henbucuoshanghai/crowed-count-/tree/3353c0a8011b6b83e6e0392258a88706378b443b |
SelfAttentionBatch | import torch
from torch import nn
import torch.nn.functional as F
class SelfAttentionBatch(nn.Module):
def __init__(self, dim, da, alpha=0.2, dropout=0.5):
super(SelfAttentionBatch, self).__init__()
self.dim = dim
self.da = da
self.alpha = alpha
self.dropout = dropout
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | hcmus-nlp-chatbot/CRSLab | SelfAttentionBatch | false | 15,508 | [
"MIT"
] | 315 | b3ab262a4ad93cbae98fe66541eb735377768a35 | https://github.com/hcmus-nlp-chatbot/CRSLab/tree/b3ab262a4ad93cbae98fe66541eb735377768a35 |
ACELoss | import torch
import torch.nn as nn
class ACELoss(nn.Module):
"""
Ref: [1] Aggregation Cross-Entropy for Sequence Recognition. CVPR-2019
"""
def __init__(self, character, eps=1e-10):
"""
Args:
character (dict): recognition dictionary
eps (float): margin of erro... | 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
... | hikopensource/DAVAR-Lab-OCR | ACELoss | false | 15,509 | [
"Apache-2.0"
] | 387 | c65285f6668864cca7a12770ae4c8d083ea1cf1b | https://github.com/hikopensource/DAVAR-Lab-OCR/tree/c65285f6668864cca7a12770ae4c8d083ea1cf1b |
MultiscalePixelLoss | import torch
import torch.nn as nn
class MultiscalePixelLoss(nn.Module):
def __init__(self, loss_f=nn.L1Loss(), scale=5):
super(MultiscalePixelLoss, self).__init__()
self.criterion = loss_f
self.downsample = nn.AvgPool2d(2, stride=2, count_include_pad=False)
self.weights = [1, 0.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
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
... | grofit/traiNNer | MultiscalePixelLoss | false | 15,510 | [
"Apache-2.0"
] | 78 | 12d006fd44ed304e4178839c53b1f3d95ca25dcb | https://github.com/grofit/traiNNer/tree/12d006fd44ed304e4178839c53b1f3d95ca25dcb |
TransformerNet | import torch
class ConvLayer(torch.nn.Module):
"""
A small wrapper around nn.Conv2d, so as to make the code cleaner and allow for experimentation with padding
"""
def __init__(self, in_channels, out_channels, kernel_size, stride):
super().__init__()
self.conv2d = torch.nn.Conv2d(i... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | gordicaleksa/pytorch-nst-feedforward | TransformerNet | false | 15,511 | [
"MIT"
] | 50 | 00c96e8e3f1b0b7fb4c14254fd0c6f1281a29598 | https://github.com/gordicaleksa/pytorch-nst-feedforward/tree/00c96e8e3f1b0b7fb4c14254fd0c6f1281a29598 |
TripletLoss | import torch
import torch.nn as nn
class TripletLoss(nn.Module):
"""Triplet loss for metric learning
"""
def __init__(self, margin=1.0, p=2, loss_weight=1.0, reduction='mean'):
""" Initialization.
Args:
margin(float): a margin distance between for anchor-positive and anchor-... | 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... | hikopensource/DAVAR-Lab-OCR | TripletLoss | false | 15,512 | [
"Apache-2.0"
] | 387 | c65285f6668864cca7a12770ae4c8d083ea1cf1b | https://github.com/hikopensource/DAVAR-Lab-OCR/tree/c65285f6668864cca7a12770ae4c8d083ea1cf1b |
TSAFusion | import torch
import torch.nn as nn
class TSAFusion(nn.Module):
"""Temporal Spatial Attention (TSA) fusion module.
Temporal: Calculate the correlation between center frame and
neighboring frames;
Spatial: It has 3 pyramid levels, the attention is similar to SFT.
(SFT: Recovering realistic ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | grofit/traiNNer | TSAFusion | false | 15,513 | [
"Apache-2.0"
] | 78 | 12d006fd44ed304e4178839c53b1f3d95ca25dcb | https://github.com/grofit/traiNNer/tree/12d006fd44ed304e4178839c53b1f3d95ca25dcb |
CReLU | import torch
import torch.nn as nn
class Scale(nn.Module):
def __init__(self, nchannels, bias=True, init_scale=1.0):
super().__init__()
self.nchannels = nchannels
self.weight = nn.Parameter(torch.Tensor(1, nchannels, 1, 1))
if bias:
self.bias = nn.Parameter(torch.Tenso... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
emp... | hilman-dayo/ObjectDetection-OneStageDet | CReLU | false | 15,514 | [
"MIT"
] | 331 | 44054ad335e24e99a98fdad0d18b9bf3a80c941c | https://github.com/hilman-dayo/ObjectDetection-OneStageDet/tree/44054ad335e24e99a98fdad0d18b9bf3a80c941c |
MixPad2d | import torch
from torch import nn
class MixPad2d(nn.Module):
"""Mixed padding modes for H and W dimensions
Args:
padding (tuple): the size of the padding for x and y, ie (pad_x, pad_y)
modes (tuple): the padding modes for x and y, the values of each can be
``'constant'``, ``'refle... | 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... | hhj1897/face_parsing | MixPad2d | false | 15,515 | [
"MIT"
] | 70 | 9cd26b6916f562a2ab356b6b22e9ad93e19f2051 | https://github.com/hhj1897/face_parsing/tree/9cd26b6916f562a2ab356b6b22e9ad93e19f2051 |
PaddedMaxPool2d | import torch
import torch.nn as nn
import torch.nn.functional as F
class PaddedMaxPool2d(nn.Module):
""" Maxpool layer with a replicating padding.
Args:
kernel_size (int or tuple): Kernel size for maxpooling
stride (int or tuple, optional): The stride of the window; Default ``kernel_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
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
emp... | hilman-dayo/ObjectDetection-OneStageDet | PaddedMaxPool2d | false | 15,516 | [
"MIT"
] | 331 | 44054ad335e24e99a98fdad0d18b9bf3a80c941c | https://github.com/hilman-dayo/ObjectDetection-OneStageDet/tree/44054ad335e24e99a98fdad0d18b9bf3a80c941c |
ScaleReLU | import torch
import torch.nn as nn
class Scale(nn.Module):
def __init__(self, nchannels, bias=True, init_scale=1.0):
super().__init__()
self.nchannels = nchannels
self.weight = nn.Parameter(torch.Tensor(1, nchannels, 1, 1))
if bias:
self.bias = nn.Parameter(torch.Tenso... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
emp... | hilman-dayo/ObjectDetection-OneStageDet | ScaleReLU | false | 15,517 | [
"MIT"
] | 331 | 44054ad335e24e99a98fdad0d18b9bf3a80c941c | https://github.com/hilman-dayo/ObjectDetection-OneStageDet/tree/44054ad335e24e99a98fdad0d18b9bf3a80c941c |
DiceLoss | import torch
import torch.nn as nn
def binaray_dice_loss(predict, target, smooth=1, p=2, weight=None):
"""Dice loss for binary classification
Args:
predict(Tensor): a tensor of shape [N, H, W]
target(Tensor): a tensor of shape same with predict
smooth(float): a float number to smooth ... | 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... | hikopensource/DAVAR-Lab-OCR | DiceLoss | false | 15,518 | [
"Apache-2.0"
] | 387 | c65285f6668864cca7a12770ae4c8d083ea1cf1b | https://github.com/hikopensource/DAVAR-Lab-OCR/tree/c65285f6668864cca7a12770ae4c8d083ea1cf1b |
TransformerBlock | import math
import torch
import torch.nn.functional as F
def gelu(x):
"""
GELU activation function.
"""
return x * 0.5 * (1.0 + torch.erf(x / math.sqrt(2.0)))
class MultiHeadedAttention(torch.nn.Module):
"""
Implement of multi-head attention.
"""
def __init__(self, n_heads, hidden_s... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
im... | haophancs/TREQS | TransformerBlock | false | 15,519 | [
"MIT"
] | 149 | 49e354ce2a08cf963ec139d99936020e0f80ced8 | https://github.com/haophancs/TREQS/tree/49e354ce2a08cf963ec139d99936020e0f80ced8 |
L2Norm | import torch
import torch.nn as nn
class Scale(nn.Module):
def __init__(self, nchannels, bias=True, init_scale=1.0):
super().__init__()
self.nchannels = nchannels
self.weight = nn.Parameter(torch.Tensor(1, nchannels, 1, 1))
if bias:
self.bias = nn.Parameter(torch.Tenso... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_... | hilman-dayo/ObjectDetection-OneStageDet | L2Norm | false | 15,520 | [
"MIT"
] | 331 | 44054ad335e24e99a98fdad0d18b9bf3a80c941c | https://github.com/hilman-dayo/ObjectDetection-OneStageDet/tree/44054ad335e24e99a98fdad0d18b9bf3a80c941c |
MultiHeadedAttention | import torch
import numpy as np
import torch.utils.data
class ScaledDotProductAttention(torch.nn.Module):
"""
Scaled, softmax attention module for Transformer as defined by
Attention(Q, K, V) on pg 4. Returns the final attention vectors as well as
the attention matrices (pairwise scores). """
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.... | hengwei-chan/protein_transformer | MultiHeadedAttention | false | 15,521 | [
"BSD-3-Clause"
] | 77 | 988bb0fcbb94b37e5a02071bd345ea073ad605f8 | https://github.com/hengwei-chan/protein_transformer/tree/988bb0fcbb94b37e5a02071bd345ea073ad605f8 |
DiceLoss | import torch
import torch.nn as nn
class DiceLoss(nn.Module):
def __init__(self, ignore_target=-1):
super().__init__()
self.ignore_target = ignore_target
def forward(self, input, target):
"""
:param input: (N), logit
:param target: (N), {0, 1}
:return:
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
emp... | hlesmqh/WS3D | DiceLoss | false | 15,522 | [
"MIT"
] | 100 | 6816eeb135923a59de34ee5d94be2d0fd3ec83f9 | https://github.com/hlesmqh/WS3D/tree/6816eeb135923a59de34ee5d94be2d0fd3ec83f9 |
LossPredictionLoss | import torch
import torch.nn as nn
import torch.nn.parallel
import torch.optim
import torch.utils.data
import torch.utils.data.distributed
from math import sqrt as sqrt
from itertools import product as product
class LossPredictionLoss(nn.Module):
def __init__(self, margin=1.0):
super(LossPredictionLoss, ... | 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... | hilman-dayo/active_learning | LossPredictionLoss | false | 15,523 | [
"Apache-2.0"
] | 54 | cc5b0388be25946e794d59d95e4d9c8c56e24207 | https://github.com/hilman-dayo/active_learning/tree/cc5b0388be25946e794d59d95e4d9c8c56e24207 |
PPReLU | import torch
import torch.nn as nn
class Scale(nn.Module):
def __init__(self, nchannels, bias=True, init_scale=1.0):
super().__init__()
self.nchannels = nchannels
self.weight = nn.Parameter(torch.Tensor(1, nchannels, 1, 1))
if bias:
self.bias = nn.Parameter(torch.Tenso... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
emp... | hilman-dayo/ObjectDetection-OneStageDet | PPReLU | false | 15,524 | [
"MIT"
] | 331 | 44054ad335e24e99a98fdad0d18b9bf3a80c941c | https://github.com/hilman-dayo/ObjectDetection-OneStageDet/tree/44054ad335e24e99a98fdad0d18b9bf3a80c941c |
Scale | import torch
import torch.nn as nn
class Scale(nn.Module):
def __init__(self, nchannels, bias=True, init_scale=1.0):
super().__init__()
self.nchannels = nchannels
self.weight = nn.Parameter(torch.Tensor(1, nchannels, 1, 1))
if bias:
self.bias = nn.Parameter(torch.Tenso... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | hilman-dayo/ObjectDetection-OneStageDet | Scale | false | 15,525 | [
"MIT"
] | 331 | 44054ad335e24e99a98fdad0d18b9bf3a80c941c | https://github.com/hilman-dayo/ObjectDetection-OneStageDet/tree/44054ad335e24e99a98fdad0d18b9bf3a80c941c |
PositionEmbedding2D | import logging
import torch
import torch.nn as nn
def get_root_logger(log_file=None, log_level=logging.INFO):
"""Use `get_logger` method in mmcv to get the root logger.
The logger will be initialized if it has not been initialized. By default a
StreamHandler will be added. If `log_file` is specified, a 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 logging
import torch.n... | hikopensource/DAVAR-Lab-OCR | PositionEmbedding2D | false | 15,526 | [
"Apache-2.0"
] | 387 | c65285f6668864cca7a12770ae4c8d083ea1cf1b | https://github.com/hikopensource/DAVAR-Lab-OCR/tree/c65285f6668864cca7a12770ae4c8d083ea1cf1b |
BertAttention | from _paritybench_helpers import _mock_config
import math
import torch
from typing import *
from torch import nn
import torch.utils.checkpoint
class BertSelfAttention(nn.Module):
def __init__(self, config):
super().__init__()
if (config.hidden_size % config.num_attention_heads != 0 and not
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | hiaoxui/soft-prompts | BertAttention | false | 15,527 | [
"Apache-2.0"
] | 48 | 214dbedf735fe1c98ab2be3a26066d50ff0a86d8 | https://github.com/hiaoxui/soft-prompts/tree/214dbedf735fe1c98ab2be3a26066d50ff0a86d8 |
SigmoidFocalClassificationLoss | import torch
import torch.nn as nn
def _sigmoid_cross_entropy_with_logits(logits, labels):
loss = torch.clamp(logits, min=0) - logits * labels.type_as(logits)
loss += torch.log1p(torch.exp(-torch.abs(logits)))
return loss
class SigmoidFocalClassificationLoss(nn.Module):
"""Sigmoid focal cross entrop... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import torc... | hlesmqh/WS3D | SigmoidFocalClassificationLoss | false | 15,528 | [
"MIT"
] | 100 | 6816eeb135923a59de34ee5d94be2d0fd3ec83f9 | https://github.com/hlesmqh/WS3D/tree/6816eeb135923a59de34ee5d94be2d0fd3ec83f9 |
MarginRankingLoss | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.parallel
import torch.optim
import torch.utils.data
import torch.utils.data.distributed
from math import sqrt as sqrt
from itertools import product as product
class MarginRankingLoss(nn.Module):
def __init__(self, margin=1.0):
... | import torch
from torch import device
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
import torch.nn.parallel
import torch.opti... | hilman-dayo/active_learning | MarginRankingLoss | false | 15,529 | [
"Apache-2.0"
] | 54 | cc5b0388be25946e794d59d95e4d9c8c56e24207 | https://github.com/hilman-dayo/active_learning/tree/cc5b0388be25946e794d59d95e4d9c8c56e24207 |
RollRev | import torch
from torch import nn
def roll(x, step, axis):
shape = x.shape
for i, s in enumerate(step):
if s >= 0:
x1 = x.narrow(axis[i], 0, s)
x2 = x.narrow(axis[i], s, shape[axis[i]] - s)
else:
x2 = x.narrow(axis[i], shape[axis[i]] + s, -s)
x1 ... | 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... | hongyehu/NeuralRG | RollRev | false | 15,530 | [
"Apache-2.0"
] | 65 | ff4eb18f7f9e083dac6f3da3995f3f69ecf381e8 | https://github.com/hongyehu/NeuralRG/tree/ff4eb18f7f9e083dac6f3da3995f3f69ecf381e8 |
Reorg | import torch
import torch.nn as nn
class Reorg(nn.Module):
""" This layer reorganizes a tensor according to a stride.
The dimensions 2,3 will be sliced by the stride and then stacked in dimension 1. (input must have 4 dimensions)
Args:
stride (int): stride to divide the input tensor
"""
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | hilman-dayo/ObjectDetection-OneStageDet | Reorg | false | 15,531 | [
"MIT"
] | 331 | 44054ad335e24e99a98fdad0d18b9bf3a80c941c | https://github.com/hilman-dayo/ObjectDetection-OneStageDet/tree/44054ad335e24e99a98fdad0d18b9bf3a80c941c |
DiceLoss | import torch
import torch.nn as nn
class DiceLoss(nn.Module):
def __init__(self, eps=1e-06):
super().__init__()
assert isinstance(eps, float)
self.eps = eps
def forward(self, pred, target, mask=None):
pred = pred.contiguous().view(pred.size()[0], -1)
target = target.c... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
emp... | hongxuenong/mmocr | DiceLoss | false | 15,532 | [
"Apache-2.0"
] | 2,261 | e8e3a059f8f2e4fca96af37751c33563fc48e2ba | https://github.com/hongxuenong/mmocr/tree/e8e3a059f8f2e4fca96af37751c33563fc48e2ba |
MultiHeadAttn | import torch
import torch.cuda
from torch.nn import functional as F
from torch import nn
import torch.distributed
import torch.utils.data
import torch.optim
class MultiHeadAttn(nn.Module):
def __init__(self, n_head, d_model, d_head, dropout, dropatt=0.1,
pre_lnorm=False):
super(MultiHeadAttn, sel... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | hamjam/NeMo | MultiHeadAttn | false | 15,533 | [
"Apache-2.0"
] | 4,145 | b3484d32e1317666151f931bfa39867d88ed8658 | https://github.com/hamjam/NeMo/tree/b3484d32e1317666151f931bfa39867d88ed8658 |
PLU | import torch
import torch.nn as nn
class PLU(nn.Module):
"""
y = max(alpha*(x+c)−c, min(alpha*(x−c)+c, x))
from PLU: The Piecewise Linear Unit Activation Function
"""
def __init__(self, alpha=0.1, c=1):
super().__init__()
self.alpha = alpha
self.c = c
def forward(self... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
emp... | hilman-dayo/ObjectDetection-OneStageDet | PLU | false | 15,534 | [
"MIT"
] | 331 | 44054ad335e24e99a98fdad0d18b9bf3a80c941c | https://github.com/hilman-dayo/ObjectDetection-OneStageDet/tree/44054ad335e24e99a98fdad0d18b9bf3a80c941c |
GraphConv | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import init
class MeanAggregator(nn.Module):
def forward(self, features, A):
x = torch.bmm(A, features)
return x
class GraphConv(nn.Module):
def __init__(self, in_dim, out_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
import torch.nn as nn
from to... | hongxuenong/mmocr | GraphConv | false | 15,535 | [
"Apache-2.0"
] | 2,261 | e8e3a059f8f2e4fca96af37751c33563fc48e2ba | https://github.com/hongxuenong/mmocr/tree/e8e3a059f8f2e4fca96af37751c33563fc48e2ba |
AppendLayer | import torch
import numpy as np
import torch.nn as nn
class AppendLayer(nn.Module):
def __init__(self, noise=0.001, *args, **kwargs):
super().__init__(*args, **kwargs)
self.log_var = nn.Parameter(torch.DoubleTensor(1, 1))
nn.init.constant_(self.log_var, val=np.log(noise))
def forward... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
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... | hssandriss/pybnn | AppendLayer | false | 15,536 | [
"BSD-3-Clause"
] | 110 | e878553a24ce9ebdde9088f285c7f292e4ee8885 | https://github.com/hssandriss/pybnn/tree/e878553a24ce9ebdde9088f285c7f292e4ee8885 |
ConvolutionLayer | import torch
import torch.nn as nn
class ConvolutionLayer(nn.Module):
def __init__(self, channels, filters, kernel_size, stride=1, dilation=1):
super(ConvolutionLayer, self).__init__()
padding = kernel_size // 2
padding += padding * (dilation - 1)
self.conv = nn.Conv1d(channels, 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... | huak95/attacut | ConvolutionLayer | false | 15,537 | [
"MIT"
] | 54 | 100333931023cd009daeddec0cba4cdfce3d0b68 | https://github.com/huak95/attacut/tree/100333931023cd009daeddec0cba4cdfce3d0b68 |
rbbox_corners_aligned | import torch
import torch.nn as nn
class rbbox_corners_aligned(nn.Module):
def _init_(self, gboxes):
super(rbbox_corners_aligned, self)._init_()
self.corners_gboxes = gboxes
return
def forward(ctx, gboxes):
N = gboxes.shape[0]
center_x = gboxes[:, 0]
center_y ... | 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... | hlesmqh/WS3D | rbbox_corners_aligned | false | 15,538 | [
"MIT"
] | 100 | 6816eeb135923a59de34ee5d94be2d0fd3ec83f9 | https://github.com/hlesmqh/WS3D/tree/6816eeb135923a59de34ee5d94be2d0fd3ec83f9 |
GCN | from torch.nn import Module
import math
import torch
from torch import nn
import torch.nn.functional as F
from torch.nn.parameter import Parameter
from torch.nn.modules.module import Module
class GraphConvolution(Module):
"""
Simple GCN layer, similar to https://arxiv.org/abs/1609.02907
"""
def __ini... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | hongfz16/Garment4D | GCN | false | 15,539 | [
"MIT"
] | 89 | 9317dc262f3d35eb9e6cd6a7bfbb29f04560ca35 | https://github.com/hongfz16/Garment4D/tree/9317dc262f3d35eb9e6cd6a7bfbb29f04560ca35 |
Joiner | import torch
from torch import nn
import torch.nn.functional as F
class Joiner(nn.Module):
def __init__(self, input_dim: 'int', output_dim: 'int'):
super().__init__()
self.output_linear = nn.Linear(input_dim, output_dim)
def forward(self, encoder_out: 'torch.Tensor', decoder_out: 'torch.Tens... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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... | huangruizhe/icefall | Joiner | false | 15,541 | [
"Apache-2.0"
] | 173 | ea8af0ee9af5169d93f8f389ffebbc27a1d9e82a | https://github.com/huangruizhe/icefall/tree/ea8af0ee9af5169d93f8f389ffebbc27a1d9e82a |
Squeezing | import torch
from torch import nn
class Squeezing(nn.Module):
def __init__(self, filterSize=2):
super(Squeezing, self).__init__()
self.filterSize = filterSize
def forward(self, input):
scale_factor = self.filterSize
batch_size, in_channels, in_height, in_width = input.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 import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_str... | hongyehu/NeuralRG | Squeezing | false | 15,542 | [
"Apache-2.0"
] | 65 | ff4eb18f7f9e083dac6f3da3995f3f69ecf381e8 | https://github.com/hongyehu/NeuralRG/tree/ff4eb18f7f9e083dac6f3da3995f3f69ecf381e8 |
Warp | import torch
from torch import Tensor
import torch.nn as nn
import torch.nn.functional as F
def coords_grid(flow: 'Tensor') ->Tensor:
"""Generate shifted coordinate grid based based input flow.
Args:
flow (Tensor): Estimated optical flow.
Returns:
Tensor: The coordinate that shifted by i... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
from torch import Tensor
import torch.nn as nn
assert_size_stride = torch._C._d... | hologerry/mmflow | Warp | false | 15,543 | [
"Apache-2.0"
] | 481 | 40caf064851bd95317424e31cc137c0007a2bece | https://github.com/hologerry/mmflow/tree/40caf064851bd95317424e31cc137c0007a2bece |
PCEN | import torch
import torch.nn as nn
from torch.nn.parameter import Parameter
import torch.quantization
import torch.utils.data.distributed
class PCEN(nn.Module):
def __init__(self):
super(PCEN, self).__init__()
"""
initialising the layer param with the best parametrised values i searched o... | 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
from torch.nn.parameter import Parameter
import torch.qua... | hovercraft-github/wav2letter.pytorch | PCEN | false | 15,544 | [
"MIT"
] | 121 | e2b82b418a7854522540e0925bcf894c0ca80e6a | https://github.com/hovercraft-github/wav2letter.pytorch/tree/e2b82b418a7854522540e0925bcf894c0ca80e6a |
MultiHeadAttention | import math
import torch
import torch.utils.data
from torch import nn
from torch.nn import LayerNorm as FusedLayerNorm
class MultiHeadAttention(nn.Module):
"""
Multi-head scaled dot-product attention layer.
Args:
hidden_size: size of the embeddings in the model, also known as d_model
num_a... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | hieuvecto/CASIA-SURF_CeFA | MultiHeadAttention | false | 15,545 | [
"MIT"
] | 133 | 71dfd846ce968b3ed26974392a6e0c9b40aa12ae | https://github.com/hieuvecto/CASIA-SURF_CeFA/tree/71dfd846ce968b3ed26974392a6e0c9b40aa12ae |
GlobalAveragePooling | import torch
from torch import nn
import torch.nn.functional as F
class GlobalAveragePooling(nn.Module):
def __init__(self):
super(GlobalAveragePooling, self).__init__()
def forward(self, feat):
num_channels = feat.size(1)
return F.avg_pool2d(feat, (feat.size(2), feat.size(3))).view(... | 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... | hugovk/EnAET | GlobalAveragePooling | false | 15,546 | [
"MIT"
] | 87 | 596a1be95f4ebfc5fc4f372f251e66fb03e23b5a | https://github.com/hugovk/EnAET/tree/596a1be95f4ebfc5fc4f372f251e66fb03e23b5a |
BPR_max | import torch
import torch.nn as nn
import torch.nn.functional as F
class BPR_max(nn.Module):
def __init__(self):
super(BPR_max, self).__init__()
def forward(self, logit):
logit_softmax = F.softmax(logit, dim=1)
diff = logit.diag().view(-1, 1).expand_as(logit) - logit
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
... | hungthanhpham94/GRU4REC-pytorch | BPR_max | false | 15,547 | [
"Apache-2.0"
] | 184 | 666b84264c4afae757fe55c6997dcf0a4da1d44e | https://github.com/hungthanhpham94/GRU4REC-pytorch/tree/666b84264c4afae757fe55c6997dcf0a4da1d44e |
mbr_convex_hull | import torch
import torch.nn as nn
class mbr_convex_hull(nn.Module):
def _init_(self, hull_points_2d):
super(mbr_convex_hull, self)._init_()
self.hull_points_2d = hull_points_2d
return
def forward(ctx, hull_points_2d):
N = hull_points_2d.shape[0]
edges = hull_points_2... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | hlesmqh/WS3D | mbr_convex_hull | false | 15,548 | [
"MIT"
] | 100 | 6816eeb135923a59de34ee5d94be2d0fd3ec83f9 | https://github.com/hlesmqh/WS3D/tree/6816eeb135923a59de34ee5d94be2d0fd3ec83f9 |
GlobalWeightedAvgPool2d | import torch
from torch import nn
class GlobalWeightedAvgPool2d(nn.Module):
"""
Global Weighted Average Pooling from paper "Global Weighted Average
Pooling Bridges Pixel-level Localization and Image-level Classification"
"""
def __init__(self, features: 'int', flatten=False):
super().__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 math as tl_math
from torch im... | huangjiadidi/dfdc_deepfake_challenge | GlobalWeightedAvgPool2d | false | 15,549 | [
"MIT"
] | 499 | 1f78fe93a5a445ced386e43b3b0378ee567eaa77 | https://github.com/huangjiadidi/dfdc_deepfake_challenge/tree/1f78fe93a5a445ced386e43b3b0378ee567eaa77 |
ScalableTanh | import torch
from torch import nn
class ScalableTanh(nn.Module):
def __init__(self, input_size):
super(ScalableTanh, self).__init__()
self.scale = nn.Parameter(torch.zeros(input_size), requires_grad=True)
def forward(self, x):
return self.scale * torch.tanh(x)
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.triton_helpers import libdevice
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | hongyehu/NeuralRG | ScalableTanh | false | 15,550 | [
"Apache-2.0"
] | 65 | ff4eb18f7f9e083dac6f3da3995f3f69ecf381e8 | https://github.com/hongyehu/NeuralRG/tree/ff4eb18f7f9e083dac6f3da3995f3f69ecf381e8 |
Net | import torch
import torch.nn as nn
class Net(nn.Module):
def __init__(self, n_inputs, n_units=[50, 50, 50]):
super(Net, self).__init__()
self.fc1 = nn.Linear(n_inputs, n_units[0])
self.fc2 = nn.Linear(n_units[0], n_units[1])
self.fc3 = nn.Linear(n_units[1], n_units[2])
sel... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as ... | hssandriss/pybnn | Net | false | 15,551 | [
"BSD-3-Clause"
] | 110 | e878553a24ce9ebdde9088f285c7f292e4ee8885 | https://github.com/hssandriss/pybnn/tree/e878553a24ce9ebdde9088f285c7f292e4ee8885 |
ScaleDotProductAttention | import math
import torch
from torch import nn
class ScaleDotProductAttention(nn.Module):
"""
compute scale dot product attention
Query : given sentence that we focused on (decoder)
Key : every sentence to check relationship with Qeury(encoder)
Value : every sentence same with Key (encoder)
""... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | hyunwoongko/transformer | ScaleDotProductAttention | false | 15,552 | [
"Apache-2.0"
] | 233 | 8f7aaa19d37b088c156db0512868127ba9bf1a0f | https://github.com/hyunwoongko/transformer/tree/8f7aaa19d37b088c156db0512868127ba9bf1a0f |
TOP1_max | import torch
import torch.nn as nn
import torch.nn.functional as F
class TOP1_max(nn.Module):
def __init__(self):
super(TOP1_max, self).__init__()
def forward(self, logit):
logit_softmax = F.softmax(logit, dim=1)
diff = -(logit.diag().view(-1, 1).expand_as(logit) - logit)
los... | 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
... | hungthanhpham94/GRU4REC-pytorch | TOP1_max | false | 15,553 | [
"Apache-2.0"
] | 184 | 666b84264c4afae757fe55c6997dcf0a4da1d44e | https://github.com/hungthanhpham94/GRU4REC-pytorch/tree/666b84264c4afae757fe55c6997dcf0a4da1d44e |
ConvolutionModule | import torch
from torch import Tensor
from torch import nn
class Swish(torch.nn.Module):
"""Construct an Swish object."""
def forward(self, x: 'Tensor') ->Tensor:
"""Return Swich activation function."""
return x * torch.sigmoid(x)
class ConvolutionModule(nn.Module):
"""ConvolutionModule... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 T... | huangruizhe/icefall | ConvolutionModule | false | 15,554 | [
"Apache-2.0"
] | 173 | ea8af0ee9af5169d93f8f389ffebbc27a1d9e82a | https://github.com/huangruizhe/icefall/tree/ea8af0ee9af5169d93f8f389ffebbc27a1d9e82a |
UnetGeneratorWBC | import torch
from torch.nn import functional as F
import torch.nn as nn
def tf_2xupsample_bilinear(x):
b, c, h, w = x.shape
out = torch.zeros(b, c, h * 2, w * 2)
out[:, :, ::2, ::2] = x
padded = F.pad(x, (0, 1, 0, 1), mode='replicate')
out[:, :, 1::2, ::2] = (padded[:, :, :-1, :-1] + padded[:, :, ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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 function... | grofit/traiNNer | UnetGeneratorWBC | false | 15,555 | [
"Apache-2.0"
] | 78 | 12d006fd44ed304e4178839c53b1f3d95ca25dcb | https://github.com/grofit/traiNNer/tree/12d006fd44ed304e4178839c53b1f3d95ca25dcb |
IOUloss | import torch
import torch.nn as nn
import torch.utils.data
class IOUloss(nn.Module):
def __init__(self, reduction='none', loss_type='iou'):
super(IOUloss, self).__init__()
self.reduction = reduction
self.loss_type = loss_type
def forward(self, pred, target):
assert pred.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
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
import torch.utils.data
assert_size_stride = torch._C._dynamo.guard... | hyperfraise/ByteTrack | IOUloss | false | 15,556 | [
"MIT"
] | 1,039 | d742a3321c14a7412f024f2218142c7441c1b699 | https://github.com/hyperfraise/ByteTrack/tree/d742a3321c14a7412f024f2218142c7441c1b699 |
MyBCEWithLogitsLoss | import torch
import torch.utils.data
import torch
import torch.nn as nn
class MyBCEWithLogitsLoss(nn.Module):
def __init__(self):
nn.Module.__init__(self)
self.m = nn.BCEWithLogitsLoss()
def forward(self, positives, negatives):
values = torch.cat((positives, negatives), 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 libdevice, math as tl_math
import torc... | huoxusg/ScenarioMeta | MyBCEWithLogitsLoss | false | 15,557 | [
"MIT"
] | 79 | ce753da45a3d46ac08961ffc71b2131ae3f7e551 | https://github.com/huoxusg/ScenarioMeta/tree/ce753da45a3d46ac08961ffc71b2131ae3f7e551 |
LayerNorm | import torch
from torch import nn
class LayerNorm(nn.Module):
def __init__(self, d_model, eps=1e-12):
super(LayerNorm, self).__init__()
self.gamma = nn.Parameter(torch.ones(d_model))
self.beta = nn.Parameter(torch.zeros(d_model))
self.eps = eps
def forward(self, x):
m... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | hyunwoongko/transformer | LayerNorm | false | 15,558 | [
"Apache-2.0"
] | 233 | 8f7aaa19d37b088c156db0512868127ba9bf1a0f | https://github.com/hyunwoongko/transformer/tree/8f7aaa19d37b088c156db0512868127ba9bf1a0f |
KeyValue | import torch
import torch.nn
import torch.utils.data.dataset
class KeyValue(torch.nn.Module):
def __init__(self, indim, keydim, valdim):
super(KeyValue, self).__init__()
self.key_conv = torch.nn.Conv2d(indim, keydim, kernel_size=3,
padding=1, stride=1)
self.value_conv = torch.... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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
import torch.utils.data.dataset
assert_size_stride = torch._C._d... | hzxie/RMNet | KeyValue | false | 15,559 | [
"MIT"
] | 66 | 32a16f9c9473463a41dd6e95f72b06dd830fc1eb | https://github.com/hzxie/RMNet/tree/32a16f9c9473463a41dd6e95f72b06dd830fc1eb |
Self_Attn | import torch
from torch import nn
class Self_Attn(nn.Module):
""" Self attention Layer"""
def __init__(self, in_dim, activation):
super(Self_Attn, self).__init__()
self.chanel_in = in_dim
self.activation = activation
if in_dim >= 8:
self.query_conv = nn.Conv2d(in_c... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | hugovk/EnAET | Self_Attn | false | 15,560 | [
"MIT"
] | 87 | 596a1be95f4ebfc5fc4f372f251e66fb03e23b5a | https://github.com/hugovk/EnAET/tree/596a1be95f4ebfc5fc4f372f251e66fb03e23b5a |
QueryEncoder | import torch
from torch import nn
import torch.nn.functional as F
class QueryEncoder(nn.Module):
def __init__(self, input_size):
super(QueryEncoder, self).__init__()
self.fc1 = nn.Linear(input_size, 16)
self.fc2 = nn.Linear(16, 10)
self.fc3 = nn.Linear(10, 8)
def forward(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... | huyi-work/UnifiedEmbeddingModel | QueryEncoder | false | 15,561 | [
"MIT"
] | 50 | 85c8442122213d1f1b1027df0fd34f428259aaa4 | https://github.com/huyi-work/UnifiedEmbeddingModel/tree/85c8442122213d1f1b1027df0fd34f428259aaa4 |
MyHingeLoss | import torch
import torch.utils.data
import torch
import torch.nn as nn
class MyHingeLoss(nn.Module):
def __init__(self, margin=0.0):
nn.Module.__init__(self)
self.m = nn.MarginRankingLoss(margin=margin)
def forward(self, positives, negatives):
labels = positives.new_ones(positives.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
import torch.utils.data
import torch
import torch.nn as nn
assert_size_stride = torch._C.... | huoxusg/ScenarioMeta | MyHingeLoss | false | 15,562 | [
"MIT"
] | 79 | ce753da45a3d46ac08961ffc71b2131ae3f7e551 | https://github.com/huoxusg/ScenarioMeta/tree/ce753da45a3d46ac08961ffc71b2131ae3f7e551 |
DocumentEncoder | import torch
from torch import nn
import torch.nn.functional as F
class DocumentEncoder(nn.Module):
def __init__(self, input_size, hidden_layer_sizes=(100,), activation=(
'relu',), solver='adam'):
super(DocumentEncoder, self).__init__()
self.fc1 = nn.Linear(input_size, 12)
self.fc... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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... | huyi-work/UnifiedEmbeddingModel | DocumentEncoder | false | 15,563 | [
"MIT"
] | 50 | 85c8442122213d1f1b1027df0fd34f428259aaa4 | https://github.com/huyi-work/UnifiedEmbeddingModel/tree/85c8442122213d1f1b1027df0fd34f428259aaa4 |
PositionalEncodingImageBoxes | import torch
from torch import nn as nn
import torch.nn.init
from torchvision import models as models
class PositionalEncodingImageBoxes(nn.Module):
def __init__(self, d_model, mode='project-and-sum'):
super().__init__()
self.mode = mode
if mode == 'project-and-sum':
self.map ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import 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 as nn
import torch.nn.init
from torchvision import models a... | huylb314/TERAN | PositionalEncodingImageBoxes | false | 15,564 | [
"Apache-2.0"
] | 46 | f6a380db423e75fcdaa6ef44f1a79d293a38efba | https://github.com/huylb314/TERAN/tree/f6a380db423e75fcdaa6ef44f1a79d293a38efba |
AdaptiveConcatPool3d | import torch
import torch.nn as nn
import torch.nn.functional as F
class AdaptiveConcatPool3d(nn.Module):
def forward(self, x):
return torch.cat((F.adaptive_avg_pool3d(x, 1), F.
adaptive_max_pool3d(x, 1)), dim=1)
def get_inputs():
return [torch.rand([4, 4, 4, 4])]
def get_init_inputs(... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | i-pan/kaggle-melanoma | AdaptiveConcatPool3d | false | 15,565 | [
"MIT"
] | 68 | caaec0d7e9cafc7b405eb86e7fdf00107d89e1d9 | https://github.com/i-pan/kaggle-melanoma/tree/caaec0d7e9cafc7b405eb86e7fdf00107d89e1d9 |
MultiHeadAttention | import math
import torch
from torch import nn
class ScaleDotProductAttention(nn.Module):
"""
compute scale dot product attention
Query : given sentence that we focused on (decoder)
Key : every sentence to check relationship with Qeury(encoder)
Value : every sentence same with Key (encoder)
""... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | hyunwoongko/transformer | MultiHeadAttention | false | 15,566 | [
"Apache-2.0"
] | 233 | 8f7aaa19d37b088c156db0512868127ba9bf1a0f | https://github.com/hyunwoongko/transformer/tree/8f7aaa19d37b088c156db0512868127ba9bf1a0f |
ChannelAttentionBlock | import torch
import torch.nn as nn
class ChannelAttentionBlock(nn.Module):
def __init__(self, in_channels):
super(ChannelAttentionBlock, self).__init__()
self.gamma = nn.Parameter(torch.zeros(1))
self.softmax = nn.Softmax(dim=-1)
def forward(self, x):
"""
:param x: in... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | iMED-Lab/ROSE | ChannelAttentionBlock | false | 15,567 | [
"Apache-2.0"
] | 64 | 8d99a2a06fc645410b1d388193b3148404e61230 | https://github.com/iMED-Lab/ROSE/tree/8d99a2a06fc645410b1d388193b3148404e61230 |
focal_loss | import torch
import torch.nn as nn
def clip_by_tensor(t, t_min, t_max):
"""
clip_by_tensor
:param t: tensor
:param t_min: min
:param t_max: max
:return: cliped tensor
"""
t = t.float()
result = (t >= t_min).float() * t + (t < t_min).float() * t_min
result = (result <= t_max).fl... | 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_... | iMED-Lab/ROSE | focal_loss | false | 15,568 | [
"Apache-2.0"
] | 64 | 8d99a2a06fc645410b1d388193b3148404e61230 | https://github.com/iMED-Lab/ROSE/tree/8d99a2a06fc645410b1d388193b3148404e61230 |
DenseCrossEntropy | import torch
import torch.nn as nn
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 = loss.sum(-1)
return loss.mean()
def g... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
... | i-pan/kaggle-melanoma | DenseCrossEntropy | false | 15,569 | [
"MIT"
] | 68 | caaec0d7e9cafc7b405eb86e7fdf00107d89e1d9 | https://github.com/i-pan/kaggle-melanoma/tree/caaec0d7e9cafc7b405eb86e7fdf00107d89e1d9 |
MemoryReader | import math
import torch
import torch.nn
import torch.nn.functional as F
import torch.utils.data.dataset
class MemoryReader(torch.nn.Module):
def __init__(self):
super(MemoryReader, self).__init__()
def forward(self, m_key, m_val, q_key, q_val):
B, D_e, T, H, W = m_key.size()
_, D_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.... | hzxie/RMNet | MemoryReader | false | 15,570 | [
"MIT"
] | 66 | 32a16f9c9473463a41dd6e95f72b06dd830fc1eb | https://github.com/hzxie/RMNet/tree/32a16f9c9473463a41dd6e95f72b06dd830fc1eb |
BPRLoss | import torch
import torch.nn as nn
import torch.nn.functional as F
class BPRLoss(nn.Module):
def __init__(self):
super(BPRLoss, self).__init__()
def forward(self, logit):
"""
Args:
logit (BxB): Variable that stores the logits for the items in the mini-batch
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import torc... | hungthanhpham94/GRU4REC-pytorch | BPRLoss | false | 15,571 | [
"Apache-2.0"
] | 184 | 666b84264c4afae757fe55c6997dcf0a4da1d44e | https://github.com/hungthanhpham94/GRU4REC-pytorch/tree/666b84264c4afae757fe55c6997dcf0a4da1d44e |
LossFunction | import torch
import torch.nn as nn
from torch.autograd import Variable
import torch.nn.functional as F
class BPRLoss(nn.Module):
def __init__(self):
super(BPRLoss, self).__init__()
def forward(self, logit):
"""
Args:
logit (BxB): Variable that stores the logits for the it... | 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 Variable
import torch.nn.functional as F
assert_size_stride = torch._C._dynamo.guards.asser... | hungthanhpham94/GRU4REC-pytorch | LossFunction | false | 15,572 | [
"Apache-2.0"
] | 184 | 666b84264c4afae757fe55c6997dcf0a4da1d44e | https://github.com/hungthanhpham94/GRU4REC-pytorch/tree/666b84264c4afae757fe55c6997dcf0a4da1d44e |
GEGLU | import torch
import torch.nn.functional as F
from torch import nn
class GEGLU(nn.Module):
def forward(self, x):
x, gates = x.chunk(2, dim=-1)
return F.gelu(gates) * 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 libdevice
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | idolumbantobing/vit-pytorch | GEGLU | false | 15,573 | [
"MIT"
] | 9,373 | eb70d8dca041cc387b3e1f72d965d8814eeab29a | https://github.com/idolumbantobing/vit-pytorch/tree/eb70d8dca041cc387b3e1f72d965d8814eeab29a |
BPRLoss | import torch
import torch.utils.data
import torch
import torch.nn as nn
class BPRLoss(nn.Module):
def __init__(self):
nn.Module.__init__(self)
self.m = nn.LogSigmoid()
def forward(self, positives, negatives):
return -self.m(positives - negatives).mean()
def get_inputs():
return... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import torc... | huoxusg/ScenarioMeta | BPRLoss | false | 15,574 | [
"MIT"
] | 79 | ce753da45a3d46ac08961ffc71b2131ae3f7e551 | https://github.com/huoxusg/ScenarioMeta/tree/ce753da45a3d46ac08961ffc71b2131ae3f7e551 |
SirenLayer | import torch
from torch import nn
from math import sqrt
class Sine(nn.Module):
"""Sine activation with scaling.
Args:
w0 (float): Omega_0 parameter from SIREN paper.
"""
def __init__(self, w0=1.0):
super().__init__()
self.w0 = w0
def forward(self, x):
return torc... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import math as tl_math
from torch im... | idgmatrix/coin | SirenLayer | false | 15,575 | [
"MIT"
] | 84 | 2f2df0614ed4fc866d4b7715ee206081e08b9424 | https://github.com/idgmatrix/coin/tree/2f2df0614ed4fc866d4b7715ee206081e08b9424 |
PEG | import torch
from torch import nn
class Residual(nn.Module):
def __init__(self, fn):
super().__init__()
self.fn = fn
def forward(self, x, **kwargs):
return self.fn(x, **kwargs) + x
class PEG(nn.Module):
def __init__(self, dim, kernel_size=3):
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 import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_st... | idolumbantobing/vit-pytorch | PEG | false | 15,576 | [
"MIT"
] | 9,373 | eb70d8dca041cc387b3e1f72d965d8814eeab29a | https://github.com/idolumbantobing/vit-pytorch/tree/eb70d8dca041cc387b3e1f72d965d8814eeab29a |
Probability | import torch
import torch.nn as nn
class Probability(nn.Module):
"""A layer that predicts the probabilities
"""
def __init__(self, n_primitives, input_channels, make_dense=False):
super(Probability, self).__init__()
self._n_primitives = n_primitives
self._make_dense = make_dense
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | ianhuang0630/CSQ | Probability | false | 15,577 | [
"MIT"
] | 98 | 5f1fe99a8d9da73692643b3911d675dce269a03d | https://github.com/ianhuang0630/CSQ/tree/5f1fe99a8d9da73692643b3911d675dce269a03d |
Mlp | import torch
import torch.utils.data
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.optim
import torch.utils.data.distributed
class Mlp(nn.Module):
def __init__(self, in_features, hidden_features=None, out_features=None,
act_layer=nn.GELU, drop=0.0):
super().__init__()
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.utils.... | iamhankai/ghostnet | Mlp | false | 15,578 | [
"BSD-3-Clause"
] | 220 | 1262dacffdea62f9983ef0231177aea720e25f12 | https://github.com/iamhankai/ghostnet/tree/1262dacffdea62f9983ef0231177aea720e25f12 |
GatedLinearUnit | import torch
import torch.nn as nn
import torch as th
import torch.nn.functional as F
class GatedLinearUnit(nn.Module):
def forward(self, x, mask):
x = th.cat((x, mask), 1)
return F.glu(x, 1)
def get_inputs():
return [torch.rand([4, 4, 4, 4]), torch.rand([4, 4, 4, 4])]
def get_init_inputs... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | iamshant/mmt | GatedLinearUnit | false | 15,579 | [
"Apache-2.0"
] | 201 | 2716e9037f2d59e9aadd92d607bcf753f0146946 | https://github.com/iamshant/mmt/tree/2716e9037f2d59e9aadd92d607bcf753f0146946 |
ReduceDim | import torch
import torch.nn as nn
import torch.nn.functional as F
class ReduceDim(nn.Module):
def __init__(self, input_dimension, output_dimension):
super(ReduceDim, self).__init__()
self.fc = nn.Linear(input_dimension, output_dimension)
def forward(self, x):
x = self.fc(x)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | iamshant/mmt | ReduceDim | false | 15,580 | [
"Apache-2.0"
] | 201 | 2716e9037f2d59e9aadd92d607bcf753f0146946 | https://github.com/iamshant/mmt/tree/2716e9037f2d59e9aadd92d607bcf753f0146946 |
L2Norm | import torch
from torch import nn
class L2Norm(nn.Module):
def forward(self, x, eps=1e-06):
norm = x.norm(dim=1, keepdim=True).clamp(min=eps)
return x / norm
def get_inputs():
return [torch.rand([4, 4, 4, 4])]
def get_init_inputs():
return [[], {}]
| import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
from torch import nn
assert_... | idolumbantobing/vit-pytorch | L2Norm | false | 15,581 | [
"MIT"
] | 9,373 | eb70d8dca041cc387b3e1f72d965d8814eeab29a | https://github.com/idolumbantobing/vit-pytorch/tree/eb70d8dca041cc387b3e1f72d965d8814eeab29a |
BilinearWithBias | from torch.nn import Module
import math
import torch
from torch.nn.parameter import Parameter
import torch.nn.functional as F
from torch.nn.modules import Module
class BilinearWithBias(Module):
def __init__(self, in1_features, in2_features, out_features):
super(BilinearWithBias, 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.nn import Module
import math
from torch.nn.parameter import Parameter... | ianyfan/depccg | BilinearWithBias | false | 15,582 | [
"MIT"
] | 75 | dda01a72ad09ee36fb5d626a473cc2a0d267c57b | https://github.com/ianyfan/depccg/tree/dda01a72ad09ee36fb5d626a473cc2a0d267c57b |
Refine | import torch
import torch.nn
import torch.nn.functional as F
import torch.utils.data.dataset
class ResBlock(torch.nn.Module):
def __init__(self, indim, outdim=None, stride=1):
super(ResBlock, self).__init__()
if outdim is None:
outdim = indim
if indim == outdim and stride == 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
import torch.... | hzxie/RMNet | Refine | false | 15,583 | [
"MIT"
] | 66 | 32a16f9c9473463a41dd6e95f72b06dd830fc1eb | https://github.com/hzxie/RMNet/tree/32a16f9c9473463a41dd6e95f72b06dd830fc1eb |
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... | iesl/diora-public | Bilinear | false | 15,584 | [
"Apache-2.0"
] | 81 | 110b9b0881907ec049dd60cd93ff6ef084582b3b | https://github.com/iesl/diora-public/tree/110b9b0881907ec049dd60cd93ff6ef084582b3b |
Sine | import torch
from torch import nn
class Sine(nn.Module):
"""Sine activation with scaling.
Args:
w0 (float): Omega_0 parameter from SIREN paper.
"""
def __init__(self, w0=1.0):
super().__init__()
self.w0 = w0
def forward(self, x):
return torch.sin(self.w0 * x)
d... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import math as tl_math
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_... | idgmatrix/coin | Sine | false | 15,585 | [
"MIT"
] | 84 | 2f2df0614ed4fc866d4b7715ee206081e08b9424 | https://github.com/idgmatrix/coin/tree/2f2df0614ed4fc866d4b7715ee206081e08b9424 |
ArcFaceLoss | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
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 = los... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import math... | i-pan/kaggle-melanoma | ArcFaceLoss | false | 15,586 | [
"MIT"
] | 68 | caaec0d7e9cafc7b405eb86e7fdf00107d89e1d9 | https://github.com/i-pan/kaggle-melanoma/tree/caaec0d7e9cafc7b405eb86e7fdf00107d89e1d9 |
A2CCritic | import torch
import torch as t
import torch.nn as nn
class A2CCritic(nn.Module):
def __init__(self, state_dim):
super().__init__()
self.fc1 = nn.Linear(state_dim, 16)
self.fc2 = nn.Linear(16, 16)
self.fc3 = nn.Linear(16, 1)
def forward(self, state):
v = t.relu(self.fc... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | iffiX/machin | A2CCritic | false | 15,587 | [
"MIT"
] | 287 | 7fa986b1bafdefff117d6ff73d14644a5488de9d | https://github.com/iffiX/machin/tree/7fa986b1bafdefff117d6ff73d14644a5488de9d |
FCDiscriminator_Local | import torch
import torch.nn as nn
class FCDiscriminator_Local(nn.Module):
def __init__(self, num_classes, ndf=64):
super(FCDiscriminator_Local, self).__init__()
self.conv1 = nn.Conv2d(num_classes + 2048, ndf, kernel_size=4,
stride=2, padding=1)
self.conv2 = nn.Conv2d(ndf, ndf... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | gabriel-tjio/ASH | FCDiscriminator_Local | false | 15,588 | [
"MIT"
] | 300 | 40ae044a7ca1809f91ba89671d223a96eda327da | https://github.com/gabriel-tjio/ASH/tree/40ae044a7ca1809f91ba89671d223a96eda327da |
A2CActorDisc | import torch
from torch.distributions import Categorical
import torch as t
import torch.nn as nn
class A2CActorDisc(nn.Module):
def __init__(self, state_dim, action_num):
super().__init__()
self.fc1 = nn.Linear(state_dim, 16)
self.fc2 = nn.Linear(16, 16)
self.fc3 = nn.Linear(16, a... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | iffiX/machin | A2CActorDisc | false | 15,589 | [
"MIT"
] | 287 | 7fa986b1bafdefff117d6ff73d14644a5488de9d | https://github.com/iffiX/machin/tree/7fa986b1bafdefff117d6ff73d14644a5488de9d |
LanguageModelCriterion | import torch
import torch.nn as nn
from torch.autograd import *
def to_contiguous(tensor):
if tensor.is_contiguous():
return tensor
else:
return tensor.contiguous()
class LanguageModelCriterion(nn.Module):
def __init__(self):
super(LanguageModelCriterion, self).__init__()
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
import torch.nn as nn
from torch.autograd import *
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torc... | ifty1987/PORL | LanguageModelCriterion | false | 15,590 | [
"MIT"
] | 61 | 979d5462b5c74bcca8013d9c54d86b676d3e2d43 | https://github.com/ifty1987/PORL/tree/979d5462b5c74bcca8013d9c54d86b676d3e2d43 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.