How to use available method in hypothesis

Best Python code snippet using hypothesis

test_conversion.py

Source:test_conversion.py Github

copy

Full Screen

1# Copyright (c) 2017 Sony Corporation. All Rights Reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14from nnabla.utils.converter.nnabla import NnpImporter, NnpExporter15from collections import OrderedDict16import os17import shutil18import pytest19import nnabla20import nnabla.utils.load as nnload21import numpy as np22import pdb23CAFFE2_AVAILABLE = False24try:25 import caffe2.python.onnx.backend as oc226 CAFFE2_AVAILABLE = True27except:28 pass29ONNX_AVAILABLE = False30try:31 import onnx32 ONNX_AVAILABLE = True33except:34 pass35try:36 from nnabla.utils.converter.onnx import OnnxImporter, OnnxExporter37except:38 ONNX_AVAILABLE = False39CNTK_AVAILABLE = False40try:41 import cntk42 import cntk.ops.functions as cntkf43 CNTK_AVAILABLE = True44except:45 print('Need to install CNTK for testing.')46# The directory of which the input ONNX files will be at47REFERENCE_AVAILABLE = False48TEST_DATA_DIR = os.path.abspath(os.path.join(os.path.dirname(49 __file__), '..', '..', '..', '..', '..', 'nnabla-sample-data', 'reference', 'onnx'))50if os.path.exists(TEST_DATA_DIR):51 REFERENCE_AVAILABLE = True52print(TEST_DATA_DIR)53# Set a path to this parameter (preferably the same as TEST_DATA_DIR)54# if you want to update all the NNP files55DEFAULT_NNP_EXPORT_PATH = None56try:57 from .gen_report import gen_report58except:59 print("Cannot generate report since no gen_report module.")60 def gen_report(import_result, export_result):61 pass62import_result = {}63export_result = {}64def print_buffer_shape(net):65 for k, v in net.functions.items():66 out = v.outputs[0]67 print(out.name, net.variables[out.name].variable_instance.shape)68def run_executor(nn_net, exec_name):69 """Run specified executor and return its network"""70 exe = nn_net.executors[exec_name]71 exe.network.forward(exe.forward_sequence)72 return exe.network73def convert_onnx_to_nnp_and_compare(74 tmpdir, onnx_dir, onnx_name, nnp_name, out_name, exec_name,75 backend="caffe2",76 in_img=None, in_name="",77 compare_values=True, show_onnx=False, show_nnp=False,78 show_output=False, atol=1e-08,79 export_nnp_path=DEFAULT_NNP_EXPORT_PATH):80 """Convert specified ONNX to NNP and compare each81 results ran by Caffe2 and NNabla"""82 path = os.path.join(onnx_dir, onnx_name)83 backend_out = None84 func_name = ''85 if backend == "caffe2" and CAFFE2_AVAILABLE:86 # Process onnx with caffe2 backend87 model = onnx.load(path)88 func_name = model.graph.node[0].op_type89 if show_onnx:90 print(model)91 c2out = None92 rep = oc2.prepare(model)93 if type(in_img) is np.ndarray:94 c2out = rep.run([in_img])95 else:96 c2out = rep.run([])97 # for k in rep.workspace.Blobs():98 # v = rep.workspace.FetchBlob(k)99 # print(k, v.shape)100 backend_out = c2out[out_name]101 elif backend == "cntk" and CNTK_AVAILABLE:102 n = cntkf.Function.load(path, format=cntk.ModelFormat.ONNX)103 cntk_out = None104 if type(in_img) is np.ndarray:105 cntk_out = n.eval({in_name: in_img})106 else:107 cntk_out = n.eval()108 backend_out = cntk_out109 else:110 raise ValueError("Unknown backend specified")111 import_result[func_name] = 'NG'112 # Process onnx with naabla113 r = OnnxImporter(path)114 nnp = r.execute()115 assert nnp is not None116 assert len(nnp.other_files) == 0117 assert nnp.protobuf is not None118 if show_nnp:119 print(nnp.protobuf)120 nnpex = NnpExporter(nnp, batch_size=0)121 nnpdir = tmpdir.mkdir("nnp")122 p = os.path.join(str(nnpdir), nnp_name)123 nnpex._export_nnp(p)124 if export_nnp_path:125 shutil.copy2(p, export_nnp_path)126 # read exported nnp and run network127 # pdb.set_trace()128 nn_net = nnload.load([p])129 if type(in_img) is np.ndarray:130 net = nn_net.executors[exec_name].network131 in_data = net.variables[in_name]132 in_data.variable_instance.d = in_img133 exe = run_executor(nn_net, exec_name)134 # print_buffer_shape(exe)135 # in_data = exe.variables["in_data_0"]136 # print(in_data.variable_instance.d)137 nnout = exe.variables[out_name].variable_instance.d138 # print(nnout.variable_instance.d)139 # Compare both naabla and backend results140 if show_output:141 print(backend_out, nnout)142 assert backend_out.shape == nnout.shape143 if compare_values:144 assert np.allclose(backend_out, nnout, atol=atol)145 import_result[func_name] = 'OK'146def convert_nnp_to_onnx_and_compare(147 tmpdir, nnp_dir, nnp_name, onnx_name, out_name, exec_name,148 backend="caffe2",149 in_img=None, in_name="", compare_values=True, show_nnp=False,150 show_onnx=False, show_output=False, atol=1e-08,151 export_onnx_path=None):152 """Convert specified NNP to ONNX and compare153 each results ran by CNTK and NNabla"""154 # Process nnp with nnabla155 path = os.path.join(nnp_dir, nnp_name)156 nn_net = nnload.load([path])157 if type(in_img) is np.ndarray:158 net = nn_net.executors[exec_name].network159 in_data = net.variables[in_name]160 in_data.variable_instance.d = in_img161 exe = run_executor(nn_net, exec_name)162 nnout = exe.variables[out_name].variable_instance.d163 # Convert nnp to ONNX164 r = NnpImporter(path)165 nnp = r.execute()166 assert nnp is not None167 assert len(nnp.other_files) == 0168 assert nnp.protobuf is not None169 if show_nnp:170 print(nnp.protobuf)171 func_name = nnp.protobuf.network[0].function[0].type172 print(func_name)173 export_result[func_name] = 'NG'174 onnxex = OnnxExporter(nnp, -1)175 onnxdir = tmpdir.mkdir("onnx")176 p = os.path.join(str(onnxdir), onnx_name)177 onnxex.execute(p)178 if export_onnx_path:179 shutil.copy2(p, export_onnx_path)180 # read exported onnx and run network181 model = onnx.load(p)182 if show_onnx:183 print(model)184 # pdb.set_trace()185 backend_out = None186 if backend == "caffe2" and CAFFE2_AVAILABLE:187 # Process onnx with caffe2 backend188 c2out = None189 rep = oc2.prepare(model)190 if type(in_img) is np.ndarray:191 c2out = rep.run([in_img])192 else:193 c2out = rep.run([])194 # for k in rep.workspace.Blobs():195 # v = rep.workspace.FetchBlob(k)196 # print(k, v.shape)197 backend_out = c2out[out_name]198 elif backend == "cntk" and CNTK_AVAILABLE:199 n = cntkf.Function.load(p, format=cntk.ModelFormat.ONNX)200 cntk_out = None201 if type(in_img) is np.ndarray:202 cntk_out = n.eval({in_name: in_img})203 else:204 cntk_out = n.eval()205 backend_out = cntk_out206 else:207 raise ValueError("Unknown backend specified")208 # Compare both naabla and backend out results209 if show_output:210 print(backend_out, nnout)211 assert backend_out.shape == nnout.shape212 if compare_values:213 assert np.allclose(backend_out, nnout, atol=atol)214 export_result[func_name] = 'OK'215@pytest.fixture216def nnp_fixture():217 # We need to remove all parameters for each test case218 # because the buffer shape will differ while having same names219 nnabla.clear_parameters()220@pytest.fixture(scope="module", autouse=True)221def gen_report_fixture():222 yield223 gen_report(import_result, export_result)224def test_onnx_nnp_conversion_concat(tmpdir, nnp_fixture):225 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):226 pytest.skip('CAFFE2 does not installed.')227 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,228 "concat.onnx", "concat.nnp",229 "out_data_1", "exec_0")230def test_nnp_onnx_conversion_concat(tmpdir, nnp_fixture):231 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):232 pytest.skip('CAFFE2 does not installed.')233 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,234 "concat.nnp", "concat.onnx",235 "out_data_1", "exec_0")236def test_onnx_nnp_conversion_conv(tmpdir, nnp_fixture):237 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):238 pytest.skip('CAFFE2 does not installed.')239 convert_onnx_to_nnp_and_compare(240 tmpdir, TEST_DATA_DIR, "conv.onnx", "conv.nnp", "out_data_1", "exec_0")241def test_nnp_onnx_conversion_conv(tmpdir, nnp_fixture):242 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):243 pytest.skip('CAFFE2 does not installed.')244 convert_nnp_to_onnx_and_compare(245 tmpdir, TEST_DATA_DIR, "conv.nnp", "conv.onnx", "out_data_1", "exec_0")246def test_onnx_nnp_conversion_dropout(tmpdir, nnp_fixture):247 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):248 pytest.skip('CAFFE2 does not installed.')249 # We do not check if the values match because a dropout250 # output yield random results251 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,252 "dropout.onnx", "dropout.nnp",253 "out_data_1", "exec_0",254 compare_values=False)255def test_nnp_onnx_conversion_dropout(tmpdir, nnp_fixture):256 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):257 pytest.skip('CAFFE2 does not installed.')258 # We do not check if the values match because a dropout259 # output yield random results260 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,261 "dropout.nnp", "dropout.onnx",262 "out_data_1", "exec_0",263 compare_values=False)264def test_onnx_nnp_conversion_dropout_is_test(tmpdir, nnp_fixture):265 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):266 pytest.skip('CAFFE2 does not installed.')267 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,268 "dropout_test.onnx", "dropout_test.nnp",269 "out_data_1", "exec_0")270def test_nnp_onnx_conversion_dropout_is_test(tmpdir, nnp_fixture):271 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):272 pytest.skip('CAFFE2 does not installed.')273 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,274 "dropout_test.nnp", "dropout_test.onnx",275 "out_data_1", "exec_0")276def test_onnx_nnp_conversion_gap(tmpdir, nnp_fixture):277 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):278 pytest.skip('CAFFE2 does not installed.')279 convert_onnx_to_nnp_and_compare(280 tmpdir, TEST_DATA_DIR, "gap.onnx", "gap.nnp", "out_data_1", "exec_0")281def test_nnp_onnx_conversion_gap(tmpdir, nnp_fixture):282 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):283 pytest.skip('CAFFE2 does not installed.')284 convert_nnp_to_onnx_and_compare(285 tmpdir, TEST_DATA_DIR, "gap.nnp", "gap.onnx", "out_data_1", "exec_0")286def test_onnx_nnp_conversion_maxpool(tmpdir, nnp_fixture):287 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):288 pytest.skip('CAFFE2 does not installed.')289 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,290 "maxpool.onnx", "maxpool.nnp",291 "out_data_1", "exec_0")292def test_nnp_onnx_conversion_maxpool(tmpdir, nnp_fixture):293 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):294 pytest.skip('CAFFE2 does not installed.')295 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,296 "maxpool.nnp", "maxpool.onnx",297 "out_data_1", "exec_0")298def test_onnx_nnp_conversion_maxpool_p0_s2_k3(tmpdir, nnp_fixture):299 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):300 pytest.skip('CAFFE2 does not installed.')301 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,302 "maxpool_p0_s2_k3.onnx",303 "maxpool_p0_s2_k3.nnp",304 "out_data_1", "exec_0")305def test_nnp_onnx_conversion_maxpool_p0_s3_k3(tmpdir, nnp_fixture):306 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):307 pytest.skip('CAFFE2 does not installed.')308 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,309 "maxpool_p0_s2_k3.nnp",310 "maxpool_p0_s2_k3.onnx",311 "out_data_1", "exec_0")312def test_onnx_nnp_conversion_relu(tmpdir, nnp_fixture):313 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):314 pytest.skip('CAFFE2 does not installed.')315 convert_onnx_to_nnp_and_compare(316 tmpdir, TEST_DATA_DIR, "relu.onnx", "relu.nnp", "out_data_1", "exec_0")317def test_nnp_onnx_conversion_relu(tmpdir, nnp_fixture):318 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):319 pytest.skip('CAFFE2 does not installed.')320 convert_nnp_to_onnx_and_compare(321 tmpdir, TEST_DATA_DIR, "relu.nnp", "relu.onnx", "out_data_1", "exec_0")322def test_onnx_nnp_conversion_softmax(tmpdir, nnp_fixture):323 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):324 pytest.skip('CAFFE2 does not installed.')325 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,326 "softmax.onnx", "softmax.nnp",327 "out_data_1", "exec_0")328def test_nnp_onnx_conversion_softmax(tmpdir, nnp_fixture):329 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):330 pytest.skip('CAFFE2 does not installed.')331 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,332 "softmax.nnp", "softmax.onnx",333 "out_data_1", "exec_0")334def test_onnx_nnp_conversion_average_pool(tmpdir, nnp_fixture):335 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):336 pytest.skip('CAFFE2 does not installed.')337 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,338 "average_pool.onnx", "average_pool.nnp",339 "out_data_1", "exec_0")340def test_nnp_onnx_conversion_average_pool(tmpdir, nnp_fixture):341 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):342 pytest.skip('CAFFE2 does not installed.')343 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,344 "average_pool.nnp", "average_pool.onnx",345 "out_data_1", "exec_0")346# def test_onnx_nnp_conversion_average_pool_p0_0_1_1_s1_k2(tmpdir, nnp_fixture):347# if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):348# pytest.skip('CAFFE2 does not installed.')349# convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,350# "average_pool_p0_0_1_1_s1_k2.onnx",351# "average_pool_p0_0_1_1_s1_k2.nnp",352# "out_data_1", "exec_0",353# export_nnp_path=TEST_DATA_DIR)354#355#356# def test_nnp_onnx_conversion_average_pool_p0_0_1_1_s1_k2(tmpdir, nnp_fixture):357# if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):358# pytest.skip('CAFFE2 does not installed.')359# convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,360# "average_pool_p0_0_1_1_s1_k2.nnp",361# "average_pool_p0_0_1_1_s1_k2.onnx",362# "out_data_1", "exec_0")363def test_onnx_nnp_conversion_sum(tmpdir, nnp_fixture):364 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):365 pytest.skip('CAFFE2 does not installed.')366 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,367 "sum.onnx", "sum.nnp",368 "out_data_1", "exec_0")369def test_nnp_onnx_conversion_sum(tmpdir, nnp_fixture):370 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):371 pytest.skip('CAFFE2 does not installed.')372 convert_nnp_to_onnx_and_compare(373 tmpdir, TEST_DATA_DIR, "sum.nnp", "sum.onnx", "out_data_1", "exec_0")374def test_onnx_nnp_conversion_batch_normalization(tmpdir, nnp_fixture):375 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):376 pytest.skip('CAFFE2 does not installed.')377 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,378 "batch_norm.onnx", "batch_norm.nnp",379 "out_data_1", "exec_0", atol=1e-05)380def test_nnp_onnx_conversion_batch_normalization(tmpdir, nnp_fixture):381 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):382 pytest.skip('CAFFE2 does not installed.')383 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,384 "batch_norm.nnp", "batch_norm.onnx",385 "out_data_1", "exec_0", atol=1e-05)386def test_onnx_nnp_conversion_gemm(tmpdir, nnp_fixture):387 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):388 pytest.skip('CAFFE2 does not installed.')389 convert_onnx_to_nnp_and_compare(390 tmpdir, TEST_DATA_DIR, "gemm.onnx", "gemm.nnp", "out_data_1", "exec_0")391@pytest.mark.skip392def test_nnp_onnx_conversion_gemm(tmpdir, nnp_fixture):393 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):394 pytest.skip('CAFFE2 does not installed.')395 convert_nnp_to_onnx_and_compare(396 tmpdir, TEST_DATA_DIR, "gemm.nnp", "gemm.onnx", "out_data_1", "exec_0")397def test_onnx_nnp_conversion_add_no_broadcast(tmpdir, nnp_fixture):398 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):399 pytest.skip('CAFFE2 does not installed.')400 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,401 "add_no_broadcast.onnx",402 "add_no_broadcast.nnp",403 "out_data_1", "exec_0")404def test_nnp_onnx_conversion_add_no_broadcast(tmpdir, nnp_fixture):405 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):406 pytest.skip('CAFFE2 does not installed.')407 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,408 "add_no_broadcast.nnp",409 "add_no_broadcast.onnx",410 "out_data_1", "exec_0")411def test_onnx_nnp_conversion_add_broadcast_axis1(tmpdir, nnp_fixture):412 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):413 pytest.skip('CAFFE2 does not installed.')414 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,415 "add_broadcast_axis1.onnx",416 "add_broadcast_axis1.nnp",417 "out_data_1", "exec_0")418def test_nnp_onnx_conversion_add_broadcast_axis1(tmpdir, nnp_fixture):419 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):420 pytest.skip('CAFFE2 does not installed.')421 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,422 "add_broadcast_axis1.nnp",423 "add_broadcast_axis1.onnx",424 "out_data_1", "exec_0")425def test_onnx_nnp_conversion_mul_no_broadcast(tmpdir, nnp_fixture):426 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):427 pytest.skip('CAFFE2 does not installed.')428 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,429 "mul_no_broadcast.onnx",430 "mul_no_broadcast.nnp",431 "out_data_1", "exec_0")432def test_nnp_onnx_conversion_mul_no_broadcast(tmpdir, nnp_fixture):433 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):434 pytest.skip('CAFFE2 does not installed.')435 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,436 "mul_no_broadcast.nnp",437 "mul_no_broadcast.onnx",438 "out_data_1", "exec_0")439def test_onnx_nnp_conversion_mul_broadcast_axis1(tmpdir, nnp_fixture):440 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):441 pytest.skip('CAFFE2 does not installed.')442 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,443 "mul_broadcast_axis1.onnx",444 "mul_broadcast_axis1.nnp",445 "out_data_1", "exec_0")446def test_nnp_onnx_conversion_mul_broadcast_axis1(tmpdir, nnp_fixture):447 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):448 pytest.skip('CAFFE2 does not installed.')449 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,450 "mul_broadcast_axis1.nnp",451 "mul_broadcast_axis1.onnx",452 "out_data_1", "exec_0")453def test_onnx_nnp_conversion_constant(tmpdir, nnp_fixture):454 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):455 pytest.skip('CAFFE2 does not installed.')456 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,457 "constant.onnx", "constant.nnp",458 "Pooling33_Output_0", "exec_0")459@pytest.mark.skip(reason="Current version of reshape does not supported yet.")460def test_onnx_nnp_conversion_reshape(tmpdir, nnp_fixture):461 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):462 pytest.skip('CAFFE2 does not installed.')463 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,464 "reshape.onnx", "reshape.nnp",465 "out_data_1", "exec_0")466@pytest.mark.skip(reason="Current version of reshape does not supported yet.")467def test_nnp_onnx_conversion_reshape(tmpdir, nnp_fixture):468 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):469 pytest.skip('CAFFE2 does not installed.')470 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,471 "reshape.nnp", "reshape.onnx",472 "out_data_1", "exec_0")473def test_onnx_nnp_conversion_matmul(tmpdir, nnp_fixture):474 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):475 pytest.skip('CAFFE2 does not installed.')476 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,477 "matmul.onnx", "matmul.nnp",478 "out_data_1", "exec_0")479def test_nnp_onnx_conversion_matmul(tmpdir, nnp_fixture):480 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):481 pytest.skip('CAFFE2 does not installed.')482 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,483 "matmul.nnp", "matmul.onnx",484 "out_data_1", "exec_0")485def test_onnx_nnp_conversion_transpose(tmpdir, nnp_fixture):486 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):487 pytest.skip('CAFFE2 does not installed.')488 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,489 "transpose.onnx", "transpose.nnp",490 "out_data_1", "exec_0")491def test_nnp_onnx_conversion_transpose(tmpdir, nnp_fixture):492 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):493 pytest.skip('CAFFE2 does not installed.')494 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,495 "transpose.nnp", "transpose.onnx",496 "out_data_1", "exec_0")497def test_onnx_nnp_conversion_abs(tmpdir, nnp_fixture):498 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):499 pytest.skip('CAFFE2 does not installed.')500 convert_onnx_to_nnp_and_compare(501 tmpdir, TEST_DATA_DIR, "abs.onnx", "abs.nnp", "out_data_1", "exec_0")502def test_nnp_onnx_conversion_abs(tmpdir, nnp_fixture):503 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):504 pytest.skip('CAFFE2 does not installed.')505 convert_nnp_to_onnx_and_compare(506 tmpdir, TEST_DATA_DIR, "abs.nnp", "abs.onnx", "out_data_1", "exec_0")507def test_onnx_nnp_conversion_sigmoid(tmpdir, nnp_fixture):508 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):509 pytest.skip('CAFFE2 does not installed.')510 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,511 "sigmoid.onnx", "sigmoid.nnp",512 "out_data_1", "exec_0")513def test_nnp_onnx_conversion_sigmoid(tmpdir, nnp_fixture):514 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):515 pytest.skip('CAFFE2 does not installed.')516 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,517 "sigmoid.nnp", "sigmoid.onnx",518 "out_data_1", "exec_0")519def test_onnx_nnp_conversion_tanh(tmpdir, nnp_fixture):520 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):521 pytest.skip('CAFFE2 does not installed.')522 convert_onnx_to_nnp_and_compare(523 tmpdir, TEST_DATA_DIR, "tanh.onnx", "tanh.nnp", "out_data_1", "exec_0")524def test_nnp_onnx_conversion_tanh(tmpdir, nnp_fixture):525 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):526 pytest.skip('CAFFE2 does not installed.')527 convert_nnp_to_onnx_and_compare(528 tmpdir, TEST_DATA_DIR, "tanh.nnp", "tanh.onnx", "out_data_1", "exec_0")529def test_onnx_nnp_conversion_leaky_relu(tmpdir, nnp_fixture):530 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):531 pytest.skip('CAFFE2 does not installed.')532 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,533 "leaky_relu.onnx", "leaky_relu.nnp",534 "out_data_1", "exec_0")535def test_nnp_onnx_conversion_leaky_relu(tmpdir, nnp_fixture):536 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):537 pytest.skip('CAFFE2 does not installed.')538 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,539 "leaky_relu.nnp", "leaky_relu.onnx",540 "out_data_1", "exec_0")541def test_onnx_nnp_conversion_log(tmpdir, nnp_fixture):542 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):543 pytest.skip('CAFFE2 does not installed.')544 convert_onnx_to_nnp_and_compare(545 tmpdir, TEST_DATA_DIR, "log.onnx", "log.nnp", "out_data_1", "exec_0")546def test_nnp_onnx_conversion_log(tmpdir, nnp_fixture):547 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):548 pytest.skip('CAFFE2 does not installed.')549 convert_nnp_to_onnx_and_compare(550 tmpdir, TEST_DATA_DIR, "log.nnp", "log.onnx", "out_data_1", "exec_0")551def test_onnx_nnp_conversion_not(tmpdir, nnp_fixture):552 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):553 pytest.skip('CAFFE2 does not installed.')554 convert_onnx_to_nnp_and_compare(555 tmpdir, TEST_DATA_DIR, "not.onnx", "not.nnp", "out_data_1", "exec_0")556def test_nnp_onnx_conversion_not(tmpdir, nnp_fixture):557 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):558 pytest.skip('CAFFE2 does not installed.')559 convert_nnp_to_onnx_and_compare(560 tmpdir, TEST_DATA_DIR, "not.nnp", "not.onnx", "out_data_1", "exec_0")561def test_onnx_nnp_conversion_elu(tmpdir, nnp_fixture):562 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):563 pytest.skip('CAFFE2 does not installed.')564 convert_onnx_to_nnp_and_compare(565 tmpdir, TEST_DATA_DIR, "elu.onnx", "elu.nnp", "out_data_1", "exec_0")566def test_nnp_onnx_conversion_elu(tmpdir, nnp_fixture):567 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):568 pytest.skip('CAFFE2 does not installed.')569 convert_nnp_to_onnx_and_compare(570 tmpdir, TEST_DATA_DIR, "elu.nnp", "elu.onnx", "out_data_1", "exec_0")571def test_onnx_nnp_conversion_selu(tmpdir, nnp_fixture):572 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):573 pytest.skip('CAFFE2 does not installed.')574 convert_onnx_to_nnp_and_compare(575 tmpdir, TEST_DATA_DIR, "selu.onnx", "selu.nnp", "out_data_1", "exec_0")576def test_nnp_onnx_conversion_selu(tmpdir, nnp_fixture):577 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):578 pytest.skip('CAFFE2 does not installed.')579 convert_nnp_to_onnx_and_compare(580 tmpdir, TEST_DATA_DIR, "selu.nnp", "selu.onnx", "out_data_1", "exec_0")581def test_onnx_nnp_conversion_reduce_sum(tmpdir, nnp_fixture):582 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):583 pytest.skip('CAFFE2 does not installed.')584 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,585 "reduce_sum.onnx", "reduce_sum.nnp",586 "out_data_1", "exec_0")587def test_nnp_onnx_conversion_reduce_sum(tmpdir, nnp_fixture):588 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):589 pytest.skip('CAFFE2 does not installed.')590 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,591 "reduce_sum.nnp", "reduce_sum.onnx",592 "out_data_1", "exec_0")593def test_onnx_nnp_conversion_reduce_mean(tmpdir, nnp_fixture):594 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):595 pytest.skip('CAFFE2 does not installed.')596 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,597 "reduce_mean.onnx", "reduce_mean.nnp",598 "out_data_1", "exec_0")599def test_nnp_onnx_conversion_reduce_mean(tmpdir, nnp_fixture):600 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):601 pytest.skip('CAFFE2 does not installed.')602 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,603 "reduce_mean.nnp", "reduce_mean.onnx",604 "out_data_1", "exec_0")605def test_onnx_nnp_conversion_and_no_broadcast(tmpdir, nnp_fixture):606 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):607 pytest.skip('CAFFE2 does not installed.')608 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,609 "and_no_broadcast.onnx",610 "and_no_broadcast.nnp",611 "out_data_1", "exec_0")612def test_nnp_onnx_conversion_and_no_broadcast(tmpdir, nnp_fixture):613 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):614 pytest.skip('CAFFE2 does not installed.')615 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,616 "and_no_broadcast.nnp",617 "and_no_broadcast.onnx",618 "out_data_1", "exec_0")619def test_onnx_nnp_conversion_and_broadcast_axis1(tmpdir, nnp_fixture):620 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):621 pytest.skip('CAFFE2 does not installed.')622 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,623 "and_broadcast_axis1.onnx",624 "and_broadcast_axis1.nnp",625 "out_data_1", "exec_0")626def test_nnp_onnx_conversion_and_broadcast_axis1(tmpdir, nnp_fixture):627 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):628 pytest.skip('CAFFE2 does not installed.')629 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,630 "and_broadcast_axis1.nnp",631 "and_broadcast_axis1.onnx",632 "out_data_1", "exec_0")633def test_onnx_nnp_conversion_or_no_broadcast(tmpdir, nnp_fixture):634 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):635 pytest.skip('CAFFE2 does not installed.')636 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,637 "or_no_broadcast.onnx",638 "or_no_broadcast.nnp",639 "out_data_1", "exec_0")640def test_nnp_onnx_conversion_or_no_broadcast(tmpdir, nnp_fixture):641 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):642 pytest.skip('CAFFE2 does not installed.')643 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,644 "or_no_broadcast.nnp",645 "or_no_broadcast.onnx",646 "out_data_1", "exec_0")647def test_onnx_nnp_conversion_or_broadcast_axis1(tmpdir, nnp_fixture):648 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):649 pytest.skip('CAFFE2 does not installed.')650 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,651 "or_broadcast_axis1.onnx",652 "or_broadcast_axis1.nnp",653 "out_data_1", "exec_0")654def test_nnp_onnx_conversion_or_broadcast_axis1(tmpdir, nnp_fixture):655 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):656 pytest.skip('CAFFE2 does not installed.')657 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,658 "or_broadcast_axis1.nnp",659 "or_broadcast_axis1.onnx",660 "out_data_1", "exec_0")661def test_onnx_nnp_conversion_xor_no_broadcast(tmpdir, nnp_fixture):662 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):663 pytest.skip('CAFFE2 does not installed.')664 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,665 "xor_no_broadcast.onnx",666 "xor_no_broadcast.nnp",667 "out_data_1", "exec_0")668def test_nnp_onnx_conversion_xor_no_broadcast(tmpdir, nnp_fixture):669 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):670 pytest.skip('CAFFE2 does not installed.')671 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,672 "xor_no_broadcast.nnp",673 "xor_no_broadcast.onnx",674 "out_data_1", "exec_0")675def test_onnx_nnp_conversion_xor_broadcast_axis1(tmpdir, nnp_fixture):676 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):677 pytest.skip('CAFFE2 does not installed.')678 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,679 "xor_broadcast_axis1.onnx",680 "xor_broadcast_axis1.nnp",681 "out_data_1", "exec_0")682def test_nnp_onnx_conversion_xor_broadcast_axis1(tmpdir, nnp_fixture):683 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):684 pytest.skip('CAFFE2 does not installed.')685 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,686 "xor_broadcast_axis1.nnp",687 "xor_broadcast_axis1.onnx",688 "out_data_1", "exec_0")689def test_onnx_nnp_conversion_div_no_broadcast(tmpdir, nnp_fixture):690 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):691 pytest.skip('CAFFE2 does not installed.')692 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,693 "div_no_broadcast.onnx",694 "div_no_broadcast.nnp",695 "out_data_1", "exec_0")696def test_nnp_onnx_conversion_div_no_broadcast(tmpdir, nnp_fixture):697 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):698 pytest.skip('CAFFE2 does not installed.')699 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,700 "div_no_broadcast.nnp",701 "div_no_broadcast.onnx",702 "out_data_1", "exec_0")703def test_onnx_nnp_conversion_div_broadcast_axis1(tmpdir, nnp_fixture):704 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):705 pytest.skip('CAFFE2 does not installed.')706 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,707 "div_broadcast_axis1.onnx",708 "div_broadcast_axis1.nnp",709 "out_data_1", "exec_0")710def test_nnp_onnx_conversion_div_broadcast_axis1(tmpdir, nnp_fixture):711 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):712 pytest.skip('CAFFE2 does not installed.')713 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,714 "div_broadcast_axis1.nnp",715 "div_broadcast_axis1.onnx",716 "out_data_1", "exec_0")717def test_onnx_nnp_conversion_pow_no_broadcast(tmpdir, nnp_fixture):718 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):719 pytest.skip('CAFFE2 does not installed.')720 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,721 "pow_no_broadcast.onnx",722 "pow_no_broadcast.nnp",723 "out_data_1", "exec_0")724def test_nnp_onnx_conversion_pow_no_broadcast(tmpdir, nnp_fixture):725 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):726 pytest.skip('CAFFE2 does not installed.')727 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,728 "pow_no_broadcast.nnp",729 "pow_no_broadcast.onnx",730 "out_data_1", "exec_0")731def test_onnx_nnp_conversion_pow_broadcast_axis1(tmpdir, nnp_fixture):732 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):733 pytest.skip('CAFFE2 does not installed.')734 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,735 "pow_broadcast_axis1.onnx",736 "pow_broadcast_axis1.nnp",737 "out_data_1", "exec_0")738def test_nnp_onnx_conversion_pow_broadcast_axis1(tmpdir, nnp_fixture):739 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):740 pytest.skip('CAFFE2 does not installed.')741 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,742 "pow_broadcast_axis1.nnp",743 "pow_broadcast_axis1.onnx",744 "out_data_1", "exec_0")745def test_onnx_nnp_conversion_sub_no_broadcast(tmpdir, nnp_fixture):746 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):747 pytest.skip('CAFFE2 does not installed.')748 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,749 "sub_no_broadcast.onnx",750 "sub_no_broadcast.nnp",751 "out_data_1", "exec_0")752def test_nnp_onnx_conversion_sub_no_broadcast(tmpdir, nnp_fixture):753 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):754 pytest.skip('CAFFE2 does not installed.')755 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,756 "sub_no_broadcast.nnp",757 "sub_no_broadcast.onnx",758 "out_data_1", "exec_0")759def test_onnx_nnp_conversion_sub_broadcast_axis1(tmpdir, nnp_fixture):760 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):761 pytest.skip('CAFFE2 does not installed.')762 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,763 "sub_broadcast_axis1.onnx",764 "sub_broadcast_axis1.nnp",765 "out_data_1", "exec_0")766def test_nnp_onnx_conversion_sub_broadcast_axis1(tmpdir, nnp_fixture):767 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):768 pytest.skip('CAFFE2 does not installed.')769 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,770 "sub_broadcast_axis1.nnp",771 "sub_broadcast_axis1.onnx",772 "out_data_1", "exec_0")773def test_onnx_nnp_conversion_less_no_broadcast(tmpdir, nnp_fixture):774 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):775 pytest.skip('CAFFE2 does not installed.')776 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,777 "less_no_broadcast.onnx",778 "less_no_broadcast.nnp",779 "out_data_1", "exec_0")780def test_nnp_onnx_conversion_less_no_broadcast(tmpdir, nnp_fixture):781 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):782 pytest.skip('CAFFE2 does not installed.')783 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,784 "less_no_broadcast.nnp",785 "less_no_broadcast.onnx",786 "out_data_1", "exec_0")787def test_onnx_nnp_conversion_less_broadcast_axis1(tmpdir, nnp_fixture):788 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):789 pytest.skip('CAFFE2 does not installed.')790 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,791 "less_broadcast_axis1.onnx",792 "less_broadcast_axis1.nnp",793 "out_data_1", "exec_0")794def test_nnp_onnx_conversion_less_broadcast_axis1(tmpdir, nnp_fixture):795 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):796 pytest.skip('CAFFE2 does not installed.')797 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,798 "less_broadcast_axis1.nnp",799 "less_broadcast_axis1.onnx",800 "out_data_1", "exec_0")801def test_onnx_nnp_conversion_greater_no_broadcast(tmpdir, nnp_fixture):802 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):803 pytest.skip('CAFFE2 does not installed.')804 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,805 "greater_no_broadcast.onnx",806 "greater_no_broadcast.nnp",807 "out_data_1", "exec_0")808def test_nnp_onnx_conversion_greater_no_broadcast(tmpdir, nnp_fixture):809 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):810 pytest.skip('CAFFE2 does not installed.')811 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,812 "greater_no_broadcast.nnp",813 "greater_no_broadcast.onnx",814 "out_data_1", "exec_0")815def test_onnx_nnp_conversion_greater_broadcast_axis1(tmpdir, nnp_fixture):816 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):817 pytest.skip('CAFFE2 does not installed.')818 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,819 "greater_broadcast_axis1.onnx",820 "greater_broadcast_axis1.nnp",821 "out_data_1", "exec_0")822def test_nnp_onnx_conversion_greater_broadcast_axis1(tmpdir, nnp_fixture):823 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):824 pytest.skip('CAFFE2 does not installed.')825 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,826 "greater_broadcast_axis1.nnp",827 "greater_broadcast_axis1.onnx",828 "out_data_1", "exec_0")829def test_onnx_nnp_conversion_equal_no_broadcast_bool(tmpdir, nnp_fixture):830 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):831 pytest.skip('CAFFE2 does not installed.')832 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,833 "equal_no_broadcast_bool.onnx",834 "equal_no_broadcast_bool.nnp",835 "out_data_1", "exec_0")836def test_nnp_onnx_conversion_equal_no_broadcast_bool(tmpdir, nnp_fixture):837 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):838 pytest.skip('CAFFE2 does not installed.')839 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,840 "equal_no_broadcast_bool.nnp",841 "equal_no_broadcast_bool.onnx",842 "out_data_1", "exec_0")843def test_onnx_nnp_conversion_equal_broadcast_axis1_bool(tmpdir, nnp_fixture):844 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):845 pytest.skip('CAFFE2 does not installed.')846 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,847 "equal_broadcast_axis1_bool.onnx",848 "equal_broadcast_axis1_bool.nnp",849 "out_data_1", "exec_0")850def test_nnp_onnx_conversion_equal_broadcast_axis1_bool(tmpdir, nnp_fixture):851 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):852 pytest.skip('CAFFE2 does not installed.')853 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,854 "equal_broadcast_axis1_bool.nnp",855 "equal_broadcast_axis1_bool.onnx",856 "out_data_1", "exec_0")857def test_onnx_nnp_conversion_equal_no_broadcast_int(tmpdir, nnp_fixture):858 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):859 pytest.skip('CAFFE2 does not installed.')860 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,861 "equal_no_broadcast_int.onnx",862 "equal_no_broadcast_int.nnp",863 "out_data_1", "exec_0")864def test_nnp_onnx_conversion_equal_no_broadcast_int(tmpdir, nnp_fixture):865 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):866 pytest.skip('CAFFE2 does not installed.')867 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,868 "equal_no_broadcast_int.nnp",869 "equal_no_broadcast_int.onnx",870 "out_data_1", "exec_0")871def test_onnx_nnp_conversion_equal_broadcast_axis1_int(tmpdir, nnp_fixture):872 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):873 pytest.skip('CAFFE2 does not installed.')874 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,875 "equal_broadcast_axis1_int.onnx",876 "equal_broadcast_axis1_int.nnp",877 "out_data_1", "exec_0")878def test_nnp_onnx_conversion_equal_broadcast_axis1_int(tmpdir, nnp_fixture):879 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):880 pytest.skip('CAFFE2 does not installed.')881 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,882 "equal_broadcast_axis1_int.nnp",883 "equal_broadcast_axis1_int.onnx",884 "out_data_1", "exec_0")885def test_onnx_nnp_conversion_max(tmpdir, nnp_fixture):886 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):887 pytest.skip('CAFFE2 does not installed.')888 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,889 "max.onnx",890 "max.nnp",891 "out_data_1", "exec_0")892def test_nnp_onnx_conversion_max(tmpdir, nnp_fixture):893 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):894 pytest.skip('CAFFE2 does not installed.')895 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,896 "max.nnp",897 "max.onnx",898 "out_data_1", "exec_0")899def test_onnx_nnp_conversion_min(tmpdir, nnp_fixture):900 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):901 pytest.skip('CAFFE2 does not installed.')902 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,903 "min.onnx",904 "min.nnp",905 "out_data_1", "exec_0")906def test_nnp_onnx_conversion_min(tmpdir, nnp_fixture):907 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):908 pytest.skip('CAFFE2 does not installed.')909 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,910 "min.nnp",911 "min.onnx",912 "out_data_1", "exec_0")913def test_onnx_nnp_conversion_exp(tmpdir, nnp_fixture):914 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):915 pytest.skip('CAFFE2 does not installed.')916 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,917 "exp.onnx",918 "exp.nnp",919 "out_data_1", "exec_0")920def test_nnp_onnx_conversion_exp(tmpdir, nnp_fixture):921 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):922 pytest.skip('CAFFE2 does not installed.')923 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,924 "exp.nnp",925 "exp.onnx",926 "out_data_1", "exec_0")927def test_onnx_nnp_conversion_identity(tmpdir, nnp_fixture):928 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):929 pytest.skip('CAFFE2 does not installed.')930 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,931 "identity.onnx",932 "identity.nnp",933 "out_data_1", "exec_0")934def test_nnp_onnx_conversion_identity(tmpdir, nnp_fixture):935 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):936 pytest.skip('CAFFE2 does not installed.')937 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,938 "identity.nnp",939 "identity.onnx",940 "out_data_1", "exec_0")941def test_onnx_nnp_conversion_prelu_c1(tmpdir, nnp_fixture):942 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):943 pytest.skip('CAFFE2 does not installed.')944 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,945 "prelu_c1.onnx",946 "prelu_c1.nnp",947 "out_data_1", "exec_0")948def test_nnp_onnx_conversion_prelu_c1(tmpdir, nnp_fixture):949 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):950 pytest.skip('CAFFE2 does not installed.')951 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,952 "prelu_c1.nnp",953 "prelu_c1.onnx",954 "out_data_1", "exec_0")955def test_onnx_nnp_conversion_prelu_c3(tmpdir, nnp_fixture):956 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):957 pytest.skip('CAFFE2 does not installed.')958 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,959 "prelu_c3.onnx",960 "prelu_c3.nnp",961 "out_data_1", "exec_0")962def test_nnp_onnx_conversion_prelu_c3(tmpdir, nnp_fixture):963 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):964 pytest.skip('CAFFE2 does not installed.')965 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,966 "prelu_c3.nnp",967 "prelu_c3.onnx",968 "out_data_1", "exec_0")969def test_onnx_nnp_conversion_reciprocal(tmpdir, nnp_fixture):970 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):971 pytest.skip('CAFFE2 does not installed.')972 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,973 "reciprocal.onnx",974 "reciprocal.nnp",975 "Reciprocal4_Output_0", "exec_0")976def test_nnp_onnx_conversion_reciprocal(tmpdir, nnp_fixture):977 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):978 pytest.skip('CAFFE2 does not installed.')979 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,980 "reciprocal.nnp",981 "reciprocal.onnx",982 "Reciprocal4_Output_0", "exec_0")983def test_onnx_nnp_conversion_reduce_min(tmpdir, nnp_fixture):984 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):985 pytest.skip('CAFFE2 does not installed.')986 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,987 "reduce_min.onnx",988 "reduce_min.nnp",989 "ReduceElements7_Output_0", "exec_0")990def test_nnp_onnx_conversion_reduce_min(tmpdir, nnp_fixture):991 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):992 pytest.skip('CAFFE2 does not installed.')993 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,994 "reduce_min.nnp",995 "reduce_min.onnx",996 "ReduceElements7_Output_0", "exec_0")997def test_onnx_nnp_conversion_reduce_max(tmpdir, nnp_fixture):998 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):999 pytest.skip('CAFFE2 does not installed.')1000 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,1001 "reduce_max.onnx",1002 "reduce_max.nnp",1003 "ReduceElements7_Output_0", "exec_0")1004def test_nnp_onnx_conversion_reduce_max(tmpdir, nnp_fixture):1005 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1006 pytest.skip('CAFFE2 does not installed.')1007 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,1008 "reduce_max.nnp",1009 "reduce_max.onnx",1010 "ReduceElements7_Output_0", "exec_0")1011def test_onnx_nnp_conversion_neg(tmpdir, nnp_fixture):1012 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1013 pytest.skip('CAFFE2 does not installed.')1014 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,1015 "neg.onnx",1016 "neg.nnp",1017 "Negate4_Output_0", "exec_0")1018def test_nnp_onnx_conversion_neg(tmpdir, nnp_fixture):1019 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1020 pytest.skip('CAFFE2 does not installed.')1021 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,1022 "neg.nnp",1023 "neg.onnx",1024 "Negate4_Output_0", "exec_0")1025def test_onnx_nnp_conversion_log_softmax(tmpdir, nnp_fixture):1026 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1027 pytest.skip('CAFFE2 does not installed.')1028 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,1029 "log_softmax.onnx",1030 "log_softmax.nnp",1031 "Block17_Output_0", "exec_0")1032def test_nnp_onnx_conversion_log_softmax(tmpdir, nnp_fixture):1033 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1034 pytest.skip('CAFFE2 does not installed.')1035 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,1036 "log_softmax.nnp",1037 "log_softmax.onnx",1038 "Block17_Output_0", "exec_0")1039def test_onnx_nnp_conversion_clip_maxNone_minNone(tmpdir, nnp_fixture):1040 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1041 pytest.skip('CAFFE2 does not installed.')1042 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,1043 "clip_maxNone_minNone.onnx",1044 "clip_maxNone_minNone.nnp",1045 "out_data_1", "exec_0")1046def test_nnp_onnx_conversion_clip_maxNone_minNone(tmpdir, nnp_fixture):1047 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1048 pytest.skip('CAFFE2 does not installed.')1049 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,1050 "clip_maxNone_minNone.nnp",1051 "clip_maxNone_minNone.onnx",1052 "out_data_1", "exec_0")1053def test_onnx_nnp_conversion_clip_max1_0_minNone(tmpdir, nnp_fixture):1054 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1055 pytest.skip('CAFFE2 does not installed.')1056 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,1057 "clip_max1.0_minNone.onnx",1058 "clip_max1.0_minNone.nnp",1059 "out_data_1", "exec_0")1060def test_nnp_onnx_conversion_clip_max1_0_minNone(tmpdir, nnp_fixture):1061 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1062 pytest.skip('CAFFE2 does not installed.')1063 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,1064 "clip_max1.0_minNone.nnp",1065 "clip_max1.0_minNone.onnx",1066 "out_data_1", "exec_0")1067def test_onnx_nnp_conversion_clip_maxNone_min_1_0(tmpdir, nnp_fixture):1068 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1069 pytest.skip('CAFFE2 does not installed.')1070 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,1071 "clip_maxNone_min-1.0.onnx",1072 "clip_maxNone_min-1.0.nnp",1073 "out_data_1", "exec_0")1074def test_nnp_onnx_conversion_clip_maxNone_min_1_0(tmpdir, nnp_fixture):1075 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1076 pytest.skip('CAFFE2 does not installed.')1077 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,1078 "clip_maxNone_min-1.0.nnp",1079 "clip_maxNone_min-1.0.onnx",1080 "out_data_1", "exec_0")1081def test_onnx_nnp_conversion_clip_max1_0_min_1_0(tmpdir, nnp_fixture):1082 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1083 pytest.skip('CAFFE2 does not installed.')1084 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,1085 "clip_max1.0_min-1.0.onnx",1086 "clip_max1.0_min-1.0.nnp",1087 "out_data_1", "exec_0")1088def test_nnp_onnx_conversion_clip_max1_0_min_1_0(tmpdir, nnp_fixture):1089 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1090 pytest.skip('CAFFE2 does not installed.')1091 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,1092 "clip_max1.0_min-1.0.nnp",1093 "clip_max1.0_min-1.0.onnx",1094 "out_data_1", "exec_0")1095def test_onnx_nnp_conversion_softplus(tmpdir, nnp_fixture):1096 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1097 pytest.skip('CAFFE2 does not installed.')1098 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,1099 "softplus.onnx",1100 "softplus.nnp",1101 "out_data_1", "exec_0")1102def test_nnp_onnx_conversion_softplus(tmpdir, nnp_fixture):1103 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1104 pytest.skip('CAFFE2 does not installed.')1105 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,1106 "softplus.nnp",1107 "softplus.onnx",1108 "out_data_1", "exec_0")1109def test_onnx_nnp_conversion_softsign(tmpdir, nnp_fixture):1110 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1111 pytest.skip('CAFFE2 does not installed.')1112 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,1113 "softsign.onnx",1114 "softsign.nnp",1115 "out_data_1", "exec_0")1116def test_nnp_onnx_conversion_softsign(tmpdir, nnp_fixture):1117 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1118 pytest.skip('CAFFE2 does not installed.')1119 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,1120 "softsign.nnp",1121 "softsign.onnx",1122 "out_data_1", "exec_0")1123def test_onnx_nnp_conversion_lrn_c4_s3(tmpdir, nnp_fixture):1124 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1125 pytest.skip('CAFFE2 does not installed.')1126 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,1127 "lrn_c4_s3.onnx",1128 "lrn_c4_s3.nnp",1129 "out_data_1", "exec_0")1130def test_nnp_onnx_conversion_lrn_c4_s3(tmpdir, nnp_fixture):1131 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1132 pytest.skip('CAFFE2 does not installed.')1133 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,1134 "lrn_c4_s3.nnp",1135 "lrn_c4_s3.onnx",1136 "out_data_1", "exec_0",1137 atol=1e-4)1138def test_onnx_nnp_conversion_pad_mconstant_v0_pl0_0_0_1_0_1(tmpdir,1139 nnp_fixture):1140 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CNTK_AVAILABLE):1141 pytest.skip('CNTK does not installed.')1142 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,1143 "pad_mconstant_v0_pl0_0_0_1_0_1.onnx",1144 "pad_mconstant_v0_pl0_0_0_1_0_1.nnp",1145 "Pad4_Output_0", "exec_0",1146 backend="cntk")1147def test_nnp_onnx_conversion_pad_mconstant_v0_pl0_0_0_1_0_1(tmpdir,1148 nnp_fixture):1149 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CNTK_AVAILABLE):1150 pytest.skip('CNTK does not installed.')1151 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,1152 "pad_mconstant_v0_pl0_0_0_1_0_1.nnp",1153 "pad_mconstant_v0_pl0_0_0_1_0_1.onnx",1154 "Pad4_Output_0", "exec_0",1155 backend="cntk")1156def test_onnx_nnp_conversion_reduce_prod(tmpdir, nnp_fixture):1157 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CNTK_AVAILABLE):1158 pytest.skip('CNTK does not installed.')1159 convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,1160 "reduce_prod.onnx",1161 "reduce_prod.nnp",1162 "ReduceElements7_Output_0", "exec_0",1163 backend="cntk")1164def test_nnp_onnx_conversion_reduce_prod(tmpdir, nnp_fixture):1165 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1166 pytest.skip('CAFFE2 does not installed.')1167 if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CNTK_AVAILABLE):1168 pytest.skip('CNTK does not installed.')1169 convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,1170 "reduce_prod.nnp",1171 "reduce_prod.onnx",1172 "ReduceElements7_Output_0", "exec_0",1173 backend="cntk")1174# Even sized LRN is not tested because we only support1175# Odd sizes for now.1176# def test_onnx_nnp_conversion_lrn_c3_s2(tmpdir, nnp_fixture):1177# if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1178# pytest.skip('CAFFE2 does not installed.')1179# convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,1180# "lrn_c3_s2.onnx",1181# "lrn_c3_s2.nnp",1182# "out_data_1", "exec_0")1183# def test_onnx_nnp_conversion_squeezenet(tmpdir, nnp_fixture):1184# if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1185# pytest.skip('CAFFE2 does not installed.')1186# img = np.random.rand(1, 3, 224, 224).astype(np.float32)1187# convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,1188# "squeezenet.onnx", "squeezenet.nnp",1189# "softmaxout_1", "exec_0",1190# in_name="data_0", in_img=img)1191# def test_nnp_onnx_conversion_squeezenet(tmpdir, nnp_fixture):1192# if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1193# pytest.skip('CAFFE2 does not installed.')1194# img = np.random.rand(1, 3, 224, 224).astype(np.float32)1195# convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,1196# "squeezenet.nnp", "squeezenet.onnx",1197# "softmaxout_1", "exec_0",1198# in_name="data_0", in_img=img)1199# def test_nnp_onnx_conversion_lenet(tmpdir, nnp_fixture):1200# if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1201# pytest.skip('CAFFE2 does not installed.')1202# img = np.random.rand(128, 1, 28, 28).astype(np.float32)1203# convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,1204# "lenet_result.nnp",1205# "lenet_result.onnx",1206# "y", "Runtime",1207# in_name="x", in_img=img)1208# @pytest.mark.slow1209# def test_onnx_nnp_conversion_inception_v2(tmpdir, nnp_fixture):1210# if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1211# pytest.skip('CAFFE2 does not installed.')1212# img = np.random.rand(1, 3, 224, 224).astype(np.float32)1213# convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,1214# "inception_v2.onnx", "inception_v2.nnp",1215# "prob_1", "exec_0",1216# in_name="data_0", in_img=img)1217# @pytest.mark.slow1218# def test_nnp_onnx_conversion_inception_v2(tmpdir, nnp_fixture):1219# if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1220# pytest.skip('CAFFE2 does not installed.')1221# img = np.random.rand(1, 3, 224, 224).astype(np.float32)1222# convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,1223# "inception_v2.nnp", "inception_v2.onnx",1224# "prob_1", "exec_0",1225# in_name="data_0", in_img=img)1226# @pytest.mark.slow1227# def test_onnx_nnp_conversion_densenet121(tmpdir, nnp_fixture):1228# if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1229# pytest.skip('CAFFE2 does not installed.')1230# img = np.random.rand(1, 3, 224, 224).astype(np.float32)1231# convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,1232# "densenet121.onnx", "densenet121.nnp",1233# "fc6_1", "exec_0",1234# in_name="data_0", in_img=img, atol=1e-5)1235# @pytest.mark.slow1236# def test_nnp_onnx_conversion_densenet121(tmpdir, nnp_fixture):1237# if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1238# pytest.skip('CAFFE2 does not installed.')1239# img = np.random.rand(1, 3, 224, 224).astype(np.float32)1240# convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,1241# "densenet121.nnp", "densenet121.onnx",1242# "fc6_1", "exec_0",1243# in_name="data_0", in_img=img, atol=1e-5)1244# @pytest.mark.slow1245# def test_onnx_nnp_conversion_resnet50(tmpdir, nnp_fixture):1246# if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1247# pytest.skip('CAFFE2 does not installed.')1248# img = np.random.rand(1, 3, 224, 224).astype(np.float32)1249# convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,1250# "resnet50.onnx", "resnet50.nnp",1251# "gpu_0/softmax_1", "exec_0",1252# in_name="gpu_0/data_0", in_img=img,1253# atol=1e-5)1254# @pytest.mark.slow1255# def test_nnp_onnx_conversion_resnet50(tmpdir, nnp_fixture):1256# if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1257# pytest.skip('CAFFE2 does not installed.')1258# img = np.random.rand(1, 3, 224, 224).astype(np.float32)1259# convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,1260# "resnet50.nnp", "resnet50.onnx",1261# "gpu_0/softmax_1", "exec_0",1262# in_name="gpu_0/data_0", in_img=img,1263# atol=1e-5)1264# @pytest.mark.slow1265# def test_onnx_nnp_conversion_vgg19(tmpdir, nnp_fixture):1266# if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1267# pytest.skip('CAFFE2 does not installed.')1268# img = np.random.rand(1, 3, 224, 224).astype(np.float32)1269# convert_onnx_to_nnp_and_compare(1270# tmpdir, TEST_DATA_DIR, "vgg19.onnx", "vgg19.nnp", "prob_1", "exec_0",1271# in_name="data_0", in_img=img)1272# @pytest.mark.slow1273# def test_nnp_onnx_conversion_vgg19(tmpdir, nnp_fixture):1274# if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1275# pytest.skip('CAFFE2 does not installed.')1276# img = np.random.rand(1, 3, 224, 224).astype(np.float32)1277# convert_nnp_to_onnx_and_compare(1278# tmpdir, TEST_DATA_DIR, "vgg19.nnp", "vgg19.onnx", "prob_1", "exec_0",1279# in_name="data_0", in_img=img)1280# @pytest.mark.slow1281# def test_onnx_nnp_conversion_zfnet512(tmpdir, nnp_fixture):1282# if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1283# pytest.skip('CAFFE2 does not installed.')1284# img = np.random.rand(1, 3, 224, 224).astype(np.float32)1285# convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,1286# "zfnet512.onnx", "zfnet512.nnp",1287# "gpu_0/softmax_1", "exec_0",1288# in_name="gpu_0/data_0", in_img=img)1289# @pytest.mark.slow1290# def test_nnp_onnx_conversion_zfnet512(tmpdir, nnp_fixture):1291# if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1292# pytest.skip('CAFFE2 does not installed.')1293# img = np.random.rand(1, 3, 224, 224).astype(np.float32)1294# convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,1295# "zfnet512.nnp", "zfnet512.onnx",1296# "gpu_0/softmax_1", "exec_0",1297# in_name="gpu_0/data_0", in_img=img)1298# @pytest.mark.slow1299# def test_onnx_nnp_conversion_bvlc_googlenet(tmpdir, nnp_fixture):1300# if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1301# pytest.skip('CAFFE2 does not installed.')1302# img = np.random.rand(1, 3, 224, 224).astype(np.float32)1303# convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,1304# "bvlc_googlenet.onnx",1305# "bvlc_googlenet.nnp",1306# "prob_1", "exec_0",1307# in_name="data_0", in_img=img)1308# @pytest.mark.slow1309# def test_nnp_onnx_conversion_bvlc_googlenet(tmpdir, nnp_fixture):1310# if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1311# pytest.skip('CAFFE2 does not installed.')1312# img = np.random.rand(1, 3, 224, 224).astype(np.float32)1313# convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,1314# "bvlc_googlenet.nnp",1315# "bvlc_googlenet.onnx",1316# "prob_1", "exec_0",1317# in_name="data_0", in_img=img,1318# atol=1e-5)1319# @pytest.mark.slow1320# def test_onnx_nnp_conversion_bvlc_caffenet(tmpdir, nnp_fixture):1321# if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1322# pytest.skip('CAFFE2 does not installed.')1323# img = np.random.rand(1, 3, 224, 224).astype(np.float32)1324# convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,1325# "bvlc_caffenet.onnx", "bvlc_caffenet.nnp",1326# "prob_1", "exec_0",1327# in_name="data_0", in_img=img)1328# @pytest.mark.slow1329# def test_nnp_onnx_conversion_bvlc_caffenet(tmpdir, nnp_fixture):1330# if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1331# pytest.skip('CAFFE2 does not installed.')1332# img = np.random.rand(1, 3, 224, 224).astype(np.float32)1333# convert_nnp_to_onnx_and_compare(tmpdir, TEST_DATA_DIR,1334# "bvlc_caffenet.nnp",1335# "bvlc_caffenet.onnx",1336# "prob_1", "exec_0",1337# in_name="data_0", in_img=img)1338# @pytest.mark.slow1339# def test_onnx_nnp_conversion_shufflenet(tmpdir, nnp_fixture):1340# if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1341# pytest.skip('CAFFE2 does not installed.')1342# img = np.random.rand(1, 3, 224, 224).astype(np.float32)1343# convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,1344# "shufflenet.onnx", "shufflenet.nnp",1345# "gpu_0/softmax_1", "exec_0",1346# in_name="gpu_0/data_0", in_img=img)1347# @pytest.mark.slow1348# def test_onnx_nnp_conversion_mnist(tmpdir, nnp_fixture):1349# if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CNTK_AVAILABLE):1350# pytest.skip('CNTK does not installed.')1351# img = np.random.rand(1, 1, 28, 28).astype(np.float32)1352# convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,1353# "mnist.onnx", "mnist.nnp",1354# "Plus214_Output_0", "exec_0",1355# in_name="Input3", in_img=img,1356# backend="cntk",1357# export_nnp_path=TEST_DATA_DIR)1358# @pytest.mark.slow1359# def test_onnx_nnp_conversion_inception_v1(tmpdir, nnp_fixture):1360# if not (REFERENCE_AVAILABLE and ONNX_AVAILABLE and CAFFE2_AVAILABLE):1361# pytest.skip('CAFFE2 does not installed.')1362# img = np.random.rand(1, 3, 224, 224).astype(np.float32)1363# convert_onnx_to_nnp_and_compare(tmpdir, TEST_DATA_DIR,1364# "inception_v1.onnx", "inception_v1.nnp",1365# "prob_1", "exec_0",...

