Skip to content

Releases: ShigekiKarita/tfd

v0.0.5

15 May 16:59
Compare
Choose a tag to compare

C header only package

dub add tfd:deimos

import/export TF graph between Python and D

see example/graph_import

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

10 May 22:05
Compare
Choose a tag to compare
Pre-release
v0.0.4

add python-d example.

Very basic high-level API for tensor, operation, graph, and session

09 May 19:25
Compare
Choose a tag to compare
v0.0.3

add example in readme

remove protobuf-c

09 May 15:28
Compare
Choose a tag to compare
remove protobuf-c Pre-release
Pre-release
v0.0.2

fix ci name

v0.0.1

02 May 13:26
Compare
Choose a tag to compare
v0.0.1 Pre-release
Pre-release
add codecov