Releases: ShigekiKarita/tfd
Releases · ShigekiKarita/tfd
v0.0.5
C header only package
dub add tfd:deimos
import/export TF graph between Python and D
mir.ndslice integration
@nogc nothrow @safe
unittest
{
import tfd;
import mir.ndslice : iota, sliced;
auto s = iota(2, 3);
Tensor t = s.tensor; // reference counted TF_Tensor type
const st = t.slicedAs(s);
assert(t.dataType == TF_INT64);
assert(t.shape[] == s.shape);
assert(st == s);
}
python-like scripting session.run usage
unittest
{
import tfd;
/// tensor add
with (newGraph)
{
import mir.ndslice : as, iota;
auto i = iota(2, 3, 4).as!float;
auto x = placeholder!float("x", 2, 3, 4);
auto two = constant(i);
auto add = x + two;
auto results = session.run([add], [x: i.tensor]);
assert(results[0].sliced!(float, 3) == i * 2);
}
}
@nogc nothrow
usage
version (tfd_test)
@nogc nothrow @safe
unittest
{
import std.typecons : tuple;
import tfd.tensor : tensor, Tensor;
import tfd.graph : newGraph, Operation;
with (newGraph)
{
Operation x = placeholder!int("x");
Operation two = constant(2);
Operation add = x + two;
Operation[1] inops;
inops[0] = x;
Tensor[1] inputs;
inputs[0] = 3.tensor;
Operation[1] outops;
outops[0] = add;
Tensor[1] outputs;
session.run(inops, inputs, outops, outputs);
assert(outputs[0].scalar!int == 5);
write("tmp.pb");
}
with (newGraph)
{
read("tmp.pb");
// auto x = operationByName("x");
// auto add = operationByName("add");
}
}
Support graph import/export
v0.0.4 add python-d example.
Very basic high-level API for tensor, operation, graph, and session
v0.0.3 add example in readme
remove protobuf-c
v0.0.2 fix ci name
v0.0.1
add codecov