id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
25,499
import tensorflow as tf import numpy as np The provided code snippet includes necessary dependencies for implementing the `save_pretrained_model` function. Write a Python function `def save_pretrained_model(sess, outputs, feeds, out_dir, model_name="pretrained")` to solve the following problem: Save pretrained model a...
Save pretrained model and config
25,500
def set(opt, key: str, value): for k in key.split('.')[0:-1]: if not k in opt.keys(): opt[k] = {} opt = opt[k] print(key.index(k), "### key:", k, " v:", opt) opt.update({key[-1]: value})
null
25,501
import os import re import csv import sys import string import time import argparse import json import signal import logging from subprocess import Popen, PIPE import vaitraceDefaults def saityCheck(options: dict): cmd = options['control']['cmd'] if cmd == None or len(cmd) == 0: logging.error("Wrong co...
null
25,502
import os import re import csv import sys import string import time import argparse import json import signal import logging from subprocess import Popen, PIPE import vaitraceDefaults def merge(a: dict, b: dict): if hasattr(a, "keys") and hasattr(b, "keys"): for kb in b.keys(): if kb in a.keys()...
Configuration priority: Configuration File > Command Line > Default
25,503
import sys import os import logging import time import math import copy import threading from ctypes import * import copy import logging import argparse import json def merge(a: dict, b: dict): if hasattr(a, "keys") and hasattr(b, "keys"): for kb in b.keys(): if kb in a.keys(): ...
null
25,504
import sys import os import logging import time import math import copy import threading from ctypes import * import copy import logging import argparse import json def record_data_factory(size=10): class APMRecord(Structure): _fields_ = [('time', c_double), ('data', c_longlong * size)] def output...
null
25,505
import sys import os import ctypes import logging import json from ascii_table import * class indices (ctypes.Structure): _fields_ = [ ("m_index", ctypes.c_uint16), ("m_pc_index", ctypes.c_uint8), ("unused", ctypes.c_uint8) ] class ip_u1 (ctypes.Union): _fields_ = [ ("m_base_...
null
25,506
import sys import os import ctypes import logging import json from ascii_table import * class connectivity(ctypes.Structure): def getConnectivity(path): conn_data = open(path, 'rb').read() conn = connectivity() ret = {} ctypes.memmove(ctypes.pointer(conn), conn_data, len(conn_data)) for i in rang...
null
25,507
import sys import os import ctypes import logging import json from ascii_table import * class mem_u2 (ctypes.Union): _fields_ = [ ("m_base_address", ctypes.c_int64), ("flow_id", ctypes.c_int64) ] class mem_topology (ctypes.Structure): _fields_ = [ ("m_count", ctypes.c_int32), ...
null
25,508
import sys import os import ctypes import logging import json from ascii_table import * path = checkPath() exit(-1) def checkPath(): alt_dirs = [ "/sys/devices/platform/amba/amba:zyxclmm_drm/", "/sys/devices/platform/axi/axi:zyxclmm_drm/", "/sys/devices/platform/amba_pl@0/amba_pl@0:zyxclmm_...
null
25,509
import sys import os import ctypes import logging import json from ascii_table import * for dpu_idx in ip_layout['cus'].keys(): DPU_TOPO.setdefault(dpu_idx, {})['name'] = ip_layout['cus'][dpu_idx][0] DPU_TOPO.setdefault(dpu_idx, {})['address'] = ip_layout['cus'][dpu_idx][1] DPU_TOPO.setdefault(dpu_idx, {})[...
null
25,510
from ctypes import * import sys import os import time import atexit import copy power_records = [] def print_statistics(): idle_power = min(power_records) max_power = max(power_records) ave_power = sum(power_records) / len(power_records) report_fmt = "Power Statistics: Idle {:.3f} w, Peak {:.3f} w, Av...
null
25,511
import sys import os import logging import time import math import copy import threading from ctypes import * import copy import logging import json def merge(a: dict, b: dict): if hasattr(a, "keys") and hasattr(b, "keys"): for kb in b.keys(): if kb in a.keys(): merge(a[kb], b[k...
null
25,512
def print_ascii_table(rows): headers = tuple(rows[0]) lens = [] def str_len(_x): return len(str(_x)) for i in range(len(headers)): lens.append( str_len(max([x[i] for x in rows], key=lambda x: str_len(x)))) formats = [] hformats = [] for i in range(len(header...
null
25,513
import sys import os import platform print(exec_cmd) os.system(exec_cmd) def overlay_fs_bug_exist(): pl = platform.uname().release.split('.') kernel_maj, kernel_min = int(pl[0]), int(pl[1]) if kernel_maj >= 4 and kernel_min >= 8: return False overlay_fs = os.system('o=`df /usr/lib/ |grep overl...
null
25,514
import sys import os import platform def check_ftrace_path(): return True
null
25,515
import sys import os import platform tmp_lib_dir = os.path.join(tmp_dir, "lib") ori_lib_dir = "/usr/lib/." env_cmd = "" print(exec_cmd) os.system(exec_cmd) def overlay_fs_workaround(): # 1. Create temp dir and copy libs os.system("mkdir -p %s" % tmp_lib_dir) print("Copying libraries") os.system("cp -r ...
null
25,516
import sys import os import platform tmp_dir = "/workspace/tmp/" print(exec_cmd) os.system(exec_cmd) def clean_tmp(): print("Removing temp files") os.system("rm -rf %s" % tmp_dir)
null
25,517
import sys import os import platform print(exec_cmd) os.system(exec_cmd) def chmod_cur(): print("Changing mode of current dir") os.system("chmod 777 ./")
null
25,518
import functools import ctypes def vaitrace_start(): pass
null
25,519
import functools import ctypes def vaitrace_stop(): pass
null
25,520
import functools import ctypes def vaitrace_timesync(): pass
null
25,521
import functools import ctypes f_tracepoint = libvart_util.tracepoint_py_func f_tracepoint.argtypes = [ctypes.c_int, ctypes.c_char_p] f_tracepoint.restype = None def vai_tracepoint(func): @functools.wraps(func) def wrapper(*args, **kw): fname = func.__name__ fname_c_char_p = ctypes.c_char_p(byt...
null
25,522
from ctypes import * import logging import tracer.tracerBase import copy import os The provided code snippet includes necessary dependencies for implementing the `checkAPM` function. Write a Python function `def checkAPM()` to solve the following problem: /sys/class/uio/uio1/device/of_node/name Here is the function: ...
/sys/class/uio/uio1/device/of_node/name
25,523
import logging import time __tracers = [] def getTracerInstances() -> list: return __tracers
null
25,524
import logging import time __tracers = [] def getAvailableTracers() -> list: return [t.name for t in __tracers]
null
25,525
import logging import time __tracers = [] def getSourceRequirement() -> list: req = [] for t in __tracers: if type(t.source) is str: req.append(t.source) elif type(t.source) is list: req = req + t.source else: assert (True) return req
null
25,526
import logging import time __tracers = [] def start(): global __start_time __start_time = time.monotonic() for t in __tracers: if t.enabled == False: continue t.start()
null
25,527
import logging import time __tracers = [] def stop(): global __stop_time __stop_time = time.monotonic() for t in __tracers: if t.enabled == False: continue t.stop()
null
25,528
import logging import time __tracers = [] def process(data: dict): for t in __tracers: if t.enabled == False: continue logging.debug("Processing [%s]..." % t.name) t.process(data, [__start_time, __stop_time])
null
25,529
import logging import time __tracers = [] def prepare(options: dict) -> dict: debug = options['control'].get('debug', False) def merge(a: dict, b: dict): if hasattr(a, "keys") and hasattr(b, "keys"): for kb in b.keys(): if kb in a.keys(): merge(a[kb], b[...
null
25,530
import logging import time __tracers = [] def getData(): data = {} for t in __tracers: if t.enabled == False: continue logging.debug("Getting Data [%s]..." % t.name) data.update({t.name: t.getData()}) data.setdefault("timesync", {}).update({t.name: t.timesync}) ...
null
25,531
import logging import time __tracers = [] def register(tracerInstance): __tracers.append(tracerInstance)
null
25,532
import tracer.tracerBase import sys import os import ctypes import logging import json HW_zynq = [ {'type': 'CPU', 'file': ['/proc/cpuinfo', '/sys/kernel/debug/clk/acpu/clk_rate']}, {'type': 'Memory', 'file': ['/proc/meminfo']} ] HW_alveo = [ {'type': 'CPU', 'file': ['/proc/cpui...
null
25,533
from ctypes import * import logging import tracer.tracerBase import copy import os def record_data_factory(size=10): class APMRecord(Structure): _fields_ = [('time', c_double), ('data', c_longlong * size)] def output(self): data_cur = [] list_data = [] data_cur ...
null
25,534
import sys import os import collector import logging import json from tempfile import TemporaryDirectory def trans_col(i): result = {} for rec in i.split(';'): if len(rec.split(':')) < 2: continue k, v = rec.split(':', 1) result.update({k: v}) return result def trans_row...
null
25,535
__collectors = [] def getCollectorInstances(): return __collectors
null
25,536
__collectors = [] def getCollectorInstances(name: str): for c in __collectors: if match(name == c.name): return c return None
null
25,537
__collectors = [] def getAvailableCollectors(): return [c.name for c in __collectors]
null
25,538
__activeCollectors = [] def start(): for c in __activeCollectors: c.start()
null
25,539
__activeCollectors = [] def stop(): for c in __activeCollectors: c.stop()
null
25,540
__collectors = [] __activeCollectors = [] def prepare(conf: dict, requirements: list) -> dict: def match(req: str, collector): if req.lower() == collector.name.lower(): return True return False for name in list(set(requirements)): for c in __collectors: if match...
null
25,541
__activeCollectors = [] The provided code snippet includes necessary dependencies for implementing the `getData` function. Write a Python function `def getData(source=None) -> dict` to solve the following problem: Make sure all avtive has been stopped Here is the function: def getData(source=None) -> dict: data ...
Make sure all avtive has been stopped
25,542
__collectors = [] def register(collectorInstance): __collectors.append(collectorInstance)
null
25,543
import os import sys import time import signal import time import logging from subprocess import Popen, PIPE import collector import tracer import vaitraceCfgManager import vaitraceSetting def handler(signum, frame): logging.info("Killing process...") logging.info("Processing trace data, please wait...") gl...
Help find the path of cmd in PATH
25,544
import os import sys import time import signal from multiprocessing import Process from threading import Thread import collector import tracer import logging pyProc = None def pyRunCtx(pyCmd): sys.argv[:] = pyCmd progname = pyCmd[0] sys.path.insert(0, os.path.dirname(progname)) logging.info("vaitrace co...
Preparing
25,545
import os import re import csv import sys import string import time import argparse import json import signal import platform import gzip import pickle import time import logging from subprocess import Popen, PIPE import tracer import writer import vaitraceCfgManager import vaitraceSetting import writer.vtf.convert imp...
null
25,546
import sys import os import re import platform import logging from vaitraceOptions import merge import vaitraceDefaults def getx86CpuTscKhz(): try: cmd = 'cat /proc/cpuinfo | grep "cpu MHz"' khz = int(float(os.popen(cmd).readlines()[0].split()[3])) * 1000 except: assert () return khz...
null
25,547
import sys import os import argparse import logging import vaitraceCfgManager import vaitraceSetting import vaitraceCppRunner import vaitracePyRunner import vaitraceDefaults import vaitraceWriter The provided code snippet includes necessary dependencies for implementing the `checkPermisson` function. Write a Python fu...
Checking Permission
25,548
import sys import os import argparse import logging import vaitraceCfgManager import vaitraceSetting import vaitraceCppRunner import vaitracePyRunner import vaitraceDefaults import vaitraceWriter def getVersion(): head = "vaitrace ver:\n" version = "" project = "" internal_version = "" try: ...
-o: trace file: save trace file [default: trace.txt] -c: conf: input config file -t: time: tracing time in second(s) -p: python: for tracing python application -v: show version
25,549
import sys import os import argparse import logging import vaitraceCfgManager import vaitraceSetting import vaitraceCppRunner import vaitracePyRunner import vaitraceDefaults import vaitraceWriter def printHelpExit(parser): parser.print_help() exit(-1)
null
25,550
import csv import time import pickle import sys import os import gzip import logging from writer.parser.vart_parser import * from writer.parser.tracepointUtil import * from writer.parser.statUtil import * from writer.parser.pyfunc import * from writer.parser.cppfunc import * nmu_events = [] nmu_info = {} def convert_n...
null
25,551
from .ascii_table import * from collections import namedtuple import sys import os import logging from writer.parser.vart_parser import * from writer.parser.tracepointUtil import * from writer.parser.statUtil import * from writer.parser.pyfunc import * from writer.parser.cppfunc import * from writer.parser.cpu_task imp...
null
25,552
from enum import Enum, auto class vaiTimelineEvent: def __str__(self): if self.type == 'period': t = "Duration:%10.8f" % self.duration else: t = "TimeStamp:%10.8f" % self.ts return "Core %10s-%02d: Type:%6s, pid:%06d ts:%f" % \ (self.coreType, self.coreId,...
null
25,553
from enum import Enum, auto class vaiTimeline: def __init__(self, _coreType, _coreId: str, options: dict, _timeout: int = 0): self.coreType = _coreType self.coreId = _coreId self.dpuCore = None self.lastTraceItem = None self.timeline = [] self.eventStack = [] ...
null
25,554
import re from writer.parser.timelineUtil import * pattFtrace = re.compile( r""" (?P<taskComm>.+)\- (?P<taskPid>\d{1,})\s+\[ (?P<cpuID>\d{3})\].{4,}\s (?P<timeStamp>\d+\.\d{6})\:\s+ (?P<func>[\w:]+)\:\s+ (?P<info>.*) """, re.X | re.M ) class ftraceEvent: ...
Selet trace clock
25,555
import time import os import math import logging import decimal import json import vaitraceSetting from copy import deepcopy from writer.parser.timelineUtil import * from writer.parser.tracepointUtil import * from writer.parser import xmodel_parser import writer.parser.statUtil from writer.parser.unitUtil import * POIN...
Add FPS data
25,556
from writer.parser.timelineUtil import * from writer.parser.tracepointUtil import * from writer.parser.statUtil import * from functools import reduce def get_funcname(data: dict) -> str: return
null
25,557
from writer.parser.timelineUtil import * from writer.parser.tracepointUtil import * from writer.parser.statUtil import * from functools import reduce def cpuTaskPaired(start: vaiTimelineEvent, end: vaiTimelineEvent): if not (start.type == 'start' and end.type == 'done'): return None if end.ts < start.ts...
null
25,558
from writer.parser.timelineUtil import * from writer.parser.tracepointUtil import * from writer.parser.statUtil import * def get_funcname(data: dict) -> str: return
null
25,559
from writer.parser.timelineUtil import * from writer.parser.tracepointUtil import * from writer.parser.statUtil import * def pyFuncPaired(start: vaiTimelineEvent, end: vaiTimelineEvent): if not (start.type == 'start' and end.type == 'done'): return None if end.ts < start.ts: return None if s...
null
25,560
import sys import os.path import xml.etree.ElementTree as ET from python import Root from functools import reduce class mcInst: def __init__(self, inst): self.inst = inst def code_gen(self): inst = self.inst words = [] reserved_id = 1 reserved_name = "redvered" fo...
null
25,561
def to_Ki(_num): return _num / 1000.0
null
25,562
def to_Mi(_num): return _num / 1000.0 / 1000.0
null
25,563
def to_Gi(_num): return _num / 1000.0 / 1000.0 / 1000.0
null
25,564
def to_KB(_num): return _num / 1000.0
null
25,565
def to_MB(_num): return _num / 1000.0 / 1000.0
null
25,566
def to_GB(_num): return _num / 1000.0 / 1000.0 / 1000.0
null
25,567
from functools import reduce import sys import os import logging import copy from ctypes import * import json import logging import binascii from . import dpu_mc_parser def idx_to_name(idx): return idx.rsplit('|', 2)[0]
null
25,568
from functools import reduce import sys import os import logging import copy from ctypes import * import json import logging import binascii from . import dpu_mc_parser SUBGRAPH_DB = {} def get_subg_info(sub_g: dict, rank_id): """ Example subg data { "subgraph_name":"subgraph_pool5","id":"0-3","dpu_name":""...
null
25,569
from writer.parser.timelineUtil import * import re def select_trace(trace_data, sel_by, val) -> []: if trace_data is None: return [] return [d for d in trace_data if d.get(sel_by, None) == val]
null
25,570
from writer.parser.timelineUtil import * import re def select_trace_classes(trace_data, classes) -> []: if type(classes) != list: raise TypeError if trace_data is None: return [] return [d for d in trace_data if d.get("classname", None) in classes]
null
25,571
from writer.parser.timelineUtil import * import re class tracepointEvent: def __init__(self, l: dict): """event_state: 1: start, 0: end, -1: not defined""" self.event_state = int(l.pop("event_state", -1)) self.pid = int(l.pop("pid", 0)) self.cpu_id = int(l.pop("cpu_id", -1)) ...
Selet trace clock
25,572
from writer.parser.timelineUtil import * from writer.parser.tracepointUtil import * from writer.parser.statUtil import * from writer.parser.ftraceUtil import * def cppFuncPaired(start: vaiTimelineEvent, end: vaiTimelineEvent): if not (start.type == 'start' and end.type == 'done'): return None if end.ts ...
null
25,573
from writer.parser.tracepointUtil import * def analyse_power(data): power_report = {} if len(data) == 0: return {} idle_power = min(data) peak_power = max(data) ave_power = sum(data) / len(data) power_report["idle_power"] = idle_power power_report["peak_power"] = peak_power p...
null
25,574
import sys import os import logging import copy from ctypes import * import logging import binascii __dpu_mc_parser = [] def process_mc(dpu_name: str, mc_data_str: str, _debug=True, ret_items=["load_img_size", "load_para_size", "save_size", "workload"]) -> list: # init return data with 0 ret = [] for i in ...
null
25,575
import sys import os import logging import copy from ctypes import * import logging import binascii __dpu_mc_parser = [] def register(mcParserInstance): __dpu_mc_parser.append(mcParserInstance)
null
25,576
from ctypes import * from typing import List import cv2 import numpy as np import vart import pathlib import xir import os import math import threading import time import sys def CPUCalcSoftmax(data, size, scale): sum = 0.0 result = [0 for i in range(size)] for i in range(size): result[i] = math.ex...
null
25,577
from ctypes import * from typing import List import cv2 import numpy as np import vart import pathlib import xir import os import math import threading import time import sys def get_script_directory(): path = os.getcwd() return path
null
25,578
from ctypes import * from typing import List import cv2 import numpy as np import vart import pathlib import xir import os import math import threading import time import sys def TopK(datain, size, filePath): cnt = [i for i in range(size)] pair = zip(datain, cnt) pair = sorted(pair, reverse=True) soft...
null
25,579
from ctypes import * from typing import List import cv2 import numpy as np import vart import pathlib import xir import os import math import threading import time import sys MEANS = [_B_MEAN, _G_MEAN, _R_MEAN] SCALES = [0.007843137, 0.007843137, 0.007843137] def resize_shortest_edge(image, size): H, W = image.shap...
null
25,580
from ctypes import * from typing import List import cv2 import numpy as np import vart import pathlib import xir import os import math import threading import time import sys The provided code snippet includes necessary dependencies for implementing the `runInceptionV1` function. Write a Python function `def runIncept...
get tensor
25,581
from ctypes import * from typing import List import cv2 import numpy as np import vart import pathlib import xir import os import math import threading import time import sys def get_child_subgraph_dpu(graph: "Graph") -> List["Subgraph"]: assert graph is not None, "'graph' should not be None." root_subgraph = ...
null
25,582
from ctypes import * from typing import List import cv2 import numpy as np import xir import vart import os import math import threading import time import sys def CPUCalcSoftmax(data, size, scale): sum = 0.0 result = [0 for i in range(size)] for i in range(size): result[i] = math.exp(data[i] * sca...
null
25,583
from ctypes import * from typing import List import cv2 import numpy as np import xir import vart import os import math import threading import time import sys def get_script_directory(): path = os.getcwd() return path
null
25,584
from ctypes import * from typing import List import cv2 import numpy as np import xir import vart import os import math import threading import time import sys def TopK(datain, size, filePath): cnt = [i for i in range(size)] pair = zip(datain, cnt) pair = sorted(pair, reverse=True) softmax_new, cnt_ne...
null
25,585
from ctypes import * from typing import List import cv2 import numpy as np import xir import vart import os import math import threading import time import sys MEANS = [_B_MEAN, _G_MEAN, _R_MEAN] SCALES = [1.0, 1.0, 1.0] def preprocess_one_image_fn(image_path, fix_scale, width=224, height=224): means = MEANS s...
null
25,586
from ctypes import * from typing import List import cv2 import numpy as np import xir import vart import os import math import threading import time import sys The provided code snippet includes necessary dependencies for implementing the `runResnet50` function. Write a Python function `def runResnet50(runner: "Runner...
get tensor
25,587
from ctypes import * from typing import List import cv2 import numpy as np import xir import vart import os import math import threading import time import sys def get_child_subgraph_dpu(graph: "Graph") -> List["Subgraph"]: assert graph is not None, "'graph' should not be None." root_subgraph = graph.get_root_...
null
25,588
from typing import List import cv2 import numpy as np import sys import math import xir import vart def preprocess_one_image(image_path, width, height, means , scales, fixpos): image = cv2.imread(image_path) image = cv2.resize(image,(width, height)) B, G, R = cv2.split(image) fix_scale = 2 ** fixpos B =...
null
25,589
from typing import List import cv2 import numpy as np import sys import math import xir import vart def CPUCalcSoftmax(data, size): sum = 0.0 result = [0 for i in range(size)] for i in range(size): result[i] = math.exp(data[i]) sum += result[i] for i in range(size): result[i] /=...
null
25,590
from typing import List import cv2 import numpy as np import sys import math import xir import vart def TopK(datain, size, filePath): cnt = [i for i in range(size)] pair = zip(datain, cnt) pair = sorted(pair, reverse=True) softmax_new, cnt_new = zip(*pair) fp = open(filePath, "r") data1 = fp.re...
null
25,591
from typing import List import cv2 import numpy as np import sys import math import xir import vart def get_child_subgraph_dpu(graph: "Graph") -> List["Subgraph"]: assert graph is not None, "'graph' should not be None." root_subgraph = graph.get_root_subgraph() assert ( root_subgraph is not None ...
null
25,592
import vart def Runner(subgraph, mode): return vart.Runner.create_runner(subgraph, mode)
null
25,593
import os import subprocess import sys import shutil from setuptools import Extension, setup, find_packages from setuptools.command.build_ext import build_ext def get_shell_result(shell_cmd): proc = subprocess.Popen(shell_cmd, stdout=subprocess.PIPE, shell=True) outs, _ = proc.communicate(timeout=2) res = ...
null
25,594
import os import subprocess import sys import shutil from setuptools import Extension, setup, find_packages from setuptools.command.build_ext import build_ext def clean_install_info(): try: for dir_name in ["dist", "target_factory.egg-info"]: if os.path.exists(dir_name): ...
null
25,595
import numpy as np import tensorflow as tf from PIL import Image from OnBoard import SummaryCollector The provided code snippet includes necessary dependencies for implementing the `demo_add_graph_wego_tf2` function. Write a Python function `def demo_add_graph_wego_tf2(logdir)` to solve the following problem: OnBoard ...
OnBoard API Demo for WeGO-TF2.x, introduction of how to use OnBoard when you run a model. It would generate an event file in `logdir` by your defination, you can use exactly the same command of TensorBoard to obtain the visualize results: `tensorboard --logdir=same/as/logdir`.
25,596
import numpy as np import tensorflow as tf from PIL import Image from OnBoard import SummaryCollector The provided code snippet includes necessary dependencies for implementing the `demo_add_graph_tf2` function. Write a Python function `def demo_add_graph_tf2(logdir)` to solve the following problem: OnBoard API Demo f...
OnBoard API Demo for TorchVision models, samely as the usage for WeGO model. OnBoard is not depend on WeGO, you can use it when you run the original Tensorflow 2.x models. The usage of them are exactly the same.
25,597
import numpy as np import tensorflow as tf from PIL import Image from OnBoard import SummaryCollector The provided code snippet includes necessary dependencies for implementing the `demo_add_text` function. Write a Python function `def demo_add_text(logdir)` to solve the following problem: OnBoard API Demo for adding ...
OnBoard API Demo for adding images to visualize in TensorBoard.
25,598
import numpy as np import tensorflow as tf from PIL import Image from OnBoard import SummaryCollector The provided code snippet includes necessary dependencies for implementing the `demo_add_image` function. Write a Python function `def demo_add_image(logdir)` to solve the following problem: OnBoard API Demo for addin...
OnBoard API Demo for adding images to visualize in TensorBoard.