Skip to content

Instantly share code, notes, and snippets.

View hotbaby's full-sized avatar

阳阳 hotbaby

  • 20:25 (UTC +08:00)
View GitHub Profile
@hotbaby
hotbaby / asr_fbank_mfcc.ipynb
Created March 4, 2024 02:01 — forked from murphypei/asr_fbank_mfcc.ipynb
ASR FBANK MFCC 特征提取
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hotbaby
hotbaby / whisper_distribtued_infer.py
Last active February 27, 2024 06:55
whisper多卡分布式推理
# encoding: utf8
import json
import torch
import argparse
import whisper
from whisper import Whisper, ModelDimensions
from torch.utils.data import Dataset, DataLoader
from lightning import Trainer
# encoding: utf8
import logging
import torch
import torch.distributed
from torch.distributed import ReduceOp
def print_rank_0(msg, *args, **kwargs):
rank = torch.distributed.get_rank()
@hotbaby
hotbaby / multihead_attention.py
Last active April 15, 2024 10:10
PyTorch多头自注意力机制
# encoding: utf8
import math
import torch
import torch.nn as nn
class MultiHeadAttention(nn.Module):
def __init__(self, n_feat, n_head=4):
@hotbaby
hotbaby / pytorch_collective_communication.py
Created January 10, 2023 05:56
PyTorch集合通信collective communication
# encoding: utf8
import os
import torch
import torch.distributed as dist
import torch.multiprocessing as mp
def cm_broadcast_object_demo(rank: int, world_size: int):
dist.init_process_group("gloo", world_size=world_size, rank=rank)
@hotbaby
hotbaby / ddp_demo.py
Last active January 11, 2023 03:32
PyTorch分布式训练DDP Demo
# encoding: utf8
import os
import time
import random
import contextlib
import torch
import torch.nn as nn
import torch.optim as optim
import torch.distributed as dist
@hotbaby
hotbaby / list2tensor.py
Last active April 13, 2021 03:34
Pytorch List转Tensor
l = [[1, 1675, 4028, 8271, 42, 2], [1, 1675, 4028, 8844, 10135, 10757, 9478, 42, 2]]
# maximum rows and columns
max_rows = len(l)
max_cols = max(len(row) for row in l)
# padded rows
padded = [row + [0] * (max_cols - len(row)) for row in l]
# unpack nested list