Skip to content
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

Fixing last failed test for Release build #1187

Open
khuck opened this issue Jun 2, 2020 · 4 comments
Open

Fixing last failed test for Release build #1187

khuck opened this issue Jun 2, 2020 · 4 comments

Comments

@khuck
Copy link
Contributor

khuck commented Jun 2, 2020

The release build has one last failing test:
http://omega.nic.uoregon.edu:8020/#/builders/2/builds/167/steps/16/logs/stdio

I tracked this down to temporaries output.tensor() and target.tensor() going out of scope in cat_cross_operation::cat_cross3d():

primitive_argument_type cat_cross_operation::cat_cross3d(
arg_type&& target, arg_type&& output, bool from_logits, int axis) const
{
assign_tensor<arg_type> output_(output);
assign_tensor<arg_type> target_(target);
if(from_logits)
{
output_ = softmax3d_axis2(output.tensor());
}
else
{
if(axis == 0) {
auto norm = sum3d(output.tensor(),axis);
for(std::size_t j = 0; j < output.tensor().pages(); ++j) {
auto slice = blaze::pageslice(output.tensor(),j);
slice = blaze::map(slice, norm,[](double s_,double n_){
return s_/n_;
});
}
} else if(axis == 1) {
auto norm = sum3d(output.tensor(),axis);
for(std::size_t j = 0; j < output.tensor().rows(); ++j) {
auto slice = blaze::rowslice(output.tensor(),j);
slice = blaze::map(slice, norm,[](double s_,double n_){
return s_/n_;
});
}
} else {
auto norm = sum3d(output.tensor(),axis);
for(std::size_t j = 0; j < output.tensor().columns(); ++j) {
auto slice = blaze::columnslice(output.tensor(),j);
slice = blaze::map(slice, norm,[](double s_,double n_){
return s_/n_;
});
}
}
}
target_ = blaze::map(
target.tensor(), output.tensor(), [](double t_, double o_) {
return -t_ *
std::log((std::min)(clip_high, (std::max)(clip_low, o_)));
});
matrix_type ans = sum3d(target.tensor(), axis);
if(axis == 1)
ans = blaze::trans(ans);
primitive_argument_type part1(std::move(ans)), part2(std::move(output));
primitive_arguments_type both{part1, part2};
phylanx::ir::range tup(both);
return primitive_argument_type{ std::move(tup) };
}

I'll submit a pull request for that issue (see #1188).

However, after fixing that crash, the python code fails assertions:

AssertionError: [[ 0.96681002  2.18922338  3.41163674  4.6340501 ]
 [ 5.85646346  7.07887682  8.30129018  9.52370354]
 [10.7461169  11.96853026 13.19094362 14.41335698]]
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> /var/lib/buildbot/slaves/phylanx/x86_64-gcc7-release/build/tests/unit/python/execution_tree/categorical_crossentropy.py(79)<module>()
-> assert np.all(np.abs(v1 - v2) < 1.0e-13), v1 - v2
(Pdb) p v1
array([[ 3.,  7., 11., 15.],
       [19., 23., 27., 31.],
       [35., 39., 43., 47.]])
(Pdb) p v2
array([[ 2.03318998,  4.81077662,  7.58836326, 10.3659499 ],
       [13.14353654, 15.92112318, 18.69870982, 21.47629646],
       [24.2538831 , 27.03146974, 29.80905638, 32.58664302]])
(Pdb) list
 74  	    o = 3 * np.ones(10)
 75  	    o[4] = 2
 76  	
 77  	    v1 = cc(t, o, flag, -1)
 78  	    v2 = cat_cross(t, o, flag)
 79  ->	    assert np.all(np.abs(v1 - v2) < 1.0e-13), v1 - v2
 80  	
 81  	    t = np.linspace(1.0e-9, 10e-9, 10)
 82  	    t[2] = 10
 83  	    o = 3 * np.ones(10)
 84  	    o[4] = 2
(Pdb) 
@hkaiser
Copy link
Member

hkaiser commented Jun 2, 2020

Which test is failing, concretely? Could you elaborate, please?

@khuck
Copy link
Contributor Author

khuck commented Jun 2, 2020

I am trying to hunt that down, which isn't easy because this program requires a mix of gdb and pdb since it's a python script test case.

@khuck
Copy link
Contributor Author

khuck commented Jun 2, 2020

Which test is failing, concretely? Could you elaborate, please?

it is the tests.unit.python.execution_tree.categorical_crossentropy test, if that's what you mean

khuck added a commit that referenced this issue Jun 2, 2020
@khuck
Copy link
Contributor Author

khuck commented Jun 2, 2020

@hkaiser Specifically, the temporaries that appear to go out of scope are those bound by the lambda and sum3d() calls here:

target_ = blaze::map(
target.tensor(), output.tensor(), [](double t_, double o_) {
return -t_ *
std::log((std::min)(clip_high, (std::max)(clip_low, o_)));
});
matrix_type ans = sum3d(target.tensor(), axis);

So while I've fixed the crash, the assertion fails on line 125 of tests/unit/python/execution_tree/categorical_crossentropy.py in the 3d test when axis is -1 and flag is True.

for axis in [-1, 0, 1, 2]:
for flag in [True, False]:
t = np.linspace(1, 24, 24)
t = np.reshape(t, (3, 4, 2))
o = np.linspace(.1 * 1 + .3, .1 * 24 + .3, 24)
o = np.reshape(o, (3, 4, 2))
v2 = cat_cross(t, o, flag, axis)
t = np.linspace(1, 24, 24)
t = np.reshape(t, (3, 4, 2))
o = np.linspace(.1 * 1 + .3, .1 * 24 + .3, 24)
o = np.reshape(o, (3, 4, 2))
v1 = cc(t, o, flag, axis)
assert np.all(np.abs(v1 - v2) < 1.0e-13), v1 - v2

I get these matrices:

(Pdb) p v1
array([[ 3.,  7., 11., 15.],
       [19., 23., 27., 31.],
       [35., 39., 43., 47.]])
(Pdb) p v2
array([[ 2.03318998,  4.81077662,  7.58836326, 10.3659499 ],
       [13.14353654, 15.92112318, 18.69870982, 21.47629646],
       [24.2538831 , 27.03146974, 29.80905638, 32.58664302]])
(Pdb) p flag
True
(Pdb) p axis
-1
(Pdb) p o
array([[[0.4, 0.5],
        [0.6, 0.7],
        [0.8, 0.9],
        [1. , 1.1]],

       [[1.2, 1.3],
        [1.4, 1.5],
        [1.6, 1.7],
        [1.8, 1.9]],

       [[2. , 2.1],
        [2.2, 2.3],
        [2.4, 2.5],
        [2.6, 2.7]]])
(Pdb) p t
array([[[ 1.,  2.],
        [ 3.,  4.],
        [ 5.,  6.],
        [ 7.,  8.]],

       [[ 9., 10.],
        [11., 12.],
        [13., 14.],
        [15., 16.]],

       [[17., 18.],
        [19., 20.],
        [21., 22.],
        [23., 24.]]])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants