- -------------------------------------------------- --------- --------------------------- --------------------------
- Feature Tensor CudaTensor ClTensor
- -------------------------------------------------- --------- --------------------------- --------------------------
- Accessing tensor properties [x] [x] [x] Tensor creation [x] by converting a cpu Tensor by converting a cpu Tensor Accessing or modifying a single value [x] [] [] Iterating on a Tensor [x] [] []
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 ../src/arraymancer | |
import macros | |
import math | |
func sigmoid*[T: SomeReal](x: T): T {.inline.} = | |
1 / (1 + exp(-x)) | |
proc gru_cell_forward[T: SomeReal](input, hidden, | |
w_input, w_recur, |
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 ../src/arraymancer | |
import macros | |
# dumpASTGen: | |
# let b = (a[_, 0..<2], a[_, 2..<4], a[_, 4..<6]) | |
macro split[T](x: Tensor[T], n_chunks: static[int], axis = 0): untyped = | |
## Splits a Tensor into n chunks. | |
## For efficiency reason, n is required at compile-time | |
## Split is done without copy, orginal and each chunk share data. |
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
# Works on checkout 8ce9e434348f6f63b81f7a788bd4093996dbaca7, from 11 days ago but not on latest | |
import opencl | |
{.experimental.} | |
type clResource = PCommandQueue | PKernel | PProgram | PMem | PContext | |
template release*(queue: PCommandQueue) = check releaseCommandQueue(queue) | |
template release*(kernel: PKernel) = check releaseKernel(kernel) |
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 ../tensor/tensor, nimlapack | |
proc syev*(jobz: cstring; uplo: cstring; n: ptr cint; a: ptr cfloat; lda: ptr cint; | |
w: ptr cfloat; work: ptr cfloat; lwork: ptr cint; info: ptr cint) {.inline.}= | |
ssyev(jobz, uplo, n, a, lda, | |
w, work, lwork, info) | |
proc syev*(jobz: cstring; uplo: cstring; n: ptr cint; a: ptr cdouble; lda: ptr cint; | |
w: ptr cdouble; work: ptr cdouble; lwork: ptr cint; info: ptr cint) {.inline.}= |
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
packageName = "stint" | |
version = "0.0.1" | |
author = "Status Research & Development GmbH" | |
description = "Efficient stack-based multiprecision int in Nim" | |
license = "Apache License 2.0 or MIT" | |
srcDir = "src" | |
### Dependencies | |
requires "nim >= 0.18" |
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 Mamy André-Ratsimbazafy | |
# | |
# 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
proc streaming_index_max*[T](t: Tensor[T], axis: int): tuple[indices: Tensor[int], maxes: Tensor[T]] = | |
assert axis in {0, 1}, "Only 1D and 2D tensors are supported at the moment for argmax" | |
if axis == 0: | |
result.indices = newTensorUninit[int](1, t.shape[1]) | |
result.maxes = newTensorUninit[T](1, t.shape[1]) | |
else: | |
result.indices = newTensorUninit[int](t.shape[0], 1) | |
result.maxes = newTensorUninit[T](t.shape[0], 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
import macros, tables, hashes | |
import ../src/arraymancer | |
proc flatten*(s: openarray[int]): int {.inline.}= | |
assert s.len != 0 | |
result = 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
import macros | |
type Conv2DLayer[T] = object | |
data: T | |
type Context[T] = ref object | |
data: T | |
#################################### |