-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat]: add avx string split feature (#364)
* add avx string split feature * add pip requirement for eas_prediction * update incr_record ops * add step counter hook
- Loading branch information
1 parent
135671a
commit 3604da3
Showing
25 changed files
with
83 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- encoding:utf-8 -*- | ||
# Copyright (c) Alibaba, Inc. and its affiliates. | ||
import logging | ||
import os | ||
|
||
import tensorflow as tf | ||
from tensorflow.python.ops import string_ops | ||
|
||
import easy_rec | ||
from easy_rec.python.utils import constant | ||
|
||
try: | ||
str_avx_op_path = os.path.join(easy_rec.ops_dir, 'libstr_avx_op.so') | ||
str_avx_op = tf.load_op_library(str_avx_op_path) | ||
logging.info('load avx string_split op from %s succeed' % str_avx_op_path) | ||
except Exception as ex: | ||
logging.warning('load avx string_split op failed: %s' % str(ex)) | ||
str_avx_op = None | ||
|
||
|
||
def str_split_by_chr(input_str, sep, skip_empty): | ||
if constant.has_avx_str_split() and str_avx_op is not None: | ||
assert len(sep) == 1, \ | ||
'invalid data_config.separator(%s) len(%d) != 1' % ( | ||
sep, len(sep)) | ||
return str_avx_op.avx512_string_split(input_str, sep, skip_empty=skip_empty) | ||
else: | ||
return string_ops.string_split(input_str, sep, skip_empty=skip_empty) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,24 @@ | ||
# -*- encoding:utf-8 -*- | ||
# Copyright (c) Alibaba, Inc. and its affiliates. | ||
|
||
import os | ||
|
||
SAMPLE_WEIGHT = 'SAMPLE_WEIGHT' | ||
|
||
DENSE_UPDATE_VARIABLES = 'DENSE_UPDATE_VARIABLES' | ||
|
||
SPARSE_UPDATE_VARIABLES = 'SPARSE_UPDATE_VARIABLES' | ||
ENABLE_AVX_STR_SPLIT = 'ENABLE_AVX_STR_SPLIT' | ||
|
||
|
||
def enable_avx_str_split(): | ||
os.environ[ENABLE_AVX_STR_SPLIT] = '1' | ||
|
||
|
||
def has_avx_str_split(): | ||
return ENABLE_AVX_STR_SPLIT in os.environ and os.environ[ | ||
ENABLE_AVX_STR_SPLIT] == '1' | ||
|
||
|
||
def disable_avx_str_split(): | ||
del os.environ[ENABLE_AVX_STR_SPLIT] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
eas_prediction | ||
future | ||
matplotlib | ||
oss2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters