code
stringlengths
3
6.57k
rename_function(fn, name)
inspect.getmodule(module_of)
setdefault('__macros__', {})
_same_modules(source_module, target_module)
not (source_module or target_module)
_get_filename(module)
inspect.ismodule(module)
pkgutil.get_loader(module)
isinstance(loader, importlib.machinery.SourceFileLoader)
loader.get_filename()
inspect.getfile(module)
except (TypeError, ImportError)
_get_filename(source_module)
_get_filename(target_module)
require(source_module, target_module, assignments, prefix="")
optional ("")
inspect.stack()
target_namespace.get('__name__', None)
isinstance(target_module, str)
importlib.import_module(target_module)
inspect.ismodule(target_module)
type(target_module)
this (when they exist)
_same_modules(source_module, target_module)
inspect.ismodule(source_module)
source_module.startswith(".")
source_module.split(".")
getattr(target_module, "__name__", target_module)
split(".")
while (len(source_dirs)
source_dirs.pop(0)
target_dirs.pop()
join(target_dirs + source_dirs[:-1])
importlib.import_module(source_module, package)
HyRequireError(e.args[0])
with_traceback(None)
source_module.__dict__.setdefault('__macros__', {})
require(f"{source_module.__name__}.{mangle(name)
target_namespace.setdefault('__macros__', {})
source_macros.keys()
mangle(name)
mangle('#' + prefix + unmangle(alias)
unmangle(alias)
startswith('#')
load_macros(module)
importlib.import_module(builtin_mod_name)
hasattr(builtin_mod, '__macros__')
module.__macros__.update(getattr(builtin_mod, '__macros__', {})
MacroExceptions()
__init__(self, module, macro_tree, compiler=None)
__enter__(self)
__exit__(self, exc_type, exc_value, exc_traceback)
issubclass(exc_type, HyLanguageError)
sys.exc_info()
sys.exc_info()
format(str(self.macro_tree[0])
HyMacroExpansionError(msg, self.macro_tree, filename, source)
macroexpand(tree, module, compiler=None, once=False, result_ok=True)
the (top-level)
defined (determined using `inspect.getmodule`)
inspect.ismodule(module)
importlib.import_module(module)
isinstance(tree, Expression)
in ("quote", "quasiquote")
isinstance(fn, Symbol)
mangle(fn)
hasattr(tree, 'module')
expr_modules.append(builtins)
getattr(mod, '__macros__', ()
MacroExceptions(module, tree, compiler)
m(compiler, *tree[1:])
isinstance(obj, (hy.compiler.Result, AST)
isinstance(obj, Expression)
inspect.getmodule(m)
replace_hy_obj(obj, tree)
as_model(tree)
macroexpand_1(tree, module, compiler=None)
macroexpand(tree, module, compiler, once=True)
rename_function(func, new_name)
type(c)
getattr(c, 'co_{}'.format(a)
str(new_name)
type(func)
str(new_name)
_fn.__dict__.update(func.__dict__)
code_obj_args.remove("posonlyargcount")
Jung(@graykode)
gelu(x)
torch.tanh(math.sqrt(2 / math.pi)
torch.pow(x, 3)
load_weight(model, state_dict)
state_dict.keys()
key.endswith(".g")
key.endswith(".b")
key.endswith(".w")
old_keys.append(key)
new_keys.append(new_key)
zip(old_keys, new_keys)
state_dict.pop(old_key)
getattr(state_dict, "_metadata", None)