Skip to content

Commit

Permalink
Python:Bugfix: Fix bug for unit test error
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaying committed Dec 20, 2024
1 parent 6bd87e3 commit d279779
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
1 change: 1 addition & 0 deletions pymnn/pip_package/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ def make_relative_rpath(path):
extensions, cmdclass, packages, entry_points, lib_files = configure_extension_build()

setup(
zip_safe=False,
name=package_name,
version=version,
description=("C methods for MNN Package"),
Expand Down
11 changes: 2 additions & 9 deletions pymnn/test/unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def test_Tensor(self):
self.assertEqualArray(x.getNumpyData(), data)
x = MNN.Tensor([2, 2], MNN.Halide_Type_Float, data.__array_interface__['data'][0], MNN.Tensor_DimensionType_Tensorflow)
self.assertEqualArray(x.getNumpyData(), data)
x = MNN.Tensor([2, 2], MNN.Halide_Type_Float, mp.array([[1., 2.], [3., 4.]]).ptr, MNN.Tensor_DimensionType_Tensorflow)
v = mp.array([[1., 2.], [3., 4.]])
x = MNN.Tensor([2, 2], MNN.Halide_Type_Float, v.ptr, MNN.Tensor_DimensionType_Tensorflow)
self.assertEqualArray(x.getNumpyData(), data)
def test_image_process(self):
src = np.asarray([[50, 50], [200, 50], [50, 200]], dtype=np.float32)
Expand Down Expand Up @@ -481,14 +482,6 @@ def test_matrix_band_part(self):
upper = expr.scalar(-1)
y = np.asarray([0, 1, 2, 3, -1, 0, 1, 2, -0, -1, 0, 1, -0, -0, -1, 0]).reshape([4, 4]).astype(np.float32)
self.assertEqualVar(expr.matrix_band_part(matrix, lower, upper), y)
def test_moments(self):
x = expr.const([0.0, 1.0, 2.0, 3.0, -1.0, 0.0, 1.0, 2.0, -2.0, -1.0, 0.0, 1.0, -3.0, -2.0, -1.0, 0.0], [1, 4, 4, 1], expr.NCHW, expr.float)
x = expr.convert(x, expr.NC4HW4)
shift = expr.scalar(1.0)
res = expr.moments(x, [2, 3], shift, True)
self.assertEqual(len(res), 2)
self.assertEqual(res[0].read_as_tuple(), (1.5, 0.5, -0.5, -1.5)) # mean
self.assertEqual(res[1].read_as_tuple(), (1.25, 1.25, 1.25, 1.25)) # var
def test_setdiff1d(self):
x = expr.const([-1, 2, -3, 4, 5, -6, 7, -8, -9, -10, 11, 12, 13, 14, -15, -16], [16], expr.NHWC, expr.int)
y = expr.const([-1, 2, -3, 4, 5, -6, 7, -8], [8], expr.NHWC, expr.int)
Expand Down
4 changes: 2 additions & 2 deletions source/backend/cpu/CPUBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,8 @@ Execution* CPUBackend::onCreate(const std::vector<Tensor*>& inputs, const std::v
// TODO: rm this convert when merge diff datatyoe of op
auto map = gCreator;
auto iter = map->find(opType);
if (iter == map->end()) {
MNN_PRINT("Don't support type [%s], %s\n", MNN::EnumNameOpType(op->type()), op->name()->c_str());
if (iter == map->end() ) {
MNN_PRINT("Don't support type [%s]\n", MNN::EnumNameOpType(op->type()));
return nullptr;
}
Execution* exe = nullptr;
Expand Down

0 comments on commit d279779

Please sign in to comment.