repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
dpkt | dpkt-master/dpkt/tcp.py | # $Id: tcp.py 42 2007-08-02 22:38:47Z jon.oberheide $
# -*- coding: utf-8 -*-
"""Transmission Control Protocol."""
from __future__ import print_function
from __future__ import absolute_import
from . import dpkt
from .compat import compat_ord
# TCP control flags
TH_FIN = 0x01 # end of data
TH_SYN = 0x02 # synchroniz... | 6,969 | 28.659574 | 114 | py |
dpkt | dpkt-master/dpkt/rip.py | # $Id: rip.py 23 2006-11-08 15:45:33Z dugsong $
# -*- coding: utf-8 -*-
"""Routing Information Protocol."""
from __future__ import print_function
from __future__ import absolute_import
from . import dpkt
# RIP v2 - RFC 2453
# http://tools.ietf.org/html/rfc2453
REQUEST = 1
RESPONSE = 2
class RIP(dpkt.Packet):
"... | 2,760 | 21.447154 | 71 | py |
dpkt | dpkt-master/dpkt/diameter.py | # $Id: diameter.py 23 2006-11-08 15:45:33Z dugsong $
# -*- coding: utf-8 -*-
"""Diameter."""
from __future__ import print_function
from __future__ import absolute_import
import struct
from . import dpkt
from .compat import compat_ord
# Diameter Base Protocol - RFC 3588
# http://tools.ietf.org/html/rfc3588
# Request... | 7,453 | 30.991416 | 117 | py |
dpkt | dpkt-master/dpkt/loopback.py | # $Id: loopback.py 38 2007-03-17 03:33:16Z dugsong $
# -*- coding: utf-8 -*-
"""Platform-dependent loopback header."""
# https://wiki.wireshark.org/NullLoopback
from __future__ import absolute_import
from . import dpkt
from . import ethernet
from . import ip
from . import ip6
class Loopback(dpkt.Packet):
"""Pl... | 2,542 | 28.569767 | 102 | py |
dpkt | dpkt-master/dpkt/icmp.py | # $Id: icmp.py 45 2007-08-03 00:05:22Z jon.oberheide $
# -*- coding: utf-8 -*-
"""Internet Control Message Protocol."""
from __future__ import print_function
from __future__ import absolute_import
from . import dpkt
# Types (icmp_type) and codes (icmp_code) -
# http://www.iana.org/assignments/icmp-parameters
ICMP_CO... | 6,235 | 31.649215 | 107 | py |
dpkt | dpkt-master/dpkt/ospf.py | # $Id: ospf.py 23 2006-11-08 15:45:33Z dugsong $
# -*- coding: utf-8 -*-
"""Open Shortest Path First."""
from __future__ import absolute_import
from . import dpkt
AUTH_NONE = 0
AUTH_PASSWORD = 1
AUTH_CRYPTO = 2
class OSPF(dpkt.Packet):
"""Open Shortest Path First.
TODO: Longer class information....
At... | 1,354 | 19.846154 | 65 | py |
dpkt | dpkt-master/dpkt/tftp.py | # $Id: tftp.py 23 2006-11-08 15:45:33Z dugsong $
# -*- coding: utf-8 -*-
"""Trivial File Transfer Protocol."""
from __future__ import print_function
from __future__ import absolute_import
import struct
from . import dpkt
# Opcodes
OP_RRQ = 1 # read request
OP_WRQ = 2 # write request
OP_DATA = 3 # data packet
OP_A... | 3,803 | 28.952756 | 114 | py |
dpkt | dpkt-master/dpkt/http2.py | # -*- coding: utf-8 -*-
"""Hypertext Transfer Protocol Version 2."""
import struct
import codecs
from . import dpkt
HTTP2_PREFACE = b'\x50\x52\x49\x20\x2a\x20\x48\x54\x54\x50\x2f\x32\x2e\x30\x0d\x0a\x0d\x0a\x53\x4d\x0d\x0a\x0d\x0a'
# Frame types
HTTP2_FRAME_DATA = 0
HTTP2_FRAME_HEADERS = 1
HTTP2_FRAME_PRIORITY = 2... | 29,215 | 38.588076 | 115 | py |
dpkt | dpkt-master/dpkt/dhcp.py | # $Id: dhcp.py 23 2006-11-08 15:45:33Z dugsong $
# -*- coding: utf-8 -*-
"""Dynamic Host Configuration Protocol."""
from __future__ import print_function
from __future__ import absolute_import
import struct
from . import arp
from . import dpkt
from .compat import compat_ord
DHCP_OP_REQUEST = 1
DHCP_OP_REPLY = 2
DHC... | 9,433 | 34.6 | 114 | py |
dpkt | dpkt-master/dpkt/pcap.py | # $Id: pcap.py 77 2011-01-06 15:59:38Z dugsong $
# -*- coding: utf-8 -*-
"""Libpcap file format."""
from __future__ import print_function
from __future__ import absolute_import
import sys
import time
from decimal import Decimal
from . import dpkt
from .compat import intround
# big endian magics
TCPDUMP_MAGIC = 0xa1b... | 18,792 | 25.2106 | 108 | py |
dpkt | dpkt-master/dpkt/smb.py | # $Id: smb.py 23 2006-11-08 15:45:33Z dugsong $
# -*- coding: utf-8 -*-
"""Server Message Block."""
from __future__ import print_function
from __future__ import absolute_import
from . import dpkt
# https://msdn.microsoft.com/en-us/library/ee441774.aspx
SMB_FLAGS_LOCK_AND_READ_OK = 0x01
SMB_FLAGS_BUF_AVAIL = 0x02
SM... | 3,730 | 34.875 | 119 | py |
dpkt | dpkt-master/dpkt/rx.py | # $Id: rx.py 23 2006-11-08 15:45:33Z jonojono $
# -*- coding: utf-8 -*-
"""Rx Protocol."""
from __future__ import absolute_import
from . import dpkt
# Types
DATA = 0x01
ACK = 0x02
BUSY = 0x03
ABORT = 0x04
ACKALL = 0x05
CHALLENGE = 0x06
RESPONSE = 0x07
DEBUG = 0x08
# Flags
CLIENT_INITIATED = 0x01
REQUEST_ACK = 0x02
L... | 978 | 16.482143 | 47 | py |
dpkt | dpkt-master/dpkt/mrt.py | # $Id: mrt.py 29 2007-01-26 02:29:07Z jon.oberheide $
# -*- coding: utf-8 -*-
"""Multi-threaded Routing Toolkit."""
from __future__ import absolute_import
from . import dpkt
from . import bgp
# Multi-threaded Routing Toolkit
# http://www.ietf.org/internet-drafts/draft-ietf-grow-mrt-03.txt
# MRT Types
NULL = 0
START ... | 3,168 | 22.131387 | 65 | py |
dpkt | dpkt-master/dpkt/http.py | # $Id: http.py 86 2013-03-05 19:25:19Z [email protected] $
# -*- coding: utf-8 -*-
"""Hypertext Transfer Protocol."""
from __future__ import print_function
from __future__ import absolute_import
from collections import OrderedDict
from . import dpkt
from .compat import BytesIO, iteritems
def parse_headers(f):
... | 22,114 | 36.168067 | 122 | py |
dpkt | dpkt-master/dpkt/hsrp.py | # $Id: hsrp.py 23 2006-11-08 15:45:33Z dugsong $
# -*- coding: utf-8 -*-
"""Cisco Hot Standby Router Protocol."""
from __future__ import absolute_import
from . import dpkt
# Opcodes
HELLO = 0
COUP = 1
RESIGN = 2
# States
INITIAL = 0x00
LEARN = 0x01
LISTEN = 0x02
SPEAK = 0x04
STANDBY = 0x08
ACTIVE = 0x10
class HSRP... | 2,223 | 38.017544 | 120 | py |
dpkt | dpkt-master/dpkt/radius.py | # $Id: radius.py 23 2006-11-08 15:45:33Z dugsong $
# -*- coding: utf-8 -*-
"""Remote Authentication Dial-In User Service."""
from __future__ import absolute_import
from . import dpkt
from .compat import compat_ord
# http://www.untruth.org/~josh/security/radius/radius-auth.html
# RFC 2865
class RADIUS(dpkt.Packet):
... | 4,632 | 25.474286 | 118 | py |
dpkt | dpkt-master/dpkt/dtp.py | # $Id: dtp.py 23 2006-11-08 15:45:33Z dugsong $
# -*- coding: utf-8 -*-
"""Dynamic Trunking Protocol."""
from __future__ import absolute_import
import struct
from . import dpkt
TRUNK_NAME = 0x01
MAC_ADDR = 0x04
class DTP(dpkt.Packet):
"""Dynamic Trunking Protocol.
The Dynamic Trunking Protocol (DTP) is a p... | 1,664 | 24.227273 | 119 | py |
dpkt | dpkt-master/dpkt/aoecfg.py | # -*- coding: utf-8 -*-
"""ATA over Ethernet ATA command"""
from __future__ import print_function
from __future__ import absolute_import
from . import dpkt
class AOECFG(dpkt.Packet):
"""ATA over Ethernet ATA command.
See more about the AOE on \
https://en.wikipedia.org/wiki/ATA_over_Ethernet
Attrib... | 828 | 23.382353 | 96 | py |
dpkt | dpkt-master/dpkt/tns.py | # $Id: tns.py 23 2006-11-08 15:45:33Z dugsong $
# -*- coding: utf-8 -*-
"""Transparent Network Substrate."""
from __future__ import print_function
from __future__ import absolute_import
from . import dpkt
class TNS(dpkt.Packet):
"""Transparent Network Substrate.
TODO: Longer class information....
Attri... | 1,247 | 23.96 | 82 | py |
dpkt | dpkt-master/dpkt/aoe.py | # -*- coding: utf-8 -*-
"""ATA over Ethernet Protocol."""
from __future__ import absolute_import
import struct
from . import dpkt
from .compat import iteritems
class AOE(dpkt.Packet):
"""ATA over Ethernet Protocol.
See more about the AOE on
https://en.wikipedia.org/wiki/ATA_over_Ethernet
Attribute... | 3,460 | 22.228188 | 80 | py |
dpkt | dpkt-master/dpkt/ip6.py | # $Id: ip6.py 87 2013-03-05 19:41:04Z [email protected] $
# -*- coding: utf-8 -*-
"""Internet Protocol, version 6."""
from __future__ import print_function
from __future__ import absolute_import
from . import dpkt
from . import ip
from . import tcp
from .compat import compat_ord
from .utils import inet_to_str
impor... | 21,362 | 35.208475 | 118 | py |
dpkt | dpkt-master/dpkt/icmp6.py | # $Id: icmp6.py 23 2006-11-08 15:45:33Z dugsong $
# -*- coding: utf-8 -*-
"""Internet Control Message Protocol for IPv6."""
from __future__ import absolute_import
from . import dpkt
ICMP6_DST_UNREACH = 1 # dest unreachable, codes:
ICMP6_PACKET_TOO_BIG = 2 # packet too big
ICMP6_TIME_EXCEEDED = 3 # time exceeded, c... | 3,084 | 31.819149 | 119 | py |
dpkt | dpkt-master/dpkt/ipip.py | # Defines a copy of the IP protocol as IPIP so the protocol parsing in ip.py
# can decode IPIP packets.
from __future__ import absolute_import
from .ip import IP as IPIP
| 171 | 27.666667 | 76 | py |
dpkt | dpkt-master/dpkt/ah.py | # $Id: ah.py 34 2007-01-28 07:54:20Z dugsong $
# -*- coding: utf-8 -*-
"""Authentication Header."""
from __future__ import absolute_import
from . import dpkt
from . import ip
class AH(dpkt.Packet):
"""Authentication Header.
The Authentication Header (AH) protocol provides data origin authentication, data i... | 2,265 | 25.045977 | 119 | py |
dpkt | dpkt-master/dpkt/dns.py | # $Id: dns.py 27 2006-11-21 01:22:52Z dahelder $
# -*- coding: utf-8 -*-
"""Domain Name System."""
from __future__ import print_function
from __future__ import absolute_import
import struct
import codecs
from . import dpkt
from .compat import compat_ord
DNS_Q = 0
DNS_R = 1
# Opcodes
DNS_QUERY = 0
DNS_IQUERY = 1
DNS... | 26,308 | 27.077908 | 125 | py |
dpkt | dpkt-master/dpkt/sccp.py | # $Id: sccp.py 23 2006-11-08 15:45:33Z dugsong $
# -*- coding: utf-8 -*-
"""Cisco Skinny Client Control Protocol."""
from __future__ import absolute_import
from . import dpkt
KEYPAD_BUTTON = 0x00000003
OFF_HOOK = 0x00000006
ON_HOOK = 0x00000007
OPEN_RECEIVE_CHANNEL_ACK = 0x00000022
START_TONE = 0x00000082
STOP_TONE =... | 6,545 | 23.516854 | 67 | py |
dpkt | dpkt-master/dpkt/ntp.py | # $Id: ntp.py 48 2008-05-27 17:31:15Z yardley $
# -*- coding: utf-8 -*-
"""Network Time Protocol."""
from __future__ import print_function
from . import dpkt
# NTP v4
# Leap Indicator (LI) Codes
NO_WARNING = 0
LAST_MINUTE_61_SECONDS = 1
LAST_MINUTE_59_SECONDS = 2
ALARM_CONDITION = 3
# Mode Codes
RESERVED = 0
SYMMET... | 2,115 | 24.190476 | 118 | py |
dpkt | dpkt-master/dpkt/__init__.py | """fast, simple packet creation and parsing."""
from __future__ import absolute_import
from __future__ import division
import sys
__author__ = 'Various'
__author_email__ = ''
__license__ = 'BSD-3-Clause'
__url__ = 'https://github.com/kbandla/dpkt'
__version__ = '1.9.8'
from .dpkt import *
from . import ah
from . imp... | 1,865 | 20.697674 | 77 | py |
dpkt | dpkt-master/dpkt/rtp.py | # $Id: rtp.py 23 2006-11-08 15:45:33Z dugsong $
# -*- coding: utf-8 -*-
"""Real-Time Transport Protocol."""
from __future__ import absolute_import
from .dpkt import Packet
# version 1100 0000 0000 0000 ! 0xC000 14
# p 0010 0000 0000 0000 ! 0x2000 13
# x 0001 0000 0000 0000 ! 0x1000 12
# cc 0000 11... | 5,077 | 29.407186 | 99 | py |
dpkt | dpkt-master/dpkt/compat.py | from __future__ import absolute_import
from struct import pack, unpack
import sys
if sys.version_info < (3,):
compat_ord = ord
else:
def compat_ord(char):
return char
try:
from itertools import izip
compat_izip = izip
except ImportError:
compat_izip = zip
try:
from cStringIO import S... | 1,327 | 20.770492 | 87 | py |
dpkt | dpkt-master/dpkt/rfb.py | # $Id: rfb.py 47 2008-05-27 02:10:00Z jon.oberheide $
# -*- coding: utf-8 -*-
"""Remote Framebuffer Protocol."""
from __future__ import absolute_import
from . import dpkt
# Remote Framebuffer Protocol
# http://www.realvnc.com/docs/rfbproto.pdf
# Client to Server Messages
CLIENT_SET_PIXEL_FORMAT = 0
CLIENT_SET_ENCODI... | 1,927 | 18.089109 | 53 | py |
dpkt | dpkt-master/dpkt/ieee80211.py | # $Id: 80211.py 53 2008-12-18 01:22:57Z jon.oberheide $
# -*- coding: utf-8 -*-
"""IEEE 802.11."""
from __future__ import print_function
from __future__ import absolute_import
import struct
from . import dpkt
from .compat import ntole, ntole64
# Frame Types
MGMT_TYPE = 0
CTL_TYPE = 1
DATA_TYPE = 2
# Frame Sub-Types... | 32,495 | 30.276227 | 109 | py |
dpkt | dpkt-master/dpkt/snoop.py | # $Id$
# -*- coding: utf-8 -*-
"""Snoop file format."""
from __future__ import absolute_import
import time
from abc import abstractmethod
from . import dpkt
from .compat import intround
# RFC 1761
SNOOP_MAGIC = 0x736E6F6F70000000
SNOOP_VERSION = 2
SDL_8023 = 0
SDL_8024 = 1
SDL_8025 = 2
SDL_8026 = 3
SDL_ETHER = 4
... | 15,023 | 26.021583 | 81 | py |
dpkt | dpkt-master/dpkt/ssl.py | # $Id: ssl.py 90 2014-04-02 22:06:23Z [email protected] $
# Portion Copyright 2012 Google Inc. All rights reserved.
# -*- coding: utf-8 -*-
"""Secure Sockets Layer / Transport Layer Security."""
from __future__ import absolute_import
import struct
import binascii
from . import dpkt
from . import ssl_ciphersuites
f... | 49,787 | 46.014164 | 123 | py |
dpkt | dpkt-master/dpkt/h225.py | # $Id: h225.py 23 2006-11-08 15:45:33Z dugsong $
# -*- coding: utf-8 -*-
"""ITU-T H.225.0 Call Signaling."""
from __future__ import print_function
from __future__ import absolute_import
import struct
from . import dpkt
from . import tpkt
# H225 Call Signaling
#
# Call messages and information elements (IEs) are def... | 11,388 | 36.837209 | 123 | py |
dpkt | dpkt-master/dpkt/netbios.py | # $Id: netbios.py 23 2006-11-08 15:45:33Z dugsong $
# -*- coding: utf-8 -*-
"""Network Basic Input/Output System."""
from __future__ import absolute_import
import struct
from . import dpkt
from . import dns
from .compat import compat_ord
def encode_name(name):
"""
Return the NetBIOS first-level encoded name... | 10,061 | 29.583587 | 100 | py |
dpkt | dpkt-master/dpkt/asn1.py | # $Id: asn1.py 23 2006-11-08 15:45:33Z dugsong $
# -*- coding: utf-8 -*-
"""Abstract Syntax Notation #1."""
from __future__ import absolute_import
from __future__ import print_function
import struct
from calendar import timegm
from . import dpkt
from .compat import compat_ord
# Type class
CLASSMASK = 0xc0
UNIVERSAL ... | 9,011 | 27.884615 | 112 | py |
dpkt | dpkt-master/dpkt/pcapng.py | """pcap Next Generation file format"""
# Spec: https://pcapng.github.io/pcapng/
# pylint: disable=no-member
# pylint: disable=attribute-defined-outside-init
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division # so python 2 doesn't do integer division
from stru... | 49,325 | 31.366142 | 114 | py |
dpkt | dpkt-master/dpkt/igmp.py | # $Id: igmp.py 23 2006-11-08 15:45:33Z dugsong $
# -*- coding: utf-8 -*-
"""Internet Group Management Protocol."""
from __future__ import absolute_import
from . import dpkt
class IGMP(dpkt.Packet):
"""Internet Group Management Protocol.
TODO: Longer class information....
Attributes:
__hdr__: He... | 1,135 | 21.72 | 65 | py |
dpkt | dpkt-master/dpkt/rtcp.py | # $Id: rtcp.py 23 2023-01-22 11:22:33Z pajarom $
# -*- coding: utf-8 -*-
# RFC3550 and RFC3611
"""RTP Control Protocol."""
from __future__ import absolute_import
from . import dpkt
from .dpkt import Packet
import math
# 0 1 2 3
# 0 1 2 3 4 5 6 7 8... | 40,027 | 34.204925 | 100 | py |
dpkt | dpkt-master/dpkt/vrrp.py | # $Id: vrrp.py 88 2013-03-05 19:43:17Z [email protected] $
# -*- coding: utf-8 -*-
"""Virtual Router Redundancy Protocol."""
from __future__ import print_function
from __future__ import absolute_import
from . import dpkt
class VRRP(dpkt.Packet):
"""Virtual Router Redundancy Protocol.
TODO: Longer class i... | 1,990 | 21.625 | 91 | py |
APNN-TC | APNN-TC-master/cutlass_kernel/run-gemm.py | #!/usr/bin/env python
import os
B = 64
N_K_list = [
128,
256,
384,
512,
640,
768,
896,
1024
]
for N_K in N_K_list:
os.system("./bench_gemm.bin {} {} {}".format(B, N_K, N_K)) | 212 | 10.833333 | 62 | py |
APNN-TC | APNN-TC-master/cutlass_kernel/run-conv.py | #!/usr/bin/env python
import os
os.system("./bench_conv.bin --benchmark --iteration 1000") | 91 | 22 | 58 | py |
APNN-TC | APNN-TC-master/APNN-TC-lib/bmmaTensorCoreGemm/others/bit_and_utility.py | # w = "574528ee 5d2aa02a 4cf15010 52a214fa 32e7ba61 2d357b57 184882df 47a35144 4d75bd23 2a0eaeec 2f31ba80 217dedaf 1a861652 0129747a 3d4f71a6 1e565b6a 12715a44 5c692df2 1f6f4752 65504cc9 4e5785aa 042408ac 2ab32c6b 25521f4a 16a4fb2f 4f3509ca 0ca1a2ad 584a5056 2a39fb9d 52a99e65 2a827cbc 017f248c 2fd43e8f 7773cccd 5421398... | 4,195 | 101.341463 | 1,309 | py |
APNN-TC | APNN-TC-master/APNN-TC-lib/bmmaTensorCoreGemm/others/speed.py | Batch = 8
H = 32
W = 32
CIN = 128
COUT = 128
bmma_ms_avg = 0.0165
TOPS = ((Batch * 9.0 * CIN * H * W * COUT * 2)/(bmma_ms_avg/1000.0)) / 1e12
print("Conv2: ", TOPS)
Batch = 8
H = 16
W = 16
CIN = 128
COUT = 256
bmma_ms_avg = 0.0248
TOPS = ((Batch * 9.0 * CIN * H * W * COUT * 2)/(bmma_ms_avg/1000.0)) / 1e12
print("... | 337 | 13.083333 | 75 | py |
APNN-TC | APNN-TC-master/cutlass_nn/analysis.py | #!/usr/bin/env python3
import re
import sys
if len(sys.argv) < 2:
raise ValueError("Usage: ./1_analysis.py result.log")
fp = open(sys.argv[1], "r")
dataset_li = []
time_li = []
for line in fp:
if "(ms):" in line:
time = re.findall(r'[0-9].[0-9]+', line)[0]
print(time)
time_li.append(... | 618 | 25.913043 | 72 | py |
OPTMLSTM | OPTMLSTM-main/example_OPTM_LSTM.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: Adam Ntakaris ([email protected], @gmail.com)
"""
from keras.layers import Dense
import keras
import numpy as np
import OPTMCell
# Note: Random data example for illustration purposes only
# OPTM-LSTM is a narrow artificial intelligence model
# I... | 1,004 | 27.714286 | 75 | py |
OPTMLSTM | OPTMLSTM-main/OPTMCell.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: Adam Ntakaris ([email protected], @gmail.com)
Important: This is an extension based on
https://github.com/keras-team/keras/blob/v2.10.0/keras/layers/rnn/lstm.py
"""
import tensorflow.compat.v2 as tf
from keras import activations
from keras im... | 13,682 | 35.782258 | 79 | py |
simdutf | simdutf-master/singleheader/amalgamate.py | #!/usr/bin/env python3
#
# Creates the amalgamated source files.
#
import sys
import os.path
import subprocess
import os
import re
import shutil
import datetime
if sys.version_info[0] < 3:
sys.stdout.write("Sorry, requires Python 3.x or better\n")
sys.exit(1)
SCRIPTPATH = os.path.dirname(os.path.abspath(sys.a... | 7,400 | 38.57754 | 134 | py |
simdutf | simdutf-master/benchmarks/dataset/scripts/utf8type.py | #!/usr/bin/env python
import sys
if(len(sys.argv)<2):
print("please provide a file name")
sys.exit(-1)
assert sys.version_info >= (3, 0)
filename = sys.argv[1]
counts=[0,0,0,0]#ascii, ascii+two, ascii+two_three, others
block_count=0
with open(filename, "rb") as file_content:
array = file_content.read()
... | 1,153 | 27.146341 | 81 | py |
simdutf | simdutf-master/benchmarks/dataset/wikipedia_mars/convert_to_utf6.py | #!/usr/bin/env python3
from pathlib import Path
def main():
def input_files():
for path in Path('.').glob('*.*'):
if path.suffix in ('.html', '.txt'):
yield path
for path in input_files():
text = path.read_text(encoding='utf8')
dstpath = path.paren... | 476 | 21.714286 | 54 | py |
simdutf | simdutf-master/benchmarks/competition/inoue2008/script.py | ## prefix_to_length_table
## We do
## const uint8_t prefix = (input[position] >> 5);
## so
## 00000000 becomes 000
## 10000000 becomes 100
## 11000000 becomes 110
## 11100000 becomes 111
prefix_to_length_table = []
for i in range(0b111 + 1):
if(i < 0b100):
# ascii
prefix_to_length_table.append(1... | 1,872 | 24.310811 | 74 | py |
simdutf | simdutf-master/benchmarks/competition/u8u16/proto/u8u16.py | #!/usr/bin/python
# u8u16.py
#
# Python prototype implementation
# Robert D. Cameron
# revised August 5, 2009 - use generated UTF-8 definitions
#
#
#
#----------------------------------------------------------------------------
#
# We use python's unlimited precision integers for unbounded bit streams.
# This permits... | 11,320 | 27.953964 | 92 | py |
simdutf | simdutf-master/benchmarks/competition/u8u16/lib/libgen/make_test.py | #
# make_simd_operation_test.py
#
# Copyright (C) 2007 Dan Lin, Robert D. Cameron
# Licensed to International Characters Inc. and Simon Fraser University
# under the Academic Free License version 3.0
# Licensed to the public under the Open Software License version 3.0.
# make_simd_operation_test.py ... | 9,550 | 34.243542 | 202 | py |
simdutf | simdutf-master/benchmarks/competition/u8u16/lib/libgen/make_basic_ops.py | #
# make_basic_ops.py
#
# Copyright (C) 2007 Dan Lin, Robert D. Cameron
# Licensed to International Characters Inc. and Simon Fraser University
# under the Academic Free License version 3.0
# Licensed to the public under the Open Software License version 3.0.
# make_basic_ops.py generates inline def... | 5,447 | 44.024793 | 135 | py |
simdutf | simdutf-master/benchmarks/competition/u8u16/lib/libgen/make_half_operand_versions.py | #
# make_half_operand_versions.py
#
# Copyright (C) 2007 Robert D. Cameron, Dan Lin
# Licensed to International Characters Inc. and Simon Fraser University
# under the Academic Free License version 3.0
# Licensed to the public under the Open Software License version 3.0.
#
# make_halfoperand_versions... | 6,451 | 39.578616 | 98 | py |
simdutf | simdutf-master/benchmarks/competition/utf8lut/scripts/measure.py | import subprocess, os, sys, re, shutil, json
RunsCount = 10000
ConvertToUtf16 = "FileConverter_msvc %s %s"
Solutions_Decode = {
"trivial": "FileConverter_msvc %s temp.out -b=0 -k={0} --small",
"utf8lut:1S": "FileConverter_msvc %s temp.out -b=3 -k={0} --small",
"utf8lut:4S": "FileConverter_msvc %s temp... | 3,519 | 36.052632 | 134 | py |
simdutf | simdutf-master/benchmarks/competition/utf8lut/scripts/html_table.py | import json, sys
with open(sys.argv[1] + "/results.json", 'rt') as f:
data = json.load(f)
tests = data['tests']
solutions = data['solutions']
print('<tr>')
print(' <th></th>')
for sol in solutions:
print(' <th>%s</th>' % sol)
print('</tr>')
for test in tests:
print('<tr>')
print(' <th>%s</th>' % t... | 633 | 23.384615 | 60 | py |
simdutf | simdutf-master/benchmarks/competition/utf8lut/scripts/resize.py | import sys, os
filename = sys.argv[1]
want_size = int(sys.argv[2])
buff_size = 2**20
remains = want_size
with open(filename + '.tmp', 'wb') as fo:
while remains > 0:
with open(filename, 'rb') as fi:
while remains > 0:
chunk = fi.read(buff_size)
if len(chunk) == ... | 544 | 26.25 | 43 | py |
simdutf | simdutf-master/scripts/sse_validate_utf16le_testcases.py | from itertools import product
from random import randint, seed
from sse_validate_utf16le_proof import bitmask
# This is a copy from sse_validate_utf16le_proof.py with
# adjusted the mask for the 16-bit base
def mask(words):
L = bitmask(words, 'L')
H = bitmask(words, 'H')
V = (~(L | H)) & 0xffff
a = L... | 2,787 | 20.446154 | 72 | py |
simdutf | simdutf-master/scripts/benchmark_print.py | import sys
from pathlib import Path
from table import Table
class Input:
def __init__(self):
self.procedure = None
self.input_size = None
self.iterations = None
self.dataset = None
@property
def dataset_name(self):
if self.dataset:
return self.dataset.s... | 4,564 | 23.281915 | 98 | py |
simdutf | simdutf-master/scripts/table.py | class TableBase(object):
def __init__(self):
self.headers = []
self.rows = []
def set_header(self, header):
assert len(header) > 0
self.headers = [self.normalize(header)]
def add_header(self, header):
assert len(header) > 0
self.headers.append(self.normal... | 7,636 | 25.517361 | 111 | py |
simdutf | simdutf-master/scripts/release.py | #!/usr/bin/env python3
########################################################################
# Generates a new release.
########################################################################
import sys
import re
import subprocess
import io
import os
import fileinput
if sys.version_info < (3, 0):
sys.stdout.wri... | 7,269 | 37.877005 | 222 | py |
simdutf | simdutf-master/scripts/common.py | import textwrap
import sys
if sys.version_info[0] < 3:
print('You need to run this with Python 3')
sys.exit(1)
indent = ' ' * 4
def fill(text):
tmp = textwrap.fill(text)
return textwrap.indent(tmp, indent)
def filltab(text):
tmp = textwrap.fill(text, width=120)
return textwrap.indent(tmp, '\t... | 576 | 22.08 | 84 | py |
simdutf | simdutf-master/scripts/sse_utf8_utf16_decode.py | #!/usr/bin/env python3
from common import *
def is_bit_set(mask, i):
return (mask & ( 1<<i )) == ( 1<<i )
# computes the location of the 0 bits (index starts at zero)
def compute_locations(mask):
answer = []
i = 0
while( (mask >> i) > 0 ):
if(is_bit_set(mask,i)):
answer.append(i)
... | 5,685 | 29.406417 | 183 | py |
simdutf | simdutf-master/scripts/sse_validate_utf16le_proof.py | # Note: Validation is done for 8-word input, we just need to check 3^8 = 6561 cases
# Validation for 16-word inputs reqires 3**16 = 43'046'721 checks
ELEMENTS_COUNT = 8
ALL_MASK = (1 << ELEMENTS_COUNT) - 1
ALL_BUT_ONE_MASK = (ALL_MASK >> 1)
# 'V' - single-word character (always valid)
# 'L' - low surr... | 3,541 | 24.666667 | 105 | py |
simdutf | simdutf-master/scripts/sse_convert_utf16_to_utf8.py | #!/usr/bin/env python3
import sys
def format_array(array):
result = []
for value in array:
if value < 0 or value == 0x80:
result.append('0x80')
else:
result.append(str(value))
return ', '.join(result)
def assure_array_length(array, size, value = 0x80):
while... | 11,181 | 25.434988 | 102 | py |
simdutf | simdutf-master/scripts/create_latex_table.py | #!/usr/bin/env python3
import sys
import re
import argparse
# Construct an argument parser
all_args = argparse.ArgumentParser()
# Add arguments to the parser
all_args.add_argument("-f", "--file", required=True,
help="file name")
args = vars(all_args.parse_args())
filename = args['file']
with open(filename) as f:
... | 1,426 | 22.783333 | 114 | py |
InDuDoNet | InDuDoNet-main/test_clinic.py | import os.path
import os
import os.path
import argparse
import numpy as np
import torch
from CLINIC_metal.preprocess_clinic.preprocessing_clinic import clinic_input_data
from network.indudonet import InDuDoNet
import nibabel
import time
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
parser = argparse.ArgumentParser(descript... | 4,225 | 43.484211 | 116 | py |
InDuDoNet | InDuDoNet-main/train.py | # !/usr/bin/env python
# -*- coding:utf-8 -*-
"""
Created on Tue Nov 5 11:56:06 2020
@author: hongwang ([email protected])
MICCAI2021: ``InDuDoNet: An Interpretable Dual Domain Network for CT Metal Artifact Reduction''
paper link: https://arxiv.org/pdf/2109.05298.pdf
"""
from __future__ import print_function
imp... | 6,328 | 44.532374 | 182 | py |
InDuDoNet | InDuDoNet-main/test_deeplesion.py | import os
import os.path
import argparse
import numpy as np
import torch
import time
import matplotlib.pyplot as plt
import h5py
import PIL
from PIL import Image
from network.indudonet import InDuDoNet
from deeplesion.build_gemotry import initialization, build_gemotry
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
parser = ... | 5,780 | 39.145833 | 117 | py |
InDuDoNet | InDuDoNet-main/deeplesion/Dataset.py | import os
import os.path
import numpy as np
import random
import h5py
import torch
import torch.utils.data as udata
import PIL.Image as Image
from numpy.random import RandomState
import scipy.io as sio
import PIL
from PIL import Image
from .build_gemotry import initialization, build_gemotry
param = initialization()
ra... | 2,795 | 34.846154 | 93 | py |
InDuDoNet | InDuDoNet-main/deeplesion/build_gemotry.py | import odl
import numpy as np
## 640geo
class initialization:
def __init__(self):
self.param = {}
self.reso = 512 / 416 * 0.03
# image
self.param['nx_h'] = 416
self.param['ny_h'] = 416
self.param['sx'] = self.param['nx_h']*self.reso
self.param['sy'] = self.... | 1,687 | 32.76 | 116 | py |
InDuDoNet | InDuDoNet-main/deeplesion/__init__.py | from .Dataset import MARTrainDataset
from .build_gemotry import initialization, build_gemotry | 94 | 46.5 | 57 | py |
InDuDoNet | InDuDoNet-main/network/priornet.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class UNet(nn.Module):
def __init__(self, n_channels=2, n_classes=1, n_filter=32):
super(UNet, self).__init__()
self.inc = inconv(n_channels, n_filter)
self.down1 = down(n_filter, n_filter*2)
self.down2 = down(n_filt... | 3,438 | 28.646552 | 122 | py |
InDuDoNet | InDuDoNet-main/network/indudonet.py | """
MICCAI2021: ``InDuDoNet: An Interpretable Dual Domain Network for CT Metal Artifact Reduction''
paper link: https://arxiv.org/pdf/2109.05298.pdf
"""
import os
import torch
import torch.nn as nn
import torch.nn.functional as F
from odl.contrib import torch as odl_torch
from .priornet import UNet
import sys
#sys.pat... | 8,679 | 41.54902 | 168 | py |
InDuDoNet | InDuDoNet-main/network/build_gemotry.py | import odl
import numpy as np
## 640geo
class initialization:
def __init__(self):
self.param = {}
self.reso = 512 / 416 * 0.03
# image
self.param['nx_h'] = 416
self.param['ny_h'] = 416
self.param['sx'] = self.param['nx_h']*self.reso
self.param['sy'] = self.... | 1,687 | 32.76 | 116 | py |
InDuDoNet | InDuDoNet-main/network/__init__.py | from .indudonet import InDuDoNet
from .priornet import UNet
from .build_gemotry import initialization, build_gemotry | 119 | 39 | 57 | py |
InDuDoNet | InDuDoNet-main/CLINIC_metal/preprocess_clinic/preprocessing_clinic.py | # Given clinical Xma, generate data,including: XLI, M, Sma, SLI, Tr for infering InDuDoNet
import nibabel
import numpy as np
import os
from scipy.interpolate import interp1d
from .utils import get_config
from .build_gemotry import initialization, imaging_geo
import PIL
from PIL import Image
config = get_config('CLINIC_... | 3,013 | 37.151899 | 127 | py |
InDuDoNet | InDuDoNet-main/CLINIC_metal/preprocess_clinic/build_gemotry.py | import odl # https://github.com/odlgroup/odl
import numpy as np
## 640geo
class initialization:
def __init__(self):
self.param = {}
self.reso = 512 / 416 * 0.03
# image
self.param['nx_h'] = 416
self.param['ny_h'] = 416
self.param['sx'] = self.param['nx_h']*self.reso... | 1,878 | 38.978723 | 134 | py |
InDuDoNet | InDuDoNet-main/CLINIC_metal/preprocess_clinic/utils/torch.py | """Helper functions for torch
"""
__all__ = [
"get_device", "is_cuda", "copy_model", "find_layer", "to_npy", "get_last_checkpoint",
"print_model", "save_graph", "backprop_on", "backprop_off", "add_post", "flatten_model",
"FunctionModel"]
import os
import os.path as path
import numpy as np
import torch
imp... | 4,786 | 28.549383 | 100 | py |
InDuDoNet | InDuDoNet-main/CLINIC_metal/preprocess_clinic/utils/misc.py | __all__ = ["read_dir", "get_config", "update_config", "save_config",
"convert_coefficient2hu", "convert_hu2coefficient", "arange", "get_connected_components",
"EasyDict"]
import os
import os.path as path
import yaml
import numpy as np
class EasyDict(object):
def __init__(self, opt): self.opt = opt
d... | 4,990 | 28.886228 | 93 | py |
InDuDoNet | InDuDoNet-main/CLINIC_metal/preprocess_clinic/utils/log.py | import os
import os.path as path
import csv
import numpy as np
import yaml
from PIL import Image
from tqdm import tqdm
from collections import defaultdict, OrderedDict
class Logger(object):
def __init__(self, log_dir, epoch=0, name="log"):
self.log_dir = log_dir
self.epoch = epoch
self.nam... | 7,187 | 41.282353 | 112 | py |
InDuDoNet | InDuDoNet-main/CLINIC_metal/preprocess_clinic/utils/__init__.py | from .misc import *
from .torch import *
from .log import Logger | 64 | 20.666667 | 23 | py |
baselines | baselines-master/setup.py | import re
from setuptools import setup, find_packages
import sys
if sys.version_info.major != 3:
print('This Python is only compatible with Python 3, but you are running '
'Python {}. The installation will likely fail.'.format(sys.version_info.major))
extras = {
'test': [
'filelock',
... | 1,670 | 26.393443 | 104 | py |
baselines | baselines-master/baselines/results_plotter.py | import numpy as np
import matplotlib
matplotlib.use('TkAgg') # Can change to 'Agg' for non-interactive mode
import matplotlib.pyplot as plt
plt.rcParams['svg.fonttype'] = 'none'
from baselines.common import plot_util
X_TIMESTEPS = 'timesteps'
X_EPISODES = 'episodes'
X_WALLTIME = 'walltime_hrs'
Y_REWARD = 'reward'
Y_... | 3,455 | 35.378947 | 144 | py |
baselines | baselines-master/baselines/logger.py | import os
import sys
import shutil
import os.path as osp
import json
import time
import datetime
import tempfile
from collections import defaultdict
from contextlib import contextmanager
DEBUG = 10
INFO = 20
WARN = 30
ERROR = 40
DISABLED = 50
class KVWriter(object):
def writekvs(self, kvs):
raise NotImpl... | 14,802 | 28.429423 | 122 | py |
baselines | baselines-master/baselines/run.py | import sys
import re
import multiprocessing
import os.path as osp
import gym
from collections import defaultdict
import tensorflow as tf
import numpy as np
from baselines.common.vec_env import VecFrameStack, VecNormalize, VecEnv
from baselines.common.vec_env.vec_video_recorder import VecVideoRecorder
from baselines.co... | 7,388 | 28.438247 | 176 | py |
baselines | baselines-master/baselines/__init__.py | 0 | 0 | 0 | py | |
baselines | baselines-master/baselines/deepq/deepq.py | import os
import tempfile
import tensorflow as tf
import zipfile
import cloudpickle
import numpy as np
import baselines.common.tf_util as U
from baselines.common.tf_util import load_variables, save_variables
from baselines import logger
from baselines.common.schedules import LinearSchedule
from baselines.common impor... | 13,125 | 38.417417 | 145 | py |
baselines | baselines-master/baselines/deepq/utils.py | from baselines.common.input import observation_input
from baselines.common.tf_util import adjust_shape
# ================================================================
# Placeholders
# ================================================================
class TfInput(object):
def __init__(self, name="(unnamed)"):
... | 1,885 | 30.433333 | 91 | py |
baselines | baselines-master/baselines/deepq/defaults.py | def atari():
return dict(
network='conv_only',
lr=1e-4,
buffer_size=10000,
exploration_fraction=0.1,
exploration_final_eps=0.01,
train_freq=4,
learning_starts=10000,
target_network_update_freq=1000,
gamma=0.99,
prioritized_replay=True,
... | 480 | 20.863636 | 40 | py |
baselines | baselines-master/baselines/deepq/models.py | import tensorflow as tf
import tensorflow.contrib.layers as layers
def build_q_func(network, hiddens=[256], dueling=True, layer_norm=False, **network_kwargs):
if isinstance(network, str):
from baselines.common.models import get_network_builder
network = get_network_builder(network)(**network_kwarg... | 2,194 | 46.717391 | 111 | py |
baselines | baselines-master/baselines/deepq/__init__.py | from baselines.deepq import models # noqa
from baselines.deepq.build_graph import build_act, build_train # noqa
from baselines.deepq.deepq import learn, load_act # noqa
from baselines.deepq.replay_buffer import ReplayBuffer, PrioritizedReplayBuffer # noqa
def wrap_atari_dqn(env):
from baselines.common.atari_wr... | 409 | 44.555556 | 87 | py |
baselines | baselines-master/baselines/deepq/replay_buffer.py | import numpy as np
import random
from baselines.common.segment_tree import SumSegmentTree, MinSegmentTree
class ReplayBuffer(object):
def __init__(self, size):
"""Create Replay buffer.
Parameters
----------
size: int
Max number of transitions to store in the buffer. W... | 6,475 | 32.729167 | 108 | py |
baselines | baselines-master/baselines/deepq/build_graph.py | """Deep Q learning graph
The functions in this file can are used to create the following functions:
======= act ========
Function to chose an action given an observation
Parameters
----------
observation: object
Observation that can be feed into the output of make_obs_ph
stochastic: bool... | 20,635 | 44.857778 | 168 | py |
baselines | baselines-master/baselines/deepq/experiments/enjoy_pong.py | import gym
from baselines import deepq
def main():
env = gym.make("PongNoFrameskip-v4")
env = deepq.wrap_atari_dqn(env)
model = deepq.learn(
env,
"conv_only",
convs=[(32, 8, 4), (64, 4, 2), (64, 3, 1)],
hiddens=[256],
dueling=True,
total_timesteps=0
)
... | 625 | 20.586207 | 61 | py |
baselines | baselines-master/baselines/deepq/experiments/enjoy_mountaincar.py | import gym
from baselines import deepq
from baselines.common import models
def main():
env = gym.make("MountainCar-v0")
act = deepq.learn(
env,
network=models.mlp(num_layers=1, num_hidden=64),
total_timesteps=0,
load_path='mountaincar_model.pkl'
)
while True:
... | 600 | 20.464286 | 59 | py |
baselines | baselines-master/baselines/deepq/experiments/train_mountaincar.py | import gym
from baselines import deepq
from baselines.common import models
def main():
env = gym.make("MountainCar-v0")
# Enabling layer_norm here is import for parameter space noise!
act = deepq.learn(
env,
network=models.mlp(num_hidden=64, num_layers=1),
lr=1e-3,
total_t... | 616 | 21.851852 | 67 | py |
baselines | baselines-master/baselines/deepq/experiments/train_cartpole.py | import gym
from baselines import deepq
def callback(lcl, _glb):
# stop training if reward exceeds 199
is_solved = lcl['t'] > 100 and sum(lcl['episode_rewards'][-101:-1]) / 100 >= 199
return is_solved
def main():
env = gym.make("CartPole-v0")
act = deepq.learn(
env,
network='mlp'... | 646 | 19.870968 | 84 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.