Generate a random Hadamard matrix. Args: block_size (int): The size of the block, i.e., the number of rows and columns of the matrix. dtype (str): The data type, for example 'float32'. Returns: paddle.Tensor: The generated random Hadamard matrix.
(block_size: int, dtype: Union[paddle.dtype, str])
| 377 | |
| 378 | |
| 379 | def random_hadamard_matrix(block_size: int, dtype: Union[paddle.dtype, str]) -> paddle.Tensor: |
| 380 | """ |
| 381 | Generate a random Hadamard matrix. |
| 382 | |
| 383 | Args: |
| 384 | block_size (int): The size of the block, i.e., the number of rows and columns of the matrix. |
| 385 | dtype (str): The data type, for example 'float32'. |
| 386 | |
| 387 | Returns: |
| 388 | paddle.Tensor: The generated random Hadamard matrix. |
| 389 | |
| 390 | """ |
| 391 | Q = paddle.diag(paddle.ones((block_size), dtype=dtype)) |
| 392 | block = matmul_hadU(Q) |
| 393 | return block |
| 394 | |
| 395 | |
| 396 | def create_hadamard_matrix(hidden_size: int) -> paddle.Tensor: |
no test coverage detected