def test_basic(dev, target): mod, params = mlp.get_workload(batch_size=1) if not profiler_vm.enabled(): return exe = relay.vm.compile(mod, target, params=params) vm = profiler_vm.VirtualMachineProfiler(exe, dev) data = np.random.rand(1, 1, 28, 28).astype("float32") res = vm.profile(tvm.nd.array(data), func_name="main") assert "softmax" in str(res)
def test_basic(): mod, params = resnet.get_workload() if not profiler_vm.enabled(): return for target, dev in enabled_targets(): exe = relay.vm.compile(mod, target, params=params) vm = profiler_vm.VirtualMachineProfiler(exe, dev) data = np.random.rand(1, 3, 224, 224).astype("float32") res = vm.invoke("main", [data]) print("\n{}".format(vm.get_stat())) print("\n{}".format(vm.get_stat(False)))
def test_basic(): mod, params = resnet.get_workload() target = 'llvm' ctx = tvm.cpu() if not profiler_vm.enabled(): return exe = relay.vm.compile(mod, target, params=params) vm = profiler_vm.VirtualMachineProfiler(exe, ctx) data = np.random.rand(1, 3, 224, 224).astype('float32') res = vm.invoke("main", [data]) print("\n{}".format(vm.get_stat())) print("\n{}".format(vm.get_stat(False)))
rows = [] reader = csv.reader(f, delimiter=",") # force parsing in_header = True for row in reader: if in_header: headers = row in_header = False rows = [[] for x in headers] else: for i in range(len(row)): rows[i].append(row[i]) return dict(zip(headers, rows)) @pytest.mark.skipif(not profiler_vm.enabled(), reason="VM Profiler not enabled") @tvm.testing.parametrize_targets def test_vm(target, dev): dtype = "float32" x = relay.var("x", shape=(relay.Any(), relay.Any()), dtype=dtype) y = relay.var("y", shape=(relay.Any(), relay.Any()), dtype=dtype) mod = tvm.IRModule() mod["main"] = relay.Function([x, y], relay.add(x, y)) exe = relay.vm.compile(mod, target) vm = profiler_vm.VirtualMachineProfiler(exe, dev) data = np.random.rand(28, 28).astype("float32") report = vm.profile(data, data, func_name="main") assert "fused_add" in str(report) assert "Total" in str(report)
rows = [] reader = csv.reader(f, delimiter=",") # force parsing in_header = True for row in reader: if in_header: headers = row in_header = False rows = [[] for x in headers] else: for i in range(len(row)): rows[i].append(row[i]) return dict(zip(headers, rows)) @pytest.mark.skipif(not profiler_vm.enabled(), reason="VM Profiler not enabled") @tvm.testing.parametrize_targets def test_vm(target, dev): mod, params = mlp.get_workload(1) exe = relay.vm.compile(mod, target, params=params) vm = profiler_vm.VirtualMachineProfiler(exe, dev) data = np.random.rand(1, 1, 28, 28).astype("float32") report = vm.profile(data, func_name="main") assert "fused_nn_softmax" in str(report) assert "Total" in str(report) csv = read_csv(report) assert "Hash" in csv.keys() assert all([float(x) > 0 for x in csv["Duration (us)"]])