How to use identify_backend method in yandex-tank

Best Python code snippet using yandex-tank

pshape.py

Source:pshape.py Github

copy

Full Screen

...48 metrics = deepcopy(DEFAULT_METRICS)49 if len(arrs) == 0:50 return51 if DeviceMetric in metrics and all(52 identify_backend(arr) != BackendType.PYTORCH for arr in arrs53 ):54 metrics.remove(DeviceMetric)55 try:56 frame = inspect.currentframe()57 previous_frame = inspect.getframeinfo(frame.f_back)58 func_name = inspect.getframeinfo(frame).function59 if previous_frame.code_context is None:60 raise InteractiveSourceError61 call_line = previous_frame.code_context[0].strip()62 if not call_line.startswith(func_name + "("):63 warnings.warn(64 "Please don't call pshape in a compounded function like my_func(pshape(...)), this makes parsing a nightmare.",65 category=UserWarning,66 )...

Full Screen

Full Screen

metrics.py

Source:metrics.py Github

copy

Full Screen

...51 _default_value = "N/A"52class DtypeMetric(ArrayMetric):53 name = "dtype"54 def __str__(self) -> str:55 if identify_backend(self.arr) is BackendType.TENSORFLOW:56 return repr(self.value)57 else:58 return str(self.value)59class NumericMetric(ArrayMetric):60 name: str61 precision: int = 462 _default_value = np.nan63 def __str__(self) -> str:64 return f"{self.value:.{self.precision}f}"65class CallableMetric(ArrayMetric):66 def _get_value(self):67 return super()._get_value()()68class NumericCallableMetric(NumericMetric, CallableMetric):69 def _get_value(self):70 backend = identify_backend(self.arr)71 if backend is BackendType.TENSORFLOW:72 import tensorflow as tf73 return getattr(tf.math, "reduce_" + self.name)(self.arr).numpy()74 else:75 return super()._get_value()76 def is_compatible(self):77 return super().is_compatible() or (78 identify_backend(self.arr) is BackendType.TENSORFLOW79 )80class MinMetric(NumericCallableMetric):81 name = "min"82class MaxMetric(NumericCallableMetric):83 name = "max"84class MeanMetric(NumericCallableMetric):85 name = "mean"86 def _get_value(self):87 backend = identify_backend(self.arr)88 if backend is BackendType.PYTORCH:89 import torch90 # PyTorch can't compute mean of integer-like types91 self.arr = self.arr.to(torch.float)92 return super()._get_value()93# NameMetric is the default first metric and can't be used elsewhere94DEFAULT_METRICS = [ShapeMetric]95if PYTORCH_ENABLED:96 DEFAULT_METRICS += [DeviceMetric]97DEFAULT_METRICS += [DtypeMetric]98DEFAULT_METRICS += [MinMetric]99DEFAULT_METRICS += [MeanMetric]...

Full Screen

Full Screen

test_uploader_plugin.py

Source:test_uploader_plugin.py Github

copy

Full Screen

...11 ('overload', BackendTypes.OVERLOAD),12 ('overload-01', BackendTypes.OVERLOAD)13 ])14 def test_identify(self, section_name, expected_type):15 assert BackendTypes.identify_backend(section_name) == expected_type16 @pytest.mark.parametrize('section_name', [17 'meta lunapark',18 'meta ',19 ' lunapark',20 'lp ',21 'meta-'22 ])23 def test_exception(self, section_name):24 with pytest.raises(KeyError) as excinfo:25 BackendTypes.identify_backend(section_name)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run yandex-tank automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful