Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed tensor_to_tiled, float_to_bfp_batched, _gen_bfp_op functions #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bfp/bfp_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def float_to_bfp_batched(t, mant_bits, epsilon, rounding_mode, device, bfp_tile_
assert num_format == 'bfp'
orig_shape = t.size()

t = t.view(t.size()[0], -1)
t = t.contiguous().view(orig_shape[0], -1)
o = _float_to_bfp(t, mant_bits, epsilon, rounding_mode, device)
return o.view(orig_shape)

Expand All @@ -112,7 +112,7 @@ def tensor_to_tiled(t, orig_shape, bfp_tile_size):

Output: the tiled tensor, the number of tiles in each dimension, the dimensions before and after the tiling to help 'untiling'
"""
t = t.view(orig_shape[0], -1)
t = t.contiguous().view(orig_shape[0], -1)
matrix_h, matrix_w = t.size()

numberOf_h_tiles = (matrix_h + bfp_tile_size - 1) // bfp_tile_size
Expand Down Expand Up @@ -211,7 +211,7 @@ def _gen_bfp_op(op, name, bfp_args):
class NewOpIn(torch.autograd.Function):
@staticmethod
def forward(ctx, x, w):
return (float_to_bfp_batched(x, **bfp_args), w)
return (float_to_bfp_batched(x, **bfp_args), float_to_bfp_batched(w, **bfp_args))

@staticmethod
def backward(ctx, grad_x, grad_w):
Expand Down