From 03b98689bec1ea4052b68a6bf3a0fba63dab087c Mon Sep 17 00:00:00 2001 From: "weisu.yxd" Date: Sat, 21 Oct 2023 11:28:16 +0800 Subject: [PATCH] add custom op demo --- docs/source/component/custom_op.md | 6 ++++++ easy_rec/python/layers/keras/custom_ops.py | 2 +- easy_rec/python/ops/1.12/libedit_distance.so | Bin 79296 -> 79296 bytes easy_rec/python/ops/1.15/libedit_distance.so | Bin 80680 -> 80680 bytes 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/source/component/custom_op.md b/docs/source/component/custom_op.md index 45b2d434d..6b3fbdba5 100644 --- a/docs/source/component/custom_op.md +++ b/docs/source/component/custom_op.md @@ -95,6 +95,12 @@ model_config: { } keras_layer { class_name: 'EditDistance' + st_params { + fields { + key: 'text_encoding' + value: { string_value: 'latin' } + } + } } } blocks { diff --git a/easy_rec/python/layers/keras/custom_ops.py b/easy_rec/python/layers/keras/custom_ops.py index eedee439f..89f24c4e3 100644 --- a/easy_rec/python/layers/keras/custom_ops.py +++ b/easy_rec/python/layers/keras/custom_ops.py @@ -10,7 +10,7 @@ curr_dir, _ = os.path.split(__file__) parent_dir = os.path.dirname(curr_dir) ops_idr = os.path.dirname(parent_dir) -ops_dir = os.path.join(ops_idr, 'python', 'ops') +ops_dir = os.path.join(ops_idr, 'ops') if 'PAI' in tf.__version__: ops_dir = os.path.join(ops_dir, '1.12_pai') elif tf.__version__.startswith('1.12'): diff --git a/easy_rec/python/ops/1.12/libedit_distance.so b/easy_rec/python/ops/1.12/libedit_distance.so index 51180bc6b15d8081e51b3a943b09d4df65d72ddd..bc08e4f85c29118bd4ae916c085247c964c81a0b 100755 GIT binary patch delta 3412 zcmZ`+3se->8QweWDj={RARs-$Di)#WN@R;IRs|K211grvOC!j`-~&;y0b`2~+PcP7 z@wZWo4^Xh8kw%AzpdbhsFiCxcbCiT0!O$ZpsYPwnly>^vnZaO_&N*|x```KQ|M=$4 zZnnSS12;3AI9oMr{VdG&7?x>JA$TKTxpZR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