Commit b83873cd authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

minor updates

parent 479ca3da
......@@ -80,6 +80,62 @@ public class tfhello{
return ptr;
}
public static int CallableOptionsToByteArray1(){
String gpuDeviceName = "/job:localhost/replica:0/task:0/device:GPU:0";
CallableOptions callableOpts = CallableOptions.newBuilder()
.addFetch("output1:0")
.addFeed("input1:0")
.putFeedDevices("input1:0", gpuDeviceName)
.build();
System.out.println(callableOpts);
byte[] boits = callableOpts.toByteArray();
System.out.print("{");
for (int i=0; i< boits.length; ++i) {
if (i==(boits.length-1)) {
System.out.print(String.format("0x%02x", boits[i]));
}else{
System.out.print(String.format("0x%02x, ", boits[i]));
}
}
System.out.println("}");
return 0;
}
public static int CallableOptionsToByteArray2(){
String gpuDeviceName = "/job:localhost/replica:0/task:0/device:GPU:0";
CallableOptions callableOpts = CallableOptions.newBuilder()
.addFetch("output1:0")
.addFeed("input1:0")
.setFetchSkipSync(true)
.putFetchDevices("output1:0", gpuDeviceName)
.build();
//.fetch_skip_sync = false;
System.out.println(callableOpts);
byte[] boits = callableOpts.toByteArray();
System.out.print("{");
for (int i=0; i< boits.length; ++i) {
if (i==(boits.length-1)) {
System.out.print(String.format("0x%02x", boits[i]));
}else{
System.out.print(String.format("0x%02x, ", boits[i]));
}
}
System.out.println("}");
return 0;
}
public static void main(String[] args) throws Exception{
// CUDA test start
......@@ -179,9 +235,21 @@ public class tfhello{
//.setAttr("dtype",DataType.INT64)
.build();
Operation k = g.opBuilder("Const", "array_const")
.setAttr("dtype", DataType.FLOAT)
.setAttr("value", Tensor.<Float>create((float) 2.0, Float.class))
.build();
/*
Operation z = g.opBuilder("Identity", "array_tensor_out")
.addInput(x.output(0))
.build();
*/
Operation z = g.opBuilder("Mul", "array_tensor_out")
.addInput(x.output(0))
.addInput(k.output(0))
.build();
// unit8
//Tensor t = Tensor.create(px_in_uint8);
......@@ -217,16 +285,17 @@ public class tfhello{
System.out.println("Output from the first run: ");
System.out.println(Arrays.toString(obuf));
// natively got GPU device name to insert into options
// it's the same all the time
String gpuDeviceName = s.GPUDeviceName();
// GPU allocation: dims must be power of 2?
Tensor t3 = Tensor.createGPU(new long[]{256},DataType.FLOAT);
t3.isGPUTensor();
t3.setValueGPU(px_in_float);
//System.out.println(t2.nativeRef);
// Let's check what happended
// Let's check what happened
long t3_gpuptr = t3.GPUPointer();
// Print address
//System.out.println("Pointer address: "+String.format("0x%08x", t3_gpuptr));
......@@ -273,7 +342,10 @@ public class tfhello{
.putFeedDevices("array_tensor_in:0", gpuDeviceName)
.build();
System.out.println(callableOpts);
//CallableOptionsToByteArray1();
//CallableOptionsToByteArray2();
// callable handle
long feed_gpu_fetch_cpu = s.makeCallable(callableOpts.toByteArray());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment