Skip to content

Add TGATHER indices and mask - #1080

Open
frank-deng wants to merge 1 commit into
hw-native-sys:mainfrom
frank-deng:tgather2
Open

Add TGATHER indices and mask#1080
frank-deng wants to merge 1 commit into
hw-native-sys:mainfrom
frank-deng:tgather2

Conversation

@frank-deng

Copy link
Copy Markdown
Contributor

No description provided.

@frank-deng
frank-deng force-pushed the tgather2 branch 6 times, most recently from f55aae7 to 4e14e8a Compare August 4, 2026 01:14
Comment thread lib/TileOps/a5/tgather.py
for row in range(0, valid_rows, 1):
remained = valid_cols
for col in range(0, valid_cols, lanes):
indices_reg = pto.vlds(indices[row, col:])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里按照dst.valid_shape迭代indices,如果dst.valid_shape > indices.valid_shape会在运行时出错,需要加一个约束或断言dst.valid_shape必须小于等于indices.valid_shape

Comment thread lib/TileOps/a5/tgather.py


def _init_ub_buffer(dst: pto.Tile):
dtype = dst.dtype

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里的清零我感觉有性能优化空间,后面真正的tgather写的位置其实都不需要清零。如果C++ TileLib也是这么实现的那就保持现状吧。

}

// CHECK: TGATHER
// CHECK: TGATHER

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里的check太简单了,没有检查是否有tmp参数

context_attrs=context_attrs or {},
**tile_specs,
).mlir_text()
return result

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里似乎没有改动的必要

Comment on lines +7033 to +7039
Type offsetElementType = elementType;
if (auto ptrType = dyn_cast<pto::PtrType>(op.getDestination().getType()))
offsetElementType = ptrType.getElementType();
else if (auto memrefType = dyn_cast<BaseMemRefType>(op.getDestination().getType()))
offsetElementType = memrefType.getElementType();
auto offsetBytes =
convertElementOffsetToBytes(op, adaptor.getOffset(), elementType);
convertElementOffsetToBytes(op, adaptor.getOffset(), offsetElementType);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个bugfix应该拆成独立的commit并加上lit用例看护

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