Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Fix ndim error
Browse files Browse the repository at this point in the history
  • Loading branch information
cassiniXu authored and cassiniXu committed Nov 14, 2019
1 parent dd2e7e6 commit 7f7f7ab
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 3 deletions.
3 changes: 1 addition & 2 deletions python/mxnet/ndarray/numpy/_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -5308,9 +5308,8 @@ def nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None, **kwargs):
else:
raise TypeError('type {} not supported'.format(str(type(x))))

@set_module('mxnet.ndarray.numpy')


@set_module('mxnet.ndarray.numpy')
def diagflat(arr, k=0):
"""
Create a two-dimensional array with the flattened input as a diagonal.
Expand Down
25 changes: 24 additions & 1 deletion src/operator/numpy/np_diagflat_op-inl.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/*!
* \file np_diagflat_op-inl.h
* \brief Function definition of numpy-compatible diff operator
*/
#ifndef MXNET_OPERATOR_NUMPY_DIAGFLAT_OP_INL_H_
#define MXNET_OPERATOR_NUMPY_DIAGFLAT_OP_INL_H_

Expand Down Expand Up @@ -36,7 +59,7 @@ inline mxnet::TShape NumpyDiagflatShapeImpl(const mxnet::TShape& ishape, const i

if (ishape.ndim() >=2 ){
auto s = 1;
for(uint32_t i = 0; i < ishape.ndim(); i++){
for(int i = 0; i < ishape.ndim(); i++){
if(ishape[i] >= 2){
s = s * ishape[i];
}
Expand Down
23 changes: 23 additions & 0 deletions src/operator/numpy/np_diagflat_op.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/*!
* \file np_diagflat_op-inl.cc
* \brief CPU Implementation of numpy-compatible dot
*/
#include "./np_diagflat_op-inl.h"

namespace mxnet{
Expand Down
24 changes: 24 additions & 0 deletions src/operator/numpy/np_diagflat_op.cu
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/*!
* \file np_diagflat_op-inl.cu
* \brief GPU implementation of numpy-compatible diff operator
*/

#include "./np_diagflat_op-inl.h"

namespace mxnet{
Expand Down

0 comments on commit 7f7f7ab

Please sign in to comment.