This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.request | |
import json | |
import argparse | |
import ipaddress | |
from tabulate import tabulate | |
ap = argparse.ArgumentParser() | |
ap.add_argument( | |
"-t", "--timeout", default=0.1, type=float, help="timeout, default: 0.1" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from asn.grammar.dsl_ast import AbstractSyntaxTree | |
from typing import List | |
from torch import tensor | |
import torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
import random | |
from asn.components.dataset import ExprBatch, Example | |
from asn.grammar.transition_system import ApplyRuleAction, GenTokenAction, ActionTree | |
from asn.grammar.hypothesis import Hypothesis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- simple finite state machine construction for temporal properties checking | |
-- properties checking: | |
-- "Where processing is based on consent, the controller shall be able to demonstrate that the data subject has consented to processing of his or her personal data." | |
-- run the following proof command in TLV (https://cs.nyu.edu/acsys/tlv/) | |
-- mc ltl( [] ( user_consent Awaits !data_access ) ); | |
-- this yields an invalid result | |
MODULE main | |
VAR | |
-- whether user has given the consent to access the data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Distributed Splitting Function, Splitting M into N pieces" | |
function dSplitFast(M,N) | |
a = [floor(Int64,M/N)+(i<=M%N) for i=1:N] | |
b = unshift!([sum(a[1:j]) for j=1:N],0) | |
c = [p[1]+1:p[2] for p in[b[k:k+1] for k=1:N]] | |
return c | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Utility macro to call MXNet API functions" | |
macro mxcall(fv, argtypes, args...) | |
f = eval(fv) | |
args = map(esc, args) | |
quote | |
_mxret = ccall( ($(Meta.quot(f)), $MXNET_LIB), | |
Cint, $argtypes, $(args...) ) | |
if _mxret != 0 | |
err_msg = mx_get_last_error() | |
throw(MXError(err_msg)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A Demo of Matrix Multiplication on Multiple GPUs | |
using MXNet | |
"Delete & Release NDArray Memory - Good Status" | |
macro del(arr) | |
quote | |
mx.@mxcall(:MXNDArrayFree,(mx.MX_handle,),$(esc(arr)).handle.value) | |
mx.@mxcall(:MXNDArrayWaitAll,()) | |
$(esc(arr)).handle.value = C_NULL |