Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5cf3c2f
checkin transformers pipeline
gh-yewang Jun 4, 2021
b849bd2
add docker requirements
gh-yewang Jun 4, 2021
0b9b424
only trigger linux cpu
gh-yewang Jun 4, 2021
d02c298
temp remove tf instalation due to numpy version conflicts
gh-yewang Jun 4, 2021
d48928d
test numpy>=1.7
gh-yewang Jun 4, 2021
0ccc975
revert numpy and disable transformers
gh-yewang Jun 4, 2021
5137c47
add coloredlogs
gh-yewang Jun 5, 2021
39884d0
enable shape_infer_helper and install transformers when needed
gh-yewang Jun 7, 2021
3529b77
pip3?
gh-yewang Jun 7, 2021
e9a3f16
testtest
gh-yewang Jun 7, 2021
f4f75bc
enable more tets
gh-yewang Jun 7, 2021
141322c
line too long
gh-yewang Jun 7, 2021
0435db4
remove pytorch1.4 test and added back some onnx files
gh-yewang Jun 7, 2021
61da0d8
add tests
gh-yewang Jun 7, 2021
4270c41
copy dir
gh-yewang Jun 7, 2021
99ee22d
disable 2 teests
gh-yewang Jun 7, 2021
d00f5f0
trim lines
gh-yewang Jun 7, 2021
143dc8f
add missing onnx
gh-yewang Jun 7, 2021
80d44a0
fix type
gh-yewang Jun 8, 2021
1a33548
fix version conflicts
gh-yewang Jun 8, 2021
0dd7949
install psutil
gh-yewang Jun 8, 2021
096a0e0
change file path
gh-yewang Jun 8, 2021
6d1f737
mfix path
gh-yewang Jun 8, 2021
fb7047d
remove cached files
gh-yewang Jun 8, 2021
91fe045
add back attention fusion test
gh-yewang Jun 8, 2021
37d0332
labeled the shape infer test as slow
gh-yewang Jun 8, 2021
0d1441a
fix
gh-yewang Jun 8, 2021
1bca2bb
enable tf2onnx test and enable pytest
gh-yewang Jun 8, 2021
0e5f534
refactor path
gh-yewang Jun 8, 2021
5387bd3
fix typo
gh-yewang Jun 8, 2021
62872f8
add cwd
gh-yewang Jun 8, 2021
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
18 changes: 16 additions & 2 deletions cmake/onnxruntime_python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ if (onnxruntime_ENABLE_TRAINING)
target_link_libraries(onnxruntime_pybind11_state PRIVATE onnxruntime_training)
endif()

target_link_libraries(onnxruntime_pybind11_state PRIVATE
target_link_libraries(onnxruntime_pybind11_state PRIVATE
onnxruntime_session
${onnxruntime_libs}
${PROVIDERS_MIGRAPHX}
Expand Down Expand Up @@ -219,6 +219,12 @@ if (onnxruntime_BUILD_UNIT_TESTS)
file(GLOB onnxruntime_python_dhp_parallel_test_srcs CONFIGURE_DEPENDS
"${ORTTRAINING_SOURCE_DIR}/test/python/dhp_parallel/*.py"
)
file(GLOB onnxruntime_python_transformers_test_srcs CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/test/python/transformers/*.py"
)
file(GLOB onnxruntime_python_transformers_testdata_srcs CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/test/python/transformers/test_data/models/*.onnx"
)
endif()

file(GLOB onnxruntime_python_tools_srcs CONFIGURE_DEPENDS
Expand Down Expand Up @@ -278,6 +284,8 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${build_output_target}>/checkpoint
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${build_output_target}>/dhp_parallel
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${build_output_target}>/quantization
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${build_output_target}>/transformers
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${build_output_target}>/transformers/test_data/models
COMMAND ${CMAKE_COMMAND} -E copy
${ONNXRUNTIME_ROOT}/__init__.py
$<TARGET_FILE_DIR:${build_output_target}>/onnxruntime/
Expand Down Expand Up @@ -343,7 +351,7 @@ add_custom_command(
$<TARGET_FILE_DIR:${build_output_target}>
)

if (NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD
if (NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD
AND NOT onnxruntime_ENABLE_TRAINING
AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin|iOS"
AND NOT (CMAKE_SYSTEM_NAME STREQUAL "Android")
Expand Down Expand Up @@ -371,6 +379,12 @@ if (onnxruntime_BUILD_UNIT_TESTS)
COMMAND ${CMAKE_COMMAND} -E copy
${onnxruntime_python_dhp_parallel_test_srcs}
$<TARGET_FILE_DIR:${build_output_target}>/dhp_parallel/
COMMAND ${CMAKE_COMMAND} -E copy
${onnxruntime_python_transformers_test_srcs}
$<TARGET_FILE_DIR:${build_output_target}>/transformers/
COMMAND ${CMAKE_COMMAND} -E copy
${onnxruntime_python_transformers_testdata_srcs}
$<TARGET_FILE_DIR:${build_output_target}>/transformers/test_data/models/
)
endif()

Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/python/tools/transformers/benchmark_gpt2.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import onnx
from packaging import version
from transformers import AutoConfig
from gpt2_helper import DEFAULT_TOLERANCE, PRETRAINED_GPT2_MODELS
from gpt2_helper import Gpt2Helper, DEFAULT_TOLERANCE, PRETRAINED_GPT2_MODELS
from gpt2_beamsearch_helper import Gpt2HelperFactory, MODEL_CLASSES
from quantize_helper import QuantizeHelper
from benchmark_helper import create_onnxruntime_session, setup_logger, prepare_environment, Precision
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

# set path so that we could import from parent directory
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from optimizer import optimize_model

from onnxruntime.transformers.optimizer import optimize_model

class TestFusion(unittest.TestCase):
def test_attention_fusion_pruned_model(self):
Expand All @@ -24,7 +23,7 @@ def test_attention_fusion_pruned_model(self):
optimized_model = optimize_model(model_path)
os.remove(model_path)

expected_model_path = os.path.join(os.path.dirname(__file__), 'test_data', 'fusion',
expected_model_path = os.path.join(os.path.dirname(__file__), 'test_data', 'models',
'pruned_attention_opt.onnx')
expected = onnx.load(expected_model_path)
self.assertEqual(str(optimized_model.model.graph), str(expected.graph))
Expand All @@ -38,7 +37,7 @@ def test_attention_fusion_reverse_add_order(self):
os.remove(model_path)

# reverse add input order will get same optimized model
expected_model_path = os.path.join(os.path.dirname(__file__), 'test_data', 'fusion',
expected_model_path = os.path.join(os.path.dirname(__file__), 'test_data', 'models',
'pruned_attention_opt.onnx')
expected = onnx.load(expected_model_path)
self.assertEqual(str(optimized_model.model.graph), str(expected.graph))
Expand All @@ -51,11 +50,10 @@ def test_3d_attention_fusion_tf2onnx_model(self):
optimized_model = optimize_model(model_path, model_type='bert_tf', num_heads=4, hidden_size=16)
os.remove(model_path)

expected_model_path = os.path.join(os.path.dirname(__file__), 'test_data', 'fusion',
expected_model_path = os.path.join(os.path.dirname(__file__), 'test_data', 'models',
'bert_3d_attention_opt.onnx')
expected = onnx.load(expected_model_path)
self.assertEqual(str(optimized_model.model.graph), str(expected.graph))


if __name__ == '__main__':
unittest.main()
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@ def forward(self, x):
return 0.5 * x * (1.0 + torch.tanh(0.7978845608028654 * x * (1.0 + 0.044715 * x * x)))


test_cases = [
('huggingface', 'Gelu', HuggingfaceGelu),
('huggingface', 'FastGelu', HuggingfaceFastGelu),
('megatron', 'Gelu', MegatronGelu),
('megatron', 'FastGelu', MegatronFastGelu)
]
test_cases = [('huggingface', 'Gelu', HuggingfaceGelu), ('huggingface', 'FastGelu', HuggingfaceFastGelu),
('megatron', 'Gelu', MegatronGelu), ('megatron', 'FastGelu', MegatronFastGelu)]


class TestGeluFusions(unittest.TestCase):
Expand All @@ -46,7 +42,7 @@ def verify_node_count(self, bert_model, expected_node_count, test_name):

def test_fusions(self):
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from optimizer import optimize_model
from onnxruntime.transformers.optimizer import optimize_model

for test_case in test_cases:
source, operator, model_class = test_case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class TestGpt2(unittest.TestCase):
def run_benchmark_gpt2(self, arguments: str):
from benchmark_gpt2 import parse_arguments, main
from onnxruntime.transformers.benchmark_gpt2 import parse_arguments, main
args = parse_arguments(arguments.split())
csv_filename = main(args)
self.assertTrue(os.path.exists(csv_filename))
Expand Down
Loading