-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Numpy-compatible Infra #15581
Numpy-compatible Infra #15581
Changes from all commits
2e09926
c8127ae
3a437ad
2657af1
6c461f2
162eaa7
aeaeb46
846a335
fbd0a3b
131dbe3
4fe6cad
25277a5
9dc5e0a
5d8f125
b4716a9
049ded2
a584326
0d0f284
1d47418
8a2b41f
820752f
21be6f8
a54a3f2
6bd552f
42d6760
9f8d4a4
12aab7a
9cc355f
78c541f
5218a09
99a9b0a
7caacd8
a8869b6
33f1cfb
56ac957
ba54b26
6b84d53
7e8deab
0b6f2c8
b2e48d9
7ede112
024bedb
0e955a3
3262591
275b063
345c522
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -272,6 +272,14 @@ class Tuple { | |
is.get(); | ||
if (ch == '(' || ch == '[') break; | ||
if (!isspace(ch)) { | ||
if (ch == 'N') { | ||
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. can't this be on the same line using short circuit? 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. Please make your comments easier to understand. I usually give a simplified snippet to illustrate how I want the code to look like in my code reviews. 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. Sure
|
||
std::string tmp_val; | ||
is >> tmp_val; | ||
if (tmp_val == "one") { // is stores "None" | ||
t.SetDim(-1); | ||
return is; | ||
} | ||
} | ||
is.setstate(std::ios::failbit); | ||
return is; | ||
} | ||
|
@@ -653,6 +661,13 @@ inline bool shape_is_known(const TShape& x) { | |
return true; | ||
} | ||
|
||
inline bool shape_is_known(const std::vector<TShape>& shapes) { | ||
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. why inline? 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. Removing 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. I see there's no tuple implementation file. I guess it's not worth it to add it for a small function. Feel free to resolve. |
||
for (const TShape& shape : shapes) { | ||
if (!shape_is_known(shape)) return false; | ||
} | ||
return true; | ||
} | ||
|
||
/*! \brief helper function to cast type of container elements */ | ||
template<typename SrcIter, typename DstIter> | ||
inline DstIter ShapeTypeCast(const SrcIter begin, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# 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. | ||
|
||
# pylint: skip-file | ||
|
||
"""Doc placeholder for numpy ops with prefix _np.""" | ||
|
||
|
||
def _np_ones_like(a): | ||
"""Return an array of ones with the same shape and type as a given array. | ||
|
||
Parameters | ||
---------- | ||
a : ndarray | ||
The shape and data-type of `a` define these same attributes of | ||
the returned array. | ||
|
||
Returns | ||
------- | ||
out : ndarray | ||
Array of ones with the same shape and type as `a`. | ||
""" | ||
pass | ||
|
||
|
||
def _np_zeros_like(a): | ||
"""Return an array of zeros with the same shape and type as a given array. | ||
|
||
Parameters | ||
---------- | ||
a : ndarray | ||
The shape and data-type of `a` define these same attributes of | ||
the returned array. | ||
|
||
Returns | ||
------- | ||
out : ndarray | ||
Array of zeros with the same shape and type as `a`. | ||
""" | ||
pass |
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.
suggest to add a space
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.
Can you be more specific? Where should the space go to?