Finally, I found solution. It’s x1000 faster than first code.(25 ms ± 649 µs )
%%timeit
import torch
        
class SparseArray:
    def __init__(self):
        self.values = []
        self.indexs = []
        self.row = -1
        self.col = 0
        self.maxCol = 0
        
    def clear(self):
        self.row += 1
        self.maxCol = max(self.col,self.maxCol)
        self.col = 0
        
    def addFloat(self, v):        
        self.indexs.append([self.row, self.col])
        self.values.append(v)
        self.col += 1

    def addCategorical(self, idx, categorySize):
        assert (idx < categorySize)
        assert (0 <= idx)
        self.indexs.append([self.row, self.col+idx])
        self.values.append(1.0)
        self.col += categorySize
        
    def makeTensor(self):
        i = torch.LongTensor(self.indexs)
        v = torch.FloatTensor(self.values)
        return torch.sparse.FloatTensor(i.t(), v, torch.Size([self.row+1, self.maxCol]))

sa = SparseArray()
for i in range(1024*16):
    sa.clear()
    sa.addFloat(5.0)
    sa.addCategorical(i%100,100)
    
sa.makeTensor()