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

Webgl backend for bitwise AND API #7654

Merged
merged 19 commits into from
May 4, 2023
Merged

Conversation

fengwuyao
Copy link
Collaborator

Implement webgl kernels for bitwise AND API

  • Implement kernel logic in webgl
  • Tested by running yarn test under tfjs-backend-webgl

To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.

program = new BinaryOpProgram(BITWISEAND, a.shape, b.shape);
}

return webglBackend.runWebGLProgram(program, [a, b], $dtype);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe wrap it with binaryKernelFunc like tfjs-backend-webgl/kernels/Add.ts to utilize the CPU forward implementation?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We have to check webgl version for this, which is different from other binary ops. If using binaryKernelFunc, then we either have to change a lot for binaryKernelFunc or make a wrapper to call binaryKernelFunc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks! Implemented the CPU forward logic in the function.

Copy link
Collaborator

@Linchenn Linchenn left a comment

Choose a reason for hiding this comment

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

Thanks! Just left some nits.

tfjs-backend-webgl/src/kernels/BitwiseAnd.ts Outdated Show resolved Hide resolved
tfjs-backend-webgl/src/kernels/BitwiseAnd.ts Outdated Show resolved Hide resolved
tfjs-backend-webgl/src/kernels/BitwiseAnd.ts Outdated Show resolved Hide resolved
tfjs-backend-webgl/src/kernels/BitwiseAnd.ts Outdated Show resolved Hide resolved
Copy link
Member

@mattsoulanille mattsoulanille left a comment

Choose a reason for hiding this comment

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

LGTM with a nit.

tfjs-backend-webgl/src/kernels/BitwiseAnd.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@Linchenn Linchenn left a comment

Choose a reason for hiding this comment

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

LGTM! Great work, thanks!

`Unsupported webgl version. Current webgl version: ${versionNumber}`);
}

// The type of a and b are ensured to be `int` in core, therefore no need to
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: int -> int32

@fengwuyao fengwuyao force-pushed the addGLbackend branch 2 times, most recently from 2f10aa1 to 90b51bf Compare May 4, 2023 20:09
Copy link
Collaborator

@pyu10055 pyu10055 left a comment

Choose a reason for hiding this comment

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

Good work, thanks Fengwu!

@fengwuyao fengwuyao merged commit bea6729 into tensorflow:master May 4, 2023
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.

5 participants