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 |
|---|---|---|---|---|---|---|---|---|---|---|
PositionwiseFeedForward | import torch
import torch.nn as nn
import torch.utils.checkpoint
import torch.nn.functional as F
from torch.cuda.amp import autocast
class PositionwiseFeedForward(nn.Module):
""" A two-feed-forward-layer module """
def __init__(self, d_in, d_hid, dropout=0.1):
super().__init__()
self.w_1 = 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.... | bahducoup/factorized_training | PositionwiseFeedForward | false | 12,156 | [
"MIT"
] | 0 | 0af38f16338a9bcfcc11091b1a6b75befd67f234 | https://github.com/bahducoup/factorized_training/tree/0af38f16338a9bcfcc11091b1a6b75befd67f234 |
MultiHeadAttention | import torch
import torch.nn as nn
import torch.utils.checkpoint
import torch.nn.functional as F
from torch.cuda.amp import autocast
class ScaledDotProductAttention(nn.Module):
""" Scaled Dot-Product Attention """
def __init__(self, temperature, attn_dropout=0.1):
super().__init__()
self.temp... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | bahducoup/factorized_training | MultiHeadAttention | false | 12,157 | [
"MIT"
] | 0 | 0af38f16338a9bcfcc11091b1a6b75befd67f234 | https://github.com/bahducoup/factorized_training/tree/0af38f16338a9bcfcc11091b1a6b75befd67f234 |
ThreeLayerSemSegNet | import torch
import torch.nn as nn
class ThreeLayerSemSegNet(nn.Module):
def __init__(self, in_channel, out_channel):
super().__init__()
self.conv1 = torch.nn.Conv2d(in_channel, 8, kernel_size=3, padding=
1, stride=1)
self.conv2d1 = torch.nn.Conv2d(8, 4, kernel_size=3, padding... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | benkoger/kasanka | ThreeLayerSemSegNet | false | 12,158 | [
"Apache-2.0"
] | 0 | d5b1d32b7abf54845af0832da577137397089001 | https://github.com/benkoger/kasanka/tree/d5b1d32b7abf54845af0832da577137397089001 |
ThreeLayerSemSegNetWideViewHighDim | import torch
import torch.nn as nn
class ThreeLayerSemSegNetWideViewHighDim(nn.Module):
"""Each layer has more channels than the standard model"""
def __init__(self, in_channel, out_channel):
super().__init__()
self.conv1 = torch.nn.Conv2d(in_channel, 12, kernel_size=3, padding
=1... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | benkoger/kasanka | ThreeLayerSemSegNetWideViewHighDim | false | 12,159 | [
"Apache-2.0"
] | 0 | d5b1d32b7abf54845af0832da577137397089001 | https://github.com/benkoger/kasanka/tree/d5b1d32b7abf54845af0832da577137397089001 |
LowRankMultiHeadAttention | import torch
import torch.nn as nn
import torch.utils.checkpoint
import torch.nn.functional as F
from torch.cuda.amp import autocast
class ScaledDotProductAttention(nn.Module):
""" Scaled Dot-Product Attention """
def __init__(self, temperature, attn_dropout=0.1):
super().__init__()
self.temp... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | bahducoup/factorized_training | LowRankMultiHeadAttention | false | 12,160 | [
"MIT"
] | 0 | 0af38f16338a9bcfcc11091b1a6b75befd67f234 | https://github.com/bahducoup/factorized_training/tree/0af38f16338a9bcfcc11091b1a6b75befd67f234 |
ThreeLayerSemSegNetWideView | import torch
import torch.nn as nn
class ThreeLayerSemSegNetWideView(nn.Module):
def __init__(self, in_channel, out_channel):
super().__init__()
self.conv1 = torch.nn.Conv2d(in_channel, 6, kernel_size=3, padding=
1, stride=1)
self.conv1d100 = torch.nn.Conv2d(in_channel, 2, ker... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | benkoger/kasanka | ThreeLayerSemSegNetWideView | false | 12,161 | [
"Apache-2.0"
] | 0 | d5b1d32b7abf54845af0832da577137397089001 | https://github.com/benkoger/kasanka/tree/d5b1d32b7abf54845af0832da577137397089001 |
UNet | import torch
class Block(torch.nn.Module):
def __init__(self, in_channels, mid_channel, out_channels, batch_norm=False
):
super().__init__()
self.conv1 = torch.nn.Conv2d(in_channels=in_channels, out_channels=
mid_channel, kernel_size=3, padding=1)
self.conv2 = torch.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
assert_size_stride = torch._C... | amrane99/lung-segmentation | UNet | false | 12,162 | [
"MIT"
] | 0 | ab29db75ac78918da5cbf66b830acaf36cf7b44a | https://github.com/amrane99/lung-segmentation/tree/ab29db75ac78918da5cbf66b830acaf36cf7b44a |
LowRankResidualMultiHeadAttention | import torch
import torch.nn as nn
import torch.utils.checkpoint
import torch.nn.functional as F
from torch.cuda.amp import autocast
class ScaledDotProductAttention(nn.Module):
""" Scaled Dot-Product Attention """
def __init__(self, temperature, attn_dropout=0.1):
super().__init__()
self.temp... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | bahducoup/factorized_training | LowRankResidualMultiHeadAttention | false | 12,163 | [
"MIT"
] | 0 | 0af38f16338a9bcfcc11091b1a6b75befd67f234 | https://github.com/bahducoup/factorized_training/tree/0af38f16338a9bcfcc11091b1a6b75befd67f234 |
Encoder | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
class Encoder(nn.Module):
""" VAE encoder """
def __init__(self, img_channels, latent_size):
super(Encoder, self).__init__()
self.latent_size = latent_size
self.img_channels = img_channels
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
import ... | benedictquartey/softgym_wm | Encoder | false | 12,164 | [
"BSD-3-Clause"
] | 0 | 0aef75fed207b11029f6052c656a679c105b4677 | https://github.com/benedictquartey/softgym_wm/tree/0aef75fed207b11029f6052c656a679c105b4677 |
FourLayerSemSegNetWideView | import torch
import torch.nn as nn
class FourLayerSemSegNetWideView(nn.Module):
def __init__(self, in_channel, out_channel):
super().__init__()
self.conv1 = torch.nn.Conv2d(in_channel, 6, kernel_size=3, padding=
1, stride=1)
self.conv1d100 = torch.nn.Conv2d(in_channel, 2, kern... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | benkoger/kasanka | FourLayerSemSegNetWideView | false | 12,165 | [
"Apache-2.0"
] | 0 | d5b1d32b7abf54845af0832da577137397089001 | https://github.com/benkoger/kasanka/tree/d5b1d32b7abf54845af0832da577137397089001 |
ScaledDotProductAttention | import torch
import torch.nn as nn
import torch.utils.checkpoint
import torch.nn.functional as F
from torch.cuda.amp import autocast
class ScaledDotProductAttention(nn.Module):
""" Scaled Dot-Product Attention """
def __init__(self, temperature, attn_dropout=0.1):
super().__init__()
self.temp... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | bahducoup/factorized_training | ScaledDotProductAttention | false | 12,166 | [
"MIT"
] | 0 | 0af38f16338a9bcfcc11091b1a6b75befd67f234 | https://github.com/bahducoup/factorized_training/tree/0af38f16338a9bcfcc11091b1a6b75befd67f234 |
LowRankResidualEncoderLayer | import torch
import torch.nn as nn
import torch.utils.checkpoint
import torch.nn.functional as F
from torch.cuda.amp import autocast
class ScaledDotProductAttention(nn.Module):
""" Scaled Dot-Product Attention """
def __init__(self, temperature, attn_dropout=0.1):
super().__init__()
self.temp... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | bahducoup/factorized_training | LowRankResidualEncoderLayer | false | 12,167 | [
"MIT"
] | 0 | 0af38f16338a9bcfcc11091b1a6b75befd67f234 | https://github.com/bahducoup/factorized_training/tree/0af38f16338a9bcfcc11091b1a6b75befd67f234 |
GlobalAvgPool | import torch
import torch as th
from torch import nn
class GlobalAvgPool(nn.Module):
def __init__(self):
super(GlobalAvgPool, self).__init__()
def forward(self, x):
return th.mean(x, dim=[-2, -1])
def get_inputs():
return [torch.rand([4, 4, 4, 4])]
def get_init_inputs():
return [... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_str... | bjuncek/video_feature_extractor | GlobalAvgPool | false | 12,168 | [
"Apache-2.0"
] | 0 | cac06b450d1164beb3f3710d5018c19091bce348 | https://github.com/bjuncek/video_feature_extractor/tree/cac06b450d1164beb3f3710d5018c19091bce348 |
EncoderLayer | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
class AffineLayer(nn.Module):
def __init__(self, dropout, d_model, d_ff):
super(AffineLayer, self).__init__()
self.w_1 = nn.Linear(d_model, d_ff)
self.w_2 = nn.Linear(d_ff, d_model)
self.dropout = nn.Dr... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | bekirufuk/pointer_summarizer | EncoderLayer | false | 12,169 | [
"Apache-2.0"
] | 0 | 8fc9726f9337b26339848d896a09e7e8f9456bcc | https://github.com/bekirufuk/pointer_summarizer/tree/8fc9726f9337b26339848d896a09e7e8f9456bcc |
Decoder | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
class Decoder(nn.Module):
""" VAE decoder """
def __init__(self, img_channels, latent_size):
super(Decoder, self).__init__()
self.latent_size = latent_size
self.img_channels = img_channels
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
import ... | benedictquartey/softgym_wm | Decoder | false | 12,170 | [
"BSD-3-Clause"
] | 0 | 0aef75fed207b11029f6052c656a679c105b4677 | https://github.com/benedictquartey/softgym_wm/tree/0aef75fed207b11029f6052c656a679c105b4677 |
BehlerAngular | import torch
from torch import nn as nn
class BehlerAngular(nn.Module):
"""
Compute Behler type angular contribution of the angle spanned by three atoms:
:math:`2^{(1-\\zeta)} (1 + \\lambda \\cos( {\\theta}_{ijk} ) )^\\zeta`
Sets of zetas with lambdas of -1 and +1 are generated automatically.
A... | 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 as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._emp... | blindcharzard/AttnSchNet | BehlerAngular | false | 12,171 | [
"MIT"
] | 0 | 297bd130086459be6b732d68377193e244536bfc | https://github.com/blindcharzard/AttnSchNet/tree/297bd130086459be6b732d68377193e244536bfc |
MHSA | import torch
import torch.utils.data
import torch.nn as nn
class MHSA(nn.Module):
def __init__(self, n_dims, width=14, height=14, heads=4):
super(MHSA, self).__init__()
self.heads = heads
self.query = nn.Conv2d(n_dims, n_dims, kernel_size=1)
self.key = nn.Conv2d(n_dims, n_dims, ke... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | binghuiwu98/discriminatory-yolov5 | MHSA | false | 12,172 | [
"Apache-2.0"
] | 0 | 831bfdb8e0df38e247a72ca029ee3301fc14a311 | https://github.com/binghuiwu98/discriminatory-yolov5/tree/831bfdb8e0df38e247a72ca029ee3301fc14a311 |
LowRankEncoderLayer | import torch
import torch.nn as nn
import torch.utils.checkpoint
import torch.nn.functional as F
from torch.cuda.amp import autocast
class ScaledDotProductAttention(nn.Module):
""" Scaled Dot-Product Attention """
def __init__(self, temperature, attn_dropout=0.1):
super().__init__()
self.temp... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | bahducoup/factorized_training | LowRankEncoderLayer | false | 12,173 | [
"MIT"
] | 0 | 0af38f16338a9bcfcc11091b1a6b75befd67f234 | https://github.com/bahducoup/factorized_training/tree/0af38f16338a9bcfcc11091b1a6b75befd67f234 |
MultiHeadedAttention | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
class MultiHeadedAttention(nn.Module):
def __init__(self, num_head, d_model, dropout=0.1):
super(MultiHeadedAttention, self).__init__()
assert d_model % num_head == 0
self.d_k = d_model // num_head
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.... | bekirufuk/pointer_summarizer | MultiHeadedAttention | false | 12,174 | [
"Apache-2.0"
] | 0 | 8fc9726f9337b26339848d896a09e7e8f9456bcc | https://github.com/bekirufuk/pointer_summarizer/tree/8fc9726f9337b26339848d896a09e7e8f9456bcc |
Aggregate | import torch
from torch import nn as nn
class Aggregate(nn.Module):
"""Pooling layer based on sum or average with optional masking.
Args:
axis (int): axis along which pooling is done.
mean (bool, optional): if True, use average instead for sum pooling.
keepdim (bool, optional): whethe... | 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 as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._emp... | blindcharzard/AttnSchNet | Aggregate | false | 12,175 | [
"MIT"
] | 0 | 297bd130086459be6b732d68377193e244536bfc | https://github.com/blindcharzard/AttnSchNet/tree/297bd130086459be6b732d68377193e244536bfc |
GVPDropout | import torch
from torch import nn
class GVPDropout(nn.Module):
""" Separate dropout for scalars and vectors. """
def __init__(self, rate):
super().__init__()
self.vector_dropout = nn.Dropout2d(rate)
self.feat_dropout = nn.Dropout(rate)
def forward(self, feats, vectors):
r... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_str... | blazingsiyan/geometric-vector-perceptron | GVPDropout | false | 12,176 | [
"MIT"
] | 0 | eee1ee8e71148cfdb3e02b660d80f12cf1cecd0a | https://github.com/blazingsiyan/geometric-vector-perceptron/tree/eee1ee8e71148cfdb3e02b660d80f12cf1cecd0a |
ResidualBlock | import torch
import torch.nn as nn
def conv3x3(in_ch, out_ch, stride=1):
"""3x3 convolution with padding."""
return nn.Conv2d(in_ch, out_ch, kernel_size=3, stride=stride, padding=1)
class ResidualBlock(nn.Module):
"""Simple residual block with two 3x3 convolutions.
Args:
in_ch (int): number... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | blakecheng/CompressAI | ResidualBlock | false | 12,177 | [
"Apache-2.0"
] | 0 | 7a919e509bafacc99055dd88fc20315f3b9fc1fc | https://github.com/blakecheng/CompressAI/tree/7a919e509bafacc99055dd88fc20315f3b9fc1fc |
GVPLayerNorm | import torch
from torch import nn
class GVPLayerNorm(nn.Module):
""" Normal layer norm for scalars, nontrainable norm for vectors. """
def __init__(self, feats_h_size, eps=1e-08):
super().__init__()
self.eps = eps
self.feat_norm = nn.LayerNorm(feats_h_size)
def forward(self, feat... | 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... | blazingsiyan/geometric-vector-perceptron | GVPLayerNorm | false | 12,178 | [
"MIT"
] | 0 | eee1ee8e71148cfdb3e02b660d80f12cf1cecd0a | https://github.com/blazingsiyan/geometric-vector-perceptron/tree/eee1ee8e71148cfdb3e02b660d80f12cf1cecd0a |
LowRankDecoderLayer | import torch
import torch.nn as nn
import torch.utils.checkpoint
import torch.nn.functional as F
from torch.cuda.amp import autocast
class ScaledDotProductAttention(nn.Module):
""" Scaled Dot-Product Attention """
def __init__(self, temperature, attn_dropout=0.1):
super().__init__()
self.temp... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | bahducoup/factorized_training | LowRankDecoderLayer | false | 12,179 | [
"MIT"
] | 0 | 0af38f16338a9bcfcc11091b1a6b75befd67f234 | https://github.com/bahducoup/factorized_training/tree/0af38f16338a9bcfcc11091b1a6b75befd67f234 |
GroupedChannelNorm | import torch
import torch.utils.data
import torch
import torch.nn as nn
class GroupedChannelNorm(nn.Module):
def __init__(self, num_groups):
super().__init__()
self.num_groups = num_groups
def forward(self, x):
shape = list(x.shape)
new_shape = [shape[0], self.num_groups, sha... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.utils.data
import torch
import torch.nn as nn
assert_size_stride =... | bomtorazek/contrastive-unpaired-translation | GroupedChannelNorm | false | 12,180 | [
"BSD-3-Clause"
] | 0 | 07c048038375e1b9a4e464154b8dbc49f5e16ede | https://github.com/bomtorazek/contrastive-unpaired-translation/tree/07c048038375e1b9a4e464154b8dbc49f5e16ede |
MLPNet | import torch
import torch.nn as nn
import torch.nn.functional as F
class MLPNet(nn.Module):
def __init__(self):
super(MLPNet, self).__init__()
self.fc1 = nn.Linear(28 * 28, 500)
self.fc2 = nn.Linear(500, 256)
self.fc3 = nn.Linear(256, 10)
def forward(self, x):
x = x.v... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | bluebibi/flask_rest | MLPNet | false | 12,181 | [
"MIT"
] | 0 | 9b1ee876060bca5d97459bb894c73530f66c4c15 | https://github.com/bluebibi/flask_rest/tree/9b1ee876060bca5d97459bb894c73530f66c4c15 |
FusedLeakyReLU | import torch
import torch.utils.data
import torch
import torch.nn as nn
import torch.nn.functional as F
def fused_leaky_relu(input, bias, negative_slope=0.2, scale=2 ** 0.5):
return F.leaky_relu(input + bias, negative_slope) * scale
class FusedLeakyReLU(nn.Module):
def __init__(self, channel, negative_slop... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.utils.data
import torch
import torch.nn as nn
import torch.nn.functional as F
assert_size_stride = torch._C._dynamo.guards.asse... | bomtorazek/contrastive-unpaired-translation | FusedLeakyReLU | false | 12,182 | [
"BSD-3-Clause"
] | 0 | 07c048038375e1b9a4e464154b8dbc49f5e16ede | https://github.com/bomtorazek/contrastive-unpaired-translation/tree/07c048038375e1b9a4e464154b8dbc49f5e16ede |
net | import torch
import numpy as np
import torch.nn.functional as F
import torch.nn as nn
class net(nn.Module):
def __init__(self, input_size, output_size):
super(net, self).__init__()
self.fc1 = nn.Linear(in_features=input_size, out_features=64)
self.fc2 = nn.Linear(in_features=64, out_featu... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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_... | brabeem/deep-reinforcement-learning | net | false | 12,183 | [
"MIT"
] | 0 | aff919545a1b6d9d44f5aaaa13b9981c888e7169 | https://github.com/brabeem/deep-reinforcement-learning/tree/aff919545a1b6d9d44f5aaaa13b9981c888e7169 |
DecoderLayer | import torch
import torch.nn as nn
import torch.utils.checkpoint
import torch.nn.functional as F
from torch.cuda.amp import autocast
class ScaledDotProductAttention(nn.Module):
""" Scaled Dot-Product Attention """
def __init__(self, temperature, attn_dropout=0.1):
super().__init__()
self.temp... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | bahducoup/factorized_training | DecoderLayer | false | 12,184 | [
"MIT"
] | 0 | 0af38f16338a9bcfcc11091b1a6b75befd67f234 | https://github.com/bahducoup/factorized_training/tree/0af38f16338a9bcfcc11091b1a6b75befd67f234 |
Normalize | import torch
import torch.utils.data
import torch
import torch.nn as nn
class Normalize(nn.Module):
def __init__(self, power=2):
super(Normalize, self).__init__()
self.power = power
def forward(self, x):
norm = x.pow(self.power).sum(1, keepdim=True).pow(1.0 / self.power)
out ... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.utils.data
import torch
import torch.nn as nn
assert_size_stride =... | bomtorazek/contrastive-unpaired-translation | Normalize | false | 12,185 | [
"BSD-3-Clause"
] | 0 | 07c048038375e1b9a4e464154b8dbc49f5e16ede | https://github.com/bomtorazek/contrastive-unpaired-translation/tree/07c048038375e1b9a4e464154b8dbc49f5e16ede |
PoolingF | import torch
import torch.utils.data
import torch
import torch.nn as nn
class Normalize(nn.Module):
def __init__(self, power=2):
super(Normalize, self).__init__()
self.power = power
def forward(self, x):
norm = x.pow(self.power).sum(1, keepdim=True).pow(1.0 / self.power)
out ... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
import torch.utils.data
impo... | bomtorazek/contrastive-unpaired-translation | PoolingF | false | 12,186 | [
"BSD-3-Clause"
] | 0 | 07c048038375e1b9a4e464154b8dbc49f5e16ede | https://github.com/bomtorazek/contrastive-unpaired-translation/tree/07c048038375e1b9a4e464154b8dbc49f5e16ede |
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... | brabeem/deep-reinforcement-learning | Critic | false | 12,187 | [
"MIT"
] | 0 | aff919545a1b6d9d44f5aaaa13b9981c888e7169 | https://github.com/brabeem/deep-reinforcement-learning/tree/aff919545a1b6d9d44f5aaaa13b9981c888e7169 |
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.... | brabeem/deep-reinforcement-learning | Actor | false | 12,188 | [
"MIT"
] | 0 | aff919545a1b6d9d44f5aaaa13b9981c888e7169 | https://github.com/brabeem/deep-reinforcement-learning/tree/aff919545a1b6d9d44f5aaaa13b9981c888e7169 |
ContextPooler | from _paritybench_helpers import _mock_config
import math
import torch
from torch import nn
def get_mask(input, local_context):
if not isinstance(local_context, DropoutContext):
dropout = local_context
mask = None
else:
dropout = local_context.dropout
dropout *= local_context.s... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import math
from to... | c370300679/ClinicalTransformerNER | ContextPooler | false | 12,189 | [
"MIT"
] | 0 | 4a4a796775f75f6d5adc053e956ec6a0ae6fe2f3 | https://github.com/c370300679/ClinicalTransformerNER/tree/4a4a796775f75f6d5adc053e956ec6a0ae6fe2f3 |
QNetwork | import torch
import torch.nn.functional as F
import torch.nn as nn
class QNetwork(nn.Module):
def __init__(self, state_size, action_size, seed=0, fc1_units=64,
fc2_units=32):
super(QNetwork, self).__init__()
self.seed = torch.manual_seed(seed)
self.fc1 = nn.Linear(state_size, fc1_... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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_... | bwosh/DRL_Navigation | QNetwork | false | 12,190 | [
"MIT"
] | 0 | ec33a657f826a7f3681cefe2d984690afad4abb8 | https://github.com/bwosh/DRL_Navigation/tree/ec33a657f826a7f3681cefe2d984690afad4abb8 |
MultiHeadAttention | import torch
from torch import nn
class MultiHeadAttention(nn.Module):
def __init__(self, dim_self, dim_ref, num_heads, bias=True, dropout=0.0):
super().__init__()
self.num_heads = num_heads
head_dim = dim_self // num_heads
self.scale = head_dim ** -0.5
self.to_queries = 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 import triton_helpers
from torch._inductor.runtime.... | bpiyush/CLIP_prefix_caption-video | MultiHeadAttention | false | 12,192 | [
"MIT"
] | 0 | 3f6a4b8c841189e20b82fd4de127681424311599 | https://github.com/bpiyush/CLIP_prefix_caption-video/tree/3f6a4b8c841189e20b82fd4de127681424311599 |
TransformerBlock | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init
class TransformerBlock(nn.Module):
def __init__(self, input_size, d_k=16, d_v=16, n_heads=8, is_layer_norm
=False, attn_dropout=0.1):
super(TransformerBlock, self).__init__()
self.n_heads = n_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.... | bopopescu/covid-19-visualization | TransformerBlock | false | 12,193 | [
"MIT"
] | 0 | 8a9325b52f007dd5e3ee5bbd323b71bbf19b9640 | https://github.com/bopopescu/covid-19-visualization/tree/8a9325b52f007dd5e3ee5bbd323b71bbf19b9640 |
EltwiseProdScoring | import torch
import torch.nn as nn
class EltwiseProdScoring(nn.Module):
"""
Linearly mapping h and v to the same dimension, and do a elementwise
multiplication and a linear scoring
"""
def __init__(self, h_dim, a_dim, dot_dim=256):
"""Initialize layer."""
super(EltwiseProdScoring,... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | cacosandon/speaker_follower_with_objects | EltwiseProdScoring | false | 12,194 | [
"BSD-2-Clause",
"MIT"
] | 0 | f3d454fdbd1c8129887cf4ecc4743d231c7b9555 | https://github.com/cacosandon/speaker_follower_with_objects/tree/f3d454fdbd1c8129887cf4ecc4743d231c7b9555 |
EuclideanMean | import torch
from torch import Tensor
import torch.utils.data.dataloader
from torch import nn
import torch.nn
class EuclideanMean(nn.Module):
"""Implement a EuclideanMean object."""
def forward(self, data: 'Tensor') ->Tensor:
"""Performs a forward pass through the network.
Parameters
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.utils.data.dataloader
from torch import nn
import torch.nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empt... | chen-yuxuan/flair | EuclideanMean | false | 12,195 | [
"MIT"
] | 0 | 480d2c9afd66ab8d3bf40a676917e84dba3c4cee | https://github.com/chen-yuxuan/flair/tree/480d2c9afd66ab8d3bf40a676917e84dba3c4cee |
BertSelfAttention | from _paritybench_helpers import _mock_config
import math
import torch
import torch.nn as nn
class BertSelfAttention(nn.Module):
def __init__(self, config):
super().__init__()
self.num_attention_heads = config.num_attention_heads
self.attention_head_size = int(config.hidden_size / config.... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | brendon-boldt/minbert-assignment | BertSelfAttention | false | 12,196 | [
"Apache-2.0"
] | 0 | 0b562d791d34a40fd3c0383a0a32b4eeb2171cb5 | https://github.com/brendon-boldt/minbert-assignment/tree/0b562d791d34a40fd3c0383a0a32b4eeb2171cb5 |
PyTorchFeedForward | import torch
import torch.nn
import torch.autograd
import torch.nn as nn
import torch.nn.functional as F
import torch.optim
import torch.cuda
class PyTorchFeedForward(nn.Module):
def __init__(self, depth, width, input_size, output_size):
super(PyTorchFeedForward, self).__init__()
self.linears = [... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | ccoulombe/thinc | PyTorchFeedForward | false | 12,197 | [
"MIT"
] | 0 | 8d891b61ddef3ca00266ca0ec7c47e2d063a3a83 | https://github.com/ccoulombe/thinc/tree/8d891b61ddef3ca00266ca0ec7c47e2d063a3a83 |
Net | import torch
import torch.nn as nn
import torch.nn.functional as F
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.a1 = nn.Conv2d(5, 16, kernel_size=3, padding=1)
self.a2 = nn.Conv2d(16, 16, kernel_size=3, padding=1)
self.a3 = nn.Conv2d(16, 32, kernel_si... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | blockide/Chess-ML | Net | false | 12,198 | [
"MIT"
] | 0 | 3b1572f715ed710f5ce240c76bb79ae8f186f32a | https://github.com/blockide/Chess-ML/tree/3b1572f715ed710f5ce240c76bb79ae8f186f32a |
FC_Q | import torch
import torch.nn as nn
import torch.nn.functional as F
class FC_Q(nn.Module):
def __init__(self, state_dim, num_actions):
super(FC_Q, self).__init__()
self.q1 = nn.Linear(state_dim, 256)
self.q2 = nn.Linear(256, 256)
self.q3 = nn.Linear(256, num_actions)
self.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
assert_... | cedesu/BCQ | FC_Q | false | 12,199 | [
"MIT"
] | 0 | 424548510349a85c31809431494dcc6f64b611ba | https://github.com/cedesu/BCQ/tree/424548510349a85c31809431494dcc6f64b611ba |
VAE | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
class Decoder(nn.Module):
""" VAE decoder """
def __init__(self, img_channels, latent_size):
super(Decoder, self).__init__()
self.latent_size = latent_size
self.img_channels = img_channels
... | import torch
from torch import device
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from... | benedictquartey/softgym_wm | VAE | false | 12,200 | [
"BSD-3-Clause"
] | 0 | 0aef75fed207b11029f6052c656a679c105b4677 | https://github.com/benedictquartey/softgym_wm/tree/0aef75fed207b11029f6052c656a679c105b4677 |
GramMatrix | import torch
from torch import nn
class GramMatrix(nn.Module):
def forward(self, x):
b, c, h, w = x.shape
F = x.view(-1, c, b * w)
G = torch.bmm(F, F.transpose(1, 2)) / (h * w)
return G
def get_inputs():
return [torch.rand([4, 4, 4, 4])]
def get_init_inputs():
return [... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import 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... | choiking10/Image-Style-Transfer | GramMatrix | false | 12,201 | [
"MIT"
] | 0 | cc4a6c22975e16343a0fecfdfd3e707c34905e93 | https://github.com/choiking10/Image-Style-Transfer/tree/cc4a6c22975e16343a0fecfdfd3e707c34905e93 |
NeuralNetMultiplePositionalArgumentsMultiOutputsWithoutDependency | import torch
import torch.nn
import torch.onnx
class NeuralNetMultiplePositionalArgumentsMultiOutputsWithoutDependency(torch
.nn.Module):
def __init__(self, input_size, hidden_size, num_classes):
super(NeuralNetMultiplePositionalArgumentsMultiOutputsWithoutDependency
, 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.... | chethanpk/onnxruntime | NeuralNetMultiplePositionalArgumentsMultiOutputsWithoutDependency | false | 12,202 | [
"MIT"
] | 0 | c2435d24ecbeededf1dc50187ab3bd11ad4a6994 | https://github.com/chethanpk/onnxruntime/tree/c2435d24ecbeededf1dc50187ab3bd11ad4a6994 |
ToRGB | import math
import torch
import torch.utils.data
import torch
import torch.nn as nn
import torch.nn.functional as F
def make_kernel(k):
k = torch.tensor(k, dtype=torch.float32)
if len(k.shape) == 1:
k = k[None, :] * k[:, None]
k /= k.sum()
return k
def upfirdn2d_native(input, kernel, up_x, u... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import math
import torch.utils.data
import torch
import torch.nn as nn
import to... | bomtorazek/contrastive-unpaired-translation | ToRGB | false | 12,203 | [
"BSD-3-Clause"
] | 0 | 07c048038375e1b9a4e464154b8dbc49f5e16ede | https://github.com/bomtorazek/contrastive-unpaired-translation/tree/07c048038375e1b9a4e464154b8dbc49f5e16ede |
TransformerLayer | import torch
from torch import nn
import torch.nn.functional as nnf
from typing import Optional
class MlpTransformer(nn.Module):
def __init__(self, in_dim, h_dim, out_d: 'Optional[int]'=None, act=nnf.
relu, dropout=0.0):
super().__init__()
out_d = out_d if out_d is not None else in_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.... | bpiyush/CLIP_prefix_caption-video | TransformerLayer | false | 12,204 | [
"MIT"
] | 0 | 3f6a4b8c841189e20b82fd4de127681424311599 | https://github.com/bpiyush/CLIP_prefix_caption-video/tree/3f6a4b8c841189e20b82fd4de127681424311599 |
LogitCosineDistance | import torch
import torch.utils.data.dataloader
import torch.nn
def dot_product(a: 'torch.Tensor', b: 'torch.Tensor', normalize=False):
"""
Computes dot product for pairs of vectors.
:param normalize: Vectors are normalized (leads to cosine similarity)
:return: Matrix with res[i][j] = dot_product(a[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.... | chen-yuxuan/flair | LogitCosineDistance | false | 12,205 | [
"MIT"
] | 0 | 480d2c9afd66ab8d3bf40a676917e84dba3c4cee | https://github.com/chen-yuxuan/flair/tree/480d2c9afd66ab8d3bf40a676917e84dba3c4cee |
EuclideanDistance | import torch
from torch import Tensor
import torch.utils.data.dataloader
from torch import nn
import torch.nn
def arccosh(x):
"""Compute the arcosh, numerically stable."""
x = torch.clamp(x, min=1 + EPSILON)
a = torch.log(x)
b = torch.log1p(torch.sqrt(x * x - 1) / x)
return a + b
def mdot(x, 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.utils.data.dataloader
from torch import nn
import torch.nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empt... | chen-yuxuan/flair | EuclideanDistance | false | 12,206 | [
"MIT"
] | 0 | 480d2c9afd66ab8d3bf40a676917e84dba3c4cee | https://github.com/chen-yuxuan/flair/tree/480d2c9afd66ab8d3bf40a676917e84dba3c4cee |
NetworkExtension | import torch
import torch.utils
import torch
import torch.nn as nn
class NetworkExtension(nn.Module):
def __init__(self, orig_num_classes, num_classes, auxiliary):
super(NetworkExtension, self).__init__()
self._auxiliary = auxiliary
self.classifier = nn.Linear(orig_num_classes, num_classe... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.utils
import torch
import torch.nn as nn
assert_size_stride = torch... | amelieEmily/RobustDARTS | NetworkExtension | false | 12,207 | [
"Apache-2.0"
] | 0 | b26e127c6e9c330258786f5eb77b17d367f546ff | https://github.com/amelieEmily/RobustDARTS/tree/b26e127c6e9c330258786f5eb77b17d367f546ff |
SelfAttn | import torch
from torch import nn
from torch.nn import functional as F
class SelfAttn(nn.Module):
"""
self-attention with learnable parameters
"""
def __init__(self, dhid):
super().__init__()
self.scorer = nn.Linear(dhid, 1)
def forward(self, inp):
scores = F.softmax(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.... | caisarl76/alfred | SelfAttn | false | 12,208 | [
"MIT"
] | 0 | b73bdc1651e14c02440938b639fa3c7f3ab3d321 | https://github.com/caisarl76/alfred/tree/b73bdc1651e14c02440938b639fa3c7f3ab3d321 |
BinaryDiceLoss | import torch
import torch.nn as nn
class BinaryDiceLoss(nn.Module):
def __init__(self):
super(BinaryDiceLoss, self).__init__()
def forward(self, input, targets):
N = targets.size()[0]
smooth = 1
input_flat = input.view(N, -1)
targets_flat = targets.view(N, -1)
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | chenkarl/kits19 | BinaryDiceLoss | false | 12,209 | [
"MIT"
] | 0 | 7fa912320a23c6bf649566a1509aa493656b24c1 | https://github.com/chenkarl/kits19/tree/7fa912320a23c6bf649566a1509aa493656b24c1 |
ReshapeF | import torch
import torch.utils.data
import torch
import torch.nn as nn
class Normalize(nn.Module):
def __init__(self, power=2):
super(Normalize, self).__init__()
self.power = power
def forward(self, x):
norm = x.pow(self.power).sum(1, keepdim=True).pow(1.0 / self.power)
out ... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.utils.data
import torch
import torch.nn as nn
assert_size_stride =... | bomtorazek/contrastive-unpaired-translation | ReshapeF | false | 12,210 | [
"BSD-3-Clause"
] | 0 | 07c048038375e1b9a4e464154b8dbc49f5e16ede | https://github.com/bomtorazek/contrastive-unpaired-translation/tree/07c048038375e1b9a4e464154b8dbc49f5e16ede |
VAE | import torch
import torch.nn as nn
import torch.nn.functional as F
class VAE(nn.Module):
def __init__(self, state_dim, action_dim, latent_dim, max_action, device):
super(VAE, self).__init__()
self.e1 = nn.Linear(state_dim + action_dim, 750)
self.e2 = nn.Linear(750, 750)
self.mean ... | import torch
from torch import device
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from... | cedesu/BCQ | VAE | false | 12,211 | [
"MIT"
] | 0 | 424548510349a85c31809431494dcc6f64b611ba | https://github.com/cedesu/BCQ/tree/424548510349a85c31809431494dcc6f64b611ba |
Conv_Q | import torch
import torch.nn as nn
import torch.nn.functional as F
class Conv_Q(nn.Module):
def __init__(self, frames, num_actions):
super(Conv_Q, self).__init__()
self.c1 = nn.Conv2d(frames, 32, kernel_size=8, stride=4)
self.c2 = nn.Conv2d(32, 64, kernel_size=4, stride=2)
self.c3... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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_... | cedesu/BCQ | Conv_Q | false | 12,212 | [
"MIT"
] | 0 | 424548510349a85c31809431494dcc6f64b611ba | https://github.com/cedesu/BCQ/tree/424548510349a85c31809431494dcc6f64b611ba |
OutputTransition | import torch
import torch.nn as nn
class OutputTransition(nn.Module):
def __init__(self, out_ch):
super(OutputTransition, self).__init__()
self.up_conv = nn.Conv2d(64, out_ch, 1)
def forward(self, x):
out = self.up_conv(x)
return out
def get_inputs():
return [torch.rand... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | chenkarl/kits19 | OutputTransition | false | 12,213 | [
"MIT"
] | 0 | 7fa912320a23c6bf649566a1509aa493656b24c1 | https://github.com/chenkarl/kits19/tree/7fa912320a23c6bf649566a1509aa493656b24c1 |
RNN | import torch
import torch.nn as nn
from torch.autograd import Variable
class RNN(nn.Module):
def __init__(self, input_size, hidden_size, output_size):
super(RNN, self).__init__()
self.hidden_size = hidden_size
self.i2h = nn.Linear(input_size + hidden_size, hidden_size)
self.i2o = ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | chenyuntc/practical-pytorch | RNN | false | 12,214 | [
"MIT"
] | 0 | 42cbde5275d37bf3f3623a85fd71f13069d95089 | https://github.com/chenyuntc/practical-pytorch/tree/42cbde5275d37bf3f3623a85fd71f13069d95089 |
TripletLoss | import torch
from torch import nn
import torch.nn.functional as F
from torch.nn import *
from torch.optim.lr_scheduler import *
def _batch_hard(mat_distance, mat_similarity, indice=False):
sorted_mat_distance, positive_indices = torch.sort(mat_distance + -
9999999.0 * (1 - mat_similarity), dim=1, descendi... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | chrizandr/MMT | TripletLoss | false | 12,215 | [
"MIT"
] | 0 | e2bb5984efb165e7ea1ed6080610cfe176344ac0 | https://github.com/chrizandr/MMT/tree/e2bb5984efb165e7ea1ed6080610cfe176344ac0 |
SmallMnistNoDropout | import torch
import torch.nn as nn
import torch.nn
import torch.utils.data
import torch.utils.tensorboard._pytorch_graph
import torch.onnx.symbolic_caffe2
class SmallMnistNoDropout(nn.Module):
def __init__(self):
super(SmallMnistNoDropout, self).__init__()
self.conv1 = nn.Conv2d(1, 10, kernel_siz... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | arjunsuresh/aimet | SmallMnistNoDropout | false | 12,216 | [
"BSD-3-Clause"
] | 0 | f6e09cb07a91eed3a5e6b8e19e6b065303af5a39 | https://github.com/arjunsuresh/aimet/tree/f6e09cb07a91eed3a5e6b8e19e6b065303af5a39 |
CosineDistance | import torch
import torch.utils.data.dataloader
import torch.nn
def dot_product(a: 'torch.Tensor', b: 'torch.Tensor', normalize=False):
"""
Computes dot product for pairs of vectors.
:param normalize: Vectors are normalized (leads to cosine similarity)
:return: Matrix with res[i][j] = dot_product(a[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.... | chen-yuxuan/flair | CosineDistance | false | 12,217 | [
"MIT"
] | 0 | 480d2c9afd66ab8d3bf40a676917e84dba3c4cee | https://github.com/chen-yuxuan/flair/tree/480d2c9afd66ab8d3bf40a676917e84dba3c4cee |
BertSelfOutput | from _paritybench_helpers import _mock_config
import torch
import torch.nn as nn
import torch.utils.checkpoint
class BertSelfOutput(nn.Module):
def __init__(self, config, twin=False, merge=False):
super().__init__()
self.LayerNorm = nn.LayerNorm(config.hidden_size, eps=config.
layer_n... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as ... | christophschuhmann/BLIP | BertSelfOutput | false | 12,218 | [
"BSD-3-Clause"
] | 0 | 498f963762db65e7290eea02573e1749f955b3d0 | https://github.com/christophschuhmann/BLIP/tree/498f963762db65e7290eea02573e1749f955b3d0 |
LinearZeros | import torch
import torch.nn as nn
class LinearZeros(nn.Module):
def __init__(self, in_channels, out_channels, logscale_factor=3):
super().__init__()
self.linear = nn.Linear(in_channels, out_channels)
self.linear.weight.data.zero_()
self.linear.bias.data.zero_()
self.logsc... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | appuzanova/Glow-PyTorch | LinearZeros | false | 12,219 | [
"MIT"
] | 0 | 50316b1b242f0f345b2df9e3e4538cfab5a60895 | https://github.com/appuzanova/Glow-PyTorch/tree/50316b1b242f0f345b2df9e3e4538cfab5a60895 |
Conv2dZeros | import torch
import torch.nn as nn
def compute_same_pad(kernel_size, stride):
if isinstance(kernel_size, int):
kernel_size = [kernel_size]
if isinstance(stride, int):
stride = [stride]
assert len(stride) == len(kernel_size
), 'Pass kernel size and stride both as int, or both as equ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | appuzanova/Glow-PyTorch | Conv2dZeros | false | 12,220 | [
"MIT"
] | 0 | 50316b1b242f0f345b2df9e3e4538cfab5a60895 | https://github.com/appuzanova/Glow-PyTorch/tree/50316b1b242f0f345b2df9e3e4538cfab5a60895 |
MaxSpatialPoolP4 | import torch
class MaxSpatialPoolP4(torch.nn.Module):
def __init__(self, kernel_size, stride=None, padding=0):
super().__init__()
self.inner = torch.nn.MaxPool2d(kernel_size, stride, padding)
def forward(self, x):
y = x.view(x.size(0), -1, x.size(3), x.size(4))
y = self.inner... | 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... | claudio-unipv/groupcnn | MaxSpatialPoolP4 | false | 12,222 | [
"MIT"
] | 0 | 2b1514f5a0fb9a78c6f646e1c075e5c3d5af9c0c | https://github.com/claudio-unipv/groupcnn/tree/2b1514f5a0fb9a78c6f646e1c075e5c3d5af9c0c |
ModulatedConv2d | import math
import torch
import torch.utils.data
import torch
import torch.nn as nn
import torch.nn.functional as F
def make_kernel(k):
k = torch.tensor(k, dtype=torch.float32)
if len(k.shape) == 1:
k = k[None, :] * k[:, None]
k /= k.sum()
return k
def upfirdn2d_native(input, kernel, up_x, u... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import math
import ... | bomtorazek/contrastive-unpaired-translation | ModulatedConv2d | false | 12,223 | [
"BSD-3-Clause"
] | 0 | 07c048038375e1b9a4e464154b8dbc49f5e16ede | https://github.com/bomtorazek/contrastive-unpaired-translation/tree/07c048038375e1b9a4e464154b8dbc49f5e16ede |
Pooler | import torch
import torch.nn as nn
import torch.utils.data
import torch.utils.data.distributed
class Pooler(nn.Module):
""" Do pooling, possibly with a projection beforehand """
def __init__(self, d_inp, project=True, d_proj=512, pool_type='max'):
super(Pooler, self).__init__()
self.project =... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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 ... | cjmay/jiant | Pooler | false | 12,224 | [
"MIT"
] | 0 | 46e6fa9d0fc73883468646cbd0f36f4166720911 | https://github.com/cjmay/jiant/tree/46e6fa9d0fc73883468646cbd0f36f4166720911 |
ConvZ2P4 | import torch
class ConvZ2P4(torch.nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, bias=True,
stride=1, padding=1):
super().__init__()
w = torch.empty(out_channels, in_channels, kernel_size, kernel_size)
self.weight = torch.nn.Parameter(w)
torch.nn.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
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cu... | claudio-unipv/groupcnn | ConvZ2P4 | false | 12,225 | [
"MIT"
] | 0 | 2b1514f5a0fb9a78c6f646e1c075e5c3d5af9c0c | https://github.com/claudio-unipv/groupcnn/tree/2b1514f5a0fb9a78c6f646e1c075e5c3d5af9c0c |
Envelope | import torch
class Envelope(torch.nn.Module):
def __init__(self, exponent):
super(Envelope, self).__init__()
self.p = exponent
self.a = -(self.p + 1) * (self.p + 2) / 2
self.b = self.p * (self.p + 2)
self.c = -self.p * (self.p + 1) / 2
def forward(self, x):
p,... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
@triton.j... | coopersigrist/Multi-fragment-energy | Envelope | false | 12,226 | [
"MIT"
] | 0 | c21c1b884f364cf3f2ac71e393464e85ebeccb04 | https://github.com/coopersigrist/Multi-fragment-energy/tree/c21c1b884f364cf3f2ac71e393464e85ebeccb04 |
SoftEntropy | import torch
from torch import nn
import torch.nn.functional as F
from torch.nn import *
from torch.optim.lr_scheduler import *
class SoftEntropy(nn.Module):
def __init__(self):
super(SoftEntropy, self).__init__()
self.logsoftmax = nn.LogSoftmax(dim=1)
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 torch._inductor.runtime.triton_helpers import math as tl_math
from torch import nn
f... | chrizandr/MMT | SoftEntropy | false | 12,227 | [
"MIT"
] | 0 | e2bb5984efb165e7ea1ed6080610cfe176344ac0 | https://github.com/chrizandr/MMT/tree/e2bb5984efb165e7ea1ed6080610cfe176344ac0 |
FourierFeatures | import math
import torch
import torch.nn as nn
class FourierFeatures(nn.Module):
def __init__(self, in_features, out_features, std=1.0):
super().__init__()
assert out_features % 2 == 0
self.weight = nn.Parameter(torch.randn([out_features // 2,
in_features]) * std)
def for... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | corajr/diffusion_gen | FourierFeatures | false | 12,228 | [
"MIT"
] | 0 | 724377c8e244120cbd1caa75d474e3e14ded9bfa | https://github.com/corajr/diffusion_gen/tree/724377c8e244120cbd1caa75d474e3e14ded9bfa |
MaxRotationPoolP4 | import torch
class MaxRotationPoolP4(torch.nn.Module):
def forward(self, x):
return x.max(2).values
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
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torc... | claudio-unipv/groupcnn | MaxRotationPoolP4 | false | 12,229 | [
"MIT"
] | 0 | 2b1514f5a0fb9a78c6f646e1c075e5c3d5af9c0c | https://github.com/claudio-unipv/groupcnn/tree/2b1514f5a0fb9a78c6f646e1c075e5c3d5af9c0c |
LinearFeedforward | import torch
from torch import nn
from torch.nn import functional as F
import torch.utils.data
class Linear(nn.Linear):
def forward(self, x):
size = x.size()
return super().forward(x.contiguous().view(-1, size[-1])).view(*
size[:-1], -1)
class Feedforward(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 import triton_helpers
from torch import nn
from tor... | cristipp/decaNLP | LinearFeedforward | false | 12,230 | [
"BSD-3-Clause"
] | 0 | db64df36bf2b1b2ca6946aacf0ee7463ac80c4cb | https://github.com/cristipp/decaNLP/tree/db64df36bf2b1b2ca6946aacf0ee7463ac80c4cb |
ConvP4 | import torch
def _grot90(x, k):
return torch.rot90(x.roll(k, 2), k, (3, 4))
class ConvP4(torch.nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, bias=True,
stride=1, padding=1):
super().__init__()
w = torch.empty(out_channels, in_channels, 4, kernel_size, kernel... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cu... | claudio-unipv/groupcnn | ConvP4 | false | 12,231 | [
"MIT"
] | 0 | 2b1514f5a0fb9a78c6f646e1c075e5c3d5af9c0c | https://github.com/claudio-unipv/groupcnn/tree/2b1514f5a0fb9a78c6f646e1c075e5c3d5af9c0c |
Attention | import math
import torch
from torch import nn
from torch.nn import functional as F
import torch.utils.data
def matmul(x, y):
if x.dim() == y.dim():
return x @ y
if x.dim() == y.dim() - 1:
return (x.unsqueeze(-2) @ y).squeeze(-2)
return (x @ y.unsqueeze(-2)).squeeze(-2)
class Attention(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.... | cristipp/decaNLP | Attention | false | 12,232 | [
"BSD-3-Clause"
] | 0 | db64df36bf2b1b2ca6946aacf0ee7463ac80c4cb | https://github.com/cristipp/decaNLP/tree/db64df36bf2b1b2ca6946aacf0ee7463ac80c4cb |
MultiHead | import math
import torch
from torch import nn
from torch.nn import functional as F
import torch.utils.data
def matmul(x, y):
if x.dim() == y.dim():
return x @ y
if x.dim() == y.dim() - 1:
return (x.unsqueeze(-2) @ y).squeeze(-2)
return (x @ y.unsqueeze(-2)).squeeze(-2)
class Linear(nn.Li... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | cristipp/decaNLP | MultiHead | false | 12,233 | [
"BSD-3-Clause"
] | 0 | db64df36bf2b1b2ca6946aacf0ee7463ac80c4cb | https://github.com/cristipp/decaNLP/tree/db64df36bf2b1b2ca6946aacf0ee7463ac80c4cb |
CaffeNormalize | import torch
import torch.utils.data
import torch.nn as nn
class CaffeNormalize(nn.Module):
def __init__(self, features, eps=1e-07):
super(CaffeNormalize, self).__init__()
self.scale = nn.Parameter(10.0 * torch.ones(features))
self.eps = eps
def forward(self, x):
x_size = x.s... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.utils.data
import torch.nn as nn
assert_size_stride = torch._C._dy... | cynthiamao98/DepthAwareCNN | CaffeNormalize | false | 12,234 | [
"MIT"
] | 0 | 824cffaa4159e3dc7cc251a4a659e35c437bb92c | https://github.com/cynthiamao98/DepthAwareCNN/tree/824cffaa4159e3dc7cc251a4a659e35c437bb92c |
TransformerEncoderLayer | import math
import torch
from torch import nn
from torch.nn import functional as F
import torch.utils.data
def matmul(x, y):
if x.dim() == y.dim():
return x @ y
if x.dim() == y.dim() - 1:
return (x.unsqueeze(-2) @ y).squeeze(-2)
return (x @ y.unsqueeze(-2)).squeeze(-2)
class Linear(nn.Li... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | cristipp/decaNLP | TransformerEncoderLayer | false | 12,235 | [
"BSD-3-Clause"
] | 0 | db64df36bf2b1b2ca6946aacf0ee7463ac80c4cb | https://github.com/cristipp/decaNLP/tree/db64df36bf2b1b2ca6946aacf0ee7463ac80c4cb |
GradLoss | import torch
import torch.nn as nn
class GradLoss(nn.Module):
def __init__(self):
super(GradLoss, self).__init__()
def forward(self, grad_fake, grad_real):
return torch.sum(torch.mean(torch.abs(grad_real - grad_fake)))
def get_inputs():
return [torch.rand([4, 4, 4, 4]), torch.rand([4, ... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
... | d4l3k/crowds | GradLoss | false | 12,236 | [
"MIT"
] | 0 | a57eee80d66498474c86cec22dd77be9d627ad97 | https://github.com/d4l3k/crowds/tree/a57eee80d66498474c86cec22dd77be9d627ad97 |
RMSE_log | import torch
import torch.nn as nn
import torch.nn.functional as F
class RMSE_log(nn.Module):
def __init__(self):
super(RMSE_log, self).__init__()
def forward(self, fake, real):
if not fake.shape == real.shape:
_, _, H, W = real.shape
fake = F.upsample(fake, size=(H, ... | 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... | d4l3k/crowds | RMSE_log | false | 12,237 | [
"MIT"
] | 0 | a57eee80d66498474c86cec22dd77be9d627ad97 | https://github.com/d4l3k/crowds/tree/a57eee80d66498474c86cec22dd77be9d627ad97 |
RMSE | import torch
import torch.nn as nn
import torch.nn.functional as F
class RMSE(nn.Module):
def __init__(self):
super(RMSE, self).__init__()
def forward(self, fake, real):
if not fake.shape == real.shape:
_, _, H, W = real.shape
fake = F.upsample(fake, size=(H, W), mode... | 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... | d4l3k/crowds | RMSE | false | 12,238 | [
"MIT"
] | 0 | a57eee80d66498474c86cec22dd77be9d627ad97 | https://github.com/d4l3k/crowds/tree/a57eee80d66498474c86cec22dd77be9d627ad97 |
LayerNorm | import torch
import torch.utils.data
import torch.nn as nn
class LayerNorm(nn.Module):
def __init__(self, features, eps=1e-06, gamma=1.0, beta=0.0, learnable=
False):
super(LayerNorm, self).__init__()
if learnable:
self.gamma = nn.Parameter(torch.ones(features))
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 libdevice
import torch.utils.data
import torch.nn as nn
assert_size_stride = torch._C._dy... | cynthiamao98/DepthAwareCNN | LayerNorm | false | 12,239 | [
"MIT"
] | 0 | 824cffaa4159e3dc7cc251a4a659e35c437bb92c | https://github.com/cynthiamao98/DepthAwareCNN/tree/824cffaa4159e3dc7cc251a4a659e35c437bb92c |
L1 | import torch
import torch.nn as nn
import torch.nn.functional as F
class L1(nn.Module):
def __init__(self):
super(L1, self).__init__()
def forward(self, fake, real):
if not fake.shape == real.shape:
_, _, H, W = real.shape
fake = F.upsample(fake, size=(H, W), mode='bi... | 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
... | d4l3k/crowds | L1 | false | 12,240 | [
"MIT"
] | 0 | a57eee80d66498474c86cec22dd77be9d627ad97 | https://github.com/d4l3k/crowds/tree/a57eee80d66498474c86cec22dd77be9d627ad97 |
FocalLoss | import torch
from torch import nn
import torch.nn.functional as F
class FocalLoss(nn.Module):
def __init__(self, gamma):
super().__init__()
self.gamma = gamma
def forward(self, input, target):
if not target.size() == input.size():
raise ValueError(
'Target... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch ... | dainis-boumber/nlp-loss-functions | FocalLoss | false | 12,241 | [
"Apache-2.0"
] | 0 | 735d1e74bf9b9705a56cbb718b85448575efb5ee | https://github.com/dainis-boumber/nlp-loss-functions/tree/735d1e74bf9b9705a56cbb718b85448575efb5ee |
ConvEncoder | import torch
from torch import nn
class ConvEncoder(nn.Module):
""" Simple convolutional encoder network.
It consists of 5 convolutional layers, each downsampling the input by a
factor of 2, and a final fully-connected layer projecting the output to
c_dim dimenions.
Args:
c_dim (int): ou... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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... | crysoberil/ObjectReconstruction_ONetBased | ConvEncoder | false | 12,242 | [
"MIT"
] | 0 | 7c15ea8a64ee3647c86b57b16f0c85bd51ccdd47 | https://github.com/crysoberil/ObjectReconstruction_ONetBased/tree/7c15ea8a64ee3647c86b57b16f0c85bd51ccdd47 |
L1_log | import torch
import torch.nn as nn
import torch.nn.functional as F
class L1_log(nn.Module):
def __init__(self):
super(L1_log, self).__init__()
def forward(self, fake, real):
if not fake.shape == real.shape:
_, _, H, W = real.shape
fake = F.upsample(fake, size=(H, W), ... | 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
... | d4l3k/crowds | L1_log | false | 12,243 | [
"MIT"
] | 0 | a57eee80d66498474c86cec22dd77be9d627ad97 | https://github.com/d4l3k/crowds/tree/a57eee80d66498474c86cec22dd77be9d627ad97 |
NormalLoss | import torch
import torch.nn as nn
class NormalLoss(nn.Module):
def __init__(self):
super(NormalLoss, self).__init__()
def forward(self, grad_fake, grad_real):
prod = (grad_fake[:, :, None, :] @ grad_real[:, :, :, None]).squeeze(-1
).squeeze(-1)
fake_norm = torch.sqrt(tor... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as ... | d4l3k/crowds | NormalLoss | false | 12,244 | [
"MIT"
] | 0 | a57eee80d66498474c86cec22dd77be9d627ad97 | https://github.com/d4l3k/crowds/tree/a57eee80d66498474c86cec22dd77be9d627ad97 |
ScaledDotProductAttention | import torch
def masked_softmax(x, m=None, dim=-1):
"""
Softmax with mask (optional)
"""
x = torch.clamp(x, min=-15.0, max=15.0)
if m is not None:
m = m.float()
x = x * m
e_x = torch.exp(x - torch.max(x, dim=dim, keepdim=True)[0])
if m is not None:
e_x = e_x * m
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | daiki-kimura/commonsense-rl | ScaledDotProductAttention | false | 12,245 | [
"Apache-2.0"
] | 0 | 5513926957b6501ce9cfa46f77f8f2c1c4892fa5 | https://github.com/daiki-kimura/commonsense-rl/tree/5513926957b6501ce9cfa46f77f8f2c1c4892fa5 |
SoftWingLoss | import math
import torch
import torch.nn as nn
class SoftWingLoss(nn.Module):
"""Soft Wing Loss 'Structure-Coherent Deep Feature Learning for Robust Face
Alignment' Lin et al. TIP'2021.
loss =
1. |x| , if |x| < omega1
2. omega2*ln(1+|x|/epsilon) + B, if |x| >= om... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import math as tl_math
import math
import torch.nn as nn
assert_size_stride = torch._C._dynamo.g... | chenxinfeng4/mmpose | SoftWingLoss | false | 12,246 | [
"Apache-2.0"
] | 0 | b0aac4178c1f3d679d2a007e1d9c6c567fc2607d | https://github.com/chenxinfeng4/mmpose/tree/b0aac4178c1f3d679d2a007e1d9c6c567fc2607d |
CNN | import torch
import torch.nn as nn
import torch.nn.functional as F
class CNN(nn.Module):
"""
Convolutional Neural Network.
"""
def __init__(self):
super().__init__()
self.conv1 = nn.Conv2d(1, 20, kernel_size=5, stride=1)
self.fc1 = nn.Linear(8 * 8 * 20, 64)
self.fc2 = ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | danielrjiang/Ax | CNN | false | 12,247 | [
"MIT"
] | 0 | 43014b28683b3037b5c7307869cb9b75ca31ffb6 | https://github.com/danielrjiang/Ax/tree/43014b28683b3037b5c7307869cb9b75ca31ffb6 |
Attention | import torch
import torch.nn as nn
class Attention(nn.Module):
""" Applies attention mechanism on the `context` using the `query`.
**Thank you** to IBM for their initial implementation of :class:`Attention`. Here is
their `License
<https://github.com/IBM/pytorch-seq2seq/blob/master/LICENSE>`__.
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | daiki-kimura/commonsense-rl | Attention | false | 12,248 | [
"Apache-2.0"
] | 0 | 5513926957b6501ce9cfa46f77f8f2c1c4892fa5 | https://github.com/daiki-kimura/commonsense-rl/tree/5513926957b6501ce9cfa46f77f8f2c1c4892fa5 |
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... | david-varela/collaboration_and_competition | Critic | false | 12,250 | [
"MIT"
] | 0 | a170cc02eb3917af19d6aafa8b37f6089b83c35f | https://github.com/david-varela/collaboration_and_competition/tree/a170cc02eb3917af19d6aafa8b37f6089b83c35f |
CuboidPoseHead | import torch
import torch.nn as nn
from torchvision.transforms import functional as F
import torch.nn.functional as F
class CuboidPoseHead(nn.Module):
def __init__(self, beta):
"""Get results from the 3D human pose heatmap. Instead of obtaining
maximums on the heatmap, this module regresses the 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.triton_helpers import math as tl_math
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert... | chenxinfeng4/mmpose | CuboidPoseHead | false | 12,252 | [
"Apache-2.0"
] | 0 | b0aac4178c1f3d679d2a007e1d9c6c567fc2607d | https://github.com/chenxinfeng4/mmpose/tree/b0aac4178c1f3d679d2a007e1d9c6c567fc2607d |
Conv1D | import torch
import torch.nn as nn
from collections import OrderedDict
class Conv1D(nn.Module):
def __init__(self, embedding_dim, hidden_dim):
super(Conv1D, self).__init__()
self.convs = nn.Sequential(OrderedDict([('conv1', nn.Conv1d(
embedding_dim, hidden_dim, kernel_size=3, 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
from torch._inductor.runtime.... | danielTLevy/PPO-PyTorch | Conv1D | false | 12,253 | [
"MIT"
] | 0 | e9f5a34d3cf40135dfdb0ddb082c20f5035e23f7 | https://github.com/danielTLevy/PPO-PyTorch/tree/e9f5a34d3cf40135dfdb0ddb082c20f5035e23f7 |
StyledConv | import math
import torch
from torch import nn
from torch.nn import functional as F
def fused_leaky_relu(input, bias, negative_slope=0.2, scale=2 ** 0.5):
rest_dim = [1] * (input.ndim - bias.ndim - 1)
input = input
if input.ndim == 3:
return F.leaky_relu(input + bias.view(1, *rest_dim, bias.shape[0... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import math
from to... | davidetalon/StyleCLIP | StyledConv | false | 12,254 | [
"MIT"
] | 0 | 1cbf552b322cd90c417f26a259143382e2b7af8f | https://github.com/davidetalon/StyleCLIP/tree/1cbf552b322cd90c417f26a259143382e2b7af8f |
NegativeScaledDotProduct | import torch
import torch.utils.data.dataloader
import torch.nn
def dot_product(a: 'torch.Tensor', b: 'torch.Tensor', normalize=False):
"""
Computes dot product for pairs of vectors.
:param normalize: Vectors are normalized (leads to cosine similarity)
:return: Matrix with res[i][j] = dot_product(a[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 torch.utils.data.dataloader
import torch.nn
assert_size_stride = torch._C... | chen-yuxuan/flair | NegativeScaledDotProduct | false | 12,255 | [
"MIT"
] | 0 | 480d2c9afd66ab8d3bf40a676917e84dba3c4cee | https://github.com/chen-yuxuan/flair/tree/480d2c9afd66ab8d3bf40a676917e84dba3c4cee |
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.... | daiki-kimura/commonsense-rl | GAT | false | 12,256 | [
"Apache-2.0"
] | 0 | 5513926957b6501ce9cfa46f77f8f2c1c4892fa5 | https://github.com/daiki-kimura/commonsense-rl/tree/5513926957b6501ce9cfa46f77f8f2c1c4892fa5 |
FactorizationMachine | from torch.nn import Module
import math
import torch
import numpy as np
from torch.nn import *
from torch.optim import AdamW
from typing import Union
class FactorizationMachine(Module):
"""
[Factorization Machine Recommendation Model]
Learns latent space features to characterize similarity of dataset feat... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import math as tl_math
from torch.nn... | cspades/algorithm-toolkit | FactorizationMachine | false | 12,257 | [
"Apache-2.0"
] | 0 | 8731112162fb60f8ef3ab3c38524456ae96f0c2d | https://github.com/cspades/algorithm-toolkit/tree/8731112162fb60f8ef3ab3c38524456ae96f0c2d |
C2 | import torch
import torch.nn as nn
from collections import OrderedDict
class C2(nn.Module):
def __init__(self) ->None:
super(C2, self).__init__()
self.c2 = nn.Sequential(OrderedDict([('c2', nn.Conv2d(16, 32,
kernel_size=(3, 3), bias=True)), ('relu2', nn.ReLU()), ('s2',
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
import torch.nn as nn
from co... | devillove084/DeepSignal | C2 | false | 12,258 | [
"MIT"
] | 0 | 1fe122b32752b11e10ca4bef3d07ddd7de4348b5 | https://github.com/devillove084/DeepSignal/tree/1fe122b32752b11e10ca4bef3d07ddd7de4348b5 |
LinearWithGroupNorm | import torch
import torch.utils.data
from torch import nn
from math import gcd
import torch.cuda
class LinearWithGroupNorm(nn.Module):
def __init__(self, n_in: 'int', n_out: 'int', num_groups: 'int'=32,
activation: 'bool'=True) ->None:
"""
Linear layer used in LaneGCN.
:param n_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.... | bradyz/nuplan-devkit | LinearWithGroupNorm | false | 12,259 | [
"Apache-2.0"
] | 0 | 0a7a30e5d7fdf3787d9388676b7856fbd7d92992 | https://github.com/bradyz/nuplan-devkit/tree/0a7a30e5d7fdf3787d9388676b7856fbd7d92992 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.