Skip to content

Supporting scalar tensor broadcasting for AddOp #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 107 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
c430949
Merge pull request #21 from neil-tan/integTest
Knight-X Oct 28, 2017
18c18fa
Merge pull request #22 from neil-tan/integTest
neil-tan Oct 28, 2017
91cf419
context draft
neil-tan Oct 29, 2017
e2aaf98
re-vised draft
neil-tan Oct 29, 2017
7b2a5f9
wip
neil-tan Oct 29, 2017
a65a8a9
tensor extend first commit
Knight-X Oct 29, 2017
d219be5
draft for merge
neil-tan Oct 29, 2017
9b47169
Merge pull request #25 from neil-tan/context_dev
Knight-X Oct 29, 2017
c09b38e
Draft for tensor refactor
Knight-X Oct 31, 2017
f669f69
add feature to ram tensor class
Knight-X Oct 31, 2017
e5b67bd
Add python requirements for SD preparation
mbartling Oct 31, 2017
4d9269c
wip
Knight-X Oct 29, 2017
96d3186
suggesting tensor ref counter
neil-tan Nov 1, 2017
cd61f37
typo
neil-tan Nov 1, 2017
de63c85
Merge branch 'featuretensor_refactor' of ssh://github.com/neil-tan/uT…
neil-tan Nov 1, 2017
12d77c8
suggesting tensor ref counter
neil-tan Nov 1, 2017
60e0439
typo
neil-tan Nov 1, 2017
4de1ce8
Merge branch 'feature_tensor_ref' of ssh://github.com/neil-tan/uTenso…
neil-tan Nov 1, 2017
68a905f
make idxTest pass firstly
Knight-X Nov 1, 2017
6b4349a
replace tensor<T> to tensor declaration in other functions such as …
Knight-X Nov 1, 2017
83509d1
fix coding style
Knight-X Nov 1, 2017
0fb021a
Merge pull request #28 from neil-tan/feature_tensor_ref
Knight-X Nov 1, 2017
2d9ca3a
1. change read function syntax according to interface
Knight-X Nov 2, 2017
038631d
make syntax of write function correct
Knight-X Nov 2, 2017
2cc354f
Merge pull request #27 from mbartling/b/getting-started
neil-tan Nov 2, 2017
d21c4ee
Merge pull request #29 from neil-tan/featuretensor_refactor
neil-tan Nov 2, 2017
34c5e30
context ops compile sucessful
neil-tan Nov 2, 2017
bd3e49a
DType WIP; added context, ops, tesnor-ref-count
neil-tan Nov 2, 2017
1b163e0
revise main for test idx and matrixops
Knight-X Nov 2, 2017
af90dce
Merge branch 'featuretensor_refactor' of https://github.com/neil-tan/…
Knight-X Nov 2, 2017
0f31406
1. replace tensor in matriops to new one
Knight-X Nov 3, 2017
b216861
1. remove unnecessary private member
Knight-X Nov 3, 2017
b88c865
modify main function for matrixops test
Knight-X Nov 3, 2017
229abef
for arrayops test
Knight-X Nov 3, 2017
020fa1c
Update README.md
BitYog Nov 4, 2017
5fc5b6c
change readme to explain develop branch for developer
Knight-X Nov 4, 2017
6da84e1
Merge branch 'master' of https://github.com/neil-tan/uTensor
Knight-X Nov 4, 2017
cd226d8
fix tensorChkAlloc call convention
Knight-X Nov 4, 2017
b9dbeda
1. math mathops pass
Knight-X Nov 4, 2017
e804b92
delete the tensor in testcase for avoiding runing out of memory
Knight-X Nov 4, 2017
25b40a3
1. refactor NnOps to use new version tensor
Knight-X Nov 4, 2017
6f46844
1. make tensor_test pass for new tensor
Knight-X Nov 4, 2017
7a3c7fa
QntMatMal Context test
neil-tan Nov 4, 2017
12f8c93
pass the mlp test
Knight-X Nov 5, 2017
cb96d7a
1. change for making auto allocation for Tensor**
Knight-X Nov 5, 2017
10e9fc4
1. change for making auto allocation for tensor**
Knight-X Nov 5, 2017
910c3ee
1. make run_mlp pass
Knight-X Nov 5, 2017
13c2e45
1. make reallocation for tensor
Knight-X Nov 5, 2017
9095980
1. when the code is compiled with release mode, the dequantize error…
Knight-X Nov 5, 2017
5a21dbb
1. changed main function for testing run_mlp
Knight-X Nov 5, 2017
0eb520b
fix typo error
Knight-X Nov 5, 2017
6eda5da
1. add resize function and test case
Knight-X Nov 6, 2017
b0f251d
1. change read interface from
Knight-X Nov 6, 2017
c0f02e2
Merge branch 'master' into patch-1
BitYog Nov 6, 2017
ab313ba
Merge branch 'master' into patch-1
BitYog Nov 6, 2017
272fdde
Merge pull request #30 from BitYog/patch-1
mbartling Nov 8, 2017
4e1e49e
context MatMalTest passed
neil-tan Nov 9, 2017
537606c
polished up the syntax
neil-tan Nov 10, 2017
7e278d4
Op should use resize() for output tensors; syntax updates
neil-tan Nov 10, 2017
1b1a071
RefCountTest bugged
neil-tan Nov 10, 2017
12f4d9b
ref counting seems to be working; added support for UBLOX_EVK_ODIN_W2
neil-tan Nov 10, 2017
514ebc3
1. make copy and copy assignment constructor private
Knight-X Nov 11, 2017
05652bd
Merge branch 'context_smartptr' into featuretensor_refactor
Knight-X Nov 11, 2017
65c3baa
1. make arrayops pass test
Knight-X Nov 11, 2017
1382857
1. make math op test pass
Knight-X Nov 12, 2017
c95da6e
1. add function have different type to mathtest, so make addop have…
Knight-X Nov 12, 2017
b385766
transformation test seems passing
neil-tan Nov 12, 2017
0cdd92e
NnTest passed
neil-tan Nov 12, 2017
e12c231
matrix test passing, moved from context tests
neil-tan Nov 12, 2017
c9d219e
enable tensor tests as it is not dependent on Context
neil-tan Nov 12, 2017
d05aa3d
context.add() now support initializer_list
neil-tan Nov 12, 2017
115eb55
fix tensor constructor bug
Knight-X Nov 13, 2017
1c0392d
1. fix the name of DequantizeOp
Knight-X Nov 13, 2017
1e23677
1. add resize for output ptr in Relu
Knight-X Nov 13, 2017
e3316f3
1. for bug test
Knight-X Nov 13, 2017
bdfd145
sounds like run mlp work (draft)
Knight-X Nov 14, 2017
5174aba
1. remove comment for deep_mnist
Knight-X Nov 14, 2017
1021c36
Merge branch 'master' of github.com:neil-tan/uTensor into featuretens…
mbartling Nov 16, 2017
f852b5e
Merge branch 'featuretensor_refactor' of github.com:neil-tan/uTensor …
mbartling Nov 17, 2017
b4a7823
Refactor non template functions to cpp files
mbartling Nov 17, 2017
0fe89c5
Add vim to .gitignore
mbartling Nov 17, 2017
53206be
Merge pull request #47 from mbartling/f/refactor-take-2
Knight-X Nov 18, 2017
2080b0c
Merge pull request #49 from neil-tan/featuretensor_refactor
Knight-X Nov 18, 2017
838dae1
1. tensor have the name to perform lookup
Knight-X Nov 18, 2017
4c6de65
modifying context class to use TName
neil-tan Nov 18, 2017
23c7ffa
merged
neil-tan Nov 18, 2017
7041775
1. implement lookup for reference count
Knight-X Nov 18, 2017
1dba94b
1. make array pass test for name lookup optimization
Knight-X Nov 18, 2017
1bf0026
1. make nntest pass for name lookup optimization
Knight-X Nov 18, 2017
cb39597
1. make tensor transform pass for name lookup
Knight-X Nov 18, 2017
3d310f3
porting MathTests.hpp; added ctx.get() and ctx.gc(); WIP
neil-tan Nov 18, 2017
e12a69a
1. pass mlp test for name lookup
Knight-X Nov 19, 2017
860cf9f
Merge branch 'F/52' of https://github.com/neil-tan/uTensor into F/52
Knight-X Nov 19, 2017
13071ba
Math, Matrix, Context passed
neil-tan Nov 19, 2017
b7530f5
MathTests.hpp: make variable naming more consistent
neil-tan Nov 19, 2017
13872d7
1. pass run deep mlp demo for name lookup
Knight-X Nov 19, 2017
eacb822
Merge branch 'F/52' of https://github.com/neil-tan/uTensor into F/52
Knight-X Nov 19, 2017
1e58e90
updated readme
neil-tan Nov 19, 2017
147f990
release 0.1.0
neil-tan Nov 19, 2017
a91e2eb
Merge pull request #54 from neil-tan/F/52
neil-tan Nov 19, 2017
0b884b6
context stateful wip
neil-tan Nov 30, 2017
5209e03
codeGenTemplate test passed
neil-tan Nov 30, 2017
66468d8
context lambda wip
neil-tan Dec 2, 2017
1f96bc2
context: add_static, addCached, push_static; context internal gc wip
neil-tan Dec 3, 2017
ae3a7a4
updated comment in context.cpp
neil-tan Dec 3, 2017
b5c1702
Merge pull request #60 from neil-tan/F/context_cg_ref
Knight-X Dec 7, 2017
9c7fcb1
Supporting scalar tensor broadcasting
dboyliao Dec 8, 2017
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
42 changes: 21 additions & 21 deletions ArrayTests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ class ArrayOpsTest : public Test {
testStart("quantize_v2");

//reference inputs /Users/neitan01/Documents/mbed/uTensor.git/TESTS/scripts/PRE-GEN/qA
S_TENSOR b_q_ref = ctx.add(t_import.float_import ("/fs/testData/qB/in/Cast_1_0.idx", "b_q_ref"));
S_TENSOR b_min_q_ref = ctx.add(t_import.float_import("/fs/testData/qB/in/Min_1_0.idx", "b_min_q_ref"));
S_TENSOR b_max_q_ref = ctx.add(t_import.float_import("/fs/testData/qB/in/Max_1_0.idx", "b_max_q_ref"));
S_TENSOR b_q_ref = ctx.addCached(hold(t_import.float_import ("/fs/testData/qB/in/Cast_1_0.idx")), "b_q_ref");
S_TENSOR b_min_q_ref = ctx.addCached(hold(t_import.float_import("/fs/testData/qB/in/Min_1_0.idx")), "b_min_q_ref");
S_TENSOR b_max_q_ref = ctx.addCached(hold(t_import.float_import("/fs/testData/qB/in/Max_1_0.idx")), "b_max_q_ref");

//reference outputs
S_TENSOR ref_b_q = ctx.add(t_import.ubyte_import("/fs/testData/qB/out/qB_0.idx", "ref_b_q"));
S_TENSOR ref_b_min_q = ctx.add(t_import.float_import("/fs/testData/qB/out/qB_1.idx", "ref_b_min_q"));
S_TENSOR ref_b_max_q = ctx.add(t_import.float_import("/fs/testData/qB/out/qb_2.idx", "ref_b_max_q"));
S_TENSOR ref_b_q = ctx.addCached(hold(t_import.ubyte_import("/fs/testData/qB/out/qB_0.idx")), "ref_b_q");
S_TENSOR ref_b_min_q = ctx.addCached(hold(t_import.float_import("/fs/testData/qB/out/qB_1.idx")), "ref_b_min_q");
S_TENSOR ref_b_max_q = ctx.addCached(hold(t_import.float_import("/fs/testData/qB/out/qb_2.idx")), "ref_b_max_q");

S_TENSOR out_b_q = ctx.add(new RamTensor<unsigned char>(b_q_ref->getShape(), "b_q"));
S_TENSOR out_b_min_q = ctx.add(new RamTensor<float>(b_min_q_ref->getShape(), "b_min_q"));
S_TENSOR out_b_max_q = ctx.add(new RamTensor<float>(b_max_q_ref->getShape(), "b_max_q"));
S_TENSOR out_b_q = ctx.addCached(hold(new RamTensor<unsigned char>(b_q_ref->getShape())), "b_q");
S_TENSOR out_b_min_q = ctx.addCached(hold(new RamTensor<float>(b_min_q_ref->getShape())), "b_min_q");
S_TENSOR out_b_max_q = ctx.addCached(hold(new RamTensor<float>(b_max_q_ref->getShape())), "b_max_q");

//Implementation goes here
timer_start();
ctx.push(new QuantizeV2Op(), {"b_q_ref", "b_min_q_ref", "b_max_q_ref"}, {"b_q", "b_min_q", "b_max_q"});
ctx.push_static(hold(new QuantizeV2Op()), "QuantizeV2Op", {"b_q_ref", "b_min_q_ref", "b_max_q_ref"}, {"b_q", "b_min_q", "b_max_q"});
ctx.eval();
timer_stop();

Expand All @@ -44,18 +44,18 @@ class ArrayOpsTest : public Test {
testStart("dequantize");

//reference inputs
S_TENSOR a = ctx.add(t_import.ubyte_import("/fs/testData/deQ/in/rQ_0.idx", "a"));
S_TENSOR a_min = ctx.add(t_import.float_import("/fs/testData/deQ/in/rQ_1.idx", "a_min"));
S_TENSOR a_max = ctx.add(t_import.float_import("/fs/testData/deQ/in/rQ_2.idx", "a_max"));
S_TENSOR a = ctx.addCached(hold(t_import.ubyte_import("/fs/testData/deQ/in/rQ_0.idx")), "a");
S_TENSOR a_min = ctx.addCached(hold(t_import.float_import("/fs/testData/deQ/in/rQ_1.idx")), "a_min");
S_TENSOR a_max = ctx.addCached(hold(t_import.float_import("/fs/testData/deQ/in/rQ_2.idx")), "a_max");

//reference outputs
S_TENSOR out_ref = ctx.add(t_import.float_import("/fs/testData/deQ/out/deQ_0.idx", "out_ref"));
S_TENSOR out_ref = ctx.addCached(hold(t_import.float_import("/fs/testData/deQ/out/deQ_0.idx")), "out_ref");

//modify the checks below:
S_TENSOR out = ctx.add(new RamTensor<float>(out_ref->getShape(), "out"));
S_TENSOR out = ctx.addCached(hold(new RamTensor<float>(out_ref->getShape())), "out");

timer_start();
ctx.push(new DequantizeOp(), {"a", "a_min", "a_max"}, {"out"});
ctx.push_static(hold(new DequantizeOp()), "DequantizeOp", {"a", "a_min", "a_max"}, {"out"});
ctx.eval();
timer_stop();

Expand All @@ -69,18 +69,18 @@ class ArrayOpsTest : public Test {
TensorIdxImporter t_import;

//reference inputs
S_TENSOR ref_a = ctx.add(t_import.float_import("/fs/testData/ref_reshape/in/Const_0.idx", "ref_a"));
S_TENSOR ref_dim = ctx.add(t_import.int_import("/fs/testData/ref_reshape/in/Const_1_0.idx", "ref_dim"));
S_TENSOR ref_a = ctx.addCached(hold(t_import.float_import("/fs/testData/ref_reshape/in/Const_0.idx")), "ref_a");
S_TENSOR ref_dim = ctx.addCached(hold(t_import.int_import("/fs/testData/ref_reshape/in/Const_1_0.idx")), "ref_dim");

//reference outputs
S_TENSOR out_ref_2 = ctx.add(t_import.float_import("/fs/testData/ref_reshape/out/ref_reshape_0.idx", "out_ref_2"));
S_TENSOR out_ref_2 = ctx.addCached(hold(t_import.float_import("/fs/testData/ref_reshape/out/ref_reshape_0.idx")), "out_ref_2");

//modify the checks below:
S_TENSOR out_2 = ctx.add(new RamTensor<float>(out_ref_2->getShape(), "out_2"));
S_TENSOR out_2 = ctx.addCached(hold(new RamTensor<float>(out_ref_2->getShape())), "out_2");


timer_start();
ctx.push(new ReshapeOp(), {"ref_a", "ref_dim"}, {"out_2"});
ctx.push_static(hold(new ReshapeOp()), "ReshapeOp", {"ref_a", "ref_dim"}, {"out_2"});
ctx.eval();
timer_stop();

Expand Down
114 changes: 57 additions & 57 deletions MathTests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ class MathOpsTest : public Test {

//Note: raw pointers should be owned ONLY by the context. no copy of the raw pointer should exist elsewhere
// reference inputs
ctx.add(t_import.int_import("/fs/testData/rqRange/in/qMatMul_0.idx", "a"));
ctx.add(t_import.float_import("/fs/testData/rqRange/in/qMatMul_1.idx", "a_min"));
ctx.add(t_import.float_import("/fs/testData/rqRange/in/qMatMul_2.idx", "a_max"));
ctx.addCached(hold(t_import.int_import("/fs/testData/rqRange/in/qMatMul_0.idx")), "a");
ctx.addCached(hold(t_import.float_import("/fs/testData/rqRange/in/qMatMul_1.idx")), "a_min");
ctx.addCached(hold(t_import.float_import("/fs/testData/rqRange/in/qMatMul_2.idx")), "a_max");

// reference output
ctx.add(t_import.float_import("/fs/testData/rqRange/out/rqRange_0.idx", "ref_min"));
ctx.add(t_import.float_import("/fs/testData/rqRange/out/rqRange_1.idx", "ref_max"));
ctx.addCached(hold(t_import.float_import("/fs/testData/rqRange/out/rqRange_0.idx")), "ref_min");
ctx.addCached(hold(t_import.float_import("/fs/testData/rqRange/out/rqRange_1.idx")), "ref_max");

// Implementation goes here

// modify the checks below:
ctx.add(new RamTensor<float>(ctx.get("ref_min")->getShape(), "out_min"));
ctx.add(new RamTensor<float>(ctx.get("ref_max")->getShape(), "out_max"));
ctx.addCached(hold(new RamTensor<float>(ctx.get("ref_min")->getShape())), "out_min");
ctx.addCached(hold(new RamTensor<float>(ctx.get("ref_max")->getShape())), "out_max");
TNameList inputs = {"a", "a_min", "a_max"};
TNameList outputs = {"out_min", "out_max"};

timer_start();
ctx.push(new Requantization_RangeOp(), inputs, outputs);
ctx.push_static(hold(new Requantization_RangeOp()), "Requantization_RangeOp", inputs, outputs);
ctx.eval();
timer_stop();

Expand All @@ -52,33 +52,33 @@ class MathOpsTest : public Test {
ctx.gc();

// reference inputs
ctx.add(t_import.int_import("/fs/testData/rQ/in/qMatMul_0.idx", "a"));
ctx.add(t_import.float_import("/fs/testData/rQ/in/qMatMul_1.idx", "a_min"));
ctx.add(t_import.float_import("/fs/testData/rQ/in/qMatMul_2.idx", "a_max"));
ctx.add(t_import.float_import("/fs/testData/rQ/in/rqRange_0.idx", "r_a_min"));
ctx.add(t_import.float_import("/fs/testData/rQ/in/rqRange_1.idx", "r_a_max"));
ctx.addCached(hold(t_import.int_import("/fs/testData/rQ/in/qMatMul_0.idx")), "a");
ctx.addCached(hold(t_import.float_import("/fs/testData/rQ/in/qMatMul_1.idx")), "a_min");
ctx.addCached(hold(t_import.float_import("/fs/testData/rQ/in/qMatMul_2.idx")), "a_max");
ctx.addCached(hold(t_import.float_import("/fs/testData/rQ/in/rqRange_0.idx")), "r_a_min");
ctx.addCached(hold(t_import.float_import("/fs/testData/rQ/in/rqRange_1.idx")), "r_a_max");
// tf.quint8

//Note:
//Instead of using ctx.get() to obtain a shared_ptr, you may also use the shared_ptr returned by ctx.add()

// reference outputs
S_TENSOR ref_a_q = ctx.add(t_import.ubyte_import("/fs/testData/rQ/out/rQ_0.idx", "ref_a_q"));
S_TENSOR ref_a_min = ctx.add(t_import.float_import("/fs/testData/rQ/out/rQ_1.idx", "ref_a_min"));
S_TENSOR ref_a_max = ctx.add(t_import.float_import("/fs/testData/rQ/out/rQ_2.idx", "ref_a_max"));
S_TENSOR ref_a_q = ctx.addCached(hold(t_import.ubyte_import("/fs/testData/rQ/out/rQ_0.idx")), "ref_a_q");
S_TENSOR ref_a_min = ctx.addCached(hold(t_import.float_import("/fs/testData/rQ/out/rQ_1.idx")), "ref_a_min");
S_TENSOR ref_a_max = ctx.addCached(hold(t_import.float_import("/fs/testData/rQ/out/rQ_2.idx")), "ref_a_max");

// modify the checks below:
S_TENSOR a_q = ctx.add(new RamTensor<unsigned char>(ref_a_q->getShape(), "a_q"));
S_TENSOR a_min_q = ctx.add(new RamTensor<float>(ref_a_min->getShape(), "a_min_q"));
S_TENSOR a_max_q = ctx.add(new RamTensor<float>(ref_a_max->getShape(), "a_max_q"));
S_TENSOR a_q = ctx.addCached(hold(new RamTensor<unsigned char>(ref_a_q->getShape())), "a_q");
S_TENSOR a_min_q = ctx.addCached(hold(new RamTensor<float>(ref_a_min->getShape())), "a_min_q");
S_TENSOR a_max_q = ctx.addCached(hold(new RamTensor<float>(ref_a_max->getShape())), "a_max_q");


TNameList inputs = {"a", "a_min", "a_max", "r_a_min", "r_a_max"};
TNameList outputs = {"a_q", "a_min_q", "a_max_q"};

// Implementation goes here
timer_start();
ctx.push(new RequantizeOp(), inputs, outputs);
ctx.push_static(hold(new RequantizeOp()), "RequantizeOp", inputs, outputs);
ctx.eval();
timer_stop();

Expand All @@ -95,23 +95,23 @@ class MathOpsTest : public Test {
ctx.gc();

// reference inputs
ctx.add(t_import.int_import("/fs/testData/import-MatMul_eightbit_requantize/in/import-MatMul_eightbit_quantized_mat_mul_0.idx", "a"));
ctx.add(t_import.float_import("/fs/testData/import-MatMul_eightbit_requantize/in/import-MatMul_eightbit_quantized_mat_mul_1.idx", "a_min"));
ctx.add(t_import.float_import("/fs/testData/import-MatMul_eightbit_requantize/in/import-MatMul_eightbit_quantized_mat_mul_2.idx", "a_max"));
ctx.add(t_import.float_import("/fs/testData/import-MatMul_eightbit_requantize/in/import-MatMul_eightbit_requant_range_0.idx", "r_a_min"));
ctx.add(t_import.float_import("/fs/testData/import-MatMul_eightbit_requantize/in/import-MatMul_eightbit_requant_range_1.idx", "r_a_max"));
ctx.addCached(hold(t_import.int_import("/fs/testData/import-MatMul_eightbit_requantize/in/import-MatMul_eightbit_quantized_mat_mul_0.idx")), "a");
ctx.addCached(hold(t_import.float_import("/fs/testData/import-MatMul_eightbit_requantize/in/import-MatMul_eightbit_quantized_mat_mul_1.idx")), "a_min");
ctx.addCached(hold(t_import.float_import("/fs/testData/import-MatMul_eightbit_requantize/in/import-MatMul_eightbit_quantized_mat_mul_2.idx")), "a_max");
ctx.addCached(hold(t_import.float_import("/fs/testData/import-MatMul_eightbit_requantize/in/import-MatMul_eightbit_requant_range_0.idx")), "r_a_min");
ctx.addCached(hold(t_import.float_import("/fs/testData/import-MatMul_eightbit_requantize/in/import-MatMul_eightbit_requant_range_1.idx")), "r_a_max");
// tf.quint8

// reference outputs
ctx.add(t_import.ubyte_import("/fs/testData/import-MatMul_eightbit_requantize/out/import-MatMul_eightbit_requantize_0.idx", "ref_a_q"));
ctx.add(t_import.float_import("/fs/testData/import-MatMul_eightbit_requantize/out/import-MatMul_eightbit_requantize_1.idx", "ref_a_min"));
ctx.add(t_import.float_import("/fs/testData/import-MatMul_eightbit_requantize/out/import-MatMul_eightbit_requantize_2.idx", "ref_a_max"));
ctx.addCached(hold(t_import.ubyte_import("/fs/testData/import-MatMul_eightbit_requantize/out/import-MatMul_eightbit_requantize_0.idx")), "ref_a_q");
ctx.addCached(hold(t_import.float_import("/fs/testData/import-MatMul_eightbit_requantize/out/import-MatMul_eightbit_requantize_1.idx")), "ref_a_min");
ctx.addCached(hold(t_import.float_import("/fs/testData/import-MatMul_eightbit_requantize/out/import-MatMul_eightbit_requantize_2.idx")), "ref_a_max");


// modify the checks below:
ctx.add(new RamTensor<unsigned char>(ctx.get("ref_a_q")->getShape(), "a_q"));
ctx.add(new RamTensor<float>(ctx.get("ref_a_min")->getShape(), "a_min_q"));
ctx.add(new RamTensor<float>(ctx.get("ref_a_max")->getShape(), "a_max_q"));
ctx.addCached(hold(new RamTensor<unsigned char>(ctx.get("ref_a_q")->getShape())), "a_q");
ctx.addCached(hold(new RamTensor<float>(ctx.get("ref_a_min")->getShape())), "a_min_q");
ctx.addCached(hold(new RamTensor<float>(ctx.get("ref_a_max")->getShape())), "a_max_q");

S_TENSOR ref_val = ctx.get("ref_a_q");
S_TENSOR ref_min = ctx.get("ref_a_min");
Expand All @@ -122,7 +122,7 @@ class MathOpsTest : public Test {

// Implementation goes here
timer_start();
ctx.push(new RequantizeOp(), {"a", "a_min", "a_max", "r_a_min", "r_a_max"}, {"a_q", "a_min_q", "a_max_q"});
ctx.push_static(hold(new RequantizeOp()), "RequantizeOp", {"a", "a_min", "a_max", "r_a_min", "r_a_max"}, {"a_q", "a_min_q", "a_max_q"});
ctx.eval();
timer_stop();

Expand Down Expand Up @@ -158,28 +158,28 @@ class MathOpsTest : public Test {
ctx.gc();

// reference inputs
ctx.add(t_import.float_import("/fs/testData/ArgMax/in/ArgMax-input_0.idx", "ref_a"));
ctx.add(t_import.int_import("/fs/testData/ArgMax/in/ArgMax-dimension_0.idx", "ref_dim"));
ctx.addCached(hold(t_import.float_import("/fs/testData/ArgMax/in/ArgMax-input_0.idx")), "ref_a");
ctx.addCached(hold(t_import.int_import("/fs/testData/ArgMax/in/ArgMax-dimension_0.idx")), "ref_dim");

// reference outputs
/// NT: FIXME: argmax outputs int64 tensor which isn't supported by
/// int_import.
S_TENSOR ref_out = ctx.add(t_import.float_import("/fs/testData/ArgMax/out/ArgMax_0.idx", "ref_out"));
S_TENSOR ref_out = ctx.addCached(hold(t_import.float_import("/fs/testData/ArgMax/out/ArgMax_0.idx")), "ref_out");

// Implementation goes here

// modify the checks below:
S_TENSOR out = ctx.add(new RamTensor<int>(ref_out->getShape(), "out"));
S_TENSOR out = ctx.addCached(hold(new RamTensor<int>(ref_out->getShape())), "out");

TNameList inputs = {"ref_a", "ref_dim"};
TNameList outputs = {"out"};

timer_start();
ctx.push(new ArgMaxOp<float, int>(), inputs, outputs);
ctx.push_static(hold(new ArgMaxOp<float, int>()), "ArgMaxOp", inputs, outputs);
ctx.eval();
timer_stop();

Tensor* out_float = TensorCast<int, float>(out.get(), "out_float"); ///NT: /WIP how to handle the name?
Tensor* out_float = TensorCast<int, float>(out.get()); ///NT: /WIP how to handle the name?

double result = meanPercentErr<float>(ref_out.get(), out_float);

Expand All @@ -192,24 +192,24 @@ class MathOpsTest : public Test {

ctx.gc();

S_TENSOR test_input = ctx.add(TensorConstant<float>({10, 5}, 0.0f, "test_input"));
S_TENSOR test_input = ctx.add(TensorConstant<float>({10, 5}, 0.0f), "test_input");
*(test_input->write<float>(25, 0)) = 1.0f;
*(test_input->write<float>(26, 0)) = 1.0f;
*(test_input->write<float>(7, 0)) = 1.0f;
*(test_input->write<float>(48, 0)) = 1.0f;
*(test_input->write<float>(14, 0)) = 1.0f;

S_TENSOR test_dim = ctx.add(new RamTensor<int>({1}, "test_dim"));
S_TENSOR test_dim = ctx.add(new RamTensor<int>({1}), "test_dim");
*(test_dim->write<int>(0, 0)) = 0;

S_TENSOR test_out_ref = ctx.add(new RamTensor<float>({5}, "test_out_ref"));
S_TENSOR test_out_ref = ctx.add(new RamTensor<float>({5}), "test_out_ref");
*(test_out_ref->write<float>(0, 0)) = 5.0f;
*(test_out_ref->write<float>(1, 0)) = 5.0f;
*(test_out_ref->write<float>(2, 0)) = 1.0f;
*(test_out_ref->write<float>(3, 0)) = 9.0f;
*(test_out_ref->write<float>(4, 0)) = 2.0f;

S_TENSOR test_out = ctx.add(new RamTensor<float>(test_out_ref->getShape(), "test_out"));
S_TENSOR test_out = ctx.add(new RamTensor<float>(test_out_ref->getShape()), "test_out");
TNameList inputs = {"test_input", "test_dim"};
TNameList outputs = {"test_out"};

Expand All @@ -227,20 +227,20 @@ class MathOpsTest : public Test {
testStart("add");

// reference inputs
ctx.add(t_import.float_import("/fs/testData/ref_add/in/Const_5_0.idx", "a"));
ctx.add(t_import.float_import("/fs/testData/ref_add/in/Const_6_0.idx", "b"));
ctx.addCached(hold(t_import.float_import("/fs/testData/ref_add/in/Const_5_0.idx")), "a");
ctx.addCached(hold(t_import.float_import("/fs/testData/ref_add/in/Const_6_0.idx")), "b");

// reference outputs
S_TENSOR ref_out = ctx.add(t_import.float_import("/fs/testData/ref_add/out/ref_add_0.idx", "ref_out"));
S_TENSOR ref_out = ctx.addCached(hold(t_import.float_import("/fs/testData/ref_add/out/ref_add_0.idx")), "ref_out");

// Implementation goes here

// modify the checks below:
S_TENSOR out = ctx.add(new RamTensor<float>(ref_out->getShape(), "out"));
S_TENSOR out = ctx.addCached(hold(new RamTensor<float>(ref_out->getShape())), "out");
TNameList inputs = {"a", "b"};
TNameList outputs = {"out"};
timer_start();
ctx.push(new AddOp<float, float>(), inputs, outputs);
ctx.push_static(hold(new AddOp<float, float>()), "AddOp", inputs, outputs);
ctx.eval();
timer_stop();

Expand All @@ -255,21 +255,21 @@ class MathOpsTest : public Test {
ctx.gc();

// reference inputs
ctx.add(t_import.float_import("/fs/testData/ref_min/in/Const_2_0.idx", "a"));
ctx.add(t_import.int_import("/fs/testData/ref_min/in/Const_3_0.idx", "dim"));
ctx.addCached(hold(t_import.float_import("/fs/testData/ref_min/in/Const_2_0.idx")), "a");
ctx.addCached(hold(t_import.int_import("/fs/testData/ref_min/in/Const_3_0.idx")), "dim");

// reference outputs
S_TENSOR ref_out = ctx.add(t_import.float_import("/fs/testData/ref_min/out/ref_min_0.idx", "ref_out"));
S_TENSOR ref_out = ctx.addCached(hold(t_import.float_import("/fs/testData/ref_min/out/ref_min_0.idx")), "ref_out");

// Implementation goes here

// modify the checks below:
S_TENSOR out = ctx.add(new RamTensor<float>(ref_out->getShape(), "out"));
S_TENSOR out = ctx.addCached(hold(new RamTensor<float>(ref_out->getShape())), "out");
TNameList inputs = {"a", "dim"};
TNameList outputs = {"out"};

timer_start();
ctx.push(new MinOp(), inputs, outputs);
ctx.push_static(hold(new MinOp()), "MinOp", inputs, outputs);
ctx.eval();
timer_stop();

Expand All @@ -284,20 +284,20 @@ class MathOpsTest : public Test {
ctx.gc();

// reference inputs
ctx.add(t_import.float_import("/fs/testData/ref_max/in/Const_2_0.idx", "a"));
ctx.add(t_import.int_import("/fs/testData/ref_max/in/Const_4_0.idx", "dim"));
ctx.addCached(hold(t_import.float_import("/fs/testData/ref_max/in/Const_2_0.idx")), "a");
ctx.addCached(hold(t_import.int_import("/fs/testData/ref_max/in/Const_4_0.idx")), "dim");

// reference outputs
S_TENSOR ref_out = ctx.add(t_import.float_import("/fs/testData/ref_max/out/ref_max_0.idx", "ref_out"));
S_TENSOR ref_out = ctx.addCached(hold(t_import.float_import("/fs/testData/ref_max/out/ref_max_0.idx")), "ref_out");

// Implementation goes here

// modify the checks below:
S_TENSOR out = ctx.add(new RamTensor<float>(ref_out->getShape(), "out"));
S_TENSOR out = ctx.addCached(hold(new RamTensor<float>(ref_out->getShape())), "out");
TNameList inputs = {"a", "dim"};
TNameList outputs = {"out"};
timer_start();
ctx.push(new MaxOp(), inputs, outputs);
ctx.push_static(hold(new MaxOp()), "MaxOp", inputs, outputs);
ctx.eval();
timer_stop();

Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy