Prerequisite
Implementation Details
Create a new op in tfjs-core/ops
directory.
The op file should have the following elements:
1. License information.
2. JSDoc comment.
3. Input validations, if any.
4. Delegate the execution to the right kernel through ENGINE.runKernel()
.
In addition, for the kernel delegation to work properly, in kernel_names.ts
file, define:
1. kernel name.
2. input type.
3. attribute type.
Export the op file in ops.ts in the same directory.
Add tests for the op in the same directory. Test file name should be the same as the op file’s name with _test suffix.
Exclude the test in all the backends, and add annotation “Not implemented yet.”. See below for where to exclude the test in each backend:
cpu backend
In run_tests.ts
, customInclude
method, add:
// Not implemented yet.
if (testName.includes(test_name)) {
return false;
}
webgl backend
In setup_test.ts
, customInclude
method, add:
// Not implemented yet.
if (testName.includes(test_name)) {
return false;
}
node backend
In run_tests.ts
, IGNORE_LIST
, add test_name to the list.
Example PRs
Implementation Details
Create a new kernel in the kernels
directory of a backend.
The kernel file should have the following elements:
kernelConfig
.Register the kernel in register_all_kernels.ts
in the corresponding backend.
Remove the op from test exclusion list in the corresponding backend. For wasm backend, add the test to the inclusion list.
Example PRs
Add op mapping in the op list ts file, use your best judgement to assign an op category: tfjs-converter/python/tensorflowjs/op_list/{corresponding_op_category}.json
. The corresponding .ts
file will be automatically generated when converter is built. Use
the TF C++ op api as reference for tfOpName, inputs, and attrs.
Find the corresponding executor for the op and add the op to the switch, the executors are in tfjs-converter/src/operations/executors
.
Add a test to the corresponding executor test file.
Update the supported op doc in tfjs-converter/docs/supported_ops.md
.
Example PRs
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。