Full Screen

Full Screen

start_recording.py

Source:start_recording.py Github

copy

Full Screen

1"""2start_recording.py3Representation of Bandwidth's StartRecording BXML verb4@copyright Bandwidth INC5"""6from lxml import etree7from .base_verb import AbstractBxmlVerb8START_RECORDING_TAG = "StartRecording"9class StartRecording(AbstractBxmlVerb):10 def __init__(self, tag=None, username=None, password=None, recording_available_url=None, recording_available_method=None,11 file_format=None, multi_channel=None, transcribe=None, transcription_available_url=None, transcription_available_method=None):12 """13 Initializes the Record class with the following parameters14 :param str tag: Optional tag to include in the callback15 :param str username: Username for http authentication on the redirect url16 :param str password: Password for http authentication on the redirect url17 :param str recording_available_url: URL for record available callback18 :param str recording_available_method: HTTP method for record available callback19 :param str file_format: The file format to save the recording in20 :param bool multi_channel: Whether or not to record the channels separately (default is false, 1 recording)21 :param bool transcribe: True to transcribe the recording on completion, False otherwise22 :param str transcription_available_url: URL to send the transcriptionAvailable event to.23 :param str transcription_available_method: The HTTP method to use for the request to transcriptionAvailableUrl. GET or POST24 """25 self.tag = tag26 self.username = username27 self.password = password28 self.recording_available_url = recording_available_url29 self.recording_available_method = recording_available_method30 self.file_format = file_format31 self.multi_channel = multi_channel32 self.transcribe = transcribe33 self.transcription_available_url = transcription_available_url34 self.transcription_available_method = transcription_available_method35 def to_bxml(self):36 root = etree.Element(START_RECORDING_TAG)37 if self.tag is not None:38 root.set("tag", self.tag)39 if self.username is not None:40 root.set("username", self.username)41 if self.password is not None:42 root.set("password", self.password)43 if self.recording_available_url is not None:44 root.set("recordingAvailableUrl", self.recording_available_url)45 if self.recording_available_method is not None:46 root.set("recordingAvailableMethod", self.recording_available_method)47 if self.file_format is not None:48 root.set("fileFormat", self.file_format)49 if self.multi_channel is not None:50 #Convert True to "true", or False to "false"51 strn = "true" if self.multi_channel else "false"52 root.set("multiChannel", strn)53 if self.transcribe is not None:54 #Convert True to "true", or False to "false"55 strn = "true" if self.transcribe else "false"56 root.set("transcribe", strn)57 if self.transcription_available_url is not None:58 root.set("transcriptionAvailableUrl", self.transcription_available_url)59 if self.transcription_available_method is not None:60 root.set("transcriptionAvailableMethod", self.transcription_available_method)...

Full Screen

Full Screen

availability.py

Source:availability.py Github

copy

Full Screen

...31 Should return a boolean and a reason32 """33 return False, _("unavailable")34# Common availability policies35class Unavailable(Base):36 """37 Policy for when a product is unavailable38 """39 code = 'unavailable'40 message = _("Unavailable")41class Available(Base):42 """43 For when a product is always available, irrespective of stock level.44 This might be appropriate for digital products where stock doesn't need to45 be tracked and the product is always available to buy.46 """47 code = 'available'48 message = _("Available")49 def is_purchase_permitted(self, quantity):...

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 hypothesis 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