Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/runner.d
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ static:
PackageInfo("libdparse_usage"),
// workaround https://github.com/dlang-jp/Cookbook/issues/198
PackageInfo("vibe-d_usage", ["windows-x86_omf-", "linux-x86-", "osx-x86-", "osx-x86_64-"]),
// ldc2は以下Issueが原因でx86では動作しないため除外
// https://github.com/libmir/mir-algorithm/issues/461
PackageInfo("mir_usage", ["linux-x86-ldc"]),
PackageInfo("windows"),
];
}
Expand Down
3 changes: 2 additions & 1 deletion dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ subPackage "linux"
subPackage "thirdparty/libdparse"
subPackage "thirdparty/json"
subPackage "thirdparty/vibe-d"
subPackage "thirdparty/mir"

dependency "dateparser" version="~>3.0.4"

buildOptions "coverage"
buildOptions "coverage"
16 changes: 16 additions & 0 deletions thirdparty/mir/dub.sdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name "mir_usage"
description "A minimal D application."
authors "lempiji"
copyright "Copyright © 2023, lempiji"
license "public domain"
dependency "mir-algorithm" version="~>3.19.1"

configuration "library" {
targetType "library"
}

configuration "include-blas" {
targetType "library"
dependency "mir-blas" version="~>1.1.14"
versions "MIRUSAGE_INCLUDE_BLAS"
}
45 changes: 45 additions & 0 deletions thirdparty/mir/source/mir_usage/slice_blas.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
BLAS利用

mirのSliceとBLASを合わせて使う方法を整理します。
BLASを利用するには、環境に合わせて適切なライブラリを用意する必要があります。

Windowsでは既定で Intel MKL が使われます。
Posixでは既定で Open BLAS が使われます。

Source: $(LINK_TO_SRC thirdparty/mir/source/mir_usage/slice_blas.d)
Macros:
TITLE=mirのSliceとBLASを組み合わせて使う例
*/
module mir_usage.slice_blas;

version (MIRUSAGE_INCLUDE_BLAS):

/**
行列積を計算する方法

mir-blasの gemm 関数を利用します
*/
unittest
{
import mir.ndslice : slice, sliced, transposed;
import mir.blas : gemm;

// B = A.x を計算します
auto A = [
1f, 2, 3,
4, 5, 6
].sliced(2, 3);

auto x = [
1f, 2, 3
].sliced(1, 3);

auto B = slice!float(A.shape[0], x.shape[0]);

// 通常のgemmには転置フラグがありますが、transposedの有無を見て適切に処理されます
gemm(1, A, x.transposed, 0, B);

assert(B[0, 0] == 14);
assert(B[1, 0] == 32);
}
Loading
Loading