[Docs][PyOV] update python snippets (#19367)
* [Docs][PyOV] update python snippets * first snippet * Fix samples debug * Fix linter * part1 * Fix speech sample * update model state snippet * add serialize * add temp dir * CPU snippets update (#134) * snippets CPU 1/6 * snippets CPU 2/6 * snippets CPU 3/6 * snippets CPU 4/6 * snippets CPU 5/6 * snippets CPU 6/6 * make module TODO: REMEMBER ABOUT EXPORTING PYTONPATH ON CIs ETC * Add static model creation in snippets for CPU * export_comp_model done * leftovers * apply comments * apply comments -- properties * small fixes * rempve debug info * return IENetwork instead of Function * apply comments * revert precision change in common snippets * update opset * [PyOV] Edit docs for the rest of plugins (#136) * modify main.py * GNA snippets * GPU snippets * AUTO snippets * MULTI snippets * HETERO snippets * Added properties * update gna * more samples * Update docs/OV_Runtime_UG/model_state_intro.md * Update docs/OV_Runtime_UG/model_state_intro.md * attempt1 fix ci * new approach to test * temporary remove some files from run * revert cmake changes * fix ci * fix snippet * fix py_exclusive snippet * fix preprocessing snippet * clean-up main * remove numpy installation in gha * check for GPU * add logger * iexclude main * main update * temp * Temp2 * Temp2 * temp * Revert temp * add property execution devices * hide output from samples --------- Co-authored-by: p-wysocki <przemyslaw.wysocki@intel.com> Co-authored-by: Jan Iwaszkiewicz <jan.iwaszkiewicz@intel.com> Co-authored-by: Karol Blaszczak <karol.blaszczak@intel.com>
This commit is contained in:
68 files changed
+1223
-892
No files matched your search
@@ -10,7 +10,8 @@ import tempfile
|
||||
from time import perf_counter
|
||||
|
||||
import datasets
|
||||
from openvino.runtime import Core, get_version, AsyncInferQueue, PartialShape
|
||||
import openvino as ov
|
||||
from openvino.runtime import get_version
|
||||
from transformers import AutoTokenizer
|
||||
from transformers.onnx import export
|
||||
from transformers.onnx.features import FeaturesManager
|
||||
@@ -28,7 +29,7 @@ def main():
|
||||
# Download the tokenizer
|
||||
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
||||
|
||||
core = Core()
|
||||
core = ov.Core()
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
onnx_path = Path(tmp) / f'{model_name}.onnx'
|
||||
@@ -39,7 +40,7 @@ def main():
|
||||
|
||||
# Enforce dynamic input shape
|
||||
try:
|
||||
model.reshape({model_input.any_name: PartialShape([1, '?']) for model_input in model.inputs})
|
||||
model.reshape({model_input.any_name: ov.PartialShape([1, '?']) for model_input in model.inputs})
|
||||
except RuntimeError:
|
||||
log.error("Can't set dynamic shape")
|
||||
raise
|
||||
@@ -50,7 +51,7 @@ def main():
|
||||
# It is possible to set CUMULATIVE_THROUGHPUT as PERFORMANCE_HINT for AUTO device
|
||||
compiled_model = core.compile_model(model, 'CPU', tput)
|
||||
# AsyncInferQueue creates optimal number of InferRequest instances
|
||||
ireqs = AsyncInferQueue(compiled_model)
|
||||
ireqs = ov.AsyncInferQueue(compiled_model)
|
||||
|
||||
sst2 = datasets.load_dataset('glue', 'sst2')
|
||||
sst2_sentences = sst2['validation']['sentence']
|
||||
|
||||
@@ -9,7 +9,8 @@ import sys
|
||||
from time import perf_counter
|
||||
|
||||
import numpy as np
|
||||
from openvino.runtime import Core, get_version
|
||||
import openvino as ov
|
||||
from openvino.runtime import get_version
|
||||
from openvino.runtime.utils.types import get_dtype
|
||||
|
||||
|
||||
@@ -40,7 +41,7 @@ def main():
|
||||
# Pick a device by replacing CPU, for example AUTO:GPU,CPU.
|
||||
# Using MULTI device is pointless in sync scenario
|
||||
# because only one instance of openvino.runtime.InferRequest is used
|
||||
core = Core()
|
||||
core = ov.Core()
|
||||
compiled_model = core.compile_model(sys.argv[1], 'CPU', latency)
|
||||
ireq = compiled_model.create_infer_request()
|
||||
# Fill input data for the ireq
|
||||
|
||||
@@ -9,7 +9,8 @@ import statistics
|
||||
from time import perf_counter
|
||||
|
||||
import numpy as np
|
||||
from openvino.runtime import Core, get_version, AsyncInferQueue
|
||||
import openvino as ov
|
||||
from openvino.runtime import get_version
|
||||
from openvino.runtime.utils.types import get_dtype
|
||||
|
||||
|
||||
@@ -39,10 +40,10 @@ def main():
|
||||
# Create Core and use it to compile a model.
|
||||
# Pick a device by replacing CPU, for example MULTI:CPU(4),GPU(8).
|
||||
# It is possible to set CUMULATIVE_THROUGHPUT as PERFORMANCE_HINT for AUTO device
|
||||
core = Core()
|
||||
core = ov.Core()
|
||||
compiled_model = core.compile_model(sys.argv[1], 'CPU', tput)
|
||||
# AsyncInferQueue creates optimal number of InferRequest instances
|
||||
ireqs = AsyncInferQueue(compiled_model)
|
||||
ireqs = ov.AsyncInferQueue(compiled_model)
|
||||
# Fill input data for ireqs
|
||||
for ireq in ireqs:
|
||||
for model_input in compiled_model.inputs:
|
||||
|
||||
Reference in new issue
Block a user