Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnycase committed Feb 18, 2025
1 parent 627eaae commit d9a193f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ntt/include/nncase/ntt/shape_infer/reduce_axis.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ inline constexpr auto reduced_shape_by_axes_impl(

template <size_t AxesFirst, size_t... AxesRest, size_t... Dims, size_t... Ints>
inline constexpr auto
reduced_shape_by_axes_impl(const fixed_shape<Dims...> shape,
reduced_shape_by_axes_impl([[maybe_unused]] const fixed_shape<Dims...> shape,
const fixed_shape<AxesFirst, AxesRest...>,
const std::index_sequence<Ints...> ints) {
return reduced_shape_by_axes_impl(
Expand Down
7 changes: 0 additions & 7 deletions tests/kernels/test_bucket_pad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,6 @@ TEST_P(BucketPadTest, BucketPad) {
true, host_runtime_tensor::pool_cpu_only)
.expect("create tensor failed");

int64_t axis_ptr[] = {0, 1, 2, 3};
auto axis =
hrt::create(dt_int64, {4},
{reinterpret_cast<gsl::byte *>(axis_ptr), sizeof(axis_ptr)},
true, host_runtime_tensor::pool_cpu_only)
.expect("create tensor failed");

auto l_ort = runtime_tensor_2_ort_tensor(input);
auto pad_ort = runtime_tensor_2_ort_tensor(pad);
auto value_ort = runtime_tensor_2_ort_tensor(value);
Expand Down
2 changes: 1 addition & 1 deletion tests/kernels/test_layer_norm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ TEST_P(LayerNormTest, layer_norm) {

// actual
auto output =
kernels::stackvm::layer_norm((int32_t)axis_value, eps, true,
kernels::stackvm::layer_norm((int32_t)axis_value, eps, true, false,
input.impl(), scale.impl(), b.impl())
.expect("layer_norm failed");
runtime_tensor actual(output.as<tensor>().expect("as tensor failed"));
Expand Down
3 changes: 2 additions & 1 deletion tests/kernels/test_reduce_arg_max.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ TEST_P(ReduceArgMaxTest, ReduceArgMax) {
.expect("create tensor failed");

// actual
auto dtype = datatype_t::from_typecode(dt_int64).unwrap();
auto output =
kernels::stackvm::reduce_arg(runtime::stackvm::reduce_arg_op_t::arg_max,
dt_int64, a.impl(), axis.impl(),
dtype, a.impl(), axis.impl(),
keepDims.impl(), select_last_idx.impl())
.expect("reduce_arg_max failed");
runtime_tensor actual(output.as<tensor>().expect("as tensor failed"));
Expand Down
3 changes: 2 additions & 1 deletion tests/kernels/test_reduce_arg_min.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ TEST_P(ReduceArgMinTest, ReduceArgMin) {
.expect("create tensor failed");

// actual
auto dtype = datatype_t::from_typecode(dt_int64).unwrap();
auto output =
kernels::stackvm::reduce_arg(runtime::stackvm::reduce_arg_op_t::arg_min,
dt_int64, a.impl(), axis.impl(),
dtype, a.impl(), axis.impl(),
keepDims.impl(), select_last_idx.impl())
.expect("reduce_arg_max failed");
runtime_tensor actual(output.as<tensor>().expect("as tensor failed"));
Expand Down
13 changes: 12 additions & 1 deletion tests/kernels/test_swish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* limitations under the License.
*/
#include "kernel_test.h"
#include "nncase/runtime/util.h"
#include <cstddef>
#include <gtest/gtest.h>
#include <iostream>
#include <nncase/kernels/stackvm/tensor_ops.h>
Expand Down Expand Up @@ -41,12 +43,20 @@ class SwishTest : public KernelTest,
hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
.expect("create tensor failed");
init_tensor(input);

float alpha_value = 1.f;
alpha = hrt::create(nncase::dt_float32, {1},
as_span<std::byte>(std::span(&alpha_value, 1)),
true, host_runtime_tensor::pool_cpu_only)
.expect("create tensor failed");
init_tensor(alpha);
}

void TearDown() override { CLEAR_SUBCASE() }

protected:
runtime_tensor input;
runtime_tensor alpha;
};

INSTANTIATE_TEST_SUITE_P(Swish, SwishTest,
Expand All @@ -67,7 +77,8 @@ TEST_P(SwishTest, Swish) {
.expect("create tensor failed");

// actual
auto output = kernels::stackvm::swish(input.impl()).expect("swish failed");
auto output = kernels::stackvm::swish(input.impl(), alpha.impl())
.expect("swish failed");
runtime_tensor actual(output.as<tensor>().expect("as tensor failed"));

bool result = is_same_tensor(expected, actual) ||
Expand Down

0 comments on commit d9a193f

Please # to comment.