This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Pre nn patch #6201
Merged
Merged
Pre nn patch #6201
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -283,33 +283,13 @@ class NDArray { | |
* \param end end index in first dim | ||
* \return sliced NDArray | ||
*/ | ||
inline NDArray Slice(index_t begin, index_t end) const { | ||
NDArray ret = *this; | ||
CHECK(!is_none()) << "NDArray is not initialized"; | ||
CHECK_GE(shape_[0], end) << "Slice end index out of range"; | ||
size_t length = shape_.ProdShape(1, shape_.ndim()); | ||
ret.offset_ += begin * length; | ||
ret.shape_[0] = end - begin; | ||
return ret; | ||
} | ||
NDArray Slice(index_t begin, index_t end) const; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing implementation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved to cc |
||
/*! | ||
* \brief Index a NDArray | ||
* \param idx the index | ||
* \return idx-th sub array NDArray | ||
*/ | ||
inline NDArray At(index_t idx) const { | ||
NDArray ret = *this; | ||
CHECK(!is_none()) << "NDArray is not initialized"; | ||
CHECK_GT(shape_[0], idx) << "index out of range"; | ||
size_t length = shape_.ProdShape(1, shape_.ndim()); | ||
ret.offset_ += idx * length; | ||
if (shape_.ndim() > 1) { | ||
ret.shape_ = TShape(shape_.data()+1, shape_.data()+shape_.ndim()); | ||
} else { | ||
ret.shape_ = mshadow::Shape1(1); | ||
} | ||
return ret; | ||
} | ||
NDArray At(index_t idx) const; | ||
/*! | ||
* \brief Create a NDArray that shares memory with current one | ||
* The new array must have smaller memory size than the current array. | ||
|
@@ -337,13 +317,7 @@ class NDArray { | |
* \param shape new shape | ||
* \return NDArray in new shape | ||
*/ | ||
inline NDArray Reshape(const TShape &shape) const { | ||
CHECK_GE(shape_.Size(), shape.Size()) | ||
<< "NDArray.Reshape: target shape size is different from current shape"; | ||
NDArray ret = *this; | ||
ret.shape_ = shape; | ||
return ret; | ||
} | ||
NDArray Reshape(const TShape &shape) const; | ||
/*! | ||
* \brief Allocate the space if it is delayed allocated. | ||
* This is an internal function used by system that normal user should not use | ||
|
@@ -566,7 +540,7 @@ void SamplePoisson(real_t lambda, NDArray *out); | |
/*! | ||
* \brief Sample negative binomial distribution for each elements of out. | ||
* \param k failure limit | ||
* \param p success probability | ||
* \param p success probability | ||
* \param out output NDArray. | ||
*/ | ||
void SampleNegBinomial(int32_t k, real_t p, NDArray *out); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lx75249