Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

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

#Project generated test files
TESTS/scripts/testData

#Vim stuff
*.swp
121 changes: 90 additions & 31 deletionsArrayOps.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,36 +5,47 @@
#include <math.h>
#include "uTensor_util.hpp"
#include "quantization_utils.hpp"
#include "uTensorBase.hpp"

//T = inferred
//mode = MIN_FIRST
//name = unspecified
template <typename T>
void QuantizeV2(Tensor<float> input,Tensor<float> _min_range,Tensor<float> _max_range,
Tensor<T> output,Tensor<float> output_min,Tensor<float> output_max) {
void QuantizeV2(S_TENSOR input,S_TENSOR _min_range,S_TENSOR _max_range,
S_TENSOR output,S_TENSOR output_min,S_TENSOR output_max) {

float input_min_range = *(_min_range.getPointer({0}));
float input_max_range = *(_max_range.getPointer({0}));
float input_min_range = *(_min_range->read<float>(0, 0));
float input_max_range = *(_max_range->read<float>(0, 0));

if(input_max_range < input_min_range) ERR_EXIT("input_max_range must be larger than input_min_range.");

float min_range = std::min(0.0f, input_min_range);
const float epsilon = std::max(1.0f, std::max(fabsf(input_min_range),
fabsf(input_max_range))) / 100.0f;
std::vector<uint32_t> v;

std::vector<uint32_t> org = input->getShape();
for (int i = org.size() - 1; i >= 0; i--) {
v.push_back(org[i]);
}

if(output && output->getSize() == 0) {
output->resize<T>(v);
}

float max_range = std::max(input_max_range, min_range + epsilon);
max_range = std::max(0.0f, max_range);

FloatToQuantizedStruct<T> f2q(min_range, max_range);

//quantization_utils.h:149
float* input_ptr = input.getPointer({});
T* output_ptr = output.getPointer({});
float* output_min_ptr = output_min.getPointer({0});
float* output_max_ptr = output_max.getPointer({0});
constfloat* input_ptr = input->read<float>(0, 0);
T* output_ptr = output->write<T>(0, 0);
float* output_min_ptr = output_min->write<float>(0, 0);
float* output_max_ptr = output_max->write<float>(0, 0);

///NT: need error checking at some point...
for(uint32_t i = 0; i < input.getSize(); i++) {
for(uint32_t i = 0; i < input->getSize(); i++) {
float val = std::round(input_ptr[i] * f2q.range_scale);
val -= f2q.range_min_scaled - f2q.lowest_quantized();
val = std::max(val, f2q.lower_bound_float());
Expand All@@ -48,29 +59,55 @@ void QuantizeV2(Tensor<float> input, Tensor<float> _min_range, Tensor<float> _ma

}

class QuantizeV2Op : public Operator {
public:
QuantizeV2Op() {
n_inputs = 3;
n_outputs = 3;
}

virtual void compute() override {
QuantizeV2<unsigned char>(inputs[0], inputs[1], inputs[2],
outputs[0], outputs[1], outputs[2]);
}
};

//mode = MIN_FIRST
//name = unspecified
//dequantize_op.cc: 87
template <typename T>
void dequantize(Tensor<T> input,Tensor<float> min_range,Tensor<float> max_range,Tensor<float> &output) {
float min = *(min_range.getPointer({0}));
float max = *(max_range.getPointer({0}));
void dequantize(S_TENSOR input,S_TENSOR min_range,S_TENSOR max_range,S_TENSORoutput) {
float min = *(min_range->read<float>(0, 0));
float max = *(max_range->read<float>(0, 0));
//auto tensor allocation
Shape out_shape;
tensorChkAlloc(output,input.getShape());
output->resize<float>(input->getShape());

T* input_ptr = input.getPointer({});
float* output_ptr = output.getPointer({});
constT* input_ptr = input->read<T>(0, 0);
float* output_ptr = output->write<float>(0, 0);

//quantization_utils.h: 771
QuantizedToFloatStruct<T> q2f(min, max);

//quantization_utils.h: 141
for(uint32_t i = 0; i < input.getSize(); i++) {
for(uint32_t i = 0; i < input->getSize(); i++) {
float val = static_cast<float>(input_ptr[i]);
output_ptr[i] = ((q2f.range_min_rounded - q2f.lowest_quantized() * q2f.range_scale) + \
val * q2f.range_scale);
}
}
class DequantizeOp : public Operator {
public:
DequantizeOp() {
n_inputs = 3;
n_outputs = 1;
}

virtual void compute() override {
dequantize<unsigned char>(inputs[0], inputs[1], inputs[2],
outputs[0]);
}
};
/*
number_of_steps = 1 << (# of bits in T)
range_adjust = number_of_steps / (number_of_steps - 1)
Expand All@@ -84,7 +121,6 @@ void dequantize(Tensor<T> input, Tensor<float> min_range, Tensor<float> max_rang
// output_ptr[i] = QuantizedToFloat(input_ptr[i], min, max);
// }

}

//Pre:
//output.getShape == shape, or
Expand All@@ -94,14 +130,27 @@ void dequantize(Tensor<T> input, Tensor<float> min_range, Tensor<float> max_rang

///NT: This Op hasn't been tested extensively. We will have to increase the test-coverage for this function.
template <typename T>
void reshape(Tensor<T> input,Tensor<int> shape,Tensor<T> &output) {
void reshape(S_TENSOR input,S_TENSOR shape,S_TENSORoutput) {
Shape dim;
uint32_t t = input->getShape().size();
if (t == 0) {
t = 1;
}

shape->resize<int>({t});

if (t == 1) {
shape->write<int>(0, 0)[0] = -1;
} else {
shape->write<int>(0, 0)[0] = input->getSize();
shape->write<int>(0, 0)[1] = -1;
}

//validating and inferring dimensions
int infer_index = -1;
uint32_t dim_rem = input.getSize();
int* val = shape.getPointer({});
for(uint32_t i = 0; i < shape.getSize(); i++) {
uint32_t dim_rem = input->getSize();
constint* val = shape->read<int>(0, 0);
for(uint32_t i = 0; i < shape->getSize(); i++) {
if(val[i] == -1) {
if(infer_index == -1) {
infer_index = i;
Expand All@@ -123,22 +172,32 @@ void reshape(Tensor<T> input, Tensor<int> shape, Tensor<T> &output) {
if(dim_rem != 1) ERR_EXIT("supplied shape does not match up to input");


T* input_ptr = input.getPointer({});
constT* input_ptr = input->read<T>(0, 0);
//check if the output dim is valid
if(output.getSize() > 0 && dim == output.getShape()) {
if(output && output->getSize() > 0 && dim == output->getShape()) {
//copy
T* output_ptr = output.getPointer({});
std::memcpy(output_ptr, input_ptr, (std::size_t) input.getSize_in_bytes());
} else if(output.getSize() > 0 && dim != output.getShape()) {
T* output_ptr = output->write<T>(0, 0);
std::memcpy(output_ptr, input_ptr, (std::size_t) input->getSize_in_bytes());
} else if(output && output->getSize() > 0 && dim != output->getShape()) {
ERR_EXIT("output tensor dimension mismatches supplied shape")
} else {
//construct a new tensor and copy
Tensor<T> tmp(dim);
T* output_ptr = tmp.getPointer({});
std::memcpy(output_ptr, input_ptr, (std::size_t) input.getSize_in_bytes());
output = tmp;
output->resize<T>(dim);
T* output_ptr = output->write<T>(0, 0);
std::memcpy(output_ptr, input_ptr, (std::size_t) input->getSize_in_bytes());
}

}
class ReshapeOp : public Operator {
public:
ReshapeOp() {
n_inputs = 2;
n_outputs = 1;
}

virtual void compute() override {
reshape<float>(inputs[0], inputs[1], outputs[0]);
}
};

#endif //UTENSOR_ARRAY_OPS
#endif //UTENSOR_ARRAY_OPS
62 changes: 32 additions & 30 deletionsArrayTests.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,62 +4,62 @@
#include "ArrayOps.hpp"
#include "test.hpp"
#include "tensorIdxImporter.hpp"
#include "context.hpp"
#include "tensor.hpp"

class ArrayOpsTest : public Test {
TensorIdxImporter t_import;
Context ctx;
public:
void quantize_v2Test(void) {
testStart("quantize_v2");
TensorIdxImporter t_import;

//reference inputs /Users/neitan01/Documents/mbed/uTensor.git/TESTS/scripts/PRE-GEN/qA
Tensor<float> b = t_import.float_import ("/fs/testData/qB/in/Cast_1_0.idx");
Tensor<float> b_min = t_import.float_import("/fs/testData/qB/in/Min_1_0.idx");
Tensor<float> b_max = t_import.float_import("/fs/testData/qB/in/Max_1_0.idx");
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
Tensor<unsigned char> b_q_ref =t_import.ubyte_import("/fs/testData/qB/out/qB_0.idx");
Tensor<float> b_min_q_ref = t_import.float_import("/fs/testData/qB/out/qB_1.idx");
Tensor<float> b_max_q_ref = t_import.float_import("/fs/testData/qB/out/qb_2.idx");
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");

Tensor<unsigned char> b_q(b_q_ref.getShape());
Tensor<float> b_min_q(b_min_q_ref.getShape());
Tensor<float> b_max_q(b_max_q_ref.getShape());
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();
QuantizeV2(b, b_min, b_max, 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();

// printf("refMin is : %f \r\n", *(b_min_q_ref.getPointer({0})));
// printf("outMin is : %f \r\n", *(b_min_q.getPointer({0})));
// printf("diff : output(%f), outMin(%f), outMax(%f)\r\n",
// meanPercentErr(b_q_ref, b_q), meanPercentErr(b_min_q_ref, b_min_q), meanPercentErr(b_max_q_ref, b_max_q));

double result = meanPercentErr(b_q_ref, b_q) + meanPercentErr(b_min_q_ref, b_min_q) + meanPercentErr(b_max_q_ref, b_max_q);
double result = meanPercentErr<unsigned char>(ref_b_q.get(), out_b_q.get()) + meanPercentErr<float>(ref_b_min_q.get(), out_b_min_q.get()) + meanPercentErr<float>(ref_b_max_q.get(), out_b_max_q.get());
//passed(result < 0.0001);
passed(result == 0);
}

void dequantizeTest(void) {
testStart("dequantize");
TensorIdxImporter t_import;

//reference inputs
Tensor<unsigned char>a = t_import.ubyte_import("/fs/testData/deQ/in/rQ_0.idx");
Tensor<float> a_min = t_import.float_import("/fs/testData/deQ/in/rQ_1.idx");
Tensor<float> a_max = t_import.float_import("/fs/testData/deQ/in/rQ_2.idx");
S_TENSORa =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
Tensor<float> out_ref = t_import.float_import("/fs/testData/deQ/out/deQ_0.idx");
S_TENSOR out_ref =ctx.addCached(hold(t_import.float_import("/fs/testData/deQ/out/deQ_0.idx")), "out_ref");

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

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

double result = meanPercentErr(out_ref, out);
double result = meanPercentErr<float>(out.get(), out_ref.get());
//passed(result < 0.0001);
passed(result == 0);
}
Expand All@@ -69,20 +69,22 @@ class ArrayOpsTest : public Test {
TensorIdxImporter t_import;

//reference inputs
Tensor<float> ref_a = t_import.float_import("/fs/testData/ref_reshape/in/Const_0.idx");
Tensor<int> ref_dim = t_import.int_import("/fs/testData/ref_reshape/in/Const_1_0.idx");
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
Tensor<float> out_ref = t_import.float_import("/fs/testData/ref_reshape/out/ref_reshape_0.idx");
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:
Tensor<float> out(out_ref.getShape());
S_TENSOR out_2 = ctx.addCached(hold(new RamTensor<float>(out_ref_2->getShape())), "out_2");


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

double result = meanPercentErr(out_ref, out);
double result = meanPercentErr<float>(out_2.get(), out_ref_2.get());
//passed(result < 0.0001);
passed(result == 0);
}
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp