Skip to content

Commit

Permalink
fix: change ops.pad input format which changed in mindspore in Nov 2022
Browse files Browse the repository at this point in the history
  • Loading branch information
ChongWei905 committed Nov 9, 2024
1 parent bd1dbd5 commit 65f41ec
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions mindcv/models/halonet.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ def rel_logits_1d(q, rel_k, permute_mask):
x = msnp.tensordot(q, rel_k, axes=1)
x = ops.reshape(x, (-1, W, rel_size))
# pad to shift from relative to absolute indexing
x_pad = ops.pad(x, paddings=((0, 0), (0, 0), (0, 1)))
x_pad = ops.pad(x, padding=(0, 1))
x_pad = ops.flatten(x_pad)
x_pad = ops.expand_dims(x_pad, 1)
x_pad = ops.pad(x_pad, paddings=((0, 0), (0, 0), (0, rel_size - W)))
x_pad = ops.pad(x_pad, padding=(0, rel_size - W))
x_pad = ops.squeeze(x_pad, axis=())
# reshape adn slice out the padded elements
x_pad = ops.reshape(x_pad, (-1, W+1, rel_size))
Expand Down
2 changes: 1 addition & 1 deletion mindcv/models/repvgg.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def get_equivalent_kernel_bias(self):
def _pad_1x1_to_3x3_tensor(self, kernel1x1):
if kernel1x1 is None:
return 0
return ops.pad(kernel1x1, ((1, 1), (1, 1)))
return ops.pad(kernel1x1, (1, 1, 1, 1))

def _fuse_bn_tensor(self, branch):
if branch is None:
Expand Down
2 changes: 1 addition & 1 deletion mindcv/models/volo.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def construct(self, x: Tensor) -> Tensor:

h = int((H - 1) / self.stride + 1)
w = int((W - 1) / self.stride + 1)
v = ops.pad(v, ((0, 0), (0, 0), (1, 1), (1, 1)))
v = ops.pad(v, (1, 1, 1, 1))
v = self.unfold(v)
v = ops.reshape(v, (B, self.num_heads, C // self.num_heads, self.kernel_size * self.kernel_size, h * w))
v = ops.transpose(v, (0, 1, 4, 3, 2)) # B,H,N,kxk,C/H
Expand Down

0 comments on commit 65f41ec

Please sign in to comment.