Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
081cc88
chore(fbgemm-xpu): remove .gitkeep files from populated directories
aagalleg Jun 18, 2026
07bfb4b
feat(fbgemm-xpu): register invert_permute operation
aagalleg Jun 18, 2026
d6d6bad
feat(fbgemm-xpu): add SYCL kernel implementation for invert_permute
aagalleg Jun 18, 2026
14fe23c
test(fbgemm-xpu): add comprehensive test suite for invert_permute
aagalleg Jun 18, 2026
3056382
feat(fbgemm-xpu): register permute_1D_sparse_data operator
aagalleg Jun 18, 2026
b7f3bbf
feat(fbgemm-xpu): add SYCL kernels for permute_1D_sparse_data
aagalleg Jun 18, 2026
fd70ab5
test(fbgemm-xpu): add comprehensive tests for permute_1D_sparse_data
aagalleg Jun 18, 2026
b71efbe
fix(fbgemm-xpu): address PR #72 review comments
flezaalv Jul 10, 2026
dd698c2
test(fbgemm-xpu): use patched upstream FBGEMM tests for invert_permute
aagalleg Jul 9, 2026
0525a43
refactor(fbgemm-xpu): templatize invert_permute SYCL kernel over index_t
aagalleg Jul 9, 2026
c42bef0
fix(fbgemm-xpu): remove redundant ops.py and ensure fbgemm_gpu import…
aagalleg Jul 9, 2026
b6baa1b
Consolidate FBGEMM XPU test patches into single unified patch
flezaalv Jul 13, 2026
ef310d9
Fix permute_1D_sparse_data to support 2D weights tensor
flezaalv Jul 14, 2026
33197a5
chore(fbgemm-xpu): drop standalone test_permute_1d_sparse_data.py
aagalleg Jul 15, 2026
fd8ea6d
feat(fbgemm-xpu): add asynchronous_complete_cumsum XPU operator
aagalleg Jun 19, 2026
4060711
feat(fbgemm-xpu): register asynchronous_complete_cumsum operator
aagalleg Jun 19, 2026
dcdd4df
test(fbgemm-xpu): add tests for asynchronous_complete_cumsum
aagalleg Jun 19, 2026
f920e44
test(fbgemm-xpu): use patched upstream FBGEMM tests for asynchronous_…
aagalleg Jul 15, 2026
c458218
chore(repo): remove stray FBGEMM-v1.7.0 gitlink
aagalleg Jul 15, 2026
cf18480
feat(fbgemm-xpu): add SYCL communication utilities form torch-xpu-ops
aagalleg Jun 20, 2026
6560019
feat(fbgemm-xpu): add core utility infrastructure for SYCL kernels
aagalleg Jun 20, 2026
982fd55
feat(fbgemm-xpu): add permute_2D_sparse_data XPU operator
aagalleg Jun 20, 2026
63e0b3b
feat(fbgemm-xpu): register permute_2D_sparse_data operator
aagalleg Jun 20, 2026
6fb2445
test(fbgemm-xpu): add tests for permute_2D_sparse_data
aagalleg Jun 20, 2026
2a9fdb7
refactor: rename permute_2d_sparse_dataOp.cpp to snake_case
flezaalv Jul 16, 2026
61c83c0
refactor(fbgemm-xpu): improve permute_2D_sparse_data implementation
flezaalv Jul 17, 2026
f7a6360
test(fbgemm-xpu): update FBGEMM test patch with permute_2D fixes
flezaalv Jul 17, 2026
96c8af7
test(fbgemm-xpu): remove test files, use upstream FBGEMM patch instead
flezaalv Jul 17, 2026
cb53ad9
fix(fbgemm-xpu): restore permute_2D_sparse_data operator implementation
aagalleg Jul 17, 2026
69d53cf
style(fbgemm-xpu): add trailing newline to permute_2d_sparse_data_op.cpp
aagalleg Jul 17, 2026
871b69f
Initial version of block_bucketize_sparse_features operator refactor
flezaalv Jun 24, 2026
97d31df
fix(fbgemm-xpu): enable block_bucketize_sparse_features operator
flezaalv Jun 25, 2026
ecde2a4
refactor(fbgemm-xpu): split block_bucketize_sparse_features into .h/.cpp
aagalleg Jul 16, 2026
169f226
test(fbgemm-xpu): consolidate block_bucketize tests into FBGEMM patch
aagalleg Jul 17, 2026
4f8d2bf
Initial version of block_bucketize_sparse_features operator refactor
flezaalv Jun 24, 2026
21faa6f
fix(fbgemm-xpu): enable block_bucketize_sparse_features operator
flezaalv Jun 25, 2026
f1b0536
feat(fbgemm_xpu): add Jinja environment and helper functions for code…
aagalleg Jul 2, 2026
ad829f9
feat(fbgemm-xpu): add CodeTemplate class for template rendering
aagalleg Jul 2, 2026
0d2f857
feat(fbgemm-xpu): add PyTorch type utilities for code generation
aagalleg Jul 2, 2026
8acfad7
feat(fbgemm-xpu): add argument parser for generation scripts
aagalleg Jul 2, 2026
f0f001e
feat(fbgemm-xpu): fix license for jinja_environment.py
aagalleg Jul 2, 2026
4b87719
feat(fbgemm-xpu): add forward and backward kernel generation scripts
aagalleg Jul 2, 2026
302f384
fix(codegen): harden Jinja setup and remove assert-based parsing checks
aagalleg Jul 17, 2026
e5d3f39
chore(codegen): add Intel copyright header to jinja environment script
aagalleg Jul 17, 2026
31bdc51
style(fbgemm-xpu): reorder imports in __init__.py
aagalleg Jul 17, 2026
93bcb95
test(fbgemm-xpu): drop resurrected test file after rebase
aagalleg Jul 17, 2026
15d0b14
Initial version of block_bucketize_sparse_features operator refactor
flezaalv Jun 24, 2026
fc475bd
fix(fbgemm-xpu): enable block_bucketize_sparse_features operator
flezaalv Jun 25, 2026
55b081d
feat(fbgemm-xpu): add SYCL backward pass utility functions
aagalleg Jul 2, 2026
392752b
feat(fbgemm-xpu): add Vec4T vectorized data structure for memory opti…
aagalleg Jul 2, 2026
85ee1d4
feat(fbgemm-xpu): add feature gates system for runtime configuration
aagalleg Jul 2, 2026
3eb6923
feat(fbgemm-xpu): add PT2 argument index enumerations
aagalleg Jul 2, 2026
3a59956
feat(fbgemm-xpu): add UVM cache statistics index enumeration
aagalleg Jul 2, 2026
f8b4900
feat(fbgemm-xpu): add stochastic rounding utilities for precision con…
aagalleg Jul 2, 2026
605f5a0
feat(fbgemm-xpu): add WeightRow abstraction for embedding table access
aagalleg Jul 2, 2026
b76ce7f
test(fbgemm-xpu): drop resurrected test file after rebase
aagalleg Jul 18, 2026
509deaa
Initial version of block_bucketize_sparse_features operator refactor
flezaalv Jun 24, 2026
71b1267
fix(fbgemm-xpu): enable block_bucketize_sparse_features operator
flezaalv Jun 25, 2026
318541e
feat(fbgemm-xpu): add small embedding forward kernel template
aagalleg Jul 3, 2026
46295ac
feat(fbgemm-xpu): add main embedding forward kernel Jinja2 template
aagalleg Jul 3, 2026
7e80719
feat(fbgemm-xpu): add host dispatch template for nobag forward pass
aagalleg Jul 3, 2026
8aa8416
test(fbgemm-xpu): drop resurrected test file after rebase
aagalleg Jul 18, 2026
ebfb68e
Initial version of block_bucketize_sparse_features operator refactor
flezaalv Jun 24, 2026
aa91dd1
fix(fbgemm-xpu): enable block_bucketize_sparse_features operator
flezaalv Jun 25, 2026
8ea64ef
feat(fbgemm-xpu): add backward split kernel templates for dense and s…
aagalleg Jul 3, 2026
49c5706
feat(fbgemm-xpu): add backward host dispatch template for nobag unwei…
aagalleg Jul 3, 2026
93b8f93
feat(fbgemm-xpu): add PT2 wrapper template for nobag unweighted embed…
aagalleg Jul 3, 2026
4f74dd1
test(fbgemm-xpu): drop resurrected test file after rebase
aagalleg Jul 18, 2026
70f269c
Initial version of block_bucketize_sparse_features operator refactor
flezaalv Jun 24, 2026
62cd0fc
fix(fbgemm-xpu): enable block_bucketize_sparse_features operator
flezaalv Jun 25, 2026
084c90b
feat(fbgemm-xpu): add dense embedding lookup operator with autograd
aagalleg Jul 3, 2026
d7b258c
feat(fbgemm-xpu): add split embedding PT2 autograd operator with roww…
aagalleg Jul 3, 2026
6141852
feat(fbgemm-xpu): register split and dense embedding lookup operators
aagalleg Jul 3, 2026
6fe91de
test(fbgemm-xpu): drop resurrected test file after rebase
aagalleg Jul 18, 2026
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
99 changes: 99 additions & 0 deletions packages/fbgemm-xpu/src/codegen/genscript/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause

# pyre-strict
# flake8: noqa F401

import argparse
import os
from dataclasses import dataclass
from typing import Any, Dict, List

import jinja2

try:
from .jinja_environment import env
from .scripts_argsparse import args
except:
# pyre-ignore[21]
from jinja_environment import env

# pyre-ignore[21]
from scripts_argsparse import args


@dataclass
class CodeTemplate:
relative_path: str
template: jinja2.Template

@staticmethod
# pyre-ignore[3]
def load(relative_path: str):
return CodeTemplate(relative_path, env.get_template(relative_path))

def write(self, filename: str, **kwargs: Any) -> None:
"""
Render the template with the given arguments and write the result to a
file. In addition to rendering the template, this function also adds
a header and footer to the generated file to provide information about
the template source file, and to define `__TEMPLATE_SOURCE_FILE__`,
which can be used by the code to reference the template file when
logging messages and errors.
"""

# Render the generated filename #define
comment = (
"##"
if (
self.relative_path.endswith(".py")
or self.relative_path.endswith(".template")
)
else "//"
)

# Render the generated file header
file_define = (
# For Python template files, store the filename in a variable
f'__template_source_file__ = "{self.relative_path}"'
if (
self.relative_path.endswith(".py")
or self.relative_path.endswith(".template")
)
# For C/C++ template files, define filename with a macro, but only
# for non-header files (otherwise macro definitions will overlap
# and result in macro redefinition errors).
else (
f'#define __TEMPLATE_SOURCE_FILE__ "{self.relative_path}"'
if any(filename.endswith(x) for x in [".c", ".cc", ".cpp", ".cu"])
else ""
)
)

# Combine the components into the file header
generated_file_header = (
f"{comment * 40}\n"
f"{comment} GENERATED FILE INFO\n"
f"{comment}\n"
f"{comment} Template Source: {self.relative_path}\n"
f"{comment * 40}\n"
"\n"
f"{file_define}\n"
"\n"
)

# Render the template with header
output = generated_file_header + self.template.render(**kwargs)

# All generated files are written to the specified install directory.
with open(os.path.join(args.install_dir, filename), "w") as f:
f.write(output)
print(f"Written: {filename}")

@staticmethod
def copy_to_root(relative_path: str) -> None:
# Copy template from its relative path to root of the output directory
# e.g. sub/directory/foo.py -> foo.py
CodeTemplate.load(relative_path).write(relative_path.split("/")[-1])
Loading
Loading