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 |
|---|---|---|---|---|---|---|---|---|---|---|
PKT | import torch
from torch import nn
class PKT(nn.Module):
"""Probabilistic Knowledge Transfer for deep representation learning
Code from author: https://github.com/passalis/probabilistic_kt"""
def __init__(self):
super(PKT, self).__init__()
def forward(self, f_s, f_t):
return self.cosi... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
fr... | kctsiolis/RepDistiller | PKT | false | 3,932 | [
"BSD-2-Clause"
] | 0 | ce88f6e53fcf8ef81c5bac2d20ad31628dd279ac | https://github.com/kctsiolis/RepDistiller/tree/ce88f6e53fcf8ef81c5bac2d20ad31628dd279ac |
StyleLoss | import torch
import torch.nn as nn
class StyleLoss(nn.Module):
def __init__(self):
super().__init__()
self.l1loss = nn.L1Loss()
def gram(self, feature):
N, C, H, W = feature.shape
feature = feature.view(N, C, H * W)
gram_mat = torch.bmm(feature, torch.transpose(featur... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language 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.... | ljrprocc/Motif-Removal | StyleLoss | false | 3,933 | [
"MIT"
] | 0 | 8979ca91398212248a2be61345c99bdec53ae37e | https://github.com/ljrprocc/Motif-Removal/tree/8979ca91398212248a2be61345c99bdec53ae37e |
PerceptionLoss | import torch
import torch.nn as nn
class PerceptionLoss(nn.Module):
def __init__(self):
super().__init__()
self.l1loss = nn.L1Loss()
def forward(self, results, targets):
loss = 0.0
for i, (ress, tars) in enumerate(zip(results, targets)):
loss += self.l1loss(ress, ... | 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... | ljrprocc/Motif-Removal | PerceptionLoss | false | 3,934 | [
"MIT"
] | 0 | 8979ca91398212248a2be61345c99bdec53ae37e | https://github.com/ljrprocc/Motif-Removal/tree/8979ca91398212248a2be61345c99bdec53ae37e |
lp_L1_Loss | import torch
from torch.utils.data import *
import torch.nn as nn
class lp_L1_Loss(nn.Module):
def __init__(self):
super().__init__()
self.loss = nn.L1Loss(reduction='sum')
def forward(self, x, y):
b = x.shape[0]
loss = self.loss(x, y)
return loss / b
def get_inputs... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
from torch.utils.data ... | loveorchids/local_patch_retrieval | lp_L1_Loss | false | 3,935 | [
"Apache-2.0"
] | 0 | 52b2e8fdac965d56ef9f89a8c4de96d0b41d3981 | https://github.com/loveorchids/local_patch_retrieval/tree/52b2e8fdac965d56ef9f89a8c4de96d0b41d3981 |
VariableSoftmax | import torch
from torch import Tensor
from torch import nn
from typing import *
class VariableSoftmax(nn.Softmax):
"""Softmax with temperature"""
def __init__(self, temp: 'float'=1, dim: 'int'=-1):
super().__init__(dim=dim)
self.temp = temp
def forward(self, x: 'Tensor') ->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
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
from torch import nn
f... | llayer/pytorch_inferno | VariableSoftmax | false | 3,936 | [
"Apache-2.0"
] | 0 | 922eba5e04e447126506512eb82adcd9ed1dab25 | https://github.com/llayer/pytorch_inferno/tree/922eba5e04e447126506512eb82adcd9ed1dab25 |
lp_L2_Loss | import torch
from torch.utils.data import *
import torch.nn as nn
class lp_L2_Loss(nn.Module):
def __init__(self):
super().__init__()
self.loss = nn.MSELoss(reduction='sum')
def forward(self, x, y):
b = x.shape[0]
loss = self.loss(x, y)
return loss / b
def get_input... | 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.utils.data import *
import torch.nn as nn
assert_size_stride = torch._C._dynam... | loveorchids/local_patch_retrieval | lp_L2_Loss | false | 3,937 | [
"Apache-2.0"
] | 0 | 52b2e8fdac965d56ef9f89a8c4de96d0b41d3981 | https://github.com/loveorchids/local_patch_retrieval/tree/52b2e8fdac965d56ef9f89a8c4de96d0b41d3981 |
lp_KL_divergence | import torch
from torch.utils.data import *
import torch.nn as nn
class lp_KL_divergence(nn.Module):
def __init__(self):
super().__init__()
self.loss = nn.KLDivLoss(reduction='batchmean')
self.normalize = nn.Softmax(dim=-1)
def forward(self, x, y):
embed_dim = x.shape[-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
from torch.... | loveorchids/local_patch_retrieval | lp_KL_divergence | false | 3,938 | [
"Apache-2.0"
] | 0 | 52b2e8fdac965d56ef9f89a8c4de96d0b41d3981 | https://github.com/loveorchids/local_patch_retrieval/tree/52b2e8fdac965d56ef9f89a8c4de96d0b41d3981 |
GraphConvSparse | import torch
import numpy as np
import torch.nn.functional as F
import torch.nn as nn
def glorot_init(input_dim, output_dim):
init_range = np.sqrt(6.0 / (input_dim + output_dim))
initial = torch.rand(input_dim, output_dim) * 2 * init_range - init_range
return nn.Parameter(initial)
class GraphConvSparse(... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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... | ksuchoi216/learn-to-cluster | GraphConvSparse | false | 3,939 | [
"MIT"
] | 0 | bef44f92be14e00a96545061a5ecfa7a27da267e | https://github.com/ksuchoi216/learn-to-cluster/tree/bef44f92be14e00a96545061a5ecfa7a27da267e |
resnet_block | import torch
import torch.nn as nn
import torch.nn.functional as F
class resnet_block(nn.Module):
def __init__(self, dim_in, dim_out):
super(resnet_block, self).__init__()
self.dim_in = dim_in
self.dim_out = dim_out
if self.dim_in == self.dim_out:
self.conv_1 = nn.Conv... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | luixiao1223/BSP-NET-pytorch | resnet_block | false | 3,940 | [
"MIT"
] | 0 | f871c8ce6a9d52ac922e110702c47cd1c89d0a73 | https://github.com/luixiao1223/BSP-NET-pytorch/tree/f871c8ce6a9d52ac922e110702c47cd1c89d0a73 |
DiceLoss | import torch
import torch.nn as nn
import torch.nn.functional as F
class BinaryDiceLoss(nn.Module):
"""Dice loss of binary class
Args:
smooth: A float number to smooth loss, and avoid NaN error, default: 1
p: Denominator value: \\sum{x^p} + \\sum{y^p}, default: 2
predict: A tensor of s... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
... | ljrprocc/Motif-Removal | DiceLoss | false | 3,941 | [
"MIT"
] | 0 | 8979ca91398212248a2be61345c99bdec53ae37e | https://github.com/ljrprocc/Motif-Removal/tree/8979ca91398212248a2be61345c99bdec53ae37e |
SoftmaxLayer | import torch
import torch.nn as nn
class SoftmaxLayer(nn.Module):
""" Naive softmax-layer """
def __init__(self, output_dim, n_class):
"""
:param output_dim: int
:param n_class: int
"""
super(SoftmaxLayer, self).__init__()
self.hidden2tag = nn.Linear(output_dim, n_class)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | luomou97/ELMoForManyLangs | SoftmaxLayer | false | 3,942 | [
"MIT"
] | 0 | 3e97600baa3a4dde229c1e78c513785e7d50e8e1 | https://github.com/luomou97/ELMoForManyLangs/tree/3e97600baa3a4dde229c1e78c513785e7d50e8e1 |
SELU | import torch
from torch import nn
import torch.nn.functional as F
def where(condition, if_true, if_false):
"""
Torch equivalent of numpy.where.
Parameters
----------
condition : torch.ByteTensor or torch.cuda.ByteTensor
Condition to check.
if_true : torch.Tensor or torch.cuda.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
from torch._inductor.runtime.triton_helpers import libdevice
from torch import nn
import torch.nn.functional as F
assert_size_stride = torch... | krayyalasomayajula/inferno | SELU | false | 3,943 | [
"Apache-2.0"
] | 0 | 1c56f34ff19c69dec3d3cb6287b659345bce3492 | https://github.com/krayyalasomayajula/inferno/tree/1c56f34ff19c69dec3d3cb6287b659345bce3492 |
Highway | import torch
from torch import nn
import torch.nn.functional as F
class NonCausalConv1d(nn.Module):
"""Non causal Conv1d with appropriate padding to ensure sequence length stays the same.
Note Convolutions always have stride of 1 following layout in paper.
"""
def __init__(self, in_channels, 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 import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_st... | lstsm12345/DCTTS-PyTorch | Highway | false | 3,944 | [
"MIT"
] | 0 | d44b9407b654abc2069bd2a7ef6231572ace1fa7 | https://github.com/lstsm12345/DCTTS-PyTorch/tree/d44b9407b654abc2069bd2a7ef6231572ace1fa7 |
generator | import torch
import torch.nn as nn
class generator(nn.Module):
def __init__(self, p_dim, c_dim):
super(generator, self).__init__()
self.p_dim = p_dim
self.c_dim = c_dim
convex_layer_weights = torch.zeros((self.p_dim, self.c_dim))
self.convex_layer_weights = nn.Parameter(co... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | luixiao1223/BSP-NET-pytorch | generator | false | 3,945 | [
"MIT"
] | 0 | f871c8ce6a9d52ac922e110702c47cd1c89d0a73 | https://github.com/luixiao1223/BSP-NET-pytorch/tree/f871c8ce6a9d52ac922e110702c47cd1c89d0a73 |
RelationNonLocal | import torch
import torch.nn as nn
class RelationNonLocal(nn.Module):
def __init__(self, C):
super(RelationNonLocal, self).__init__()
self.conv_fv = nn.Conv2d(C, C, kernel_size=1, stride=1)
self.conv_fk = nn.Conv2d(C, C, kernel_size=1, stride=1)
self.conv_fq = nn.Conv2d(C, C, 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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | luozn15/FloorplanGAN | RelationNonLocal | false | 3,946 | [
"MIT"
] | 0 | 113813c2e857c5cd4e64c92626d359e5746e9eab | https://github.com/luozn15/FloorplanGAN/tree/113813c2e857c5cd4e64c92626d359e5746e9eab |
RegularizedLinear | import torch
from torch import nn
class RegularizedLinear(nn.Linear):
def __init__(self, *args, ar_weight=0.001, l1_weight=0.001, **kwargs):
super(RegularizedLinear, self).__init__(*args, **kwargs)
self.ar_weight = ar_weight
self.l1_weight = l1_weight
self._losses = {}
def fo... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | krayyalasomayajula/inferno | RegularizedLinear | false | 3,947 | [
"Apache-2.0"
] | 0 | 1c56f34ff19c69dec3d3cb6287b659345bce3492 | https://github.com/krayyalasomayajula/inferno/tree/1c56f34ff19c69dec3d3cb6287b659345bce3492 |
MSE | import torch
import torch.nn as nn
import torch.utils.checkpoint
class MSE(nn.Module):
def __init__(self):
super(MSE, self).__init__()
def forward(self, pred, real):
diffs = torch.add(real, -pred)
n = torch.numel(diffs.data)
mse = torch.sum(diffs.pow(2)) / n
return ms... | 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.checkpoint
assert_size_stride = torch._C._dynamo... | lyh512796310/MMSA | MSE | false | 3,948 | [
"MIT"
] | 0 | e1735afd1b4e763995ab7aacb001884a7b7146ff | https://github.com/lyh512796310/MMSA/tree/e1735afd1b4e763995ab7aacb001884a7b7146ff |
WeightedMSELoss | import torch
from torch import nn
def assert_(condition, message='', exception_type=AssertionError):
"""Like assert, but with arbitrary exception types."""
if not condition:
raise exception_type(message)
class WeightedMSELoss(nn.Module):
NEGATIVE_CLASS_WEIGHT = 1.0
def __init__(self, positi... | 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_... | krayyalasomayajula/inferno | WeightedMSELoss | false | 3,949 | [
"Apache-2.0"
] | 0 | 1c56f34ff19c69dec3d3cb6287b659345bce3492 | https://github.com/krayyalasomayajula/inferno/tree/1c56f34ff19c69dec3d3cb6287b659345bce3492 |
PatchMerging | import torch
import torch.nn as nn
import torch.nn.functional as F
class PatchMerging(nn.Module):
""" Patch Merging Layer
Args:
dim (int): Number of input channels.
norm_layer (nn.Module, optional): Normalization layer. Default: nn.LayerNorm
"""
def __init__(self, dim, norm_layer=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.triton_helpers import libdevice
import torch.nn as ... | luohwu/video-swin-transformer-pytorch | PatchMerging | false | 3,950 | [
"MIT"
] | 0 | ad96877a6db44436183a03e5b9a80c425726c982 | https://github.com/luohwu/video-swin-transformer-pytorch/tree/ad96877a6db44436183a03e5b9a80c425726c982 |
SorensenDiceLoss | import torch
from torch import nn
def assert_(condition, message='', exception_type=AssertionError):
"""Like assert, but with arbitrary exception types."""
if not condition:
raise exception_type(message)
def flatten_samples(input_):
"""
Flattens a tensor or a variable such that the channel 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._inductor.runtime import triton_helpers
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empt... | krayyalasomayajula/inferno | SorensenDiceLoss | false | 3,951 | [
"Apache-2.0"
] | 0 | 1c56f34ff19c69dec3d3cb6287b659345bce3492 | https://github.com/krayyalasomayajula/inferno/tree/1c56f34ff19c69dec3d3cb6287b659345bce3492 |
SIMSE | import torch
import torch.nn as nn
import torch.utils.checkpoint
class SIMSE(nn.Module):
def __init__(self):
super(SIMSE, self).__init__()
def forward(self, pred, real):
diffs = torch.add(real, -pred)
n = torch.numel(diffs.data)
simse = torch.sum(diffs).pow(2) / n ** 2
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
import torch.utils.checkpoint
assert_size_stride = torch._C._dynamo... | lyh512796310/MMSA | SIMSE | false | 3,952 | [
"MIT"
] | 0 | e1735afd1b4e763995ab7aacb001884a7b7146ff | https://github.com/lyh512796310/MMSA/tree/e1735afd1b4e763995ab7aacb001884a7b7146ff |
DiffLoss | import torch
import torch.nn as nn
import torch.utils.checkpoint
class DiffLoss(nn.Module):
def __init__(self):
super(DiffLoss, self).__init__()
def forward(self, input1, input2):
batch_size = input1.size(0)
input1 = input1.view(batch_size, -1)
input2 = input2.view(batch_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.triton_helpers import libdevice
import torch.nn as ... | lyh512796310/MMSA | DiffLoss | false | 3,953 | [
"MIT"
] | 0 | e1735afd1b4e763995ab7aacb001884a7b7146ff | https://github.com/lyh512796310/MMSA/tree/e1735afd1b4e763995ab7aacb001884a7b7146ff |
TimeEncode | import torch
import numpy as np
import torch.nn as nn
class TimeEncode(nn.Module):
"""Use finite fourier series with different phase and frequency to encode
time different between two event
..math::
\\Phi(t) = [\\cos(\\omega_0t+\\psi_0),\\cos(\\omega_1t+\\psi_1),...,\\cos(\\omega_nt+\\psi_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 math as tl_math
import numpy ... | lxylxyoo/WSDM2022 | TimeEncode | false | 3,954 | [
"MIT"
] | 0 | 970aa5e9d0ccf597af33368ae1ad565543daa4de | https://github.com/lxylxyoo/WSDM2022/tree/970aa5e9d0ccf597af33368ae1ad565543daa4de |
ExpActivation | import torch
import torch.nn as nn
class ExpActivation(nn.Module):
def __init__(self):
super(ExpActivation, self).__init__()
def forward(self, x):
return torch.exp(-x ** 2)
def get_inputs():
return [torch.rand([4, 4, 4, 4])]
def get_init_inputs():
return [[], {}]
| import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert... | mahkons/orthogonal | ExpActivation | false | 3,955 | [
"MIT"
] | 0 | 19a69134ca9a01ef564eab624b8c1526291770aa | https://github.com/mahkons/orthogonal/tree/19a69134ca9a01ef564eab624b8c1526291770aa |
encoder | import torch
import torch.nn as nn
import torch.nn.functional as F
class encoder(nn.Module):
def __init__(self, ef_dim):
super(encoder, self).__init__()
self.ef_dim = ef_dim
self.conv_1 = nn.Conv3d(1, self.ef_dim, 4, stride=2, padding=1,
bias=True)
self.conv_2 = nn.Con... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | luixiao1223/BSP-NET-pytorch | encoder | false | 3,956 | [
"MIT"
] | 0 | f871c8ce6a9d52ac922e110702c47cd1c89d0a73 | https://github.com/luixiao1223/BSP-NET-pytorch/tree/f871c8ce6a9d52ac922e110702c47cd1c89d0a73 |
convnet | import torch
import torch.nn as nn
class convnet(nn.Module):
def __init__(self, in_channel, dim):
super(convnet, self).__init__()
self.conv1 = nn.Conv2d(in_channel, 32, kernel_size=3, padding=1)
self.conv2 = nn.Conv2d(32, 1, kernel_size=1)
def forward(self, x):
x = self.conv1... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | lzz0007/pyGAT | convnet | false | 3,957 | [
"MIT"
] | 0 | ea09c56037185ec5924dcd20b9c09d151174d1a3 | https://github.com/lzz0007/pyGAT/tree/ea09c56037185ec5924dcd20b9c09d151174d1a3 |
MLPBody | import torch
import torch.nn.functional as F
import torch.nn as nn
def layer_init(layer, w_scale=1.0):
init_f = nn.init.orthogonal_
init_f(layer.weight.data)
layer.weight.data.mul_(w_scale)
if layer.bias is not None:
nn.init.constant_(layer.bias.data, 0)
return layer
class MLPBody(nn.Mod... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | lchenat/TSA | MLPBody | false | 3,958 | [
"Apache-2.0"
] | 0 | 661266ba16e06f63962b306a7c30d25f37920c2d | https://github.com/lchenat/TSA/tree/661266ba16e06f63962b306a7c30d25f37920c2d |
OrthogonalHouseholder | import math
import torch
import torch.nn as nn
class OrthogonalHouseholder(nn.Module):
def __init__(self, sz, bias=True):
super(OrthogonalHouseholder, self).__init__()
self.sz = sz
self.bias = bias
self.A = nn.Parameter(torch.empty((sz, sz)))
self.b = nn.Parameter(torch.em... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import math
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.a... | mahkons/orthogonal | OrthogonalHouseholder | false | 3,959 | [
"MIT"
] | 0 | 19a69134ca9a01ef564eab624b8c1526291770aa | https://github.com/mahkons/orthogonal/tree/19a69134ca9a01ef564eab624b8c1526291770aa |
MyLinear | import torch
import torch.nn as nn
class MyLinear(nn.Module):
def __init__(self, in_sz, out_sz, bias=True):
super(MyLinear, self).__init__()
self.in_sz = in_sz
self.out_sz = out_sz
self.bias = bias
self.W = nn.Parameter(torch.empty((in_sz, out_sz)))
self.b = nn.Par... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | mahkons/orthogonal | MyLinear | false | 3,960 | [
"MIT"
] | 0 | 19a69134ca9a01ef564eab624b8c1526291770aa | https://github.com/mahkons/orthogonal/tree/19a69134ca9a01ef564eab624b8c1526291770aa |
OrthogonalHouseholderAlternative | import math
import torch
import torch.nn as nn
class OrthogonalHouseholderAlternative(nn.Module):
def __init__(self, sz, bias=True):
super(OrthogonalHouseholderAlternative, self).__init__()
self.sz = sz
self.bias = bias
self.A = nn.Parameter(torch.empty((sz, sz)))
self.b =... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import math
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.a... | mahkons/orthogonal | OrthogonalHouseholderAlternative | false | 3,961 | [
"MIT"
] | 0 | 19a69134ca9a01ef564eab624b8c1526291770aa | https://github.com/mahkons/orthogonal/tree/19a69134ca9a01ef564eab624b8c1526291770aa |
Conv2d_depthwise_sep | import torch
import torch.nn as nn
class Conv2d_depthwise_sep(nn.Module):
def __init__(self, nin, nout):
super(Conv2d_depthwise_sep, self).__init__()
self.depthwise = nn.Conv2d(nin, nin, kernel_size=3, padding=1,
groups=nin)
self.pointwise = nn.Conv2d(nin, nout, kernel_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
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | maet3608/torchy | Conv2d_depthwise_sep | false | 3,962 | [
"Apache-2.0"
] | 0 | 8c73732a1d4631bd97bfafdc18e52a22ff5410f7 | https://github.com/maet3608/torchy/tree/8c73732a1d4631bd97bfafdc18e52a22ff5410f7 |
MultiheadAttention | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.parameter import Parameter
import torch.utils.checkpoint
from torch.nn import Parameter
class MultiheadAttention(nn.Module):
"""Multi-headed attention.
See "Attention Is All You Need" for more details.
"""
def __init__(s... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | lyh512796310/MMSA | MultiheadAttention | false | 3,963 | [
"MIT"
] | 0 | e1735afd1b4e763995ab7aacb001884a7b7146ff | https://github.com/lyh512796310/MMSA/tree/e1735afd1b4e763995ab7aacb001884a7b7146ff |
RegWeightedL1Loss | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
def _gather_feat(feat, ind, mask=None):
dim = feat.size(2)
ind = ind.unsqueeze(2).expand(ind.size(0), ind.size(1), dim)
feat = feat.gather(1, ind)
if mask is not None:
mask = mask.unsqueeze(2).expand_as(... | 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
... | leobean/CenterNet_simple | RegWeightedL1Loss | false | 3,964 | [
"MIT"
] | 0 | 13e2eab2c049563afde5defdf90434a310a32d02 | https://github.com/leobean/CenterNet_simple/tree/13e2eab2c049563afde5defdf90434a310a32d02 |
ChannelAttention | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
class ChannelAttention(nn.Module):
def __init__(self, C):
super(ChannelAttention, self).__init__()
self.relu = nn.ReLU()
self.sigmoid = nn.Sigmoid()
self.fc1 = nn.Linear(C, int(C / 4))
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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 ... | leobean/CenterNet_simple | ChannelAttention | false | 3,965 | [
"MIT"
] | 0 | 13e2eab2c049563afde5defdf90434a310a32d02 | https://github.com/leobean/CenterNet_simple/tree/13e2eab2c049563afde5defdf90434a310a32d02 |
RBF | import torch
import torch.nn as nn
class RBF(nn.Module):
def __init__(self):
super(RBF, self).__init__()
self.mean = nn.Parameter(torch.Tensor([0.0]))
self.std = nn.Parameter(torch.Tensor([1.0]))
def forward(self, x):
gauss = torch.exp(-(x - self.mean) ** 2 / (2 * self.std **... | 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... | maet3608/torchy | RBF | false | 3,966 | [
"Apache-2.0"
] | 0 | 8c73732a1d4631bd97bfafdc18e52a22ff5410f7 | https://github.com/maet3608/torchy/tree/8c73732a1d4631bd97bfafdc18e52a22ff5410f7 |
RegLoss | import torch
import torch.nn as nn
import torch.utils.data
def _gather_feat(feat, ind, mask=None):
dim = feat.size(2)
ind = ind.unsqueeze(2).expand(ind.size(0), ind.size(1), dim)
feat = feat.gather(1, ind)
if mask is not None:
mask = mask.unsqueeze(2).expand_as(feat)
feat = feat[mask]
... | 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
... | leobean/CenterNet_simple | RegLoss | false | 3,967 | [
"MIT"
] | 0 | 13e2eab2c049563afde5defdf90434a310a32d02 | https://github.com/leobean/CenterNet_simple/tree/13e2eab2c049563afde5defdf90434a310a32d02 |
ScalarBiasScale | import torch
import torch.nn as nn
from torch.nn.parameter import Parameter
from torch.nn import init
class ScalarScaleBias(nn.Module):
def __init__(self, scale=True, scale_init=1.0, bias=True, bias_init=0.0
) ->None:
super(ScalarScaleBias, self).__init__()
if scale:
self.weig... | 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.nn.parameter import Parameter
from torch.nn import init
assert_size_stride = torch._C._dynamo.guards.assert... | maltanar/logicnets-1 | ScalarBiasScale | false | 3,968 | [
"Apache-2.0"
] | 0 | 0afa2aa5b39cb484db0fcaa542e55c8cbe586119 | https://github.com/maltanar/logicnets-1/tree/0afa2aa5b39cb484db0fcaa542e55c8cbe586119 |
Conv2d_spatial_sep | import torch
import torch.nn as nn
class Conv2d_spatial_sep(nn.Module):
def __init__(self, nin, nout):
super(Conv2d_spatial_sep, self).__init__()
self.conv1 = nn.Conv2d(nin, 1, kernel_size=(1, 3), groups=1, padding=0)
self.conv2 = nn.Conv2d(1, nout, kernel_size=(3, 1), groups=1, padding=1... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_s... | maet3608/torchy | Conv2d_spatial_sep | false | 3,969 | [
"Apache-2.0"
] | 0 | 8c73732a1d4631bd97bfafdc18e52a22ff5410f7 | https://github.com/maet3608/torchy/tree/8c73732a1d4631bd97bfafdc18e52a22ff5410f7 |
Conv_Block | import torch
import torch.nn as nn
import torch.utils.data
from torch.nn import functional as F
class Conv_Block(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, padding,
stride, pool_kernel_size=(2, 2)):
super(Conv_Block, self).__init__()
self.conv1 = 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.... | majedelhelou/PriorLearning | Conv_Block | false | 3,970 | [
"MIT"
] | 0 | f66d25993c3b99dd31d9d62abeb3e0a5623e034d | https://github.com/majedelhelou/PriorLearning/tree/f66d25993c3b99dd31d9d62abeb3e0a5623e034d |
ScalarScaleBias | import torch
import torch.nn as nn
from torch.nn.parameter import Parameter
from torch.nn import init
class ScalarScaleBias(nn.Module):
def __init__(self, scale=True, scale_init=1.0, bias=True, bias_init=0.0
) ->None:
super(ScalarScaleBias, self).__init__()
if scale:
self.weig... | 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.nn.parameter import Parameter
from torch.nn import init
assert_size_stride = torch._C._dynamo.guards.assert... | maltanar/logicnets-1 | ScalarScaleBias | false | 3,971 | [
"Apache-2.0"
] | 0 | 0afa2aa5b39cb484db0fcaa542e55c8cbe586119 | https://github.com/maltanar/logicnets-1/tree/0afa2aa5b39cb484db0fcaa542e55c8cbe586119 |
DiceLoss | import torch
import torch.nn as nn
class DiceLoss(nn.Module):
def __init__(self, weight=None, size_average=True):
super(DiceLoss, self).__init__()
def forward(self, inputs, targets, smooth=1):
inputs = inputs.contiguous()
targets = targets.contiguous()
intersection = (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... | manuelhz/dissertation | DiceLoss | false | 3,972 | [
"MIT"
] | 0 | ca89475f79505dfb6d8a3645ca85451df7fce3b6 | https://github.com/manuelhz/dissertation/tree/ca89475f79505dfb6d8a3645ca85451df7fce3b6 |
OpenPoseLoss | import torch
import torch.nn as nn
import torch.nn.functional as F
class OpenPoseLoss(nn.Module):
def __init__(self):
super(OpenPoseLoss, self).__init__()
def forward(self, saved_for_loss, heatmap_target, heat_mask, paf_target,
paf_mask):
"""
tính loss
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
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
emp... | makotovnjp/Talent5OpenPose | OpenPoseLoss | false | 3,973 | [
"Apache-2.0"
] | 0 | 1ebbbd4f226b6839d7d1627d6c33edd416c137fc | https://github.com/makotovnjp/Talent5OpenPose/tree/1ebbbd4f226b6839d7d1627d6c33edd416c137fc |
MLP | import torch
import numpy as np
from torch import nn
from torch.nn import functional as F
class MLP(nn.Module):
def __init__(self, input_shape, n_layers, n_units):
super().__init__()
self._layers = []
n_in = int(np.prod(np.array(input_shape)))
for i in range(n_layers):
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import numpy as np
from torch... | manfreddiaz/rl-laplacian | MLP | false | 3,974 | [
"MIT"
] | 0 | 034803adb5c20c3bb7822b18d675b762fdcc53dc | https://github.com/manfreddiaz/rl-laplacian/tree/034803adb5c20c3bb7822b18d675b762fdcc53dc |
PSNRLoss | import torch
import torch.nn as nn
from torch.nn.functional import mse_loss
def psnr_loss(input: 'torch.Tensor', target: 'torch.Tensor', max_val: 'float'
) ->torch.Tensor:
"""Function that computes PSNR
See :class:`~kornia.losses.PSNRLoss` for details.
"""
if not torch.is_tensor(input) or not tor... | 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
from t... | manyids2/kornia-1 | PSNRLoss | false | 3,975 | [
"ECL-2.0",
"Apache-2.0"
] | 0 | 47f5e91f502a0819be9b5a843019b37b15aa37f2 | https://github.com/manyids2/kornia-1/tree/47f5e91f502a0819be9b5a843019b37b15aa37f2 |
img_encoder | import torch
import torch.nn as nn
import torch.nn.functional as F
class resnet_block(nn.Module):
def __init__(self, dim_in, dim_out):
super(resnet_block, self).__init__()
self.dim_in = dim_in
self.dim_out = dim_out
if self.dim_in == self.dim_out:
self.conv_1 = nn.Conv... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
import torch.nn.functional as F
assert_size_stride = torch... | luixiao1223/BSP-NET-pytorch | img_encoder | false | 3,976 | [
"MIT"
] | 0 | f871c8ce6a9d52ac922e110702c47cd1c89d0a73 | https://github.com/luixiao1223/BSP-NET-pytorch/tree/f871c8ce6a9d52ac922e110702c47cd1c89d0a73 |
ClusterDistance | import torch
from torch import nn
from typing import Optional
class ClusterDistance(nn.Module):
def __init__(self, n_classes: 'int', enc_shape: 'int', cluster_centers:
'Optional[torch.Tensor]'=None) ->None:
"""
:param n_classes: number of clusters
:param enc_shape: embedding dime... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
from typing import Optional
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch.... | marx-alex/Morphelia | ClusterDistance | false | 3,977 | [
"MIT"
] | 0 | 809278b07f1a535789455d54df3cbddc850d609c | https://github.com/marx-alex/Morphelia/tree/809278b07f1a535789455d54df3cbddc850d609c |
Get_gradient_nopadding | import torch
import torch.nn as nn
import torch.nn.functional as F
class Get_gradient_nopadding(nn.Module):
def __init__(self):
super(Get_gradient_nopadding, self).__init__()
kernel_v = [[0, -1, 0], [0, 0, 0], [0, 1, 0]]
kernel_h = [[0, 0, 0], [-1, 0, 1], [0, 0, 0]]
kernel_h = 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 ... | mansum6/ESRGAN | Get_gradient_nopadding | false | 3,978 | [
"Apache-2.0"
] | 0 | 8a6b2ce20600840490ee0525cb105617b8e85c73 | https://github.com/mansum6/ESRGAN/tree/8a6b2ce20600840490ee0525cb105617b8e85c73 |
ClusterAssignment | import torch
from torch import nn
from typing import Optional
class ClusterAssignment(nn.Module):
def __init__(self, n_classes: 'int', enc_shape: 'int', alpha: 'float'=
1.0, cluster_centers: 'Optional[torch.Tensor]'=None) ->None:
"""
Module to handle the soft assignment, for a description... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
from typing import Optional
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch.... | marx-alex/Morphelia | ClusterAssignment | false | 3,979 | [
"MIT"
] | 0 | 809278b07f1a535789455d54df3cbddc850d609c | https://github.com/marx-alex/Morphelia/tree/809278b07f1a535789455d54df3cbddc850d609c |
BinaryReg | import torch
import torch.utils.data
import torch.nn as nn
class BinaryReg(nn.Module):
"""Regularization for encouraging the outputs to be binary.
"""
def __init__(self, alpha=0.1):
super().__init__()
self.alpha = alpha
def forward(self, pred):
diff = pred - 0.5
diff ... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.utils.dat... | matinraayai/pytorch_connectomics | BinaryReg | false | 3,980 | [
"MIT"
] | 0 | b11a2f7e71a8d1442fb05f7a6edfaaaa7b0d9205 | https://github.com/matinraayai/pytorch_connectomics/tree/b11a2f7e71a8d1442fb05f7a6edfaaaa7b0d9205 |
Triaffine | import torch
import torch.nn as nn
class Triaffine(nn.Module):
"""
Triaffine layer for second-order scoring.
This function has a tensor of weights `W` and bias terms if needed.
The score `s(x, y, z)` of the vector triple `(x, y, z)` is computed as `x^T z^T W y`.
Usually, `x` and `y` can be concat... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | matejklemen/morphological-dependency-parsing | Triaffine | false | 3,981 | [
"MIT"
] | 0 | 2ab24b8621debe6e3288ade01c9604a06f9bd453 | https://github.com/matejklemen/morphological-dependency-parsing/tree/2ab24b8621debe6e3288ade01c9604a06f9bd453 |
DiceLoss | import torch
import torch.utils.data
import torch.nn as nn
class DiceLoss(nn.Module):
"""DICE loss.
"""
def __init__(self, size_average=True, reduce=True, smooth=100.0, power=1):
super(DiceLoss, self).__init__()
self.smooth = smooth
self.reduce = reduce
self.power = power
... | 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.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C.... | matinraayai/pytorch_connectomics | DiceLoss | false | 3,982 | [
"MIT"
] | 0 | b11a2f7e71a8d1442fb05f7a6edfaaaa7b0d9205 | https://github.com/matinraayai/pytorch_connectomics/tree/b11a2f7e71a8d1442fb05f7a6edfaaaa7b0d9205 |
Mish | import torch
import torch.nn as nn
class Mish(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x):
return torch.mul(x, torch.tanh(torch.log(1 + torch.exp(x))))
def get_inputs():
return [torch.rand([4, 4, 4, 4])]
def get_init_inputs():
return [[], {}]
| import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import torch.nn as nn
assert_size_stride = torch._C._dynamo.gu... | mattroz/yatopi | Mish | false | 3,983 | [
"MIT"
] | 0 | 278bac6f3d2f13916ae9d43309b9f38b608426bd | https://github.com/mattroz/yatopi/tree/278bac6f3d2f13916ae9d43309b9f38b608426bd |
PatchEmbed3D | import torch
import torch.nn as nn
import torch.nn.functional as F
class PatchEmbed3D(nn.Module):
""" Video to Patch Embedding.
Args:
patch_size (int): Patch token size. Default: (2,4,4).
in_chans (int): Number of input video channels. Default: 3.
embed_dim (int): Number of linear proj... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | luohwu/video-swin-transformer-pytorch | PatchEmbed3D | false | 3,984 | [
"MIT"
] | 0 | ad96877a6db44436183a03e5b9a80c425726c982 | https://github.com/luohwu/video-swin-transformer-pytorch/tree/ad96877a6db44436183a03e5b9a80c425726c982 |
JaccardLoss | import torch
import torch.utils.data
import torch.nn as nn
from abc import ABC
class JaccardLoss(nn.Module, ABC):
"""Jaccard loss.
"""
def __init__(self, size_average=True, reduce=True, smooth=1.0):
super(JaccardLoss, self).__init__()
self.smooth = smooth
self.reduce = reduce
... | 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.nn as nn
from abc import ABC
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_stri... | matinraayai/pytorch_connectomics | JaccardLoss | false | 3,985 | [
"MIT"
] | 0 | b11a2f7e71a8d1442fb05f7a6edfaaaa7b0d9205 | https://github.com/matinraayai/pytorch_connectomics/tree/b11a2f7e71a8d1442fb05f7a6edfaaaa7b0d9205 |
Network | import torch
import torch.nn as nn
import torch.nn.parallel
import torch.utils.data
import torch.nn.functional as F
class Network(nn.Module):
def __init__(self):
super(Network, self).__init__()
self.conv1 = nn.Conv2d(3, 6, 5)
self.pool = nn.MaxPool2d(2, 2)
self.conv2 = nn.Conv2d(6... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
import ... | markosej11/Image-Claasification | Network | false | 3,986 | [
"MIT"
] | 0 | 0fea42726f36b582829a44e6fcebf8af89b518fc | https://github.com/markosej11/Image-Claasification/tree/0fea42726f36b582829a44e6fcebf8af89b518fc |
VGGBase | import torch
import torchvision
import torch.utils.data
from torch import nn
import torch.nn.functional as F
from itertools import product as product
import torch.optim
def decimate(tensor, m):
"""
Decimate a tensor by a factor 'm', i.e. downsample by keeping every 'm'th value.
This is used when we conve... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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 torchvision
import tor... | adityag6994/pytorch_ssd_training | VGGBase | false | 3,987 | [
"MIT"
] | 0 | 404f3cbef815e314337ec2c1b4f06a2403a7ce03 | https://github.com/adityag6994/pytorch_ssd_training/tree/404f3cbef815e314337ec2c1b4f06a2403a7ce03 |
sSE | import torch
import torch.nn as nn
class sSE(nn.Module):
def __init__(self, in_channels):
super().__init__()
self.pointwise = nn.Conv2d(in_channels=in_channels, out_channels=1,
kernel_size=1)
self.sigmoid = nn.Sigmoid()
def forward(self, input_tensor):
x = self.po... | import torch
from torch._inductor.select_algorithm import extern_kernels
import 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... | mattroz/yatopi | sSE | false | 3,988 | [
"MIT"
] | 0 | 278bac6f3d2f13916ae9d43309b9f38b608426bd | https://github.com/mattroz/yatopi/tree/278bac6f3d2f13916ae9d43309b9f38b608426bd |
_FakeMegatronMLP | from _paritybench_helpers import _mock_config
import torch
import torch.nn as nn
import torch.nn.functional as F
class _FakeMegatronMLP(nn.Module):
"""
A fake mlp without model parallelism for correctness testing
"""
def __init__(self, args, _):
super().__init__()
self.fc1 = nn.Linear... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as ... | liuhatry/fastmoe | _FakeMegatronMLP | false | 3,989 | [
"Apache-2.0"
] | 0 | a676bf1eae874c208a0e669bf0f79e6fb3b43623 | https://github.com/liuhatry/fastmoe/tree/a676bf1eae874c208a0e669bf0f79e6fb3b43623 |
cSE | import torch
import torch.nn as nn
class cSE(nn.Module):
def __init__(self, in_channels):
super().__init__()
reduced_filters = 1 if in_channels // 2 == 0 else in_channels // 2
self.global_avg_pool = nn.AdaptiveAvgPool2d(output_size=(1, 1))
self.pointwise_1 = nn.Conv2d(in_channels=... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | mattroz/yatopi | cSE | false | 3,990 | [
"MIT"
] | 0 | 278bac6f3d2f13916ae9d43309b9f38b608426bd | https://github.com/mattroz/yatopi/tree/278bac6f3d2f13916ae9d43309b9f38b608426bd |
AlphaMish | import torch
class AlphaMish(torch.nn.Module):
def __init__(self, in_features):
super().__init__()
self.alpha = torch.nn.Parameter(torch.zeros((in_features, 1, 1)))
self.alpha.requires_grad = True
def forward(self, x):
return torch.mul(x, torch.tanh(torch.mul(1 + torch.nn.fun... | 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, math as tl_math
assert_size_stride = torch._C._dynamo.guards.assert_size_strid... | mattroz/yatopi | AlphaMish | false | 3,991 | [
"MIT"
] | 0 | 278bac6f3d2f13916ae9d43309b9f38b608426bd | https://github.com/mattroz/yatopi/tree/278bac6f3d2f13916ae9d43309b9f38b608426bd |
SimpleErfModule | import torch
import torch.jit
import torch.onnx
import torch.nn
class SimpleErfModule(torch.nn.Module):
def forward(self, input):
return torch.special.erf(input)
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
import torch.jit
import torch.onnx
import torch.nn
assert_size_stride = torch._... | mciprian13/glow | SimpleErfModule | false | 3,992 | [
"Apache-2.0"
] | 0 | 90f88205d9bf8baff8df5bbda51c9d138e3e668b | https://github.com/mciprian13/glow/tree/90f88205d9bf8baff8df5bbda51c9d138e3e668b |
SimpleLeakyReluModule | import torch
import torch.jit
import torch.onnx
import torch.nn
class SimpleLeakyReluModule(torch.nn.Module):
def __init__(self, negative_slope=0.01, inplace=False):
super(SimpleLeakyReluModule, self).__init__()
self.negative_slope = negative_slope
self.inplace = inplace
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 torch.jit
import torch.onnx
import torch.nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torc... | mciprian13/glow | SimpleLeakyReluModule | false | 3,993 | [
"Apache-2.0"
] | 0 | 90f88205d9bf8baff8df5bbda51c9d138e3e668b | https://github.com/mciprian13/glow/tree/90f88205d9bf8baff8df5bbda51c9d138e3e668b |
SimpleArgSortModule | import torch
import torch.jit
import torch.onnx
import torch.nn
class SimpleArgSortModule(torch.nn.Module):
def __init__(self, descending=True):
super(SimpleArgSortModule, self).__init__()
self.descending = descending
def forward(self, inputs):
return torch.argsort(inputs, dim=-1, de... | 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.jit
import torch.onnx
import torch.nn
assert_size_stride = torch._C._dynamo.... | mciprian13/glow | SimpleArgSortModule | false | 3,994 | [
"Apache-2.0"
] | 0 | 90f88205d9bf8baff8df5bbda51c9d138e3e668b | https://github.com/mciprian13/glow/tree/90f88205d9bf8baff8df5bbda51c9d138e3e668b |
CriticNN | import torch
import torch.optim as optim
from torch import nn
from torch.nn import functional as F
class CriticNN(nn.Module):
def __init__(self, in_channels=3):
super(CriticNN, self).__init__()
self.fc1 = nn.Linear(4, 64)
self.fc2 = nn.Linear(64, 1)
self.optimizer = optim.Adam(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.... | maxmax1992/Q_learning | CriticNN | false | 3,995 | [
"MIT"
] | 0 | 8b2b8491d6f94b94b2fce608b93cdc31b418c5b0 | https://github.com/maxmax1992/Q_learning/tree/8b2b8491d6f94b94b2fce608b93cdc31b418c5b0 |
scSE | import torch
import torch.nn as nn
class cSE(nn.Module):
def __init__(self, in_channels):
super().__init__()
reduced_filters = 1 if in_channels // 2 == 0 else in_channels // 2
self.global_avg_pool = nn.AdaptiveAvgPool2d(output_size=(1, 1))
self.pointwise_1 = nn.Conv2d(in_channels=... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | mattroz/yatopi | scSE | false | 3,996 | [
"MIT"
] | 0 | 278bac6f3d2f13916ae9d43309b9f38b608426bd | https://github.com/mattroz/yatopi/tree/278bac6f3d2f13916ae9d43309b9f38b608426bd |
SimpleAvgPool2dModule | import torch
import torch.jit
import torch.nn.functional as F
import torch.onnx
import torch.nn
class SimpleAvgPool2dModule(torch.nn.Module):
def __init__(self, kernel_size, stride=None, padding=0):
super(SimpleAvgPool2dModule, self).__init__()
self.kernel_size = kernel_size
self.padding ... | 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.jit
import torch.onnx
import torch.nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torc... | mciprian13/glow | SimpleAvgPool2dModule | false | 3,997 | [
"Apache-2.0"
] | 0 | 90f88205d9bf8baff8df5bbda51c9d138e3e668b | https://github.com/mciprian13/glow/tree/90f88205d9bf8baff8df5bbda51c9d138e3e668b |
SimpleFmodModule | import torch
import torch.jit
import torch.onnx
import torch.nn
class SimpleFmodModule(torch.nn.Module):
def __init__(self):
super(SimpleFmodModule, self).__init__()
def forward(self, a, b):
if b.size() == torch.Size([]):
c = a.fmod(b.item())
else:
c = a.fmod(... | 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.jit
import torch.onnx
import torch.nn
assert_size_stride = torch._... | mciprian13/glow | SimpleFmodModule | false | 3,998 | [
"Apache-2.0"
] | 0 | 90f88205d9bf8baff8df5bbda51c9d138e3e668b | https://github.com/mciprian13/glow/tree/90f88205d9bf8baff8df5bbda51c9d138e3e668b |
UnaryMaxModule | import torch
import torch.jit
import torch.onnx
import torch.nn
class UnaryMaxModule(torch.nn.Module):
def __init__(self):
super(UnaryMaxModule, self).__init__()
def forward(self, a):
return torch.max(a + a)
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
from torch._inductor.runtime import triton_helpers
import torch.jit
import torch.onnx
import torch.nn
assert_size_stride = torch._C._dynamo.... | mciprian13/glow | UnaryMaxModule | false | 3,999 | [
"Apache-2.0"
] | 0 | 90f88205d9bf8baff8df5bbda51c9d138e3e668b | https://github.com/mciprian13/glow/tree/90f88205d9bf8baff8df5bbda51c9d138e3e668b |
UnaryMinModule | import torch
import torch.jit
import torch.onnx
import torch.nn
class UnaryMinModule(torch.nn.Module):
def __init__(self):
super(UnaryMinModule, self).__init__()
def forward(self, a):
return torch.min(a + a)
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
from torch._inductor.runtime import triton_helpers
import torch.jit
import torch.onnx
import torch.nn
assert_size_stride = torch._C._dynamo.... | mciprian13/glow | UnaryMinModule | false | 4,000 | [
"Apache-2.0"
] | 0 | 90f88205d9bf8baff8df5bbda51c9d138e3e668b | https://github.com/mciprian13/glow/tree/90f88205d9bf8baff8df5bbda51c9d138e3e668b |
SqueezeEmbedding | import torch
import torch.nn as nn
class SqueezeEmbedding(nn.Module):
"""
Squeeze sequence embedding length to the longest one in the batch
"""
def __init__(self, batch_first=True):
super(SqueezeEmbedding, self).__init__()
self.batch_first = batch_first
def forward(self, x, x_len... | 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... | minionssso/PyABSA | SqueezeEmbedding | false | 4,001 | [
"MIT"
] | 0 | fd9a9a6fd55552a60329fd04b6830e1bb144d50f | https://github.com/minionssso/PyABSA/tree/fd9a9a6fd55552a60329fd04b6830e1bb144d50f |
BiDAFAttention | import torch
import torch.nn as nn
import torch.nn.functional as F
def masked_softmax(logits, mask, dim=-1, log_softmax=False):
"""Take the softmax of `logits` over given dimension, and set
entries to 0 wherever `mask` is 0.
Args:
logits (torch.Tensor): Inputs to the softmax function.
mas... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | mayankiitg/cs224n | BiDAFAttention | false | 4,002 | [
"MIT"
] | 0 | c67b7904101c8f19a5a231e4fe521e764470d41b | https://github.com/mayankiitg/cs224n/tree/c67b7904101c8f19a5a231e4fe521e764470d41b |
Norm | import torch
import torch.nn as nn
class Norm(nn.Module):
def __init__(self, dim_seq, input_size, eps=1e-06):
super().__init__()
self.size = input_size
self.seq = dim_seq
self.alpha = nn.Parameter(torch.ones((self.size, self.seq)))
self.bias = nn.Parameter(torch.zeros((sel... | 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_... | mingweima/hintplaygame | Norm | false | 4,003 | [
"MIT"
] | 0 | 31f35a22111a2e5e7e5d8e90f92326bc784c5fe7 | https://github.com/mingweima/hintplaygame/tree/31f35a22111a2e5e7e5d8e90f92326bc784c5fe7 |
LinearExcitability | import math
import torch
from torch import nn
from torch.nn.parameter import Parameter
def linearExcitability(input, weight, excitability=None, bias=None):
"""Applies a linear transformation to the incoming data: :math:`y = c(xA^T) + b`.
Shape:
- input: :math:`(N, *, in_features)`
- we... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import math
from torch import nn
from torch.nn.parameter import Parameter
assert... | mhmorta/continual-learning-1 | LinearExcitability | false | 4,004 | [
"MIT"
] | 0 | 959d5238d4dd015245592993b5d044572ab58c90 | https://github.com/mhmorta/continual-learning-1/tree/959d5238d4dd015245592993b5d044572ab58c90 |
HighwayMaxoutNetwork | import torch
import torch.nn as nn
import torch.nn.functional as F
def masked_softmax(logits, mask, dim=-1, log_softmax=False):
"""Take the softmax of `logits` over given dimension, and set
entries to 0 wherever `mask` is 0.
Args:
logits (torch.Tensor): Inputs to the softmax function.
mas... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | mayankiitg/cs224n | HighwayMaxoutNetwork | false | 4,005 | [
"MIT"
] | 0 | c67b7904101c8f19a5a231e4fe521e764470d41b | https://github.com/mayankiitg/cs224n/tree/c67b7904101c8f19a5a231e4fe521e764470d41b |
CoAttention | import torch
import torch.nn as nn
import torch.nn.functional as F
def masked_softmax(logits, mask, dim=-1, log_softmax=False):
"""Take the softmax of `logits` over given dimension, and set
entries to 0 wherever `mask` is 0.
Args:
logits (torch.Tensor): Inputs to the softmax function.
mas... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | mayankiitg/cs224n | CoAttention | false | 4,006 | [
"MIT"
] | 0 | c67b7904101c8f19a5a231e4fe521e764470d41b | https://github.com/mayankiitg/cs224n/tree/c67b7904101c8f19a5a231e4fe521e764470d41b |
MySmallModel | import torch
import torch.nn as nn
class MySmallModel(nn.Module):
def __init__(self, nodes):
super().__init__()
hidden_nodes = nodes * 2
self.fc1 = nn.Linear(nodes, hidden_nodes)
self.fc2 = nn.Linear(hidden_nodes, nodes)
self.fc3 = nn.Linear(nodes, 1)
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
import torch.nn as nn
assert_... | minister19/RL_pytorch_get_started | MySmallModel | false | 4,007 | [
"MIT"
] | 0 | e444f524a14d329f9a25c53f102bc96c4ea36ad8 | https://github.com/minister19/RL_pytorch_get_started/tree/e444f524a14d329f9a25c53f102bc96c4ea36ad8 |
AttentionLayer | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import *
class AttentionLayer(nn.Module):
def __init__(self, hidden_dim_en, hidden_dim_de, projected_size):
super(AttentionLayer, self).__init__()
self.linear1 = nn.Linear(hidden_dim_en, projected_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.... | minhdo3000/visual_storytelling | AttentionLayer | false | 4,008 | [
"MIT"
] | 0 | 451c5194564fb1bb02929f57eac8f026662637b1 | https://github.com/minhdo3000/visual_storytelling/tree/451c5194564fb1bb02929f57eac8f026662637b1 |
ELBOLoss | import torch
from torch import nn
class ELBOLoss(nn.Module):
def __init__(self):
super(ELBOLoss, self).__init__()
self.recons_loss = nn.BCELoss(reduction='sum')
def forward(self, reconstruction, x, mu, log_var):
loss = -self.recons_loss(reconstruction, x)
KL_loss = 0.5 * torc... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch ... | mirmohammad/IFT6135-TP3 | ELBOLoss | false | 4,009 | [
"MIT"
] | 0 | 70453b4ea695313837ab88243b0206552eb50632 | https://github.com/mirmohammad/IFT6135-TP3/tree/70453b4ea695313837ab88243b0206552eb50632 |
JSDLoss | import math
import torch
from torch import nn
class JSDLoss(nn.Module):
def __init__(self):
super(JSDLoss, self).__init__()
def forward(self, d_x, d_y):
return -(math.log(2.0) + 0.5 * (torch.mean(torch.log(d_x)) + torch.
mean(torch.log(1.0 - d_y))))
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 math as tl_math
from torch import nn
a... | mirmohammad/IFT6135-TP3 | JSDLoss | false | 4,010 | [
"MIT"
] | 0 | 70453b4ea695313837ab88243b0206552eb50632 | https://github.com/mirmohammad/IFT6135-TP3/tree/70453b4ea695313837ab88243b0206552eb50632 |
Upsample | import torch
from torch import nn
class Upsample(nn.Module):
def __init__(self, dim):
super().__init__()
self.conv = nn.ConvTranspose2d(dim, dim, 4, 2, 1)
def forward(self, x):
return self.conv(x)
def get_inputs():
return [torch.rand([4, 4, 4, 4])]
def get_init_inputs():
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import 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... | mishooax/denoising-diffusion-pytorch | Upsample | false | 4,011 | [
"MIT"
] | 0 | 54df92c06c5cb0dc3bb43232c24c492c6f5a35c7 | https://github.com/mishooax/denoising-diffusion-pytorch/tree/54df92c06c5cb0dc3bb43232c24c492c6f5a35c7 |
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.conv2 = nn.Conv2d(3, 64, 8, 2, 3)
self.conv3 = nn.Conv2d(64, 128, 6, 2, 2)
self.conv4 = nn.Conv2d(128, 256, 4, 2, 1)
self.conv5 = 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.... | leduchuy225/HairNet | Net | false | 4,012 | [
"MIT"
] | 0 | 2d3f0b82a686d2ccc7fee4429ef5925ffabd8982 | https://github.com/leduchuy225/HairNet/tree/2d3f0b82a686d2ccc7fee4429ef5925ffabd8982 |
Attention | import torch
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
class Norm(nn.Module):
def __init__(self, dim_seq, input_size, eps=1e-06):
super().__init__()
self.size = input_size
self.seq = dim_seq
self.alpha = nn.Parameter(torch.ones((self.size, self.seq))... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | mingweima/hintplaygame | Attention | false | 4,013 | [
"MIT"
] | 0 | 31f35a22111a2e5e7e5d8e90f92326bc784c5fe7 | https://github.com/mingweima/hintplaygame/tree/31f35a22111a2e5e7e5d8e90f92326bc784c5fe7 |
Net | import torch
from torch import Tensor
from torch.functional import Tensor
import torch.nn as nn
import torch.nn.functional as F
class Net(nn.Module):
def __init__(self):
super().__init__()
self.conv1 = nn.Conv2d(3, 60, 5)
self.pool = nn.MaxPool2d(2, 2)
self.conv2 = nn.Conv2d(60, 1... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_... | minister19/RL_pytorch_get_started | Net | false | 4,014 | [
"MIT"
] | 0 | e444f524a14d329f9a25c53f102bc96c4ea36ad8 | https://github.com/minister19/RL_pytorch_get_started/tree/e444f524a14d329f9a25c53f102bc96c4ea36ad8 |
SelfAttention | import torch
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
def masked_softmax(logits, mask, dim=-1, log_softmax=False):
"""Take the softmax of `logits` over given dimension, and set
entries to 0 wherever `mask` is 0.
Args:
logits (torch.Tensor): Inputs to the softmax fu... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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.... | mayankiitg/cs224n | SelfAttention | false | 4,015 | [
"MIT"
] | 0 | c67b7904101c8f19a5a231e4fe521e764470d41b | https://github.com/mayankiitg/cs224n/tree/c67b7904101c8f19a5a231e4fe521e764470d41b |
WDLoss | import torch
from torch import nn
class WDLoss(nn.Module):
def __init__(self, _lambda):
super(WDLoss, self).__init__()
self._lambda = _lambda
def forward(self, t_x, t_y, t_z):
return -(torch.mean(t_x) - torch.mean(t_y) - self._lambda * torch.
mean((torch.norm(t_z, 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
from torch import nn
assert_... | mirmohammad/IFT6135-TP3 | WDLoss | false | 4,016 | [
"MIT"
] | 0 | 70453b4ea695313837ab88243b0206552eb50632 | https://github.com/mirmohammad/IFT6135-TP3/tree/70453b4ea695313837ab88243b0206552eb50632 |
Linear_fil | import torch
import torch.nn as nn
class Linear_fil(nn.Module):
def __init__(self, input_dim, hidden_dim):
super(Linear_fil, self).__init__()
self.lin_1 = nn.Linear(input_dim, hidden_dim)
self.act = nn.ReLU()
self.lin_2 = nn.Linear(hidden_dim, 1)
self.sigmoid = nn.Sigmoid(... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | mityanony404/TopGraph | Linear_fil | false | 4,017 | [
"MIT"
] | 0 | 23595ca5d3dfcd5bc5ebb771800e3fbe9a0d5eed | https://github.com/mityanony404/TopGraph/tree/23595ca5d3dfcd5bc5ebb771800e3fbe9a0d5eed |
SimpleStackModel | import torch
import torch.onnx
import torch.nn
class SimpleStackModel(torch.nn.Module):
def __init__(self):
super(SimpleStackModel, self).__init__()
def forward(self, a, b):
c = torch.stack((a, b), 0)
d = torch.stack((c, c), 1)
return torch.stack((d, d), 2)
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
import torch.onnx
import torch.nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guar... | mlupon/glow | SimpleStackModel | false | 4,018 | [
"Apache-2.0"
] | 0 | aedaa7b98617f1a2db651608e7f7c916a7d2c766 | https://github.com/mlupon/glow/tree/aedaa7b98617f1a2db651608e7f7c916a7d2c766 |
Net | import torch
import torch.nn as nn
class Net(nn.Module):
def __init__(self, input_dim, output_dim, hidden_dim=None, barcode_dim=0):
super().__init__()
if hidden_dim is None:
hidden_dim = [250, 100]
self.fc1 = nn.Linear(input_dim, hidden_dim[0])
self.act = nn.ReLU()
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | mityanony404/TopGraph | Net | false | 4,019 | [
"MIT"
] | 0 | 23595ca5d3dfcd5bc5ebb771800e3fbe9a0d5eed | https://github.com/mityanony404/TopGraph/tree/23595ca5d3dfcd5bc5ebb771800e3fbe9a0d5eed |
SimpleSliceModel | import torch
import torch.onnx
import torch.nn
class SimpleSliceModel(torch.nn.Module):
def __init__(self):
super(SimpleSliceModel, self).__init__()
def forward(self, tensor):
other = (tensor + tensor)[1:]
return other[0][1:]
def get_inputs():
return [torch.rand([4, 4, 4, 4])]
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.onnx
import torch.nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guar... | mlupon/glow | SimpleSliceModel | false | 4,020 | [
"Apache-2.0"
] | 0 | aedaa7b98617f1a2db651608e7f7c916a7d2c766 | https://github.com/mlupon/glow/tree/aedaa7b98617f1a2db651608e7f7c916a7d2c766 |
CAM_Module | from torch.nn import Module
import torch
import torch.utils.data
import torch
from torch.nn import Parameter
from torch.nn import Softmax
class CAM_Module(Module):
""" Channel attention module"""
def __init__(self, in_dim):
super(CAM_Module, self).__init__()
self.chanel_in = in_dim
se... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.... | mlcb-jlu/wsMedSeg | CAM_Module | false | 4,021 | [
"MIT"
] | 0 | 63bd1fd28583f11444f292f4b961870ea1b12635 | https://github.com/mlcb-jlu/wsMedSeg/tree/63bd1fd28583f11444f292f4b961870ea1b12635 |
Homoscedastic | import torch
class Homoscedastic(torch.nn.Module):
"""https://arxiv.homoscedasticorg/abs/1705.07115"""
def __init__(self, n_tasks, reduction='sum'):
super(Homoscedastic, self).__init__()
self.n_tasks = n_tasks
self.log_vars = torch.nn.Parameter(torch.zeros(self.n_tasks))
self.... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
assert_size... | moelmahdy/JRS-MTL | Homoscedastic | false | 4,022 | [
"BSD-3-Clause"
] | 0 | 5abec9e06dad2721929738b1734350ed847e9d5a | https://github.com/moelmahdy/JRS-MTL/tree/5abec9e06dad2721929738b1734350ed847e9d5a |
Model | import torch
from torch import nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, input_dim):
super(Model, self).__init__()
self.layer1 = nn.Linear(input_dim, 50)
self.layer2 = nn.Linear(50, 20)
self.layer3 = nn.Linear(20, 1)
def forward(self, x):
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch import nn
assert_s... | mlsquare/kitchen | Model | false | 4,023 | [
"MIT"
] | 0 | 3664fd289f7ea5c20cdd55e96ebe29b77effa062 | https://github.com/mlsquare/kitchen/tree/3664fd289f7ea5c20cdd55e96ebe29b77effa062 |
CDAE | import torch
from torch import nn
from torch.autograd import Variable
def add_gaussian_noise(x, std):
return x + Variable(x.data.new(x.size()).normal_(0, std))
class CDAE(nn.Module):
"""
Convolutional denoising autoencoder layer for stacked autoencoders.
Args:
in_channels: the number of cha... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch import nn
from tor... | mmcenta/eye-disease-recognition | CDAE | false | 4,025 | [
"MIT"
] | 0 | 52e1dedbce27514b605b9f8ad976d6042b7e2f14 | https://github.com/mmcenta/eye-disease-recognition/tree/52e1dedbce27514b605b9f8ad976d6042b7e2f14 |
MLP | from torch.nn import Module
import torch
from torch.nn import Linear
from torch.nn import Sigmoid
from torch.nn import ReLU
from torch.nn.init import kaiming_normal
from torch.nn.init import xavier_normal
class MLP(Module):
def __init__(self, n_inputs):
super(MLP, self).__init__()
self.hidden1 = ... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch.nn import Module
f... | mmg63/Pytorch-Code-for-Binary-classification | MLP | false | 4,026 | [
"MIT"
] | 0 | 773e909fcba41cdaba48c96e35da68acaf64c513 | https://github.com/mmg63/Pytorch-Code-for-Binary-classification/tree/773e909fcba41cdaba48c96e35da68acaf64c513 |
ConvNeuralNetwork | import torch
import torch.nn as nn
class ConvNeuralNetwork(nn.Module):
def __init__(self, num_classes=3):
super(ConvNeuralNetwork, self).__init__()
self.conv1 = nn.Conv2d(in_channels=3, out_channels=12, kernel_size=
3, stride=1, padding=1)
self.conv2 = nn.Conv2d(in_channels=12... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | mngaonkar/pytorch-image-classifier | ConvNeuralNetwork | false | 4,027 | [
"MIT"
] | 0 | f10b4363dc62c2fbbb5fbfbc56a3849da623fc80 | https://github.com/mngaonkar/pytorch-image-classifier/tree/f10b4363dc62c2fbbb5fbfbc56a3849da623fc80 |
AffineTransform | import torch
from torch import nn
class FC(nn.Module):
def __init__(self, n_dim_in, n_dim_out, equal_lr=True):
super().__init__()
norm_const = n_dim_in ** -0.5
scale_init = 1 if equal_lr else norm_const
self.scale_forward = norm_const if equal_lr else 1
self.weight = nn.Pa... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import 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... | moritztng/stylegan2-pytorch | AffineTransform | false | 4,028 | [
"MIT"
] | 0 | 8827eae2e76c54b7406b34b2d49563ae53b04001 | https://github.com/moritztng/stylegan2-pytorch/tree/8827eae2e76c54b7406b34b2d49563ae53b04001 |
NeuralNetwork | import torch
import torch.nn as nn
import torch.nn.functional as F
class NeuralNetwork(nn.Module):
def __init__(self, num_classes=3):
super(NeuralNetwork, self).__init__()
self.fc1 = nn.Linear(64 * 64 * 3, 84)
self.fc2 = nn.Linear(84, 50)
self.fc3 = nn.Linear(50, num_classes)
... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from 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_... | mngaonkar/pytorch-image-classifier | NeuralNetwork | false | 4,029 | [
"MIT"
] | 0 | f10b4363dc62c2fbbb5fbfbc56a3849da623fc80 | https://github.com/mngaonkar/pytorch-image-classifier/tree/f10b4363dc62c2fbbb5fbfbc56a3849da623fc80 |
Conv | import torch
from torch import nn
class Conv(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride=1,
padding=0, dilation=1, equal_lr=True):
super().__init__()
self.stride = stride
self.padding = padding
self.dilation = dilation
norm_const =... | import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import 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... | moritztng/stylegan2-pytorch | Conv | false | 4,030 | [
"MIT"
] | 0 | 8827eae2e76c54b7406b34b2d49563ae53b04001 | https://github.com/moritztng/stylegan2-pytorch/tree/8827eae2e76c54b7406b34b2d49563ae53b04001 |
_Classifier | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
class _Classifier(nn.Module):
def __init__(self, z_c_dim):
super(_Classifier, self).__init__()
self.fc1 = nn.Linear(z_c_dim, 50)
self.fc2 = nn.Linear(50, 10)
def forward(self, z_c):
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
import torch.nn as nn
import ... | mori97/revae | _Classifier | false | 4,031 | [
"MIT"
] | 0 | 465009076a9be78e8ddb9021a0699b32fc695f30 | https://github.com/mori97/revae/tree/465009076a9be78e8ddb9021a0699b32fc695f30 |
Distance | import torch
import torch.nn as nn
class Distance(nn.Module):
def __init__(self):
super(Distance, self).__init__()
def forward(self, s, t):
n, q = s.shape[0], t.shape[0]
dist = (t.unsqueeze(0).expand(n, q, -1) - s.unsqueeze(1).expand(n,
q, -1)).pow(2).sum(dim=2).T
... | import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_st... | msc5/ml-tools | Distance | false | 4,032 | [
"Apache-2.0"
] | 0 | 75ca504bdc0495e8a929ad73501b7de692b3089a | https://github.com/msc5/ml-tools/tree/75ca504bdc0495e8a929ad73501b7de692b3089a |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.