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

add VitSam #743

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

add VitSam #743

wants to merge 1 commit into from

Conversation

sageyou
Copy link
Collaborator

@sageyou sageyou commented Oct 23, 2023

Thank you for your contribution to the MindCV repo.
Before submitting this PR, please make sure:

@sageyou sageyou force-pushed the add_vit_sam branch 5 times, most recently from e144a2e to 76a9170 Compare October 24, 2023 03:51
Copy link
Collaborator

@geniuspatrick geniuspatrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pyproject.toml的13行注释掉,重新对这个文件跑一下pre-commit

self.num_prefix_tokens = num_prefix_tokens # exclude CLS token (or other prefix tokens)
self.ordered = ordered
self.return_indices = return_indices
self.sort = ops.Sort()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接在前向里用函数式接口

self.return_indices = return_indices
self.sort = ops.Sort()

def forward(self, x):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

construct

Comment on lines 89 to 90
x = ops.Reshape()(x, (B, self.embed_dim, -1)) # B Ph*Pw C
x = ops.Transpose()(x, (0, 2, 1))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用函数式接口

Comment on lines 87 to 89
self.mul = ops.Mul()
self.reshape = ops.Reshape()
self.transpose = ops.Transpose()
self.unstack = ops.Unstack(axis=0)
self.attn_matmul_v = ops.BatchMatMul()
self.q_matmul_k = ops.BatchMatMul(transpose_b=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

尽量替换为函数式接口

"""Multi-head Attention block with relative position embeddings."""

def __init__(
self,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

减少一级缩进



def get_decomposed_rel_pos(
q: ms.Tensor,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

减少一级缩进

@sageyou sageyou force-pushed the add_vit_sam branch 5 times, most recently from 1279c2d to 10cd680 Compare October 28, 2023 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants