Figures for Laser wiki: https://github.com/numforge/laser/wiki/Convolution-optimisation-resources
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
""" | |
Backprop as the method of Lagrange multiplers (and even the implicit function | |
theorem). | |
""" | |
from __future__ import division | |
import numpy as np | |
from arsenal.alphabet import Alphabet | |
from arsenal.math.checkgrad import finite_difference |
This file contains hidden or 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
def make_input_seqs(data, seq_len, train_split=0.9): | |
seq_len = seq_len + 1 | |
result = [] | |
for index in range(len(data) - seq_len): | |
result.append(data[index: index + seq_len, :]) | |
result = np.array(result) | |
train_ind = round(train_split * result.shape[0]) | |
train = result[:int(train_ind), :, :] | |
x_train = train[:, :-1, :] | |
y_train = train[:, -1, :] |
This file contains hidden or 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
var a: array[2, uint64] | |
func toBinString*[N: static int](x: array[N, uint64]): string = | |
const binChar = ['0', '1'] | |
const byte_size = N*8 | |
let bytes = cast[ptr array[byte_size, byte]](x.unsafeaddr) | |
result = newStringOfCap(byte_size*8) |
This file contains hidden or 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
# Copyright 2017-2018 Mamy André-Ratsimbazafy & the Arraymancer contributors | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, |
This file contains hidden or 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
# MIT License | |
# Copyright (c) 2018 Mamy André-Ratsimbazafy | |
## This files gives basic tensor library functionality, because yes we can | |
import strformat, macros, sequtils, random | |
type | |
Tensor[Rank: static[int], T] = object | |
## Tensor data structure stored on Cpu | |
## - ``shape``: Dimensions of the tensor |
This file contains hidden or 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 stint, math, algorithm | |
# config_big_384_29.h | |
# #define MODBYTES_384_29 48 /**< Number of bytes in Modulus */ | |
# #define BASEBITS_384_29 29 /**< Numbers represented to base 2*BASEBITS */ | |
# big_384_29.h | |
# #define BIGBITS_384_29 (8*MODBYTES_384_29) /**< Length in bits */ | |
# #define NLEN_384_29 (1+((8*MODBYTES_384_29-1)/BASEBITS_384_29)) /**< length in bytes */ |
This file contains hidden or 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
# Nimbus | |
# Copyright (c) 2018 Status Research & Development GmbH | |
# Licensed under either of | |
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) | |
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) | |
# at your option. This file may not be copied, modified, or distributed except according to those terms. | |
import random, sequtils, strformat | |
type |
This file contains hidden or 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 ../stint/private/datatypes | |
import macros | |
var a: UintImpl[UintImpl[uint64]] | |
proc asWordsImpl(x: NimNode, current_path: NimNode, result: var NimNode) = | |
## Transforms an UintImpl/IntImpl into an array of words | |
## at compile-time. Recursve implementation. | |
## Result is from most significant word to least significant |
This file contains hidden or 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 | |
stint, | |
../nimbus/constants, | |
../nimbus/vm/interpreter/[opcodes_impl, vm_forks], | |
../nimbus/vm/[message, computation, stack], | |
../nimbus/utils/header, | |
../nimbus/db/[db_chain, state_db, backends/memory_backend] | |
let msg = newMessage( | |
to=ZERO_ADDRESS, #fixture{"exec"}{"address"}.getStr, |