commit
785f130e61
|
@ -1,24 +0,0 @@
|
|||
branches:
|
||||
only:
|
||||
- master
|
||||
notifications:
|
||||
email: false
|
||||
dist: trusty
|
||||
sudo: false
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.m2
|
||||
language: java
|
||||
jdk:
|
||||
- openjdk8
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
env: OS=linux-x86_64 SCALA=2.10
|
||||
install: true
|
||||
script: bash ./ci/build-linux-x86_64.sh
|
||||
- os: linux
|
||||
env: OS=linux-x86_64 SCALA=2.11
|
||||
install: true
|
||||
script: bash ./ci/build-linux-x86_64.sh
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
#!/bin/bash
|
||||
################################################################################
|
||||
# Copyright (c) 2015-2018 Skymind, Inc.
|
||||
#
|
||||
# This program and the accompanying materials are made available under the
|
||||
# terms of the Apache License, Version 2.0 which is available at
|
||||
# https://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.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
################################################################################
|
||||
|
||||
set -evx
|
||||
|
||||
if [[ $TRAVIS_PULL_REQUEST == "false" ]]; then
|
||||
MAVEN_PHASE="deploy"
|
||||
else
|
||||
MAVEN_PHASE="install"
|
||||
fi
|
||||
|
||||
bash change-scala-versions.sh $SCALA
|
||||
mvn clean $MAVEN_PHASE -B -U --settings ./ci/settings.xml -Dmaven.test.skip=true -Dlocal.software.repository=sonatype
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~ Copyright (c) 2015-2018 Skymind, Inc.
|
||||
~
|
||||
~ This program and the accompanying materials are made available under the
|
||||
~ terms of the Apache License, Version 2.0 which is available at
|
||||
~ https://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.
|
||||
~
|
||||
~ SPDX-License-Identifier: Apache-2.0
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
|
||||
|
||||
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
|
||||
https://maven.apache.org/xsd/settings-1.0.0.xsd">
|
||||
<servers>
|
||||
<server>
|
||||
<id>sonatype-nexus-snapshots</id>
|
||||
<username>${env.SONATYPE_USERNAME}</username>
|
||||
<password>${env.SONATYPE_PASSWORD}</password>
|
||||
</server>
|
||||
</servers>
|
||||
</settings>
|
|
@ -1,28 +0,0 @@
|
|||
branches:
|
||||
only:
|
||||
- master
|
||||
notifications:
|
||||
email: false
|
||||
dist: trusty
|
||||
sudo: false
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.m2
|
||||
language: java
|
||||
jdk:
|
||||
- openjdk8
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
env: OS=linux-x86_64 SCALA=2.10 SPARK=1
|
||||
install: true
|
||||
script: bash ./ci/build-linux-x86_64.sh
|
||||
- os: linux
|
||||
env: OS=linux-x86_64 SCALA=2.11 SPARK=1
|
||||
install: true
|
||||
script: bash ./ci/build-linux-x86_64.sh
|
||||
- os: linux
|
||||
env: OS=linux-x86_64 SCALA=2.11 SPARK=2
|
||||
install: true
|
||||
script: bash ./ci/build-linux-x86_64.sh
|
||||
|
201
datavec/LICENSE
201
datavec/LICENSE
|
@ -1,201 +0,0 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed 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.
|
|
@ -1,29 +0,0 @@
|
|||
#!/bin/bash
|
||||
################################################################################
|
||||
# Copyright (c) 2015-2018 Skymind, Inc.
|
||||
#
|
||||
# This program and the accompanying materials are made available under the
|
||||
# terms of the Apache License, Version 2.0 which is available at
|
||||
# https://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.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
################################################################################
|
||||
|
||||
set -evx
|
||||
|
||||
if [[ $TRAVIS_PULL_REQUEST == "false" ]]; then
|
||||
MAVEN_PHASE="deploy"
|
||||
else
|
||||
MAVEN_PHASE="install"
|
||||
fi
|
||||
|
||||
bash change-scala-versions.sh $SCALA
|
||||
bash change-spark-versions.sh $SPARK
|
||||
mvn clean $MAVEN_PHASE -B -U --settings ./ci/settings.xml -Dmaven.test.skip=true -Dlocal.software.repository=sonatype
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~ Copyright (c) 2015-2018 Skymind, Inc.
|
||||
~
|
||||
~ This program and the accompanying materials are made available under the
|
||||
~ terms of the Apache License, Version 2.0 which is available at
|
||||
~ https://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.
|
||||
~
|
||||
~ SPDX-License-Identifier: Apache-2.0
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
|
||||
|
||||
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
|
||||
https://maven.apache.org/xsd/settings-1.0.0.xsd">
|
||||
<servers>
|
||||
<server>
|
||||
<id>sonatype-nexus-snapshots</id>
|
||||
<username>${env.SONATYPE_USERNAME}</username>
|
||||
<password>${env.SONATYPE_PASSWORD}</password>
|
||||
</server>
|
||||
</servers>
|
||||
</settings>
|
|
@ -1,353 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~ Copyright (c) 2015-2018 Skymind, Inc.
|
||||
~
|
||||
~ This program and the accompanying materials are made available under the
|
||||
~ terms of the Apache License, Version 2.0 which is available at
|
||||
~ https://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.
|
||||
~
|
||||
~ SPDX-License-Identifier: Apache-2.0
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
|
||||
|
||||
<profiles version="13">
|
||||
<profile kind="CodeFormatterProfile" name="GoogleStyle" version="13">
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_cascading_method_invocation_with_arguments.count_dependent" value="16|-1|16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_prefer_two_fragments" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_comment_inline_tags" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_local_variable_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter" value="1040"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type.count_dependent" value="1585|-1|1585"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields.count_dependent" value="16|-1|16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression.count_dependent" value="16|4|80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration.count_dependent" value="16|4|48"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="4"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration.count_dependent" value="16|4|49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_cascading_method_invocation_with_arguments" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.compiler.source" value="1.7"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration.count_dependent" value="16|4|48"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_local_variable_annotation" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants.count_dependent" value="16|5|48"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation.count_dependent" value="16|4|48"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package" value="1585"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_type_annotation" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_field_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_generic_type_arguments" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment_new_line_at_start_of_html_paragraph" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comment_prefix" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_parameter_annotation" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method" value="1585"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation.count_dependent" value="16|5|80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter.count_dependent" value="1040|-1|1040"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package.count_dependent" value="1585|-1|1585"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.force_if_else_statement_brace" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="3"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_package_annotation" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation.count_dependent" value="16|-1|16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type" value="1585"/>
|
||||
<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.7"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="4"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_new_anonymous_class" value="20"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable.count_dependent" value="1585|-1|1585"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field.count_dependent" value="1585|-1|1585"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration.count_dependent" value="16|5|80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant.count_dependent" value="16|-1|16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="120"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="2"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field" value="1585"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer.count_dependent" value="16|5|80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.7"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration.count_dependent" value="16|4|48"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method.count_dependent" value="1585|-1|1585"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression.count_dependent" value="16|-1|16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_member_annotation" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable" value="1585"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call.count_dependent" value="16|5|80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_generic_type_arguments.count_dependent" value="16|-1|16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression.count_dependent" value="16|5|80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration.count_dependent" value="16|5|80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_for_statement" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
|
||||
</profile>
|
||||
</profiles>
|
|
@ -49,7 +49,7 @@ import static org.nd4j.linalg.indexing.NDArrayIndex.point;
|
|||
/**
|
||||
* An image record reader for object detection.
|
||||
* <p>
|
||||
* Format of returned values: 4d array, with dimensions [minibatch, 4+C, h, w]
|
||||
* Format of returned values: 4d array, with dimensions [minibatch, 4+C, h, w] (nchw) or [minibatch, h, w, 4+C] (nhwc)
|
||||
* Where the image is quantized into h x w grid locations.
|
||||
* <p>
|
||||
* Note that this matches the format required for Deeplearning4j's Yolo2OutputLayer
|
||||
|
@ -61,42 +61,67 @@ public class ObjectDetectionRecordReader extends BaseImageRecordReader {
|
|||
private final int gridW;
|
||||
private final int gridH;
|
||||
private final ImageObjectLabelProvider labelProvider;
|
||||
private final boolean nchw;
|
||||
|
||||
protected Image currentImage;
|
||||
|
||||
/**
|
||||
* As per {@link #ObjectDetectionRecordReader(int, int, int, int, int, boolean, ImageObjectLabelProvider)} but hardcoded
|
||||
* to NCHW format
|
||||
*/
|
||||
public ObjectDetectionRecordReader(int height, int width, int channels, int gridH, int gridW, ImageObjectLabelProvider labelProvider) {
|
||||
this(height, width, channels, gridH, gridW, true, labelProvider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create ObjectDetectionRecordReader with
|
||||
*
|
||||
* @param height Height of the output images
|
||||
* @param width Width of the output images
|
||||
* @param channels Number of channels for the output images
|
||||
* @param gridH Grid/quantization size (along height dimension) - Y axis
|
||||
* @param gridW Grid/quantization size (along height dimension) - X axis
|
||||
* @param nchw If true: return NCHW format labels with array shape [minibatch, 4+C, h, w]; if false, return
|
||||
* NHWC format labels with array shape [minibatch, h, w, 4+C]
|
||||
* @param labelProvider ImageObjectLabelProvider - used to look up which objects are in each image
|
||||
*/
|
||||
public ObjectDetectionRecordReader(int height, int width, int channels, int gridH, int gridW, ImageObjectLabelProvider labelProvider) {
|
||||
public ObjectDetectionRecordReader(int height, int width, int channels, int gridH, int gridW, boolean nchw, ImageObjectLabelProvider labelProvider) {
|
||||
super(height, width, channels, null, null);
|
||||
this.gridW = gridW;
|
||||
this.gridH = gridH;
|
||||
this.nchw = nchw;
|
||||
this.labelProvider = labelProvider;
|
||||
this.appendLabel = labelProvider != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* When imageTransform != null, object is removed if new center is outside of transformed image bounds.
|
||||
*
|
||||
* @param height Height of the output images
|
||||
* @param width Width of the output images
|
||||
* @param channels Number of channels for the output images
|
||||
* @param gridH Grid/quantization size (along height dimension) - Y axis
|
||||
* @param gridW Grid/quantization size (along height dimension) - X axis
|
||||
* @param labelProvider ImageObjectLabelProvider - used to look up which objects are in each image
|
||||
* @param imageTransform ImageTransform - used to transform image and coordinates
|
||||
* As per {@link #ObjectDetectionRecordReader(int, int, int, int, int, boolean, ImageObjectLabelProvider, ImageTransform)}
|
||||
* but hardcoded to NCHW format
|
||||
*/
|
||||
public ObjectDetectionRecordReader(int height, int width, int channels, int gridH, int gridW,
|
||||
ImageObjectLabelProvider labelProvider, ImageTransform imageTransform) {
|
||||
ImageObjectLabelProvider labelProvider, ImageTransform imageTransform) {
|
||||
this(height, width, channels, gridH, gridW, true, labelProvider, imageTransform);
|
||||
}
|
||||
|
||||
/**
|
||||
* When imageTransform != null, object is removed if new center is outside of transformed image bounds.
|
||||
*
|
||||
* @param height Height of the output images
|
||||
* @param width Width of the output images
|
||||
* @param channels Number of channels for the output images
|
||||
* @param gridH Grid/quantization size (along height dimension) - Y axis
|
||||
* @param gridW Grid/quantization size (along height dimension) - X axis
|
||||
* @param labelProvider ImageObjectLabelProvider - used to look up which objects are in each image
|
||||
* @param nchw If true: return NCHW format labels with array shape [minibatch, 4+C, h, w]; if false, return
|
||||
* NHWC format labels with array shape [minibatch, h, w, 4+C]
|
||||
* @param imageTransform ImageTransform - used to transform image and coordinates
|
||||
*/
|
||||
public ObjectDetectionRecordReader(int height, int width, int channels, int gridH, int gridW, boolean nchw,
|
||||
ImageObjectLabelProvider labelProvider, ImageTransform imageTransform) {
|
||||
super(height, width, channels, null, null);
|
||||
this.gridW = gridW;
|
||||
this.gridH = gridH;
|
||||
this.nchw = nchw;
|
||||
this.labelProvider = labelProvider;
|
||||
this.appendLabel = labelProvider != null;
|
||||
this.imageTransform = imageTransform;
|
||||
|
@ -182,6 +207,10 @@ public class ObjectDetectionRecordReader extends BaseImageRecordReader {
|
|||
exampleNum++;
|
||||
}
|
||||
|
||||
if(!nchw) {
|
||||
outImg = outImg.permute(0, 2, 3, 1); //NCHW to NHWC
|
||||
outLabel = outLabel.permute(0, 2, 3, 1);
|
||||
}
|
||||
return new NDArrayRecordBatch(Arrays.asList(outImg, outLabel));
|
||||
}
|
||||
|
||||
|
@ -256,6 +285,8 @@ public class ObjectDetectionRecordReader extends BaseImageRecordReader {
|
|||
imageLoader = new NativeImageLoader(height, width, channels, imageTransform);
|
||||
}
|
||||
Image image = this.imageLoader.asImageMatrix(dataInputStream);
|
||||
if(!nchw)
|
||||
image.setImage(image.getImage().permute(0,2,3,1));
|
||||
Nd4j.getAffinityManager().ensureLocation(image.getImage(), AffinityManager.Location.DEVICE);
|
||||
|
||||
List<Writable> ret = RecordConverter.toRecord(image.getImage());
|
||||
|
@ -264,6 +295,8 @@ public class ObjectDetectionRecordReader extends BaseImageRecordReader {
|
|||
int nClasses = labels.size();
|
||||
INDArray outLabel = Nd4j.create(1, 4 + nClasses, gridH, gridW);
|
||||
label(image, imageObjectsForPath, outLabel, 0);
|
||||
if(!nchw)
|
||||
outLabel = outLabel.permute(0,2,3,1); //NCHW to NHWC
|
||||
ret.add(new NDArrayWritable(outLabel));
|
||||
}
|
||||
return ret;
|
||||
|
|
|
@ -56,168 +56,179 @@ public class TestObjectDetectionRecordReader {
|
|||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
ImageObjectLabelProvider lp = new TestImageObjectDetectionLabelProvider();
|
||||
for(boolean nchw : new boolean[]{true, false}) {
|
||||
ImageObjectLabelProvider lp = new TestImageObjectDetectionLabelProvider();
|
||||
|
||||
File f = testDir.newFolder();
|
||||
new ClassPathResource("datavec-data-image/objdetect/").copyDirectory(f);
|
||||
File f = testDir.newFolder();
|
||||
new ClassPathResource("datavec-data-image/objdetect/").copyDirectory(f);
|
||||
|
||||
String path = new File(f, "000012.jpg").getParent();
|
||||
String path = new File(f, "000012.jpg").getParent();
|
||||
|
||||
int h = 32;
|
||||
int w = 32;
|
||||
int c = 3;
|
||||
int gW = 13;
|
||||
int gH = 10;
|
||||
int h = 32;
|
||||
int w = 32;
|
||||
int c = 3;
|
||||
int gW = 13;
|
||||
int gH = 10;
|
||||
|
||||
//Enforce consistent iteration order for tests
|
||||
URI[] u = new FileSplit(new File(path)).locations();
|
||||
Arrays.sort(u);
|
||||
//Enforce consistent iteration order for tests
|
||||
URI[] u = new FileSplit(new File(path)).locations();
|
||||
Arrays.sort(u);
|
||||
|
||||
RecordReader rr = new ObjectDetectionRecordReader(h, w, c, gH, gW, lp);
|
||||
rr.initialize(new CollectionInputSplit(u));
|
||||
RecordReader rr = new ObjectDetectionRecordReader(h, w, c, gH, gW, nchw, lp);
|
||||
rr.initialize(new CollectionInputSplit(u));
|
||||
|
||||
RecordReader imgRR = new ImageRecordReader(h, w, c);
|
||||
imgRR.initialize(new CollectionInputSplit(u));
|
||||
RecordReader imgRR = new ImageRecordReader(h, w, c, nchw);
|
||||
imgRR.initialize(new CollectionInputSplit(u));
|
||||
|
||||
List<String> labels = rr.getLabels();
|
||||
assertEquals(Arrays.asList("car", "cat"), labels);
|
||||
List<String> labels = rr.getLabels();
|
||||
assertEquals(Arrays.asList("car", "cat"), labels);
|
||||
|
||||
|
||||
//000012.jpg - originally 500x333
|
||||
//000019.jpg - originally 500x375
|
||||
double[] origW = new double[]{500, 500};
|
||||
double[] origH = new double[]{333, 375};
|
||||
List<List<ImageObject>> l = Arrays.asList(
|
||||
Collections.singletonList(new ImageObject(156, 97, 351, 270, "car")),
|
||||
Arrays.asList(new ImageObject(11, 113, 266, 259, "cat"), new ImageObject(231, 88, 483, 256, "cat"))
|
||||
);
|
||||
//000012.jpg - originally 500x333
|
||||
//000019.jpg - originally 500x375
|
||||
double[] origW = new double[]{500, 500};
|
||||
double[] origH = new double[]{333, 375};
|
||||
List<List<ImageObject>> l = Arrays.asList(
|
||||
Collections.singletonList(new ImageObject(156, 97, 351, 270, "car")),
|
||||
Arrays.asList(new ImageObject(11, 113, 266, 259, "cat"), new ImageObject(231, 88, 483, 256, "cat"))
|
||||
);
|
||||
|
||||
for (int idx = 0; idx < 2; idx++) {
|
||||
assertTrue(rr.hasNext());
|
||||
List<Writable> next = rr.next();
|
||||
List<Writable> nextImgRR = imgRR.next();
|
||||
for (int idx = 0; idx < 2; idx++) {
|
||||
assertTrue(rr.hasNext());
|
||||
List<Writable> next = rr.next();
|
||||
List<Writable> nextImgRR = imgRR.next();
|
||||
|
||||
//Check features:
|
||||
assertEquals(next.get(0), nextImgRR.get(0));
|
||||
//Check features:
|
||||
assertEquals(next.get(0), nextImgRR.get(0));
|
||||
|
||||
//Check labels
|
||||
assertEquals(2, next.size());
|
||||
assertTrue(next.get(0) instanceof NDArrayWritable);
|
||||
assertTrue(next.get(1) instanceof NDArrayWritable);
|
||||
//Check labels
|
||||
assertEquals(2, next.size());
|
||||
assertTrue(next.get(0) instanceof NDArrayWritable);
|
||||
assertTrue(next.get(1) instanceof NDArrayWritable);
|
||||
|
||||
List<ImageObject> objects = l.get(idx);
|
||||
List<ImageObject> objects = l.get(idx);
|
||||
|
||||
INDArray expLabels = Nd4j.create(1, 4 + 2, gH, gW);
|
||||
for (ImageObject io : objects) {
|
||||
double fracImageX1 = io.getX1() / origW[idx];
|
||||
double fracImageY1 = io.getY1() / origH[idx];
|
||||
double fracImageX2 = io.getX2() / origW[idx];
|
||||
double fracImageY2 = io.getY2() / origH[idx];
|
||||
INDArray expLabels = Nd4j.create(1, 4 + 2, gH, gW);
|
||||
for (ImageObject io : objects) {
|
||||
double fracImageX1 = io.getX1() / origW[idx];
|
||||
double fracImageY1 = io.getY1() / origH[idx];
|
||||
double fracImageX2 = io.getX2() / origW[idx];
|
||||
double fracImageY2 = io.getY2() / origH[idx];
|
||||
|
||||
double x1C = (fracImageX1 + fracImageX2) / 2.0;
|
||||
double y1C = (fracImageY1 + fracImageY2) / 2.0;
|
||||
double x1C = (fracImageX1 + fracImageX2) / 2.0;
|
||||
double y1C = (fracImageY1 + fracImageY2) / 2.0;
|
||||
|
||||
int labelGridX = (int) (x1C * gW);
|
||||
int labelGridY = (int) (y1C * gH);
|
||||
int labelGridX = (int) (x1C * gW);
|
||||
int labelGridY = (int) (y1C * gH);
|
||||
|
||||
int labelIdx;
|
||||
if (io.getLabel().equals("car")) {
|
||||
labelIdx = 4;
|
||||
} else {
|
||||
labelIdx = 5;
|
||||
int labelIdx;
|
||||
if (io.getLabel().equals("car")) {
|
||||
labelIdx = 4;
|
||||
} else {
|
||||
labelIdx = 5;
|
||||
}
|
||||
expLabels.putScalar(0, labelIdx, labelGridY, labelGridX, 1.0);
|
||||
|
||||
expLabels.putScalar(0, 0, labelGridY, labelGridX, fracImageX1 * gW);
|
||||
expLabels.putScalar(0, 1, labelGridY, labelGridX, fracImageY1 * gH);
|
||||
expLabels.putScalar(0, 2, labelGridY, labelGridX, fracImageX2 * gW);
|
||||
expLabels.putScalar(0, 3, labelGridY, labelGridX, fracImageY2 * gH);
|
||||
}
|
||||
expLabels.putScalar(0, labelIdx, labelGridY, labelGridX, 1.0);
|
||||
|
||||
expLabels.putScalar(0, 0, labelGridY, labelGridX, fracImageX1 * gW);
|
||||
expLabels.putScalar(0, 1, labelGridY, labelGridX, fracImageY1 * gH);
|
||||
expLabels.putScalar(0, 2, labelGridY, labelGridX, fracImageX2 * gW);
|
||||
expLabels.putScalar(0, 3, labelGridY, labelGridX, fracImageY2 * gH);
|
||||
INDArray lArr = ((NDArrayWritable) next.get(1)).get();
|
||||
if(nchw) {
|
||||
assertArrayEquals(new long[]{1, 4 + 2, gH, gW}, lArr.shape());
|
||||
} else {
|
||||
assertArrayEquals(new long[]{1, gH, gW, 4 + 2}, lArr.shape());
|
||||
}
|
||||
|
||||
if(!nchw)
|
||||
expLabels = expLabels.permute(0,2,3,1); //NCHW to NHWC
|
||||
|
||||
assertEquals(expLabels, lArr);
|
||||
}
|
||||
|
||||
INDArray lArr = ((NDArrayWritable) next.get(1)).get();
|
||||
assertArrayEquals(new long[]{1, 4 + 2, gH, gW}, lArr.shape());
|
||||
assertEquals(expLabels, lArr);
|
||||
}
|
||||
rr.reset();
|
||||
Record record = rr.nextRecord();
|
||||
RecordMetaDataImageURI metadata = (RecordMetaDataImageURI) record.getMetaData();
|
||||
assertEquals(new File(path, "000012.jpg"), new File(metadata.getURI()));
|
||||
assertEquals(3, metadata.getOrigC());
|
||||
assertEquals((int) origH[0], metadata.getOrigH());
|
||||
assertEquals((int) origW[0], metadata.getOrigW());
|
||||
|
||||
rr.reset();
|
||||
Record record = rr.nextRecord();
|
||||
RecordMetaDataImageURI metadata = (RecordMetaDataImageURI)record.getMetaData();
|
||||
assertEquals(new File(path, "000012.jpg"), new File(metadata.getURI()));
|
||||
assertEquals(3, metadata.getOrigC());
|
||||
assertEquals((int)origH[0], metadata.getOrigH());
|
||||
assertEquals((int)origW[0], metadata.getOrigW());
|
||||
List<Record> out = new ArrayList<>();
|
||||
List<RecordMetaData> meta = new ArrayList<>();
|
||||
out.add(record);
|
||||
meta.add(metadata);
|
||||
record = rr.nextRecord();
|
||||
metadata = (RecordMetaDataImageURI) record.getMetaData();
|
||||
out.add(record);
|
||||
meta.add(metadata);
|
||||
|
||||
List<Record> out = new ArrayList<>();
|
||||
List<RecordMetaData> meta = new ArrayList<>();
|
||||
out.add(record);
|
||||
meta.add(metadata);
|
||||
record = rr.nextRecord();
|
||||
metadata = (RecordMetaDataImageURI)record.getMetaData();
|
||||
out.add(record);
|
||||
meta.add(metadata);
|
||||
List<Record> fromMeta = rr.loadFromMetaData(meta);
|
||||
assertEquals(out, fromMeta);
|
||||
|
||||
List<Record> fromMeta = rr.loadFromMetaData(meta);
|
||||
assertEquals(out, fromMeta);
|
||||
// make sure we don't lose objects just by explicitly resizing
|
||||
int i = 0;
|
||||
int[] nonzeroCount = {5, 10};
|
||||
|
||||
// make sure we don't lose objects just by explicitly resizing
|
||||
int i = 0;
|
||||
int[] nonzeroCount = {5, 10};
|
||||
ImageTransform transform = new ResizeImageTransform(37, 42);
|
||||
RecordReader rrTransform = new ObjectDetectionRecordReader(42, 37, c, gH, gW, nchw, lp, transform);
|
||||
rrTransform.initialize(new CollectionInputSplit(u));
|
||||
i = 0;
|
||||
while (rrTransform.hasNext()) {
|
||||
List<Writable> next = rrTransform.next();
|
||||
assertEquals(37, transform.getCurrentImage().getWidth());
|
||||
assertEquals(42, transform.getCurrentImage().getHeight());
|
||||
INDArray labelArray = ((NDArrayWritable) next.get(1)).get();
|
||||
BooleanIndexing.replaceWhere(labelArray, 1, Conditions.notEquals(0));
|
||||
assertEquals(nonzeroCount[i++], labelArray.sum().getInt(0));
|
||||
}
|
||||
|
||||
ImageTransform transform = new ResizeImageTransform(37, 42);
|
||||
RecordReader rrTransform = new ObjectDetectionRecordReader(42, 37, c, gH, gW, lp, transform);
|
||||
rrTransform.initialize(new CollectionInputSplit(u));
|
||||
i = 0;
|
||||
while (rrTransform.hasNext()) {
|
||||
List<Writable> next = rrTransform.next();
|
||||
assertEquals(37, transform.getCurrentImage().getWidth());
|
||||
assertEquals(42, transform.getCurrentImage().getHeight());
|
||||
INDArray labelArray = ((NDArrayWritable)next.get(1)).get();
|
||||
BooleanIndexing.replaceWhere(labelArray, 1, Conditions.notEquals(0));
|
||||
assertEquals(nonzeroCount[i++], labelArray.sum().getInt(0));
|
||||
}
|
||||
ImageTransform transform2 = new ResizeImageTransform(1024, 2048);
|
||||
RecordReader rrTransform2 = new ObjectDetectionRecordReader(2048, 1024, c, gH, gW, nchw, lp, transform2);
|
||||
rrTransform2.initialize(new CollectionInputSplit(u));
|
||||
i = 0;
|
||||
while (rrTransform2.hasNext()) {
|
||||
List<Writable> next = rrTransform2.next();
|
||||
assertEquals(1024, transform2.getCurrentImage().getWidth());
|
||||
assertEquals(2048, transform2.getCurrentImage().getHeight());
|
||||
INDArray labelArray = ((NDArrayWritable) next.get(1)).get();
|
||||
BooleanIndexing.replaceWhere(labelArray, 1, Conditions.notEquals(0));
|
||||
assertEquals(nonzeroCount[i++], labelArray.sum().getInt(0));
|
||||
}
|
||||
|
||||
//Make sure image flip does not break labels and are correct for new image size dimensions:
|
||||
ImageTransform transform3 = new PipelineImageTransform(
|
||||
new ResizeImageTransform(2048, 4096),
|
||||
new FlipImageTransform(-1)
|
||||
);
|
||||
RecordReader rrTransform3 = new ObjectDetectionRecordReader(2048, 1024, c, gH, gW, nchw, lp, transform3);
|
||||
rrTransform3.initialize(new CollectionInputSplit(u));
|
||||
i = 0;
|
||||
while (rrTransform3.hasNext()) {
|
||||
List<Writable> next = rrTransform3.next();
|
||||
INDArray labelArray = ((NDArrayWritable) next.get(1)).get();
|
||||
BooleanIndexing.replaceWhere(labelArray, 1, Conditions.notEquals(0));
|
||||
assertEquals(nonzeroCount[i++], labelArray.sum().getInt(0));
|
||||
}
|
||||
|
||||
//Test that doing a downscale with the native image loader directly instead of a transform does not cause an exception:
|
||||
ImageTransform transform4 = new FlipImageTransform(-1);
|
||||
RecordReader rrTransform4 = new ObjectDetectionRecordReader(128, 128, c, gH, gW, nchw, lp, transform4);
|
||||
rrTransform4.initialize(new CollectionInputSplit(u));
|
||||
i = 0;
|
||||
while (rrTransform4.hasNext()) {
|
||||
List<Writable> next = rrTransform4.next();
|
||||
|
||||
assertEquals((int) origW[i], transform4.getCurrentImage().getWidth());
|
||||
assertEquals((int) origH[i], transform4.getCurrentImage().getHeight());
|
||||
|
||||
INDArray labelArray = ((NDArrayWritable) next.get(1)).get();
|
||||
BooleanIndexing.replaceWhere(labelArray, 1, Conditions.notEquals(0));
|
||||
assertEquals(nonzeroCount[i++], labelArray.sum().getInt(0));
|
||||
}
|
||||
|
||||
ImageTransform transform2 = new ResizeImageTransform(1024, 2048);
|
||||
RecordReader rrTransform2 = new ObjectDetectionRecordReader(2048, 1024, c, gH, gW, lp, transform2);
|
||||
rrTransform2.initialize(new CollectionInputSplit(u));
|
||||
i = 0;
|
||||
while (rrTransform2.hasNext()) {
|
||||
List<Writable> next = rrTransform2.next();
|
||||
assertEquals(1024, transform2.getCurrentImage().getWidth());
|
||||
assertEquals(2048, transform2.getCurrentImage().getHeight());
|
||||
INDArray labelArray = ((NDArrayWritable)next.get(1)).get();
|
||||
BooleanIndexing.replaceWhere(labelArray, 1, Conditions.notEquals(0));
|
||||
assertEquals(nonzeroCount[i++], labelArray.sum().getInt(0));
|
||||
}
|
||||
|
||||
//Make sure image flip does not break labels and are correct for new image size dimensions:
|
||||
ImageTransform transform3 = new PipelineImageTransform(
|
||||
new ResizeImageTransform(2048, 4096),
|
||||
new FlipImageTransform(-1)
|
||||
);
|
||||
RecordReader rrTransform3 = new ObjectDetectionRecordReader(2048, 1024, c, gH, gW, lp, transform3);
|
||||
rrTransform3.initialize(new CollectionInputSplit(u));
|
||||
i = 0;
|
||||
while (rrTransform3.hasNext()) {
|
||||
List<Writable> next = rrTransform3.next();
|
||||
INDArray labelArray = ((NDArrayWritable)next.get(1)).get();
|
||||
BooleanIndexing.replaceWhere(labelArray, 1, Conditions.notEquals(0));
|
||||
assertEquals(nonzeroCount[i++], labelArray.sum().getInt(0));
|
||||
}
|
||||
|
||||
//Test that doing a downscale with the native image loader directly instead of a transform does not cause an exception:
|
||||
ImageTransform transform4 = new FlipImageTransform(-1);
|
||||
RecordReader rrTransform4 = new ObjectDetectionRecordReader(128, 128, c, gH, gW, lp, transform4);
|
||||
rrTransform4.initialize(new CollectionInputSplit(u));
|
||||
i = 0;
|
||||
while (rrTransform4.hasNext()) {
|
||||
List<Writable> next = rrTransform4.next();
|
||||
|
||||
assertEquals((int) origW[i], transform4.getCurrentImage().getWidth());
|
||||
assertEquals((int) origH[i], transform4.getCurrentImage().getHeight());
|
||||
|
||||
INDArray labelArray = ((NDArrayWritable)next.get(1)).get();
|
||||
BooleanIndexing.replaceWhere(labelArray, 1, Conditions.notEquals(0));
|
||||
assertEquals(nonzeroCount[i++], labelArray.sum().getInt(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
branches:
|
||||
only:
|
||||
- master
|
||||
notifications:
|
||||
email: false
|
||||
dist: trusty
|
||||
sudo: false
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.m2
|
||||
language: java
|
||||
jdk:
|
||||
- openjdk8
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
env: OS=linux-x86_64 CUDA=8.0 CUDNN=6 SCALA=2.10 SPARK=1
|
||||
install: true
|
||||
script: bash ./ci/build-linux-x86_64.sh
|
||||
- os: linux
|
||||
env: OS=linux-x86_64 CUDA=9.0 CUDNN=7 SCALA=2.11 SPARK=1
|
||||
install: true
|
||||
script: bash ./ci/build-linux-x86_64.sh
|
||||
- os: linux
|
||||
env: OS=linux-x86_64 CUDA=9.0 CUDNN=7 SCALA=2.11 SPARK=2
|
||||
install: true
|
||||
script: bash ./ci/build-linux-x86_64.sh
|
||||
- os: linux
|
||||
env: OS=linux-x86_64 CUDA=9.1 CUDNN=7 SCALA=2.11 SPARK=2
|
||||
install: true
|
||||
script: bash ./ci/build-linux-x86_64.sh
|
||||
|
|
@ -1,202 +0,0 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed 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.
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
#!/bin/bash
|
||||
################################################################################
|
||||
# Copyright (c) 2015-2018 Skymind, Inc.
|
||||
#
|
||||
# This program and the accompanying materials are made available under the
|
||||
# terms of the Apache License, Version 2.0 which is available at
|
||||
# https://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.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
################################################################################
|
||||
|
||||
set -evx
|
||||
|
||||
if [[ $TRAVIS_PULL_REQUEST == "false" ]]; then
|
||||
MAVEN_PHASE="deploy"
|
||||
else
|
||||
MAVEN_PHASE="install"
|
||||
fi
|
||||
|
||||
bash change-cuda-versions.sh $CUDA
|
||||
bash change-scala-versions.sh $SCALA
|
||||
bash change-spark-versions.sh $SPARK
|
||||
mvn clean $MAVEN_PHASE -B -U --settings ./ci/settings.xml -Dmaven.test.skip=true -Dlocal.software.repository=sonatype
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~ Copyright (c) 2015-2018 Skymind, Inc.
|
||||
~
|
||||
~ This program and the accompanying materials are made available under the
|
||||
~ terms of the Apache License, Version 2.0 which is available at
|
||||
~ https://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.
|
||||
~
|
||||
~ SPDX-License-Identifier: Apache-2.0
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
|
||||
|
||||
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
|
||||
https://maven.apache.org/xsd/settings-1.0.0.xsd">
|
||||
<servers>
|
||||
<server>
|
||||
<id>sonatype-nexus-snapshots</id>
|
||||
<username>${env.SONATYPE_USERNAME}</username>
|
||||
<password>${env.SONATYPE_PASSWORD}</password>
|
||||
</server>
|
||||
</servers>
|
||||
</settings>
|
|
@ -1,353 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~ Copyright (c) 2015-2018 Skymind, Inc.
|
||||
~
|
||||
~ This program and the accompanying materials are made available under the
|
||||
~ terms of the Apache License, Version 2.0 which is available at
|
||||
~ https://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.
|
||||
~
|
||||
~ SPDX-License-Identifier: Apache-2.0
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
|
||||
|
||||
<profiles version="13">
|
||||
<profile kind="CodeFormatterProfile" name="GoogleStyle" version="13">
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_cascading_method_invocation_with_arguments.count_dependent" value="16|-1|16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_prefer_two_fragments" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_comment_inline_tags" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_local_variable_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter" value="1040"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type.count_dependent" value="1585|-1|1585"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields.count_dependent" value="16|-1|16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression.count_dependent" value="16|4|80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration.count_dependent" value="16|4|48"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="4"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration.count_dependent" value="16|4|49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_cascading_method_invocation_with_arguments" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.compiler.source" value="1.7"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration.count_dependent" value="16|4|48"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_local_variable_annotation" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants.count_dependent" value="16|5|48"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation.count_dependent" value="16|4|48"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package" value="1585"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_type_annotation" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_field_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_generic_type_arguments" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment_new_line_at_start_of_html_paragraph" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comment_prefix" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_parameter_annotation" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method" value="1585"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation.count_dependent" value="16|5|80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter.count_dependent" value="1040|-1|1040"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package.count_dependent" value="1585|-1|1585"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.force_if_else_statement_brace" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="3"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_package_annotation" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation.count_dependent" value="16|-1|16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type" value="1585"/>
|
||||
<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.7"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="4"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_new_anonymous_class" value="20"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable.count_dependent" value="1585|-1|1585"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field.count_dependent" value="1585|-1|1585"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration.count_dependent" value="16|5|80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant.count_dependent" value="16|-1|16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="120"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="2"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field" value="1585"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer.count_dependent" value="16|5|80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.7"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration.count_dependent" value="16|4|48"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method.count_dependent" value="1585|-1|1585"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression.count_dependent" value="16|-1|16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_member_annotation" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable" value="1585"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call.count_dependent" value="16|5|80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_generic_type_arguments.count_dependent" value="16|-1|16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression.count_dependent" value="16|5|80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration.count_dependent" value="16|5|80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_for_statement" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
|
||||
</profile>
|
||||
</profiles>
|
|
@ -68,7 +68,7 @@ public abstract class BaseDL4JTest {
|
|||
* Override this method to set the default timeout for methods in the test class
|
||||
*/
|
||||
public long getTimeoutMilliseconds(){
|
||||
return 60_000;
|
||||
return 90_000;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,17 +24,22 @@ import org.junit.rules.Timeout;
|
|||
import java.io.File;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
/**
|
||||
* @author saudet
|
||||
*/
|
||||
public class SvhnDataFetcherTest extends BaseDL4JTest {
|
||||
|
||||
@Rule
|
||||
public Timeout timeout = Timeout.seconds(600);
|
||||
@Override
|
||||
public long getTimeoutMilliseconds() {
|
||||
return 480_000L; //Shouldn't take this long but slow download or drive access on CI machines may need extra time.
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSvhnDataFetcher() throws Exception {
|
||||
assumeTrue(isIntegrationTests()); //Ignore unless integration tests - CI can get caught up on slow disk access
|
||||
|
||||
SvhnDataFetcher fetch = new SvhnDataFetcher();
|
||||
File path = fetch.getDataSetPath(DataSetType.TRAIN);
|
||||
File path2 = fetch.getDataSetPath(DataSetType.TEST);
|
||||
|
|
|
@ -24,9 +24,7 @@ import org.datavec.image.recordreader.objdetect.impl.VocLabelProvider;
|
|||
import org.deeplearning4j.BaseDL4JTest;
|
||||
import org.deeplearning4j.TestUtils;
|
||||
import org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator;
|
||||
import org.deeplearning4j.nn.conf.ConvolutionMode;
|
||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||
import org.deeplearning4j.nn.conf.*;
|
||||
import org.deeplearning4j.nn.conf.distribution.GaussianDistribution;
|
||||
import org.deeplearning4j.nn.conf.inputs.InputType;
|
||||
import org.deeplearning4j.nn.conf.layers.ConvolutionLayer;
|
||||
|
@ -36,6 +34,8 @@ import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
|||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.nd4j.linalg.activations.Activation;
|
||||
import org.nd4j.linalg.api.buffer.DataType;
|
||||
import org.nd4j.linalg.api.ndarray.INDArray;
|
||||
|
@ -50,17 +50,28 @@ import java.io.File;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Alex Black
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
public class YoloGradientCheckTests extends BaseDL4JTest {
|
||||
|
||||
static {
|
||||
Nd4j.setDataType(DataType.DOUBLE);
|
||||
}
|
||||
|
||||
private CNN2DFormat format;
|
||||
public YoloGradientCheckTests(CNN2DFormat format){
|
||||
this.format = format;
|
||||
}
|
||||
@Parameterized.Parameters(name = "{0}")
|
||||
public static Object[] params(){
|
||||
return CNN2DFormat.values();
|
||||
}
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder testDir = new TemporaryFolder();
|
||||
|
||||
|
@ -97,8 +108,14 @@ public class YoloGradientCheckTests extends BaseDL4JTest {
|
|||
|
||||
Nd4j.getRandom().setSeed(12345);
|
||||
|
||||
INDArray input = Nd4j.rand(new int[]{mb, depthIn, h, w});
|
||||
INDArray labels = yoloLabels(mb, c, h, w);
|
||||
INDArray input, labels;
|
||||
if(format == CNN2DFormat.NCHW){
|
||||
input = Nd4j.rand(DataType.DOUBLE, mb, depthIn, h, w);
|
||||
labels = yoloLabels(mb, c, h, w);
|
||||
} else {
|
||||
input = Nd4j.rand(DataType.DOUBLE, mb, h, w, depthIn);
|
||||
labels = yoloLabels(mb, c, h, w).permute(0,2,3,1);
|
||||
}
|
||||
|
||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
||||
.dataType(DataType.DOUBLE)
|
||||
|
@ -112,6 +129,7 @@ public class YoloGradientCheckTests extends BaseDL4JTest {
|
|||
.layer(new Yolo2OutputLayer.Builder()
|
||||
.boundingBoxPriors(bbPrior)
|
||||
.build())
|
||||
.setInputType(InputType.convolutional(h, w, depthIn, format))
|
||||
.build();
|
||||
|
||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||
|
@ -120,7 +138,18 @@ public class YoloGradientCheckTests extends BaseDL4JTest {
|
|||
String msg = "testYoloOutputLayer() - minibatch = " + mb + ", w=" + w + ", h=" + h + ", l1=" + l1[i] + ", l2=" + l2[i];
|
||||
System.out.println(msg);
|
||||
|
||||
INDArray out = net.output(input);
|
||||
if(format == CNN2DFormat.NCHW){
|
||||
assertArrayEquals(new long[]{mb, yoloDepth, h, w}, out.shape());
|
||||
} else {
|
||||
assertArrayEquals(new long[]{mb, h, w, yoloDepth}, out.shape());
|
||||
}
|
||||
|
||||
net.fit(input, labels);
|
||||
|
||||
|
||||
boolean gradOK = GradientCheckUtil.checkGradients(new GradientCheckUtil.MLNConfig().net(net).input(input)
|
||||
.minAbsoluteError(1e-6)
|
||||
.labels(labels).subset(true).maxPerParam(100));
|
||||
|
||||
assertTrue(msg, gradOK);
|
||||
|
|
|
@ -183,11 +183,11 @@ public class TestCheckpointListener extends BaseDL4JTest {
|
|||
|
||||
CheckpointListener l = new CheckpointListener.Builder(f)
|
||||
.keepLast(3)
|
||||
.saveEvery(4, TimeUnit.SECONDS)
|
||||
.saveEvery(4900, TimeUnit.MILLISECONDS)
|
||||
.build();
|
||||
net.setListeners(l);
|
||||
|
||||
for(int i=0; i<5; i++ ){ //10 iterations total
|
||||
for(int i=0; i<3; i++ ){ //10 iterations total
|
||||
net.fit(iter);
|
||||
Thread.sleep(5000);
|
||||
}
|
||||
|
@ -211,9 +211,10 @@ public class TestCheckpointListener extends BaseDL4JTest {
|
|||
ns.add(n.getIterationCount());
|
||||
}
|
||||
|
||||
assertEquals(3, l.availableCheckpoints().size());
|
||||
assertEquals(ns.toString(), 3, ns.size());
|
||||
assertTrue(ns.containsAll(Arrays.asList(4,6,8)));
|
||||
assertEquals(2, l.availableCheckpoints().size());
|
||||
assertEquals(ns.toString(), 2, ns.size());
|
||||
System.out.println(ns);
|
||||
assertTrue(ns.containsAll(Arrays.asList(2,4)));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -70,6 +70,11 @@ public class TestListeners extends BaseDL4JTest {
|
|||
@Rule
|
||||
public TemporaryFolder tempDir = new TemporaryFolder();
|
||||
|
||||
@Override
|
||||
public long getTimeoutMilliseconds() {
|
||||
return 90000L;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSettingListenersUnsupervised() {
|
||||
//Pretrain layers should get copies of the listeners, in addition to the
|
||||
|
|
|
@ -171,7 +171,7 @@ public class KerasModel {
|
|||
importTrainingConfiguration(trainingJson);
|
||||
else log.warn("If enforceTrainingConfig is true, a training " +
|
||||
"configuration object has to be provided. Usually the only practical way to do this is to store" +
|
||||
" your keras model with `model.save('model_path.h5'. If you store model config and weights" +
|
||||
" your keras model with `model.save('model_path.h5')`. If you store model config and weights" +
|
||||
" separately no training configuration is attached.");
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.deeplearning4j.clustering.algorithm.Distance;
|
|||
import org.nd4j.linalg.api.buffer.DataType;
|
||||
import org.nd4j.linalg.api.ndarray.INDArray;
|
||||
import org.nd4j.linalg.api.ops.ReduceOp;
|
||||
import org.nd4j.linalg.api.ops.impl.indexaccum.IMin;
|
||||
import org.nd4j.linalg.api.ops.impl.indexaccum.custom.ArgMin;
|
||||
import org.nd4j.linalg.factory.Nd4j;
|
||||
import org.nd4j.common.primitives.Pair;
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class CentersHolder {
|
|||
private long index = 0;
|
||||
|
||||
protected transient ReduceOp op;
|
||||
protected IMin imin;
|
||||
protected ArgMin imin;
|
||||
protected transient INDArray distances;
|
||||
protected transient INDArray argMin;
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class CentersHolder {
|
|||
|
||||
if (op == null) {
|
||||
op = ClusterUtils.createDistanceFunctionOp(distanceFunction, centers, point.getArray(), 1);
|
||||
imin = new IMin(distances, argMin);
|
||||
imin = new ArgMin(distances, argMin);
|
||||
op.setZ(distances);
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ public class CentersHolder {
|
|||
|
||||
if (op == null) {
|
||||
op = ClusterUtils.createDistanceFunctionOp(distanceFunction, centers, point.getArray(), 1);
|
||||
imin = new IMin(distances, argMin);
|
||||
imin = new ArgMin(distances, argMin);
|
||||
op.setZ(distances);
|
||||
}
|
||||
|
||||
|
|
|
@ -273,10 +273,10 @@ public class KMeansTest extends BaseDL4JTest {
|
|||
ClusterSet clusterSet = kMeansClustering.applyTo(points);
|
||||
|
||||
double[] centroid1 = {2.44e8, 2.71e8, 2.98e8, 3.25e8};
|
||||
double[] centroid2 = {5.14e8, 5.41e8, 5.68e8, 5.95e8};
|
||||
double[] centroid3 = {1000000.0, 2.8E7, 5.5E7, 8.2E7};
|
||||
double[] centroid4 = {7.03E8, 7.3E8, 7.57E8, 7.84E8};
|
||||
double[] centroid5 = {3.79E8, 4.06E8, 4.33E8, 4.6E8};
|
||||
double[] centroid2 = {1000000.0, 2.8E7, 5.5E7, 8.2E7};
|
||||
double[] centroid3 = {5.95E8, 6.22e8, 6.49e8, 6.76e8};
|
||||
double[] centroid4 = {3.79E8, 4.06E8, 4.33E8, 4.6E8};
|
||||
double[] centroid5 = {5.5E7, 8.2E7, 1.09E8, 1.36E8};
|
||||
|
||||
assertArrayEquals(centroid1, clusterSet.getClusters().get(0).getCenter().getArray().toDoubleVector(), 1e-4);
|
||||
assertArrayEquals(centroid2, clusterSet.getClusters().get(1).getCenter().getArray().toDoubleVector(), 1e-4);
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.deeplearning4j.BaseDL4JTest;
|
|||
import org.junit.Rule;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.nd4j.common.io.ClassPathResource;
|
||||
import org.nd4j.linalg.api.ops.impl.indexaccum.custom.ArgMax;
|
||||
import org.deeplearning4j.models.word2vec.VocabWord;
|
||||
import org.deeplearning4j.models.word2vec.wordstore.VocabCache;
|
||||
import org.deeplearning4j.text.sentenceiterator.labelaware.LabelAwareFileSentenceIterator;
|
||||
|
@ -31,7 +32,6 @@ import org.deeplearning4j.text.tokenization.tokenizerfactory.DefaultTokenizerFac
|
|||
import org.deeplearning4j.text.tokenization.tokenizerfactory.TokenizerFactory;
|
||||
import org.junit.Test;
|
||||
import org.nd4j.linalg.api.ndarray.INDArray;
|
||||
import org.nd4j.linalg.api.ops.impl.indexaccum.IMax;
|
||||
import org.nd4j.linalg.dataset.DataSet;
|
||||
import org.nd4j.linalg.factory.Nd4j;
|
||||
import org.nd4j.common.util.SerializationUtils;
|
||||
|
@ -111,7 +111,7 @@ public class BagOfWordsVectorizerTest extends BaseDL4JTest {
|
|||
INDArray labelz = dataSet.getLabels();
|
||||
log.info("Labels array: " + labelz);
|
||||
|
||||
int idx2 = Nd4j.getExecutioner().exec(new IMax(labelz)).getInt(0);
|
||||
int idx2 = Nd4j.getExecutioner().exec(new ArgMax(labelz))[0].getInt(0);
|
||||
//int idx2 = ((IndexAccumulation) Nd4j.getExecutioner().exec(new IMax(labelz))).getFinalResult().intValue();
|
||||
|
||||
// assertEquals(1.0, dataSet.getLabels().getDouble(0), 0.1);
|
||||
|
@ -125,7 +125,7 @@ public class BagOfWordsVectorizerTest extends BaseDL4JTest {
|
|||
assertEquals(1, dataSet.getFeatures().getDouble(vocabCache.tokenFor("1").getIndex()), 0.1);
|
||||
assertEquals(0, dataSet.getFeatures().getDouble(vocabCache.tokenFor("2").getIndex()), 0.1);
|
||||
|
||||
int idx1 = Nd4j.getExecutioner().exec(new IMax(dataSet.getLabels())).getInt(0);
|
||||
int idx1 = Nd4j.getExecutioner().exec(new ArgMax(dataSet.getLabels()))[0].getInt(0);
|
||||
//int idx1 = ((IndexAccumulation) Nd4j.getExecutioner().exec(new IMax(dataSet.getLabels()))).getFinalResult().intValue();
|
||||
|
||||
//assertEquals(0.0, dataSet.getLabels().getDouble(0), 0.1);
|
||||
|
|
|
@ -21,6 +21,7 @@ import lombok.Getter;
|
|||
import lombok.Setter;
|
||||
import org.deeplearning4j.nn.api.Layer;
|
||||
import org.deeplearning4j.nn.api.ParamInitializer;
|
||||
import org.deeplearning4j.nn.conf.CNN2DFormat;
|
||||
import org.deeplearning4j.nn.conf.GradientNormalization;
|
||||
import org.deeplearning4j.nn.conf.InputPreProcessor;
|
||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||
|
@ -80,6 +81,8 @@ public class Yolo2OutputLayer extends org.deeplearning4j.nn.conf.layers.Layer {
|
|||
@JsonDeserialize(using = BoundingBoxesDeserializer.class)
|
||||
private INDArray boundingBoxes;
|
||||
|
||||
private CNN2DFormat format = CNN2DFormat.NCHW; //Default for serialization of old formats
|
||||
|
||||
private Yolo2OutputLayer() {
|
||||
//No-arg constructor for Jackson JSON
|
||||
}
|
||||
|
@ -119,7 +122,8 @@ public class Yolo2OutputLayer extends org.deeplearning4j.nn.conf.layers.Layer {
|
|||
|
||||
@Override
|
||||
public void setNIn(InputType inputType, boolean override) {
|
||||
//No op
|
||||
InputType.InputTypeConvolutional c = (InputType.InputTypeConvolutional) inputType;
|
||||
this.format = c.getFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.deeplearning4j.nn.layers.objdetect;
|
|||
import lombok.*;
|
||||
import org.deeplearning4j.nn.api.Layer;
|
||||
import org.deeplearning4j.nn.api.layers.IOutputLayer;
|
||||
import org.deeplearning4j.nn.conf.CNN2DFormat;
|
||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||
import org.deeplearning4j.nn.gradient.DefaultGradient;
|
||||
import org.deeplearning4j.nn.gradient.Gradient;
|
||||
|
@ -110,6 +111,12 @@ public class Yolo2OutputLayer extends AbstractLayer<org.deeplearning4j.nn.conf.l
|
|||
Preconditions.checkState(labels.rank() == 4, "Expected rank 4 labels array with shape [minibatch, 4+numClasses, h, w]" +
|
||||
" but got rank %s labels array with shape %s", labels.rank(), labels.shape());
|
||||
|
||||
boolean nchw = layerConf().getFormat() == CNN2DFormat.NCHW;
|
||||
INDArray input = nchw ? this.input : this.input.permute(0,3,1,2); //NHWC to NCHW
|
||||
INDArray labels = this.labels.castTo(input.dataType()); //Ensure correct dtype (same as params); no-op if already correct dtype
|
||||
if(!nchw)
|
||||
labels = labels.permute(0,3,1,2); //NHWC to NCHW
|
||||
|
||||
double lambdaCoord = layerConf().getLambdaCoord();
|
||||
double lambdaNoObj = layerConf().getLambdaNoObj();
|
||||
|
||||
|
@ -119,7 +126,7 @@ public class Yolo2OutputLayer extends AbstractLayer<org.deeplearning4j.nn.conf.l
|
|||
int b = (int) layerConf().getBoundingBoxes().size(0);
|
||||
int c = (int) labels.size(1)-4;
|
||||
|
||||
INDArray labels = this.labels.castTo(input.dataType()); //Ensure correct dtype (same as params); no-op if already correct dtype
|
||||
|
||||
|
||||
//Various shape arrays, to reuse
|
||||
long[] nhw = new long[]{mb, h, w};
|
||||
|
@ -380,13 +387,17 @@ public class Yolo2OutputLayer extends AbstractLayer<org.deeplearning4j.nn.conf.l
|
|||
epsWH.addi(dLc_din_wh);
|
||||
epsXY.addi(dLc_din_xy);
|
||||
|
||||
if(!nchw)
|
||||
epsOut = epsOut.permute(0,2,3,1); //NCHW to NHWC
|
||||
|
||||
return epsOut;
|
||||
}
|
||||
|
||||
@Override
|
||||
public INDArray activate(boolean training, LayerWorkspaceMgr workspaceMgr) {
|
||||
assertInputSet(false);
|
||||
return YoloUtils.activate(layerConf().getBoundingBoxes(), input, workspaceMgr);
|
||||
boolean nchw = layerConf().getFormat() == CNN2DFormat.NCHW;
|
||||
return YoloUtils.activate(layerConf().getBoundingBoxes(), input, nchw, workspaceMgr);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -39,12 +39,23 @@ import static org.nd4j.linalg.indexing.NDArrayIndex.*;
|
|||
*/
|
||||
public class YoloUtils {
|
||||
|
||||
/** Essentially: just apply activation functions... */
|
||||
/** Essentially: just apply activation functions... For NCHW format. For NCHW format, use one of the other activate methods */
|
||||
public static INDArray activate(INDArray boundingBoxPriors, INDArray input) {
|
||||
return activate(boundingBoxPriors, input, LayerWorkspaceMgr.noWorkspaces());
|
||||
return activate(boundingBoxPriors, input, true);
|
||||
}
|
||||
|
||||
public static INDArray activate(@NonNull INDArray boundingBoxPriors, @NonNull INDArray input, LayerWorkspaceMgr layerWorkspaceMgr){
|
||||
public static INDArray activate(INDArray boundingBoxPriors, INDArray input, boolean nchw) {
|
||||
return activate(boundingBoxPriors, input, nchw, LayerWorkspaceMgr.noWorkspaces());
|
||||
}
|
||||
|
||||
public static INDArray activate(@NonNull INDArray boundingBoxPriors, @NonNull INDArray input, LayerWorkspaceMgr layerWorkspaceMgr) {
|
||||
return activate(boundingBoxPriors, input, true, layerWorkspaceMgr);
|
||||
}
|
||||
|
||||
public static INDArray activate(@NonNull INDArray boundingBoxPriors, @NonNull INDArray input, boolean nchw, LayerWorkspaceMgr layerWorkspaceMgr){
|
||||
if(!nchw)
|
||||
input = input.permute(0,3,1,2); //NHWC to NCHW
|
||||
|
||||
long mb = input.size(0);
|
||||
long h = input.size(2);
|
||||
long w = input.size(3);
|
||||
|
@ -83,6 +94,9 @@ public class YoloUtils {
|
|||
INDArray outputClasses = output5.get(all(), all(), interval(5, 5+c), all(), all()); //Shape: [minibatch, C, H, W]
|
||||
outputClasses.assign(postSoftmax5d);
|
||||
|
||||
if(!nchw)
|
||||
output = output.permute(0,2,3,1); //NCHW to NHWC
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
|
|
@ -767,6 +767,13 @@ public class MultiLayerNetwork implements Serializable, Classifier, Layer, Neura
|
|||
if (!isInitCalled())
|
||||
init();
|
||||
|
||||
if (solver == null) {
|
||||
try (MemoryWorkspace wsO = Nd4j.getMemoryManager().scopeOutOfWorkspaces()) {
|
||||
solver = new Solver.Builder().configure(conf()).listeners(getListeners()).model(this)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
solver.getOptimizer().setGradientsAccumulator(accumulator);
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ public class GradientSharingTrainingTest extends BaseSparkTest {
|
|||
|
||||
@Override
|
||||
public long getTimeoutMilliseconds() {
|
||||
return 90000L;
|
||||
return 180000L;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
sudo: required
|
||||
dist: trusty
|
||||
language: python
|
||||
python:
|
||||
- "2.7"
|
||||
- "3.6"
|
||||
before_install:
|
||||
- sudo apt-get install -y python-dev python-pip python-virtualenv pkg-config
|
||||
install:
|
||||
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
|
||||
wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh;
|
||||
else
|
||||
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
|
||||
fi
|
||||
- bash miniconda.sh -b -p $HOME/miniconda
|
||||
- export PATH="$HOME/miniconda/bin:$PATH"
|
||||
- hash -r
|
||||
- conda config --set always_yes yes --set changeps1 no
|
||||
- conda update -q conda
|
||||
- conda info -a
|
||||
- travis_retry conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION nose
|
||||
- source activate test-environment
|
||||
- pip install Cython --install-option="--no-cython-compile"
|
||||
- pip install -e .[tests]
|
||||
script: py.test --pep8 -m pep8
|
201
jumpy/LICENSE
201
jumpy/LICENSE
|
@ -1,201 +0,0 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed 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.
|
|
@ -17,6 +17,10 @@ option(FLATBUFFERS_BUILD_FLATC "Enable the build of the flatbuffers compiler" OF
|
|||
set(FLATBUFFERS_BUILD_FLATC "OFF" CACHE STRING "Hack to disable flatc build" FORCE)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
|
||||
include(GenCompilation)
|
||||
|
||||
if (SD_CUDA)
|
||||
enable_language(CUDA)
|
||||
set(CMAKE_CUDA_STANDARD 11)
|
||||
|
@ -251,7 +255,6 @@ set(CPACK_PACKAGE_VERSION_MINOR "8")
|
|||
set(CPACK_PACKAGE_VERSION_PATCH "0")
|
||||
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "libnd4j")
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
||||
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
|
||||
|
||||
# Determine distribution and release — may require redhat-lsb-core installed on CentOS / RH
|
||||
|
|
202
libnd4j/LICENSE
202
libnd4j/LICENSE
|
@ -1,202 +0,0 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed 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.
|
||||
|
|
@ -77,7 +77,7 @@ If you're adding new ops, and want to make sure they run ok on your specific dev
|
|||
Despite being simple - it still provides you with time spent in various parts of Graph.
|
||||
|
||||
```c++
|
||||
Environment::getInstance()->setProfiling(true);
|
||||
Environment::getInstance().setProfiling(true);
|
||||
auto graph = GraphExecutioner::importFromFlatBuffers("./resources/ae_00.fb");
|
||||
|
||||
auto profile = GraphProfilingHelper::profile(graph, 1000);
|
||||
|
|
|
@ -226,6 +226,14 @@ if(SD_CUDA)
|
|||
file(GLOB_RECURSE LEGACY_SOURCES false ../include/legacy/impl/*.cpp ../include/legacy/*.cu ../include/legacy/*.h)
|
||||
file(GLOB_RECURSE LOOPS_SOURCES_CUDA false ../include/loops/*.cu)
|
||||
|
||||
|
||||
file(GLOB_RECURSE COMPILATION_UNITS false ../include/loops/cuda/compilation_units/*.cu.in
|
||||
../include/ops/impl/compilation_units/*.cpp.in)
|
||||
|
||||
foreach(FL_ITEM ${COMPILATION_UNITS})
|
||||
genCompilation(FL_ITEM)
|
||||
endforeach()
|
||||
|
||||
if (HAVE_CUDNN)
|
||||
message("cuDNN included")
|
||||
file(GLOB_RECURSE CUSTOMOPS_CUDNN_SOURCES false ../include/ops/declarable/platform/cudnn/*.cu)
|
||||
|
@ -234,7 +242,9 @@ if(SD_CUDA)
|
|||
add_library(samediff_obj OBJECT ${LOOPS_SOURCES_CUDA} ${LEGACY_SOURCES}
|
||||
${CUSTOMOPS_HELPERS_SOURCES} ${HELPERS_SOURCES} ${EXEC_SOURCES}
|
||||
${LOOPS_SOURCES} ${ARRAY_SOURCES} ${TYPES_SOURCES}
|
||||
${MEMORY_SOURCES} ${GRAPH_SOURCES} ${CUSTOMOPS_SOURCES} ${INDEXING_SOURCES} ${EXCEPTIONS_SOURCES} ${OPS_SOURCES} ${PERF_SOURCES} ${CUSTOMOPS_CUDNN_SOURCES} ${CUSTOMOPS_MKLDNN_SOURCES})
|
||||
${MEMORY_SOURCES} ${GRAPH_SOURCES} ${CUSTOMOPS_SOURCES} ${INDEXING_SOURCES} ${EXCEPTIONS_SOURCES} ${OPS_SOURCES} ${PERF_SOURCES} ${CUSTOMOPS_CUDNN_SOURCES} ${CUSTOMOPS_MKLDNN_SOURCES}
|
||||
${CUSTOMOPS_GENERIC_SOURCES}
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
message("MSVC runtime for library: ${MSVC_RT_LIB}")
|
||||
|
@ -294,12 +304,23 @@ elseif(SD_CPU)
|
|||
file(GLOB_RECURSE LEGACY_SOURCES false ../include/legacy/impl/*.cpp ../include/legacy/cpu/*.cpp ../include/legacy/*.h)
|
||||
file(GLOB_RECURSE LOOPS_SOURCES false ../include/loops/*.cpp ../include/loops/*.h)
|
||||
|
||||
|
||||
file(GLOB_RECURSE COMPILATION_UNITS false ../include/ops/declarable/helpers/cpu/compilation_units/*.cpp.in
|
||||
../include/loops/cpu/compilation_units/*.cpp.in ../include/helpers/cpu/loops/*.cpp.in
|
||||
../include/ops/impl/compilation_units/*.cpp.in)
|
||||
|
||||
foreach(FL_ITEM ${COMPILATION_UNITS})
|
||||
genCompilation(FL_ITEM)
|
||||
endforeach()
|
||||
|
||||
if (SD_X86_BUILD)
|
||||
# we disable platform optimizations for certains files for linux/macos
|
||||
set_source_files_properties(cpu/NativeOps.cpp PROPERTIES COMPILE_FLAGS "-march=x86-64 -mtune=generic")
|
||||
set_source_files_properties(../include/helpers/impl/OpTracker.cpp PROPERTIES COMPILE_FLAGS "-march=x86-64 -mtune=generic")
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
if(SD_CHECK_VECTORIZATION)
|
||||
set(VECT_FILES cpu/NativeOps.cpp ${OPS_SOURCES} ${HELPERS_SOURCES} ${CUSTOMOPS_GENERIC_SOURCES} ${LOOPS_SOURCES})
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
################################################################################
|
||||
# Copyright (c) 2020 Konduit K.K.
|
||||
#
|
||||
# This program and the accompanying materials are made available under the
|
||||
# terms of the Apache License, Version 2.0 which is available at
|
||||
# https://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.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
################################################################################
|
||||
|
||||
#///////////////////////////////////////////////////////////////////////////////
|
||||
# genCompilation: Generates cpp, cu files
|
||||
# INPUT:
|
||||
# $FILE_ITEM template-configuration that utilizes libnd4j type, macros helpers
|
||||
# defined inside { include/types/types.h, include/system/type_boilerplate.h}
|
||||
# OUTPUT:
|
||||
# $CUSTOMOPS_GENERIC_SOURCES generated files will be added into this List
|
||||
#////////////////////////////////////////////////////////////////////////////////
|
||||
# A simple template-configuration file example:
|
||||
# // hints and defines what types will be generated
|
||||
# #cmakedefine LIBND4J_TYPE_GEN
|
||||
# #cmakedefine FLOAT_TYPE_GEN
|
||||
# // below if defines blocks are needed for correctly handling multiple types
|
||||
# #if defined(LIBND4J_TYPE_GEN)
|
||||
# BUILD_DOUBLE_TEMPLATE(template void someFunc, (arg_list,..),
|
||||
# LIBND4J_TYPES_@FL_TYPE_INDEX@, INDEXING_TYPES);
|
||||
# #endif
|
||||
# #if defined(FLOAT_TYPE_GEN)
|
||||
# BUILD_SINGLE_TEMPLATE(template class SomeClass,, FLOAT_TYPES_@FL_TYPE_INDEX@);
|
||||
# #endif
|
||||
#////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function(genCompilation FILE_ITEM)
|
||||
get_filename_component(FILE_ITEM_WE ${FL_ITEM} NAME_WE)
|
||||
|
||||
set(EXTENSION "cpp")
|
||||
|
||||
if(FL_ITEM MATCHES "cu.in$")
|
||||
set(EXTENSION "cu")
|
||||
endif()
|
||||
|
||||
file(READ ${FL_ITEM} CONTENT_FL)
|
||||
#check content for types
|
||||
|
||||
#set all to false
|
||||
set (FLOAT_TYPE_GEN 0)
|
||||
set (INT_TYPE_GEN 0)
|
||||
set (LIBND4J_TYPE_GEN 0)
|
||||
set (PAIRWISE_TYPE_GEN 0)
|
||||
set (RANGE_STOP -1)
|
||||
|
||||
string(REGEX MATCHALL "#cmakedefine[ \t]+[^_]+_TYPE_GEN" TYPE_MATCHES ${CONTENT_FL})
|
||||
|
||||
foreach(TYPEX ${TYPE_MATCHES})
|
||||
set(STOP -1)
|
||||
if(TYPEX MATCHES "INT_TYPE_GEN$")
|
||||
set (INT_TYPE_GEN 1)
|
||||
set(STOP 7)
|
||||
endif()
|
||||
if(TYPEX MATCHES "LIBND4J_TYPE_GEN$")
|
||||
set (LIBND4J_TYPE_GEN 1)
|
||||
set(STOP 9)
|
||||
endif()
|
||||
if(TYPEX MATCHES "FLOAT_TYPE_GEN$")
|
||||
set (FLOAT_TYPE_GEN 1)
|
||||
set(STOP 3)
|
||||
endif()
|
||||
if(TYPEX MATCHES "PAIRWISE_TYPE_GEN$")
|
||||
set (PAIRWISE_TYPE_GEN 1)
|
||||
set(STOP 12)
|
||||
endif()
|
||||
if(STOP GREATER RANGE_STOP)
|
||||
set(RANGE_STOP ${STOP})
|
||||
endif()
|
||||
|
||||
endforeach()
|
||||
|
||||
if(RANGE_STOP GREATER -1)
|
||||
foreach(FL_TYPE_INDEX RANGE 0 ${RANGE_STOP})
|
||||
# set OFF if the index is above
|
||||
if(FL_TYPE_INDEX GREATER 3)
|
||||
set (FLOAT_TYPE_GEN 0)
|
||||
endif()
|
||||
if(FL_TYPE_INDEX GREATER 7)
|
||||
set (INT_TYPE_GEN 0)
|
||||
endif()
|
||||
if(FL_TYPE_INDEX GREATER 9)
|
||||
set (LIBND4J_TYPE_GEN 0)
|
||||
endif()
|
||||
set(GENERATED_SOURCE "${CMAKE_BINARY_DIR}/compilation_units/${FILE_ITEM_WE}_${FL_TYPE_INDEX}.${EXTENSION}")
|
||||
configure_file( "${FL_ITEM}" "${GENERATED_SOURCE}" @ONLY)
|
||||
LIST(APPEND CUSTOMOPS_GENERIC_SOURCES ${GENERATED_SOURCE} )
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
set(CUSTOMOPS_GENERIC_SOURCES ${CUSTOMOPS_GENERIC_SOURCES} PARENT_SCOPE)
|
||||
endfunction()
|
|
@ -3,7 +3,7 @@
|
|||
set(CMAKE_SYSTEM_NAME Android)
|
||||
set(CMAKE_ANDROID_ARCH_ABI armeabi-v7a)
|
||||
set(CMAKE_ANDROID_NDK "$ENV{ANDROID_NDK}")
|
||||
set(CMAKE_ANDROID_STL_TYPE c++_shared)
|
||||
set(CMAKE_ANDROID_STL_TYPE c++_static)
|
||||
set(CMAKE_SYSTEM_VERSION "$ENV{ANDROID_VERSION}")
|
||||
set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION clang)
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
set(CMAKE_SYSTEM_NAME Android)
|
||||
set(CMAKE_ANDROID_ARCH_ABI arm64-v8a)
|
||||
set(CMAKE_ANDROID_NDK "$ENV{ANDROID_NDK}")
|
||||
set(CMAKE_ANDROID_STL_TYPE c++_shared)
|
||||
set(CMAKE_ANDROID_STL_TYPE c++_static)
|
||||
set(CMAKE_SYSTEM_VERSION "$ENV{ANDROID_VERSION}")
|
||||
set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION clang)
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
set(CMAKE_SYSTEM_NAME Android)
|
||||
set(CMAKE_ANDROID_ARCH_ABI x86)
|
||||
set(CMAKE_ANDROID_NDK "$ENV{ANDROID_NDK}")
|
||||
set(CMAKE_ANDROID_STL_TYPE c++_shared)
|
||||
set(CMAKE_ANDROID_STL_TYPE c++_static)
|
||||
set(CMAKE_SYSTEM_VERSION "$ENV{ANDROID_VERSION}")
|
||||
set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION clang)
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
set(CMAKE_SYSTEM_NAME Android)
|
||||
set(CMAKE_ANDROID_ARCH_ABI x86_64)
|
||||
set(CMAKE_ANDROID_NDK "$ENV{ANDROID_NDK}")
|
||||
set(CMAKE_ANDROID_STL_TYPE c++_shared)
|
||||
set(CMAKE_ANDROID_STL_TYPE c++_static)
|
||||
set(CMAKE_SYSTEM_VERSION "$ENV{ANDROID_VERSION}")
|
||||
set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION clang)
|
||||
|
||||
|
|
|
@ -22,37 +22,40 @@
|
|||
|
||||
#include <system/dll.h>
|
||||
#include <system/pointercast.h>
|
||||
#include <memory>
|
||||
#include <array/PointerWrapper.h>
|
||||
#include <array/DataType.h>
|
||||
|
||||
|
||||
namespace sd {
|
||||
class ND4J_EXPORT ConstantDataBuffer {
|
||||
private:
|
||||
Nd4jPointer _primaryBuffer = nullptr;
|
||||
Nd4jPointer _specialBuffer = nullptr;
|
||||
Nd4jLong _length = 0;
|
||||
Nd4jLong _sizeOf = 0;
|
||||
std::shared_ptr<PointerWrapper> _primaryBuffer;
|
||||
std::shared_ptr<PointerWrapper> _specialBuffer = nullptr;
|
||||
uint64_t _length = 0;
|
||||
uint8_t _sizeOf = 0;
|
||||
|
||||
public:
|
||||
ConstantDataBuffer(Nd4jPointer primary, Nd4jPointer special, Nd4jLong numEelements, Nd4jLong sizeOf);
|
||||
ConstantDataBuffer(const std::shared_ptr<PointerWrapper>& primary, uint64_t numEelements, DataType dype);
|
||||
ConstantDataBuffer(const std::shared_ptr<PointerWrapper>& primary, const std::shared_ptr<PointerWrapper>& special, uint64_t numEelements, DataType dype);
|
||||
ConstantDataBuffer(const ConstantDataBuffer &other);
|
||||
ConstantDataBuffer() = default;
|
||||
~ConstantDataBuffer() = default;
|
||||
|
||||
Nd4jLong sizeOf() const;
|
||||
Nd4jLong length() const;
|
||||
uint8_t sizeOf() const;
|
||||
uint64_t length() const;
|
||||
|
||||
Nd4jPointer primary() const;
|
||||
Nd4jPointer special() const;
|
||||
void* primary() const;
|
||||
void* special() const;
|
||||
|
||||
ConstantDataBuffer& operator=(const ConstantDataBuffer& other) = default;
|
||||
ConstantDataBuffer& operator=(ConstantDataBuffer&& other) noexcept = default;
|
||||
|
||||
template <typename T>
|
||||
T* primaryAsT() const;
|
||||
|
||||
template <typename T>
|
||||
T* primaryAsT();
|
||||
|
||||
template <typename T>
|
||||
T* specialAsT();
|
||||
T* specialAsT() const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2019-2020 Konduit K.K.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License, Version 2.0 which is available at
|
||||
* https://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.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author raver119@gmail.com
|
||||
//
|
||||
|
||||
#ifndef SD_ARRAY_CONSTANTOFFSETSBUFFER_H_
|
||||
#define SD_ARRAY_CONSTANTOFFSETSBUFFER_H_
|
||||
|
||||
#include <system/dll.h>
|
||||
#include <system/pointercast.h>
|
||||
#include <memory>
|
||||
#include <array/PointerWrapper.h>
|
||||
|
||||
namespace sd {
|
||||
|
||||
class ND4J_EXPORT ConstantOffsetsBuffer {
|
||||
private:
|
||||
std::shared_ptr<PointerWrapper> _primaryOffsets;
|
||||
std::shared_ptr<PointerWrapper> _specialOffsets;
|
||||
|
||||
public:
|
||||
ConstantOffsetsBuffer(const std::shared_ptr<PointerWrapper> &primary);
|
||||
ConstantOffsetsBuffer(const std::shared_ptr<PointerWrapper> &primary, const std::shared_ptr<PointerWrapper> &special);
|
||||
ConstantOffsetsBuffer() = default;
|
||||
~ConstantOffsetsBuffer() = default;
|
||||
|
||||
const Nd4jLong* primary() const;
|
||||
const Nd4jLong* special() const;
|
||||
const Nd4jLong* platform() const;
|
||||
};
|
||||
|
||||
} // namespace sd
|
||||
|
||||
#endif //SD_ARRAY_CONSTANTOFFSETSBUFFER_H_
|
|
@ -0,0 +1,49 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2019-2020 Konduit K.K.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License, Version 2.0 which is available at
|
||||
* https://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.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author raver119@gmail.com
|
||||
//
|
||||
|
||||
#ifndef SD_ARRAY_CONSTANTSHAPEBUFFER_H_
|
||||
#define SD_ARRAY_CONSTANTSHAPEBUFFER_H_
|
||||
|
||||
#include <system/dll.h>
|
||||
#include <system/pointercast.h>
|
||||
#include <array/PointerWrapper.h>
|
||||
#include <memory>
|
||||
|
||||
namespace sd {
|
||||
|
||||
class ND4J_EXPORT ConstantShapeBuffer {
|
||||
private:
|
||||
std::shared_ptr<PointerWrapper> _primaryShapeInfo;
|
||||
std::shared_ptr<PointerWrapper> _specialShapeInfo;
|
||||
|
||||
public:
|
||||
ConstantShapeBuffer(const std::shared_ptr<PointerWrapper> &primary);
|
||||
ConstantShapeBuffer(const std::shared_ptr<PointerWrapper> &primary, const std::shared_ptr<PointerWrapper> &special);
|
||||
ConstantShapeBuffer() = default;
|
||||
~ConstantShapeBuffer() = default;
|
||||
|
||||
const Nd4jLong* primary() const;
|
||||
const Nd4jLong* special() const;
|
||||
const Nd4jLong* platform() const;
|
||||
};
|
||||
|
||||
} // namespace sd
|
||||
|
||||
#endif //SD_ARRAY_CONSTANTSHAPEBUFFER_H_
|
|
@ -0,0 +1,38 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2019-2020 Konduit K.K.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License, Version 2.0 which is available at
|
||||
* https://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.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author raver119@gmail.com
|
||||
//
|
||||
|
||||
#ifndef SD_CUDAYPOINTERDEALLOCATOR_H_
|
||||
#define SD_CUDAYPOINTERDEALLOCATOR_H_
|
||||
|
||||
#include <system/dll.h>
|
||||
#include <system/pointercast.h>
|
||||
#include <array/PointerDeallocator.h>
|
||||
|
||||
namespace sd {
|
||||
class ND4J_EXPORT CudaPointerDeallocator : public PointerDeallocator {
|
||||
public:
|
||||
CudaPointerDeallocator() = default;
|
||||
~CudaPointerDeallocator() = default;
|
||||
|
||||
void release(void* ptr) override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //SD_CUDAYPOINTERDEALLOCATOR_H_
|
|
@ -110,7 +110,7 @@ namespace sd {
|
|||
// if proposed dataType is already floating point - return it
|
||||
if (isR(typeX))
|
||||
return typeX;
|
||||
return Environment::getInstance()->defaultFloatDataType();
|
||||
return Environment::getInstance().defaultFloatDataType();
|
||||
}
|
||||
|
||||
FORCEINLINE bool DataTypeUtils::isR(sd::DataType dataType) {
|
||||
|
@ -154,7 +154,7 @@ namespace sd {
|
|||
// if both data types are float - return biggest one
|
||||
if (rX && rY) {
|
||||
// if we allow precision boost, then we pick bigger data type
|
||||
if (sd::Environment::getInstance()->precisionBoostAllowed()) {
|
||||
if (sd::Environment::getInstance().precisionBoostAllowed()) {
|
||||
return nd4j_max(typeX, typeY);
|
||||
} else {
|
||||
// and we return first operand otherwise
|
||||
|
@ -165,7 +165,7 @@ namespace sd {
|
|||
|
||||
// if that's not real type, we apply same rules
|
||||
if (!rX && !rY) {
|
||||
if (sd::Environment::getInstance()->precisionBoostAllowed()) {
|
||||
if (sd::Environment::getInstance().precisionBoostAllowed()) {
|
||||
return nd4j_max(typeX, typeY);
|
||||
} else {
|
||||
// and we return first operand otherwise
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include <memory>
|
||||
#include <array/InteropDataBuffer.h>
|
||||
#include <memory/MemoryCounter.h>
|
||||
#include <array/ConstantShapeBuffer.h>
|
||||
|
||||
|
||||
namespace sd {
|
||||
|
@ -155,8 +156,8 @@ namespace sd {
|
|||
/**
|
||||
* contains shape info: matrix rank, numbers of elements per each dimension, dimensions strides, element-wise-stride, c-like or fortan-like order
|
||||
*/
|
||||
Nd4jLong *_shapeInfo = nullptr;
|
||||
Nd4jLong *_shapeInfoD = nullptr;
|
||||
const Nd4jLong *_shapeInfo = nullptr;
|
||||
const Nd4jLong *_shapeInfoD = nullptr;
|
||||
|
||||
/**
|
||||
* pointer on device launch context (with all data needed there).
|
||||
|
@ -354,11 +355,11 @@ namespace sd {
|
|||
* @param writeList
|
||||
* @param readList
|
||||
*/
|
||||
static void registerSpecialUse(const std::vector<const NDArray*>& writeList, const std::vector<const NDArray*>& readList);
|
||||
static void prepareSpecialUse(const std::vector<const NDArray*>& writeList, const std::vector<const NDArray*>& readList, bool synchronizeWritables = false);
|
||||
static void registerSpecialUse(const std::vector<const NDArray*>& writeList, const std::vector<const NDArray*>& readList = {});
|
||||
static void prepareSpecialUse(const std::vector<const NDArray*>& writeList, const std::vector<const NDArray*>& readList = {}, bool synchronizeWritables = false);
|
||||
|
||||
static void registerPrimaryUse(const std::vector<const NDArray*>& writeList, const std::vector<const NDArray*>& readList);
|
||||
static void preparePrimaryUse(const std::vector<const NDArray*>& writeList, const std::vector<const NDArray*>& readList, bool synchronizeWritables = false);
|
||||
static void registerPrimaryUse(const std::vector<const NDArray*>& writeList, const std::vector<const NDArray*>& readList = {});
|
||||
static void preparePrimaryUse(const std::vector<const NDArray*>& writeList, const std::vector<const NDArray*>& readList = {}, bool synchronizeWritables = false);
|
||||
|
||||
/**
|
||||
* This method returns buffer pointer offset by given number of elements, wrt own data type
|
||||
|
@ -1163,7 +1164,7 @@ namespace sd {
|
|||
|
||||
/**
|
||||
* fill target matrix with given value in one or two directions from main diagonal:
|
||||
* - down from main diagonal starting at subdiagonal number "lower" if direction = 'd' (down) or 'b' (both)
|
||||
* - down from main diagonal starting at subdiagonal number "lower" if direction = 'l' (down) or 'b' (both)
|
||||
* - up from main diagonal starting at superdiagonal number "upper"if direction = 'u' (up) or 'b' (both)
|
||||
* direction - in what direction to fill matrix. There are 3 possible directions:
|
||||
* 'u' - fill up, mathematically this corresponds to lower triangular matrix, subdiagonal "lower" unaffected
|
||||
|
@ -1219,7 +1220,7 @@ namespace sd {
|
|||
void setShapeInfo(const Nd4jLong *shapeInfo);
|
||||
void setShapeInfo(const Nd4jLong *shapeInfo, const sd::DataType dtype);
|
||||
void setShapeInfo(const ShapeDescriptor& descriptor);
|
||||
void setShapeInfo(const ConstantDataBuffer& shapeBuffer);
|
||||
void setShapeInfo(const ConstantShapeBuffer& shapeBuffer);
|
||||
|
||||
/**
|
||||
* returns absolute offset which corresponds to given sequential index
|
||||
|
@ -1230,14 +1231,13 @@ namespace sd {
|
|||
* returns reference on array element with given index
|
||||
*/
|
||||
template<typename T>
|
||||
FORCEINLINE T& t(const Nd4jLong index);
|
||||
|
||||
FORCEINLINE T& r(const Nd4jLong index);
|
||||
template<typename T>
|
||||
FORCEINLINE T& t(const Nd4jLong i, const Nd4jLong j);
|
||||
FORCEINLINE T& r(const Nd4jLong i, const Nd4jLong j);
|
||||
template<typename T>
|
||||
FORCEINLINE T& t(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k);
|
||||
FORCEINLINE T& r(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k);
|
||||
template<typename T>
|
||||
FORCEINLINE T& t(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong w);
|
||||
FORCEINLINE T& r(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong w);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1246,7 +1246,6 @@ namespace sd {
|
|||
*/
|
||||
template<typename T>
|
||||
FORCEINLINE T t(const Nd4jLong i) const;
|
||||
|
||||
template<typename T>
|
||||
FORCEINLINE T t(const Nd4jLong i, const Nd4jLong j) const;
|
||||
template<typename T>
|
||||
|
@ -1518,9 +1517,9 @@ FORCEINLINE R NDArray::templatedGet(void const* buffer, Nd4jLong index) const {
|
|||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void NDArray::setShapeInfo(Nd4jLong *shapeInfo) {
|
||||
auto buffer = ConstantShapeHelper::getInstance()->bufferForShapeInfo(shapeInfo);
|
||||
_shapeInfo = buffer.primaryAsT<Nd4jLong>();
|
||||
_shapeInfoD = buffer.specialAsT<Nd4jLong>();
|
||||
auto buffer = ConstantShapeHelper::getInstance().bufferForShapeInfo(shapeInfo);
|
||||
_shapeInfo = buffer.primary();
|
||||
_shapeInfoD = buffer.special();
|
||||
|
||||
if (shapeInfo != nullptr) {
|
||||
_dataType = ArrayOptions::dataType(_shapeInfo);
|
||||
|
@ -1537,9 +1536,9 @@ void NDArray::setShapeInfo(Nd4jLong *shapeInfo) {
|
|||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void NDArray::setShapeInfo(Nd4jLong *shapeInfo, const sd::DataType dtype) {
|
||||
auto buffer = ConstantShapeHelper::getInstance()->bufferForShapeInfo(shapeInfo);
|
||||
_shapeInfo = buffer.primaryAsT<Nd4jLong>();
|
||||
_shapeInfoD = buffer.specialAsT<Nd4jLong>();
|
||||
auto buffer = ConstantShapeHelper::getInstance().bufferForShapeInfo(shapeInfo);
|
||||
_shapeInfo = buffer.primary();
|
||||
_shapeInfoD = buffer.special();
|
||||
|
||||
if (shapeInfo != nullptr) {
|
||||
_dataType = dtype;
|
||||
|
@ -1625,7 +1624,7 @@ bool NDArray::nonNull() const {
|
|||
if (isEmpty())
|
||||
return true;
|
||||
|
||||
if(!Environment::getInstance()->isCPU())
|
||||
if(!Environment::getInstance().isCPU())
|
||||
return getDataBuffer()->special() != nullptr && specialShapeInfo() != nullptr;
|
||||
|
||||
return getDataBuffer()->primary() != nullptr && shapeInfo() != nullptr;
|
||||
|
@ -1778,70 +1777,60 @@ DataType NDArray::dataType() const {
|
|||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
T& NDArray::t(const Nd4jLong i) {
|
||||
T& NDArray::r(const Nd4jLong i) {
|
||||
|
||||
// if (i >= _length)
|
||||
// throw std::invalid_argument("NDArray::t(i): input index is out of array length !");
|
||||
if (DataTypeUtils::fromT<T>() != _dataType)
|
||||
throw std::invalid_argument("NDArray::t(i): type of array is not equal to template type T!");
|
||||
|
||||
if(!isActualOnHostSide())
|
||||
syncToHost();
|
||||
|
||||
syncToHost();
|
||||
tickWriteHost();
|
||||
|
||||
return *(reinterpret_cast<T*>(bufferWithOffset(getOffset(i))));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
T& NDArray::t(const Nd4jLong i, const Nd4jLong j) {
|
||||
T& NDArray::r(const Nd4jLong i, const Nd4jLong j) {
|
||||
|
||||
if (rankOf() != 2 || i >= sizeAt(0) || j >= sizeAt(1))
|
||||
throw std::invalid_argument("NDArray::t(i,j): one of input indexes is out of array length or rank!=2 !");
|
||||
if (DataTypeUtils::fromT<T>() != _dataType)
|
||||
throw std::invalid_argument("NDArray::t(i,j): type of array is not equal to template type T!");
|
||||
|
||||
if(!isActualOnHostSide())
|
||||
syncToHost();
|
||||
|
||||
Nd4jLong coords[2] = {i, j};
|
||||
auto offset = shape::getOffset(shapeInfo(), coords);
|
||||
syncToHost();
|
||||
tickWriteHost();
|
||||
return *(reinterpret_cast<T*>(bufferWithOffset(offset)));
|
||||
|
||||
return *(reinterpret_cast<T*>(bufferWithOffset(i * strideAt(0) + j * strideAt(1))));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T& NDArray::t(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k) {
|
||||
T& NDArray::r(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k) {
|
||||
|
||||
if (rankOf() != 3 || i >= sizeAt(0) || j >= sizeAt(1) || k >= sizeAt(2))
|
||||
throw std::invalid_argument("NDArray::t(i,j,k): one of input indexes is out of array length or rank!=3!");
|
||||
if (DataTypeUtils::fromT<T>() != _dataType)
|
||||
throw std::invalid_argument("NDArray::t(i,j,k): type of array is not equal to template type T!");
|
||||
|
||||
if(!isActualOnHostSide())
|
||||
syncToHost();
|
||||
|
||||
Nd4jLong coords[3] = {i, j, k};
|
||||
auto offset = shape::getOffset(shapeInfo(), coords);
|
||||
syncToHost();
|
||||
tickWriteHost();
|
||||
return *(reinterpret_cast<T*>(bufferWithOffset(offset)));
|
||||
|
||||
return *(reinterpret_cast<T*>(bufferWithOffset(i * strideAt(0) + j * strideAt(1) + k * strideAt(2))));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T& NDArray::t(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong w) {
|
||||
T& NDArray::r(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong w) {
|
||||
|
||||
if (rankOf() != 4 || i >= sizeAt(0) || j >= sizeAt(1) || k >= sizeAt(2) || w >= sizeAt(3))
|
||||
throw std::invalid_argument("NDArray::t(i,j,k,w): one of input indexes is out of array length or rank!=4 !");
|
||||
if (DataTypeUtils::fromT<T>() != _dataType)
|
||||
throw std::invalid_argument("NDArray::t(i,j,k,w): type of array is not equal to template type T!");
|
||||
|
||||
if(!isActualOnHostSide())
|
||||
syncToHost();
|
||||
|
||||
Nd4jLong coords[4] = {i, j, k, w};
|
||||
auto offset = shape::getOffset(shapeInfo(), coords);
|
||||
syncToHost();
|
||||
tickWriteHost();
|
||||
return *(reinterpret_cast<T*>(bufferWithOffset(offset)));
|
||||
|
||||
return *(reinterpret_cast<T*>(bufferWithOffset(i * strideAt(0) + j * strideAt(1) + k * strideAt(2) + w * strideAt(3))));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1853,10 +1842,8 @@ T NDArray::t(const Nd4jLong i) const {
|
|||
if (DataTypeUtils::fromT<T>() != _dataType)
|
||||
throw std::invalid_argument("NDArray::t(i): type of array is not equal to template type T!");
|
||||
|
||||
if(!isActualOnHostSide())
|
||||
syncToHost();
|
||||
syncToHost();
|
||||
|
||||
tickReadHost();
|
||||
return *(reinterpret_cast<const T*>(bufferWithOffset(getOffset(i))));
|
||||
}
|
||||
|
||||
|
@ -1869,48 +1856,38 @@ T NDArray::t(const Nd4jLong i, const Nd4jLong j) const {
|
|||
if (DataTypeUtils::fromT<T>() != _dataType)
|
||||
throw std::invalid_argument("NDArray::t(i,j): type of array is not equal to template type T!");
|
||||
|
||||
if(!isActualOnHostSide())
|
||||
syncToHost();
|
||||
syncToHost();
|
||||
|
||||
Nd4jLong coords[2] = {i, j};
|
||||
auto offset = shape::getOffset(shapeInfo(), coords);
|
||||
tickReadHost();
|
||||
return *(reinterpret_cast<const T*>(bufferWithOffset(offset)));
|
||||
return *(reinterpret_cast<const T*>(bufferWithOffset(i * strideAt(0) + j * strideAt(1))));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T NDArray::t(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k) const {
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
T NDArray::t(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k) const {
|
||||
|
||||
if (rankOf() != 3 || i >= sizeAt(0) || j >= sizeAt(1) || k >= sizeAt(2))
|
||||
throw std::invalid_argument("NDArray::t(i,j,k): one of input indexes is out of array length or rank!=3!");
|
||||
if (DataTypeUtils::fromT<T>() != _dataType)
|
||||
throw std::invalid_argument("NDArray::t(i,j,k): type of array is not equal to template type T!");
|
||||
if (rankOf() != 3 || i >= sizeAt(0) || j >= sizeAt(1) || k >= sizeAt(2))
|
||||
throw std::invalid_argument("NDArray::t(i,j,k): one of input indexes is out of array length or rank!=3!");
|
||||
if (DataTypeUtils::fromT<T>() != _dataType)
|
||||
throw std::invalid_argument("NDArray::t(i,j,k): type of array is not equal to template type T!");
|
||||
|
||||
if(!isActualOnHostSide())
|
||||
syncToHost();
|
||||
syncToHost();
|
||||
|
||||
Nd4jLong coords[3] = {i, j, k};
|
||||
auto offset = shape::getOffset(shapeInfo(), coords);
|
||||
tickReadHost();
|
||||
return *(reinterpret_cast<const T*>(bufferWithOffset(offset)));
|
||||
}
|
||||
return *(reinterpret_cast<const T*>(bufferWithOffset(i * strideAt(0) + j * strideAt(1) + k * strideAt(2))));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T NDArray::t(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong w) const {
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
T NDArray::t(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong w) const {
|
||||
|
||||
if (rankOf() != 4 || i >= sizeAt(0) || j >= sizeAt(1) || k >= sizeAt(2) || w >= sizeAt(3))
|
||||
throw std::invalid_argument("NDArray::t(i,j,k,w): one of input indexes is out of array length or rank!=4!");
|
||||
if (DataTypeUtils::fromT<T>() != _dataType)
|
||||
throw std::invalid_argument("NDArray::t(i,j,k,w): type of array is not equal to template type T!");
|
||||
if (rankOf() != 4 || i >= sizeAt(0) || j >= sizeAt(1) || k >= sizeAt(2) || w >= sizeAt(3))
|
||||
throw std::invalid_argument("NDArray::t(i,j,k,w): one of input indexes is out of array length or rank!=4!");
|
||||
if (DataTypeUtils::fromT<T>() != _dataType)
|
||||
throw std::invalid_argument("NDArray::t(i,j,k,w): type of array is not equal to template type T!");
|
||||
|
||||
if(!isActualOnHostSide())
|
||||
syncToHost();
|
||||
syncToHost();
|
||||
|
||||
Nd4jLong coords[4] = {i, j, k, w};
|
||||
auto offset = shape::getOffset(shapeInfo(), coords);
|
||||
tickReadHost();
|
||||
return *(reinterpret_cast<const T*>(bufferWithOffset(offset)));
|
||||
}
|
||||
return *(reinterpret_cast<const T*>(bufferWithOffset(i * strideAt(0) + j * strideAt(1) + k * strideAt(2) + w * strideAt(3))));
|
||||
}
|
||||
|
||||
#ifndef __JAVACPP_HACK__
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -181,7 +181,7 @@ NDArray::NDArray(sd::DataType dtype, sd::LaunchContext* context, const bool isSc
|
|||
_buffer->setToZeroBuffers();
|
||||
}
|
||||
else
|
||||
setShapeInfo(ConstantShapeHelper::getInstance()->emptyShapeInfo(dtype));
|
||||
setShapeInfo(ConstantShapeHelper::getInstance().emptyShapeInfo(dtype));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1088,9 +1088,11 @@ void NDArray::streamline(char o) {
|
|||
char order = o == 'a' ? this->ordering() : o;
|
||||
syncToDevice();
|
||||
std::shared_ptr<DataBuffer> newBuffer = std::make_shared<DataBuffer>(this->lengthOf() * sizeOfT(), dataType(), getContext()->getWorkspace());
|
||||
auto shapeBuffer = ConstantShapeHelper::getInstance()->bufferForShapeInfo(dataType(), order, rankOf(), shapeOf());
|
||||
NativeOpExecutioner::execTransformSame(getContext(), transform::Copy, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), newBuffer->primary(), static_cast<Nd4jLong*>(shapeBuffer.primary()), newBuffer->special(), static_cast<Nd4jLong*>(shapeBuffer.special()), nullptr, nullptr, nullptr);
|
||||
setShapeInfo(static_cast<Nd4jLong*>(shapeBuffer.primary()));
|
||||
auto shapeBuffer = ConstantShapeHelper::getInstance().bufferForShapeInfo(dataType(), order, rankOf(), shapeOf());
|
||||
NativeOpExecutioner::execTransformSame(getContext(), transform::Copy, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), newBuffer->primary(),
|
||||
shapeBuffer.primary(), newBuffer->special(),
|
||||
shapeBuffer.special(), nullptr, nullptr, nullptr);
|
||||
setShapeInfo(shapeBuffer);
|
||||
_buffer = newBuffer;
|
||||
_offset = 0;
|
||||
tickWriteDevice();
|
||||
|
@ -1355,7 +1357,7 @@ NDArray NDArray::reduceAlongDimension(sd::reduce::FloatOps op, const std::vector
|
|||
|
||||
std::vector<int> copy(dimensions);
|
||||
|
||||
auto newShape = ShapeUtils::evalReduceShapeInfo('c', copy, *this, isR() ? dataType() : Environment::getInstance()->defaultFloatDataType(), keepDims, supportOldShapes, getContext()->getWorkspace());
|
||||
auto newShape = ShapeUtils::evalReduceShapeInfo('c', copy, *this, isR() ? dataType() : Environment::getInstance().defaultFloatDataType(), keepDims, supportOldShapes, getContext()->getWorkspace());
|
||||
|
||||
NDArray result(newShape, true, getContext());
|
||||
|
||||
|
@ -1432,7 +1434,7 @@ NDArray NDArray::reduceNumber(sd::reduce::FloatOps op, void *extraParams) const
|
|||
if (isS())
|
||||
throw std::runtime_error("NDArray::reduceNumber FloatOps: you can't use this method on String array!");
|
||||
|
||||
auto shape = ConstantShapeHelper::getInstance()->scalarShapeInfo(DataTypeUtils::pickFloatingType(dataType()));
|
||||
auto shape = ConstantShapeHelper::getInstance().scalarShapeInfo(DataTypeUtils::pickFloatingType(dataType()));
|
||||
NDArray result(shape, true, this->getContext());
|
||||
|
||||
NDArray::prepareSpecialUse({&result}, {this});
|
||||
|
@ -1461,7 +1463,7 @@ NDArray NDArray::reduceNumber(sd::reduce::BoolOps op, void *extraParams) const {
|
|||
if (isS())
|
||||
throw std::runtime_error("NDArray::reduceNumber BoolOps: you can't use this method on String array!");
|
||||
|
||||
auto shape = ConstantShapeHelper::getInstance()->scalarShapeInfo(DataType::BOOL);
|
||||
auto shape = ConstantShapeHelper::getInstance().scalarShapeInfo(DataType::BOOL);
|
||||
NDArray result(shape, true, this->getContext());
|
||||
|
||||
NDArray::prepareSpecialUse({&result}, {this});
|
||||
|
@ -1476,7 +1478,7 @@ NDArray NDArray::reduceNumber(sd::reduce::LongOps op, void *extraParams) const {
|
|||
if (isS())
|
||||
throw std::runtime_error("NDArray::reduceNumber LongOps: you can't use this method on String array!");
|
||||
|
||||
auto shape = ConstantShapeHelper::getInstance()->scalarShapeInfo(DataType::INT64);
|
||||
auto shape = ConstantShapeHelper::getInstance().scalarShapeInfo(DataType::INT64);
|
||||
NDArray result(shape, true, this->getContext());
|
||||
|
||||
NDArray::prepareSpecialUse({&result}, {this});
|
||||
|
@ -1671,11 +1673,11 @@ void NDArray::printLinearBuffer() const {
|
|||
}
|
||||
else if(this->dataType() == sd::DataType::FLOAT32) {
|
||||
for(Nd4jLong e = 0; e < len; e++)
|
||||
printf("%.3f, ", this->bufferAsT<float>()[e * ews]);
|
||||
printf("%.8f, ", this->bufferAsT<float>()[e * ews]);
|
||||
}
|
||||
else if(this->dataType() == sd::DataType::DOUBLE) {
|
||||
for(Nd4jLong e = 0; e < len; e++)
|
||||
printf("%.3f, ", this->bufferAsT<double>()[e * ews]);
|
||||
printf("%.8f, ", this->bufferAsT<double>()[e * ews]);
|
||||
}
|
||||
else
|
||||
throw std::invalid_argument("NDArray::printLinearBuffer: not implemented yet for this data type !");
|
||||
|
@ -1773,7 +1775,7 @@ void NDArray::printIndexedBuffer(const char* msg, Nd4jLong limit) const {
|
|||
if (this->isZ())
|
||||
printf("%lld\n", this->e<Nd4jLong>(0));
|
||||
else if (this->isR())
|
||||
printf("%f\n", this->e<float>(0));
|
||||
printf("%.8f\n", this->e<float>(0));
|
||||
else if (this->isB()) {
|
||||
printf("%s\n", this->e<bool>(0)?"true":"false");
|
||||
}
|
||||
|
@ -1854,8 +1856,7 @@ void NDArray::setAttached(bool reallyAttached) {
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
// calculate strides
|
||||
void NDArray::updateStrides(const char order) {
|
||||
shape::updateStrides(_shapeInfo, order);
|
||||
syncShape();
|
||||
throw std::runtime_error("Forbidden method");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -2170,7 +2171,7 @@ const std::string* ND4J_EXPORT NDArray::bufferAsT() const {
|
|||
template <typename T>
|
||||
const T* NDArray::bufferAsT() const {
|
||||
// FIXME: do we REALLY want sync here?
|
||||
syncToHost();
|
||||
// syncToHost();
|
||||
|
||||
return reinterpret_cast<const T*>(buffer());
|
||||
}
|
||||
|
@ -2456,7 +2457,7 @@ void NDArray::operator+=(const NDArray& other) {
|
|||
|
||||
if (isS())
|
||||
throw std::runtime_error("NDArray::operator+=: you can't use this method on String array!");
|
||||
if (!Environment::getInstance()->isExperimentalBuild() && this->dataType() != other.dataType() && (this->dataType() != DataType::BOOL || other.dataType() != BOOL))
|
||||
if (!Environment::getInstance().isExperimentalBuild() && this->dataType() != other.dataType() && (this->dataType() != DataType::BOOL || other.dataType() != BOOL))
|
||||
throw sd::datatype_exception::build("NDArray operator+=: Cannot add different types", this->dataType(), other.dataType());
|
||||
|
||||
if (this->lengthOf() != 1 && other.lengthOf() == 1) {
|
||||
|
@ -2490,7 +2491,7 @@ void NDArray::operator-=(const NDArray& other) {
|
|||
if (isS())
|
||||
throw std::runtime_error("NDArray::operator-=: you can't use this method on String array!");
|
||||
|
||||
if (!Environment::getInstance()->isExperimentalBuild() && this->dataType() != other.dataType() && (this->dataType() != DataType::BOOL || other.dataType() != BOOL))
|
||||
if (!Environment::getInstance().isExperimentalBuild() && this->dataType() != other.dataType() && (this->dataType() != DataType::BOOL || other.dataType() != BOOL))
|
||||
throw sd::datatype_exception::build("NDArray operator-=: Cannot subtract different types", this->dataType(), other.dataType());
|
||||
|
||||
if (lengthOf() != 1 && other.lengthOf() == 1) {
|
||||
|
@ -2523,7 +2524,7 @@ void NDArray::operator-=(const NDArray& other) {
|
|||
void NDArray::operator*=(const NDArray& other) {
|
||||
if (isS())
|
||||
throw std::runtime_error("NDArray::operator*=: you can't use this method on String array!");
|
||||
if (!Environment::getInstance()->isExperimentalBuild() && this->dataType() != other.dataType() && (this->dataType() != DataType::BOOL || other.dataType() != BOOL))
|
||||
if (!Environment::getInstance().isExperimentalBuild() && this->dataType() != other.dataType() && (this->dataType() != DataType::BOOL || other.dataType() != BOOL))
|
||||
throw sd::datatype_exception::build("NDArray operator*=: Cannot multiply different types", this->dataType(), other.dataType());
|
||||
|
||||
if (lengthOf() != 1 && other.lengthOf() == 1) {
|
||||
|
@ -2559,7 +2560,7 @@ void NDArray::operator/=(const NDArray& other) {
|
|||
if (other.isB())
|
||||
throw std::runtime_error("NDArray::operator/=: you can't divide by bool array!");
|
||||
|
||||
if (!Environment::getInstance()->isExperimentalBuild() && this->dataType() != other.dataType()) {
|
||||
if (!Environment::getInstance().isExperimentalBuild() && this->dataType() != other.dataType()) {
|
||||
throw sd::datatype_exception::build("NDArray operator/=: Cannot divide different types", this->dataType(), other.dataType());
|
||||
}
|
||||
|
||||
|
@ -2597,11 +2598,9 @@ void NDArray::operator+=(const T value) {
|
|||
|
||||
auto other = NDArrayFactory::create(this->dataType(), value, getContext());
|
||||
|
||||
NDArray::prepareSpecialUse({this}, {&other});
|
||||
|
||||
NDArray::prepareSpecialUse({this}, {this, &other});
|
||||
NativeOpExecutioner::execScalar(getContext(), sd::scalar::Add, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), other.buffer(), other.shapeInfo(), other.specialBuffer(), other.specialShapeInfo(), nullptr);
|
||||
|
||||
NDArray::registerSpecialUse({this}, {});
|
||||
NDArray::registerSpecialUse({this}, {this, &other});
|
||||
}
|
||||
template ND4J_EXPORT void NDArray::operator+=(const double value);
|
||||
template ND4J_EXPORT void NDArray::operator+=(const float value);
|
||||
|
@ -2619,11 +2618,9 @@ void NDArray::operator-=(const T value) {
|
|||
|
||||
auto other = NDArrayFactory::create(dataType(), value, getContext());
|
||||
|
||||
NDArray::prepareSpecialUse({this}, {&other});
|
||||
|
||||
NDArray::prepareSpecialUse({this}, {this, &other});
|
||||
NativeOpExecutioner::execScalar(getContext(), sd::scalar::Subtract, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), other.buffer(), other.shapeInfo(), other.specialBuffer(), other.specialShapeInfo(), nullptr);
|
||||
|
||||
NDArray::registerSpecialUse({this}, {});
|
||||
NDArray::registerSpecialUse({this}, {this, &other});
|
||||
}
|
||||
template ND4J_EXPORT void NDArray::operator-=(const double value);
|
||||
template ND4J_EXPORT void NDArray::operator-=(const float value);
|
||||
|
@ -2640,10 +2637,9 @@ void NDArray::operator*=(const T scalar) {
|
|||
throw std::runtime_error("NDArray::operator*=: you can't use this method on String array!");
|
||||
|
||||
auto other = NDArrayFactory::create(this->dataType(), scalar, getContext());
|
||||
NDArray::prepareSpecialUse({this}, {&other});
|
||||
NDArray::prepareSpecialUse({this}, {this, &other});
|
||||
NativeOpExecutioner::execScalar(getContext(), sd::scalar::Multiply, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), other.buffer(), other.shapeInfo(), other.specialBuffer(), other.specialShapeInfo(), nullptr);
|
||||
|
||||
NDArray::registerSpecialUse({this}, {});
|
||||
NDArray::registerSpecialUse({this}, {this, &other});
|
||||
}
|
||||
template ND4J_EXPORT void NDArray::operator*=(const double scalar);
|
||||
template ND4J_EXPORT void NDArray::operator*=(const float scalar);
|
||||
|
@ -2663,9 +2659,9 @@ void NDArray::operator/=(const T scalar) {
|
|||
throw std::runtime_error("NDArray::operator/=: you can't use this method on String array!");
|
||||
|
||||
auto other = NDArrayFactory::create(this->dataType(), scalar, getContext());
|
||||
NDArray::prepareSpecialUse({this}, {&other});
|
||||
NDArray::prepareSpecialUse({this}, {this, &other});
|
||||
NativeOpExecutioner::execScalar(getContext(), sd::scalar::Divide, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), other.buffer(), other.shapeInfo(), other.specialBuffer(), other.specialShapeInfo(), nullptr);
|
||||
NDArray::registerSpecialUse({this}, {});
|
||||
NDArray::registerSpecialUse({this}, {this, &other});
|
||||
}
|
||||
template ND4J_EXPORT void NDArray::operator/=(const double scalar);
|
||||
template ND4J_EXPORT void NDArray::operator/=(const float scalar);
|
||||
|
@ -2837,14 +2833,14 @@ void NDArray::applyTrueBroadcast(sd::BroadcastOpsTuple op, const NDArray& other,
|
|||
Nd4jLong const* yShapeInfoD = other.specialShapeInfo();
|
||||
|
||||
if(!isSameShape(target)) {
|
||||
auto xPack = ConstantShapeHelper::getInstance()->createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), shapeInfo(), getContext()->getWorkspace());
|
||||
xShapeInfoH = reinterpret_cast<Nd4jLong const*>(xPack.primary());
|
||||
xShapeInfoD = reinterpret_cast<Nd4jLong const*>(xPack.special());
|
||||
auto xPack = ConstantShapeHelper::getInstance().createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), shapeInfo(), getContext()->getWorkspace());
|
||||
xShapeInfoH = xPack.primary();
|
||||
xShapeInfoD = xPack.special();
|
||||
}
|
||||
if(!other.isSameShape(target)) {
|
||||
auto yPack = ConstantShapeHelper::getInstance()->createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), other.shapeInfo(), other.getContext()->getWorkspace());
|
||||
yShapeInfoH = reinterpret_cast<Nd4jLong const*>(yPack.primary());
|
||||
yShapeInfoD = reinterpret_cast<Nd4jLong const*>(yPack.special());
|
||||
auto yPack = ConstantShapeHelper::getInstance().createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), other.shapeInfo(), other.getContext()->getWorkspace());
|
||||
yShapeInfoH = yPack.primary();
|
||||
yShapeInfoD = yPack.special();
|
||||
}
|
||||
|
||||
NDArray::prepareSpecialUse({&target}, {this, &other});
|
||||
|
@ -2888,14 +2884,14 @@ void NDArray::applyTrueBroadcast(sd::BroadcastBoolOpsTuple op, const NDArray& ot
|
|||
Nd4jLong const* yShapeInfoD = other.specialShapeInfo();
|
||||
|
||||
if(!isSameShape(target)) {
|
||||
auto xPack = ConstantShapeHelper::getInstance()->createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), shapeInfo(), getContext()->getWorkspace());
|
||||
xShapeInfoH = reinterpret_cast<Nd4jLong const*>(xPack.primary());
|
||||
xShapeInfoD = reinterpret_cast<Nd4jLong const*>(xPack.special());
|
||||
auto xPack = ConstantShapeHelper::getInstance().createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), shapeInfo(), getContext()->getWorkspace());
|
||||
xShapeInfoH = xPack.primary();
|
||||
xShapeInfoD = xPack.special();
|
||||
}
|
||||
if(!other.isSameShape(target)) {
|
||||
auto yPack = ConstantShapeHelper::getInstance()->createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), other.shapeInfo(), other.getContext()->getWorkspace());
|
||||
yShapeInfoH = reinterpret_cast<Nd4jLong const*>(yPack.primary());
|
||||
yShapeInfoD = reinterpret_cast<Nd4jLong const*>(yPack.special());
|
||||
auto yPack = ConstantShapeHelper::getInstance().createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), other.shapeInfo(), other.getContext()->getWorkspace());
|
||||
yShapeInfoH = yPack.primary();
|
||||
yShapeInfoD = yPack.special();
|
||||
}
|
||||
|
||||
NDArray::prepareSpecialUse({&target}, {this, &other});
|
||||
|
@ -2939,12 +2935,12 @@ void NDArray::applyTrueBroadcast(sd::BroadcastIntOpsTuple op, const NDArray& oth
|
|||
Nd4jLong const* yShapeInfoD = other.specialShapeInfo();
|
||||
|
||||
if(!isSameShape(target)) {
|
||||
auto xPack = ConstantShapeHelper::getInstance()->createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), shapeInfo(), getContext()->getWorkspace());
|
||||
auto xPack = ConstantShapeHelper::getInstance().createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), shapeInfo(), getContext()->getWorkspace());
|
||||
xShapeInfoH = reinterpret_cast<Nd4jLong const*>(xPack.primary());
|
||||
xShapeInfoD = reinterpret_cast<Nd4jLong const*>(xPack.special());
|
||||
}
|
||||
if(!other.isSameShape(target)) {
|
||||
auto yPack = ConstantShapeHelper::getInstance()->createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), other.shapeInfo(), other.getContext()->getWorkspace());
|
||||
auto yPack = ConstantShapeHelper::getInstance().createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), other.shapeInfo(), other.getContext()->getWorkspace());
|
||||
yShapeInfoH = reinterpret_cast<Nd4jLong const*>(yPack.primary());
|
||||
yShapeInfoD = reinterpret_cast<Nd4jLong const*>(yPack.special());
|
||||
}
|
||||
|
@ -3072,7 +3068,7 @@ void NDArray::applyBroadcast(sd::broadcast::Ops op, const std::vector<int>& dime
|
|||
|
||||
// if (other.lengthOf() == lengthOf() && this->rankOf() == other.rankOf()) {
|
||||
// NDArray::prepareSpecialUse({&target}, {this, &other});
|
||||
// NativeOpExecutioner::execPairwiseTransform(getContext(), fromBroadcastToPairwise(op), buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), other.buffer(), other.shapeInfo(), other.specialBuffer(), other.specialShapeInfo(), target.buffer(), target.shapeInfo(), target.specialBuffer(), target.specialShapeInfo(), nullptr);
|
||||
// NativeOpExecutioner::execPairwiseTransform(getContext(), fromBroadcastToPairwise(op), buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), other.buffer(), other.shapeInfo(), other.specialBuffer(), other.specialShapeInfo(), target.buffer(), target.shapeInfo(), target.specialBuffer(), target.special(), nullptr);
|
||||
// NDArray::registerSpecialUse({&target}, {this, &other});
|
||||
// return;
|
||||
// }
|
||||
|
@ -3093,12 +3089,12 @@ void NDArray::applyBroadcast(sd::broadcast::Ops op, const std::vector<int>& dime
|
|||
Nd4jLong const* yShapeInfoD = other.specialShapeInfo();
|
||||
|
||||
if(!isSameShape(target)) {
|
||||
auto xPack = ConstantShapeHelper::getInstance()->createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), shapeInfo(), getContext()->getWorkspace(), copy);
|
||||
auto xPack = ConstantShapeHelper::getInstance().createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), shapeInfo(), getContext()->getWorkspace(), copy);
|
||||
xShapeInfoH = reinterpret_cast<Nd4jLong const*>(xPack.primary());
|
||||
xShapeInfoD = reinterpret_cast<Nd4jLong const*>(xPack.special());
|
||||
}
|
||||
if(!other.isSameShape(target)) {
|
||||
auto yPack = ConstantShapeHelper::getInstance()->createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), other.shapeInfo(), other.getContext()->getWorkspace(), copy);
|
||||
auto yPack = ConstantShapeHelper::getInstance().createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), other.shapeInfo(), other.getContext()->getWorkspace(), copy);
|
||||
yShapeInfoH = reinterpret_cast<Nd4jLong const*>(yPack.primary());
|
||||
yShapeInfoD = reinterpret_cast<Nd4jLong const*>(yPack.special());
|
||||
}
|
||||
|
@ -3124,7 +3120,7 @@ void NDArray::applyBroadcast(sd::broadcast::BoolOps op, const std::vector<int>&
|
|||
|
||||
// if (other.lengthOf() == lengthOf() && this->rankOf() == other.rankOf()) {
|
||||
// NDArray::prepareSpecialUse({&target}, {this, &other});
|
||||
// NativeOpExecutioner::execPairwiseBoolTransform(getContext(), fromBroadcastToPairwiseBool(op), buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), other.buffer(), other.shapeInfo(), other.specialBuffer(), other.specialShapeInfo(), target.buffer(), target.shapeInfo(), target.specialBuffer(), target.specialShapeInfo(), nullptr);
|
||||
// NativeOpExecutioner::execPairwiseBoolTransform(getContext(), fromBroadcastToPairwiseBool(op), buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), other.buffer(), other.shapeInfo(), other.specialBuffer(), other.specialShapeInfo(), target.buffer(), target.shapeInfo(), target.specialBuffer(), target.special(), nullptr);
|
||||
// NDArray::registerSpecialUse({&target}, {this, &other});
|
||||
// return;
|
||||
// }
|
||||
|
@ -3147,12 +3143,12 @@ void NDArray::applyBroadcast(sd::broadcast::BoolOps op, const std::vector<int>&
|
|||
Nd4jLong const* yShapeInfoD = other.specialShapeInfo();
|
||||
|
||||
if(!isSameShape(target)) {
|
||||
auto xPack = ConstantShapeHelper::getInstance()->createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), shapeInfo(), getContext()->getWorkspace(), copy);
|
||||
auto xPack = ConstantShapeHelper::getInstance().createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), shapeInfo(), getContext()->getWorkspace(), copy);
|
||||
xShapeInfoH = reinterpret_cast<Nd4jLong const*>(xPack.primary());
|
||||
xShapeInfoD = reinterpret_cast<Nd4jLong const*>(xPack.special());
|
||||
}
|
||||
if(!other.isSameShape(target)) {
|
||||
auto yPack = ConstantShapeHelper::getInstance()->createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), other.shapeInfo(), other.getContext()->getWorkspace(), copy);
|
||||
auto yPack = ConstantShapeHelper::getInstance().createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), other.shapeInfo(), other.getContext()->getWorkspace(), copy);
|
||||
yShapeInfoH = reinterpret_cast<Nd4jLong const*>(yPack.primary());
|
||||
yShapeInfoD = reinterpret_cast<Nd4jLong const*>(yPack.special());
|
||||
}
|
||||
|
@ -3179,7 +3175,7 @@ void NDArray::applyBroadcast(sd::broadcast::IntOps op, const std::vector<int>& d
|
|||
|
||||
// if (other.lengthOf() == lengthOf() && this->rankOf() == other.rankOf()) {
|
||||
// NDArray::prepareSpecialUse({&target}, {this, &other});
|
||||
// NativeOpExecutioner::execPairwiseIntTransform(getContext(), fromBroadcastToPairwiseInt(op), buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), other.buffer(), other.shapeInfo(), other.specialBuffer(), other.specialShapeInfo(), target.buffer(), target.shapeInfo(), target.specialBuffer(), target.specialShapeInfo(), nullptr);
|
||||
// NativeOpExecutioner::execPairwiseIntTransform(getContext(), fromBroadcastToPairwiseInt(op), buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), other.buffer(), other.shapeInfo(), other.specialBuffer(), other.specialShapeInfo(), target.buffer(), target.shapeInfo(), target.specialBuffer(), target.special(), nullptr);
|
||||
// NDArray::registerSpecialUse({&target}, {this, &other});
|
||||
// return;
|
||||
// }
|
||||
|
@ -3202,12 +3198,12 @@ void NDArray::applyBroadcast(sd::broadcast::IntOps op, const std::vector<int>& d
|
|||
Nd4jLong const* yShapeInfoD = other.specialShapeInfo();
|
||||
|
||||
if(!isSameShape(target)) {
|
||||
auto xPack = ConstantShapeHelper::getInstance()->createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), shapeInfo(), getContext()->getWorkspace(), copy);
|
||||
auto xPack = ConstantShapeHelper::getInstance().createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), shapeInfo(), getContext()->getWorkspace(), copy);
|
||||
xShapeInfoH = reinterpret_cast<Nd4jLong const*>(xPack.primary());
|
||||
xShapeInfoD = reinterpret_cast<Nd4jLong const*>(xPack.special());
|
||||
}
|
||||
if(!other.isSameShape(target)) {
|
||||
auto yPack = ConstantShapeHelper::getInstance()->createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), other.shapeInfo(), other.getContext()->getWorkspace(), copy);
|
||||
auto yPack = ConstantShapeHelper::getInstance().createShapeInfoWithUnitiesForBroadcast(target.shapeInfo(), other.shapeInfo(), other.getContext()->getWorkspace(), copy);
|
||||
yShapeInfoH = reinterpret_cast<Nd4jLong const*>(yPack.primary());
|
||||
yShapeInfoD = reinterpret_cast<Nd4jLong const*>(yPack.special());
|
||||
}
|
||||
|
@ -3225,8 +3221,8 @@ void NDArray::applyBroadcast(sd::broadcast::Ops op, const std::initializer_list<
|
|||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
void* NDArray::operator new(size_t i) {
|
||||
if (sd::memory::MemoryRegistrator::getInstance()->hasWorkspaceAttached()) {
|
||||
sd::memory::Workspace* ws = sd::memory::MemoryRegistrator::getInstance()->getWorkspace();
|
||||
if (sd::memory::MemoryRegistrator::getInstance().hasWorkspaceAttached()) {
|
||||
sd::memory::Workspace* ws = sd::memory::MemoryRegistrator::getInstance().getWorkspace();
|
||||
return ws->allocateBytes((Nd4jLong) i);
|
||||
}
|
||||
else {
|
||||
|
@ -3238,7 +3234,7 @@ void* NDArray::operator new(size_t i) {
|
|||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
void NDArray::operator delete(void* p) {
|
||||
if (!sd::memory::MemoryRegistrator::getInstance()->hasWorkspaceAttached())
|
||||
if (!sd::memory::MemoryRegistrator::getInstance().hasWorkspaceAttached())
|
||||
free(p);
|
||||
}
|
||||
|
||||
|
@ -3444,8 +3440,8 @@ void NDArray::varianceAlongDimension(sd::variance::Ops op, NDArray& target, cons
|
|||
NativeOpExecutioner::execSummaryStatsScalar(getContext(), op, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), nullptr, target.buffer(), target.shapeInfo(), target.specialBuffer(), target.specialShapeInfo(), biasCorrected);
|
||||
else {
|
||||
std::vector<int> copy(dimensions);
|
||||
auto pDims = sd::Environment::getInstance()->isCPU() ? copy.data() : nullptr;
|
||||
auto packX = sd::ConstantTadHelper::getInstance()->tadForDimensions(this->shapeInfo(), dimensions);
|
||||
auto pDims = sd::Environment::getInstance().isCPU() ? copy.data() : nullptr;
|
||||
auto packX = sd::ConstantTadHelper::getInstance().tadForDimensions(this->shapeInfo(), dimensions);
|
||||
NativeOpExecutioner::execSummaryStats(getContext(), op, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), nullptr, target.buffer(), target.shapeInfo(), target.specialBuffer(), target.specialShapeInfo(), pDims, dimensions.size(), packX.platformShapeInfo(), packX.platformOffsets(), biasCorrected);
|
||||
synchronize("NDArray::varianceAlongDimension");
|
||||
}
|
||||
|
@ -3758,8 +3754,7 @@ T NDArray::e(const Nd4jLong i, const Nd4jLong j) const {
|
|||
if (rankOf() != 2 || i >= shapeOf()[0] || j >= shapeOf()[1])
|
||||
throw std::invalid_argument("NDArray::e(i,j): one of input indexes is out of array length or rank!=2 !");
|
||||
|
||||
const Nd4jLong coords[2] = {i, j};
|
||||
const auto xOffset = shape::getOffset(shapeInfo(), coords);
|
||||
const auto xOffset = i * strideAt(0) + j * strideAt(1);
|
||||
|
||||
NDArray::preparePrimaryUse({}, {this});
|
||||
NDArray::registerPrimaryUse({}, {this});
|
||||
|
@ -3778,8 +3773,7 @@ T NDArray::e(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k) const {
|
|||
if (rankOf() != 3 || i >= shapeOf()[0] || j >= shapeOf()[1] || k >= shapeOf()[2])
|
||||
throw std::invalid_argument("NDArray::e(i,j,k): one of input indexes is out of array length or rank!=3 !");
|
||||
|
||||
const Nd4jLong coords[3] = {i, j, k};
|
||||
const auto xOffset = shape::getOffset(shapeInfo(), coords);
|
||||
const auto xOffset = i * strideAt(0) + j * strideAt(1) + k * strideAt(2);
|
||||
|
||||
NDArray::preparePrimaryUse({}, {this});
|
||||
NDArray::registerPrimaryUse({}, {this});
|
||||
|
@ -3798,8 +3792,7 @@ T NDArray::e(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLon
|
|||
if (rankOf() != 4 || i >= shapeOf()[0] || j >= shapeOf()[1] || k >= shapeOf()[2] || l >= shapeOf()[3])
|
||||
throw std::invalid_argument("NDArray::e(i,j,k,l): one of input indexes is out of array length or rank!=4 !");
|
||||
|
||||
const Nd4jLong coords[4] = {i, j, k, l};
|
||||
const auto xOffset = shape::getOffset(shapeInfo(), coords);
|
||||
const auto xOffset = i * strideAt(0) + j * strideAt(1) + k * strideAt(2) + l * strideAt(3);
|
||||
|
||||
NDArray::preparePrimaryUse({}, {this});
|
||||
NDArray::registerPrimaryUse({}, {this});
|
||||
|
@ -4117,8 +4110,8 @@ void NDArray::applyIndexReduce(sd::indexreduce::Ops op, NDArray& target, const s
|
|||
else {
|
||||
std::vector<int> copy = dimensions;
|
||||
shape::checkDimensions(rankOf(), copy);
|
||||
auto pDims = sd::Environment::getInstance()->isCPU() ? copy.data() : nullptr;
|
||||
auto packX = sd::ConstantTadHelper::getInstance()->tadForDimensions(shapeInfo(), copy);
|
||||
auto pDims = sd::Environment::getInstance().isCPU() ? copy.data() : nullptr;
|
||||
auto packX = sd::ConstantTadHelper::getInstance().tadForDimensions(shapeInfo(), copy);
|
||||
NativeOpExecutioner::execIndexReduce(getContext(), op, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), params, target.buffer(), target.shapeInfo(), target.specialBuffer(), target.specialShapeInfo(), pDims, copy.size(), packX.platformShapeInfo(), packX.platformOffsets());
|
||||
synchronize("NDArray::applyIndexReduce");
|
||||
}
|
||||
|
@ -4191,10 +4184,10 @@ NDArray NDArray::applyReduce3(sd::reduce3::Ops op, const NDArray& other, const s
|
|||
}
|
||||
else {
|
||||
|
||||
auto pDims = sd::Environment::getInstance()->isCPU() ? copy.data() : nullptr;
|
||||
auto pDims = sd::Environment::getInstance().isCPU() ? copy.data() : nullptr;
|
||||
|
||||
auto packX = sd::ConstantTadHelper::getInstance()->tadForDimensions(shapeInfo(), copy);
|
||||
auto packY = sd::ConstantTadHelper::getInstance()->tadForDimensions(other.shapeInfo(), copy);
|
||||
auto packX = sd::ConstantTadHelper::getInstance().tadForDimensions(shapeInfo(), copy);
|
||||
auto packY = sd::ConstantTadHelper::getInstance().tadForDimensions(other.shapeInfo(), copy);
|
||||
|
||||
if(!shape::equalsSoft(packX.primaryShapeInfo(), packY.primaryShapeInfo()) || (packX.numberOfTads() != packY.numberOfTads() && packX.numberOfTads() != 1 && packY.numberOfTads() != 1))
|
||||
throw std::runtime_error("NDArray::applyReduce3 cuda method: arrays tads are inconsistent !");
|
||||
|
@ -4220,15 +4213,15 @@ NDArray NDArray::applyAllReduce3(sd::reduce3::Ops op, const NDArray& other, cons
|
|||
shape::checkDimensions(rankOf(), copy);
|
||||
shape::checkDimensions(other.rankOf(), copy);
|
||||
|
||||
auto packX = ConstantTadHelper::getInstance()->tadForDimensions(shapeInfo(), copy);
|
||||
auto packY = ConstantTadHelper::getInstance()->tadForDimensions(other.shapeInfo(), copy);
|
||||
auto packX = ConstantTadHelper::getInstance().tadForDimensions(shapeInfo(), copy);
|
||||
auto packY = ConstantTadHelper::getInstance().tadForDimensions(other.shapeInfo(), copy);
|
||||
|
||||
// check tads shapes
|
||||
if(!shape::equalsSoft(packX.primaryShapeInfo(), packY.primaryShapeInfo()))
|
||||
throw std::runtime_error("NDArray::applyAllReduce3 method: the shapes of array tads are different !");
|
||||
|
||||
// set newShape for output array
|
||||
auto newShape = ConstantShapeHelper::getInstance()->createShapeInfo(DataTypeUtils::pickFloatingType(dataType()), 'c', {packX.numberOfTads(), packY.numberOfTads()});
|
||||
auto newShape = ConstantShapeHelper::getInstance().createShapeInfo(DataTypeUtils::pickFloatingType(dataType()), 'c', {packX.numberOfTads(), packY.numberOfTads()});
|
||||
|
||||
// create output array
|
||||
NDArray result(newShape, true, getContext());
|
||||
|
@ -4236,7 +4229,7 @@ NDArray NDArray::applyAllReduce3(sd::reduce3::Ops op, const NDArray& other, cons
|
|||
// create dynamic array of extra parameters if array extraParams is empty (==nullptr)
|
||||
void* params = extraParams != nullptr ? const_cast<ExtraArguments*>(extraParams)->argumentsAsT(dataType()) : nullptr;
|
||||
|
||||
auto pDims = sd::Environment::getInstance()->isCPU() ? copy.data() : nullptr;
|
||||
auto pDims = sd::Environment::getInstance().isCPU() ? copy.data() : nullptr;
|
||||
|
||||
NDArray::prepareSpecialUse({&result}, {this, &other});
|
||||
NativeOpExecutioner::execReduce3All(getContext(), op, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), params, other.buffer(), other.shapeInfo(), other.specialBuffer(), other.specialShapeInfo(), result.buffer(), result.shapeInfo(), result.specialBuffer(), result.specialShapeInfo(), pDims, copy.size(), packX.platformShapeInfo(), packX.platformOffsets(), packY.platformShapeInfo(), packY.platformOffsets());
|
||||
|
@ -4268,7 +4261,7 @@ void NDArray::reduceAlongDimension(sd::reduce::FloatOps op, NDArray& target, con
|
|||
NativeOpExecutioner::execReduceFloatScalar(getContext(), op, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(),nullptr, target.buffer(), target.shapeInfo(), target.specialBuffer(), target.specialShapeInfo());
|
||||
}
|
||||
else {
|
||||
auto packX = sd::ConstantTadHelper::getInstance()->tadForDimensions(shapeInfo(), copy);
|
||||
auto packX = sd::ConstantTadHelper::getInstance().tadForDimensions(shapeInfo(), copy);
|
||||
NativeOpExecutioner::execReduceFloat(getContext(), op, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), nullptr, target.buffer(), target.shapeInfo(), target.specialBuffer(), target.specialShapeInfo(), copy.data(), copy.size(), packX.platformShapeInfo(), packX.platformOffsets());
|
||||
}
|
||||
synchronize("NDArray::reduceAlongDimension FloatOps");
|
||||
|
@ -4299,8 +4292,8 @@ void NDArray::reduceAlongDimension(sd::reduce::SameOps op, NDArray& target, cons
|
|||
NativeOpExecutioner::execReduceSameScalar(getContext(), op, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), nullptr, target.buffer(), target.shapeInfo(), target.specialBuffer(), target.specialShapeInfo());
|
||||
}
|
||||
else { //if (!isEmpty()) {
|
||||
auto pDims = sd::Environment::getInstance()->isCPU() ? copy.data() : nullptr;
|
||||
auto packX = sd::ConstantTadHelper::getInstance()->tadForDimensions(this->shapeInfo(), copy);
|
||||
auto pDims = sd::Environment::getInstance().isCPU() ? copy.data() : nullptr;
|
||||
auto packX = sd::ConstantTadHelper::getInstance().tadForDimensions(this->shapeInfo(), copy);
|
||||
NativeOpExecutioner::execReduceSame(getContext(), op, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), nullptr, target.buffer(), target.shapeInfo(), target.specialBuffer(), target.specialShapeInfo(), pDims, copy.size(), packX.platformShapeInfo(), packX.platformOffsets());
|
||||
}
|
||||
synchronize("NDArray::reduceAlongDimension SameOps");
|
||||
|
@ -4331,8 +4324,8 @@ void NDArray::reduceAlongDimension(sd::reduce::LongOps op, NDArray& target, cons
|
|||
NativeOpExecutioner::execReduceLongScalar(getContext(), op, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), nullptr, target.buffer(), target.shapeInfo(), target.specialBuffer(), target.specialShapeInfo());
|
||||
}
|
||||
else {
|
||||
auto pDims = sd::Environment::getInstance()->isCPU() ? copy.data() : nullptr;
|
||||
auto packX = sd::ConstantTadHelper::getInstance()->tadForDimensions(this->shapeInfo(), copy);
|
||||
auto pDims = sd::Environment::getInstance().isCPU() ? copy.data() : nullptr;
|
||||
auto packX = sd::ConstantTadHelper::getInstance().tadForDimensions(this->shapeInfo(), copy);
|
||||
NativeOpExecutioner::execReduceLong(getContext(), op, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), nullptr, target.buffer(), target.shapeInfo(), target.specialBuffer(), target.specialShapeInfo(), pDims, copy.size(), packX.platformShapeInfo(), packX.platformOffsets());
|
||||
}
|
||||
synchronize("NDArray::reduceAlongDimension LongOps");
|
||||
|
@ -4363,8 +4356,8 @@ void NDArray::reduceAlongDimension(sd::reduce::BoolOps op, NDArray& target, cons
|
|||
NativeOpExecutioner::execReduceBoolScalar(getContext(), op, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), nullptr, target.buffer(), target.shapeInfo(), target.specialBuffer(), target.specialShapeInfo());
|
||||
}
|
||||
else {
|
||||
auto pDims = sd::Environment::getInstance()->isCPU() ? copy.data() : nullptr;
|
||||
auto packX = sd::ConstantTadHelper::getInstance()->tadForDimensions(this->shapeInfo(), copy);
|
||||
auto pDims = sd::Environment::getInstance().isCPU() ? copy.data() : nullptr;
|
||||
auto packX = sd::ConstantTadHelper::getInstance().tadForDimensions(this->shapeInfo(), copy);
|
||||
NativeOpExecutioner::execReduceBool(getContext(), op, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), nullptr, target.buffer(), target.shapeInfo(), target.specialBuffer(), target.specialShapeInfo(), pDims, copy.size(), packX.platformShapeInfo(), packX.platformOffsets());
|
||||
}
|
||||
synchronize("NDArray::reduceAlongDimension LongOps");
|
||||
|
@ -4411,8 +4404,7 @@ void NDArray::p(const Nd4jLong i, const Nd4jLong j, const T value) {
|
|||
throw std::invalid_argument("NDArray:pe(i,j, value): one of input indexes is out of array length or rank!=2 !");
|
||||
|
||||
void *p = reinterpret_cast<void *>(const_cast<T *>(&value));
|
||||
Nd4jLong coords[2] = {i, j};
|
||||
auto xOffset = shape::getOffset(shapeInfo(), coords);
|
||||
auto xOffset = i * strideAt(0) + j * strideAt(1);
|
||||
|
||||
NDArray::preparePrimaryUse({this}, {}, true);
|
||||
BUILD_SINGLE_PARTIAL_SELECTOR(dataType(), templatedSet<, T>(this->buffer(), xOffset, p), LIBND4J_TYPES);
|
||||
|
@ -4440,11 +4432,10 @@ void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const T va
|
|||
if (rankOf() != 3 || i >= shapeOf()[0] || j >= shapeOf()[1] || k >= shapeOf()[2])
|
||||
throw std::invalid_argument("NDArray:pe(i,j,k, value): one of input indexes is out of array length or rank!=3 !");
|
||||
|
||||
NDArray::preparePrimaryUse({this}, {}, true);
|
||||
|
||||
void *p = reinterpret_cast<void *>(const_cast<T *>(&value));
|
||||
Nd4jLong coords[3] = {i, j, k};
|
||||
auto xOffset = shape::getOffset(shapeInfo(), coords);
|
||||
auto xOffset = i * strideAt(0) + j * strideAt(1) + k * strideAt(2);
|
||||
|
||||
NDArray::preparePrimaryUse({this}, {}, true);
|
||||
BUILD_SINGLE_PARTIAL_SELECTOR(dataType(), templatedSet<, T>(this->buffer(), xOffset, p), LIBND4J_TYPES);
|
||||
NDArray::registerPrimaryUse({this}, {});
|
||||
}
|
||||
|
@ -4470,8 +4461,7 @@ void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4j
|
|||
throw std::invalid_argument("NDArray::p(i,j,k,l, value): one of input indexes is out of array length or rank!=4 !");
|
||||
|
||||
void *p = reinterpret_cast<void *>(const_cast<T *>(&value));
|
||||
Nd4jLong coords[4] = {i, j, k, l};
|
||||
auto xOffset = shape::getOffset(shapeInfo(), coords);
|
||||
auto xOffset = i * strideAt(0) + j * strideAt(1) + k * strideAt(2) + l * strideAt(3);
|
||||
|
||||
NDArray::preparePrimaryUse({this}, {}, true);
|
||||
BUILD_SINGLE_PARTIAL_SELECTOR(dataType(), templatedSet<, T>(this->buffer(), xOffset, p), LIBND4J_TYPES);
|
||||
|
@ -4535,7 +4525,7 @@ void NDArray::addRowVector(const NDArray& row, NDArray& target) const {
|
|||
|
||||
int dimension = 1;
|
||||
|
||||
auto packX = sd::ConstantTadHelper::getInstance()->tadForDimensions(this->shapeInfo(), dimension);
|
||||
auto packX = sd::ConstantTadHelper::getInstance().tadForDimensions(this->shapeInfo(), dimension);
|
||||
|
||||
NDArray::prepareSpecialUse({&target}, {this, &row});
|
||||
NativeOpExecutioner::execBroadcast(getContext(), sd::broadcast::Ops::Add, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), row.buffer(), row.shapeInfo(), row.specialBuffer(), row.specialShapeInfo(), target.buffer(), target.shapeInfo(), target.specialBuffer(), target.specialShapeInfo(), nullptr, 1, packX.platformShapeInfo(), packX.platformOffsets(), nullptr, nullptr);
|
||||
|
@ -4554,7 +4544,7 @@ void NDArray::subRowVector(const NDArray& row, NDArray& target) const {
|
|||
|
||||
int dimension = 1;
|
||||
|
||||
auto packX = sd::ConstantTadHelper::getInstance()->tadForDimensions(this->shapeInfo(), dimension);
|
||||
auto packX = sd::ConstantTadHelper::getInstance().tadForDimensions(this->shapeInfo(), dimension);
|
||||
|
||||
NDArray::prepareSpecialUse({&target}, {this, &row});
|
||||
NativeOpExecutioner::execBroadcast(getContext(), sd::broadcast::Ops::Subtract, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), row.buffer(), row.shapeInfo(), row.specialBuffer(), row.specialShapeInfo(), target.buffer(), target.shapeInfo(), target.specialBuffer(), target.specialShapeInfo(), &dimension, 1, packX.platformShapeInfo(), packX.platformOffsets(), nullptr, nullptr);
|
||||
|
@ -4574,7 +4564,7 @@ void NDArray::mulRowVector(const NDArray &row, NDArray &target) const {
|
|||
|
||||
int dimension = 1;
|
||||
|
||||
auto packX = sd::ConstantTadHelper::getInstance()->tadForDimensions(this->shapeInfo(), dimension);
|
||||
auto packX = sd::ConstantTadHelper::getInstance().tadForDimensions(this->shapeInfo(), dimension);
|
||||
|
||||
NDArray::prepareSpecialUse({&target}, {this, &row});
|
||||
NativeOpExecutioner::execBroadcast(getContext(), sd::broadcast::Ops::Multiply, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), row.buffer(), row.shapeInfo(), row.specialBuffer(), row.specialShapeInfo(), target.buffer(), target.shapeInfo(), target.specialBuffer(), target.specialShapeInfo(), nullptr, 1, packX.platformShapeInfo(), packX.platformOffsets(), nullptr, nullptr);
|
||||
|
@ -4595,7 +4585,7 @@ void NDArray::divRowVector(const NDArray &row, NDArray &target) const {
|
|||
|
||||
int dimension = 1;
|
||||
|
||||
auto packX = sd::ConstantTadHelper::getInstance()->tadForDimensions(this->shapeInfo(), dimension);
|
||||
auto packX = sd::ConstantTadHelper::getInstance().tadForDimensions(this->shapeInfo(), dimension);
|
||||
|
||||
NDArray::prepareSpecialUse({&target}, {this, &row});
|
||||
NativeOpExecutioner::execBroadcast(getContext(), sd::broadcast::Divide, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), row.buffer(), row.shapeInfo(), row.specialBuffer(), row.specialShapeInfo(), target.buffer(), target.shapeInfo(), target.specialBuffer(), target.specialShapeInfo(), nullptr, 1, packX.platformShapeInfo(), packX.platformOffsets(), nullptr, nullptr);
|
||||
|
@ -4613,7 +4603,7 @@ void NDArray::addiRowVector(const NDArray& row) {
|
|||
|
||||
int dimension = 1;
|
||||
|
||||
auto packX = sd::ConstantTadHelper::getInstance()->tadForDimensions(this->shapeInfo(), dimension);
|
||||
auto packX = sd::ConstantTadHelper::getInstance().tadForDimensions(this->shapeInfo(), dimension);
|
||||
|
||||
NDArray::prepareSpecialUse({this}, {&row});
|
||||
NativeOpExecutioner::execBroadcast(getContext(), sd::broadcast::Ops::Add, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), row.buffer(), row.shapeInfo(), row.specialBuffer(), row.specialShapeInfo(), this->buffer(), this->shapeInfo(), this->specialBuffer(), this->specialShapeInfo(), nullptr, 1, packX.platformShapeInfo(), packX.platformOffsets(), nullptr, nullptr);
|
||||
|
@ -4631,7 +4621,7 @@ void NDArray::addColumnVector(const NDArray &column, NDArray &target) const {
|
|||
|
||||
int dimension = 0;
|
||||
|
||||
auto packX = sd::ConstantTadHelper::getInstance()->tadForDimensions(this->shapeInfo(), dimension);
|
||||
auto packX = sd::ConstantTadHelper::getInstance().tadForDimensions(this->shapeInfo(), dimension);
|
||||
|
||||
NDArray::prepareSpecialUse({&target}, {this, &column});
|
||||
NativeOpExecutioner::execBroadcast(getContext(), sd::broadcast::Ops::Add, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), column.buffer(), column.shapeInfo(), column.specialBuffer(), column.specialShapeInfo(), target.buffer(), target.shapeInfo(), target.specialBuffer(), target.specialShapeInfo(), nullptr, 1, packX.platformShapeInfo(), packX.platformOffsets(), nullptr, nullptr);
|
||||
|
@ -4648,7 +4638,7 @@ void NDArray::addiColumnVector(const NDArray &column) {
|
|||
|
||||
int dimension = 0;
|
||||
|
||||
auto packX = sd::ConstantTadHelper::getInstance()->tadForDimensions(this->shapeInfo(), dimension);
|
||||
auto packX = sd::ConstantTadHelper::getInstance().tadForDimensions(this->shapeInfo(), dimension);
|
||||
|
||||
NDArray::prepareSpecialUse({this}, {&column});
|
||||
NativeOpExecutioner::execBroadcast(getContext(), sd::broadcast::Ops::Add, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), column.buffer(), column.shapeInfo(), column.specialBuffer(), column.specialShapeInfo(), this->buffer(), this->shapeInfo(), this->specialBuffer(), this->specialShapeInfo(), nullptr, 1, packX.platformShapeInfo(), packX.platformOffsets(), nullptr, nullptr);
|
||||
|
@ -4665,7 +4655,7 @@ void NDArray::muliColumnVector(const NDArray& column) {
|
|||
|
||||
int dimension = 0;
|
||||
|
||||
auto packX = sd::ConstantTadHelper::getInstance()->tadForDimensions(this->shapeInfo(), dimension);
|
||||
auto packX = sd::ConstantTadHelper::getInstance().tadForDimensions(this->shapeInfo(), dimension);
|
||||
|
||||
NDArray::prepareSpecialUse({this}, {&column});
|
||||
NativeOpExecutioner::execBroadcast(getContext(), sd::broadcast::Ops::Multiply, buffer(), shapeInfo(), specialBuffer(), specialShapeInfo(), column.buffer(), column.shapeInfo(), column.specialBuffer(), column.specialShapeInfo(), this->buffer(), this->shapeInfo(), this->specialBuffer(), this->specialShapeInfo(), nullptr, 1, packX.platformShapeInfo(), packX.platformOffsets(), nullptr, nullptr);
|
||||
|
@ -4706,7 +4696,7 @@ ResultSet NDArray::multipleTensorsAlongDimension(const std::vector<int> &indices
|
|||
if (indices.size() == 0)
|
||||
return result;
|
||||
|
||||
auto pack = ConstantTadHelper::getInstance()->tadForDimensions(shapeInfo(), const_cast<int*>(dimensions.data()), dimensions.size());
|
||||
auto pack = ConstantTadHelper::getInstance().tadForDimensions(shapeInfo(), const_cast<int*>(dimensions.data()), dimensions.size());
|
||||
|
||||
auto tadLength = shape::length(pack.primaryShapeInfo());
|
||||
auto numTads = lengthOf() / tadLength;
|
||||
|
@ -4827,7 +4817,7 @@ ResultSet NDArray::allTensorsAlongDimension(const std::vector<int> &dimensions)
|
|||
throw std::runtime_error("NDArray::allTensorsAlongDimension static function: all input dimensions must be smaller than rank of input array !");
|
||||
|
||||
|
||||
auto pack = ConstantTadHelper::getInstance()->tadForDimensions(_shapeInfo, const_cast<int*>(dimensions.data()), dimensions.size());
|
||||
auto pack = ConstantTadHelper::getInstance().tadForDimensions(_shapeInfo, const_cast<int*>(dimensions.data()), dimensions.size());
|
||||
auto numTads = pack.numberOfTads();
|
||||
|
||||
for (Nd4jLong idx = 0; idx < numTads; idx++ ) {
|
||||
|
@ -4940,11 +4930,11 @@ void NDArray::setShapeInfo(const Nd4jLong *shapeInfo) {
|
|||
if (shapeInfo != nullptr) {
|
||||
|
||||
ShapeDescriptor descriptor(shapeInfo);
|
||||
auto shapeBuffer = ConstantShapeHelper::getInstance()->bufferForShapeInfo(descriptor);
|
||||
auto shapeBuffer = ConstantShapeHelper::getInstance().bufferForShapeInfo(descriptor);
|
||||
|
||||
_shapeInfo = reinterpret_cast<Nd4jLong *>(shapeBuffer.primary());
|
||||
_shapeInfo = shapeBuffer.primary();
|
||||
#ifdef __CUDABLAS__
|
||||
_shapeInfoD = reinterpret_cast<Nd4jLong *>(shapeBuffer.special());
|
||||
_shapeInfoD = shapeBuffer.special();
|
||||
#endif
|
||||
|
||||
if(ArrayOptions::arrayType(_shapeInfo) == ArrayType::EMPTY)
|
||||
|
@ -4967,11 +4957,11 @@ void NDArray::setShapeInfo(const Nd4jLong *shapeInfo, const sd::DataType dtype)
|
|||
|
||||
Nd4jLong* shapeInfoTemp = ShapeBuilders::copyShapeInfoAndType(shapeInfo, dtype, true, getContext()->getWorkspace());
|
||||
ShapeDescriptor descriptor(shapeInfoTemp);
|
||||
auto shapeBuffer = ConstantShapeHelper::getInstance()->bufferForShapeInfo(descriptor);
|
||||
auto shapeBuffer = ConstantShapeHelper::getInstance().bufferForShapeInfo(descriptor);
|
||||
|
||||
_shapeInfo = reinterpret_cast<Nd4jLong *>(shapeBuffer.primary());
|
||||
_shapeInfo = shapeBuffer.primary();
|
||||
#ifdef __CUDABLAS__
|
||||
_shapeInfoD = reinterpret_cast<Nd4jLong *>(shapeBuffer.special());
|
||||
_shapeInfoD = shapeBuffer.special();
|
||||
#endif
|
||||
|
||||
if(ArrayOptions::arrayType(_shapeInfo) == ArrayType::EMPTY)
|
||||
|
@ -4990,11 +4980,11 @@ void NDArray::setShapeInfo(const Nd4jLong *shapeInfo, const sd::DataType dtype)
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
void NDArray::setShapeInfo(const ShapeDescriptor& descriptor) {
|
||||
|
||||
auto shapeBuffer = ConstantShapeHelper::getInstance()->bufferForShapeInfo(const_cast<ShapeDescriptor &>(descriptor));
|
||||
auto shapeBuffer = ConstantShapeHelper::getInstance().bufferForShapeInfo(const_cast<ShapeDescriptor &>(descriptor));
|
||||
|
||||
_shapeInfo = reinterpret_cast<Nd4jLong *>(shapeBuffer.primary());
|
||||
_shapeInfo = shapeBuffer.primary();
|
||||
#ifdef __CUDABLAS__
|
||||
_shapeInfoD = reinterpret_cast<Nd4jLong *>(shapeBuffer.special());
|
||||
_shapeInfoD = shapeBuffer.special();
|
||||
#endif
|
||||
|
||||
if(ArrayOptions::arrayType(_shapeInfo) == ArrayType::EMPTY)
|
||||
|
@ -5006,11 +4996,11 @@ void NDArray::setShapeInfo(const ShapeDescriptor& descriptor) {
|
|||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void NDArray::setShapeInfo(const ConstantDataBuffer& shapeBuffer) {
|
||||
void NDArray::setShapeInfo(const ConstantShapeBuffer& shapeBuffer) {
|
||||
|
||||
_shapeInfo = reinterpret_cast<Nd4jLong *>(const_cast<ConstantDataBuffer&>(shapeBuffer).primary());
|
||||
_shapeInfo = shapeBuffer.primary();
|
||||
#ifdef __CUDABLAS__
|
||||
_shapeInfoD = reinterpret_cast<Nd4jLong *>(const_cast<ConstantDataBuffer&>(shapeBuffer).special());
|
||||
_shapeInfoD = shapeBuffer.special();
|
||||
#endif
|
||||
|
||||
if(ArrayOptions::arrayType(_shapeInfo) == ArrayType::EMPTY)
|
||||
|
@ -5361,7 +5351,7 @@ NDArray operator+(T1&& arr1, T2&& arr2) {
|
|||
|
||||
if (arr1.isS() || arr2.isS())
|
||||
throw std::runtime_error("operator+(T&& arr1, T&& arr2): you can't use this method on String arrays!");
|
||||
if (!Environment::getInstance()->isExperimentalBuild() && arr1.dataType() != arr2.dataType() && (arr1.dataType() != DataType::BOOL || arr2.dataType() != BOOL))
|
||||
if (!Environment::getInstance().isExperimentalBuild() && arr1.dataType() != arr2.dataType() && (arr1.dataType() != DataType::BOOL || arr2.dataType() != BOOL))
|
||||
throw sd::datatype_exception::build("operator+(T&& arr1, T&& arr2): Cannot multiply different types", arr1.dataType(), arr2.dataType());
|
||||
|
||||
PointersManager pointersManager(arr1.getContext(), "operator+(T&& arr1, T&& arr2)");
|
||||
|
@ -5411,7 +5401,7 @@ NDArray operator-(T1&& arr1, T2&& arr2) {
|
|||
|
||||
if (arr1.isS() || arr2.isS())
|
||||
throw std::runtime_error("operator-(T&& arr1, T&& arr2): you can't use this method on String arrays!");
|
||||
if (!Environment::getInstance()->isExperimentalBuild() && arr1.dataType() != arr2.dataType() && (arr1.dataType() != DataType::BOOL || arr2.dataType() != BOOL))
|
||||
if (!Environment::getInstance().isExperimentalBuild() && arr1.dataType() != arr2.dataType() && (arr1.dataType() != DataType::BOOL || arr2.dataType() != BOOL))
|
||||
throw sd::datatype_exception::build("operator-(T&& arr1, T&& arr2): Cannot multiply different types", arr1.dataType(), arr2.dataType());
|
||||
|
||||
PointersManager pointersManager(arr1.getContext(), "operator-(T&& arr1, T&& arr2)");
|
||||
|
@ -5461,7 +5451,7 @@ NDArray operator*(T1&& arr1, T2&& arr2) {
|
|||
|
||||
if (arr1.isS() || arr2.isS())
|
||||
throw std::runtime_error("operator*(T&& arr1, T&& arr2): you can't use this method on String arrays!");
|
||||
if (!Environment::getInstance()->isExperimentalBuild() && arr1.dataType() != arr2.dataType() && (arr1.dataType() != DataType::BOOL || arr2.dataType() != BOOL))
|
||||
if (!Environment::getInstance().isExperimentalBuild() && arr1.dataType() != arr2.dataType() && (arr1.dataType() != DataType::BOOL || arr2.dataType() != BOOL))
|
||||
throw sd::datatype_exception::build("operator*(T&& arr1, T&& arr2): Cannot multiply different types", arr1.dataType(), arr2.dataType());
|
||||
|
||||
PointersManager pointersManager(arr1.getContext(), "operator*(T&& arr1, T&& arr2)");
|
||||
|
@ -5511,7 +5501,7 @@ NDArray operator/(T1&& arr1, T2&& arr2) {
|
|||
|
||||
if (arr1.isS() || arr2.isS())
|
||||
throw std::runtime_error("operator/(T&& arr1, T&& arr2): you can't use this method on String arrays!");
|
||||
if (!Environment::getInstance()->isExperimentalBuild() && arr1.dataType() != arr2.dataType() && (arr1.dataType() != DataType::BOOL || arr2.dataType() != BOOL))
|
||||
if (!Environment::getInstance().isExperimentalBuild() && arr1.dataType() != arr2.dataType() && (arr1.dataType() != DataType::BOOL || arr2.dataType() != BOOL))
|
||||
throw sd::datatype_exception::build("operator/(T&& arr1, T&& arr2): Cannot multiply different types", arr1.dataType(), arr2.dataType());
|
||||
|
||||
PointersManager pointersManager(arr1.getContext(), "operator/(T&& arr1, T&& arr2)");
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2018 Skymind, Inc.
|
||||
* Copyright (c) 2019-2020 Konduit K.K.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
|
@ -16,11 +15,25 @@
|
|||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author raver119@gmail.com
|
||||
// @author raver119@gmail.com
|
||||
//
|
||||
|
||||
#include "../specials_double.hpp"
|
||||
#ifndef SD_POINTERDEALLOCATOR_H_
|
||||
#define SD_POINTERDEALLOCATOR_H_
|
||||
|
||||
#include <system/dll.h>
|
||||
#include <system/pointercast.h>
|
||||
|
||||
namespace sd {
|
||||
BUILD_DOUBLE_TEMPLATE(template class DoubleMethods, , LIBND4J_TYPES, LIBND4J_TYPES_4);
|
||||
}
|
||||
|
||||
class ND4J_EXPORT PointerDeallocator {
|
||||
public:
|
||||
PointerDeallocator() = default;
|
||||
~PointerDeallocator() = default;
|
||||
|
||||
virtual void release(void* ptr);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //SD_POINTERDEALLOCATOR_H_
|
|
@ -0,0 +1,49 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2019-2020 Konduit K.K.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License, Version 2.0 which is available at
|
||||
* https://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.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author raver119@gmail.com
|
||||
//
|
||||
|
||||
#ifndef SD_ARRAY_POINTER_H_
|
||||
#define SD_ARRAY_POINTER_H_
|
||||
|
||||
#include <system/dll.h>
|
||||
#include <system/pointercast.h>
|
||||
#include <array/PointerDeallocator.h>
|
||||
#include <memory>
|
||||
|
||||
namespace sd {
|
||||
class ND4J_EXPORT PointerWrapper {
|
||||
private:
|
||||
void* _pointer = nullptr;
|
||||
std::shared_ptr<PointerDeallocator> _deallocator;
|
||||
|
||||
public:
|
||||
PointerWrapper(void* ptr, const std::shared_ptr<PointerDeallocator> &deallocator = {});
|
||||
PointerWrapper() = default;
|
||||
~PointerWrapper();
|
||||
|
||||
void* pointer() const;
|
||||
|
||||
template <typename T>
|
||||
T* pointerAsT() const {
|
||||
return reinterpret_cast<T*>(pointer());
|
||||
}
|
||||
};
|
||||
} // namespace sd
|
||||
|
||||
#endif //SD_ARRAY_POINTER_H_
|
|
@ -0,0 +1,38 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2019-2020 Konduit K.K.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License, Version 2.0 which is available at
|
||||
* https://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.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author raver119@gmail.com
|
||||
//
|
||||
|
||||
#ifndef SD_PRIMARYPOINTERDEALLOCATOR_H_
|
||||
#define SD_PRIMARYPOINTERDEALLOCATOR_H_
|
||||
|
||||
#include <system/dll.h>
|
||||
#include <system/pointercast.h>
|
||||
#include <array/PointerDeallocator.h>
|
||||
|
||||
namespace sd {
|
||||
class ND4J_EXPORT PrimaryPointerDeallocator : public PointerDeallocator {
|
||||
public:
|
||||
PrimaryPointerDeallocator() = default;
|
||||
~PrimaryPointerDeallocator() = default;
|
||||
|
||||
void release(void* ptr) override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //SD_PRIMARYPOINTERDEALLOCATOR_H_
|
|
@ -21,17 +21,18 @@
|
|||
#ifndef DEV_TESTS_TADPACK_H
|
||||
#define DEV_TESTS_TADPACK_H
|
||||
|
||||
#include "ConstantDataBuffer.h"
|
||||
#include <array/ConstantOffsetsBuffer.h>
|
||||
#include <array/ConstantShapeBuffer.h>
|
||||
|
||||
namespace sd {
|
||||
class ND4J_EXPORT TadPack {
|
||||
private:
|
||||
ConstantDataBuffer _tadShape;
|
||||
ConstantDataBuffer _tadOffsets;
|
||||
ConstantShapeBuffer _tadShape;
|
||||
ConstantOffsetsBuffer _tadOffsets;
|
||||
Nd4jLong _numTads = 0 ;
|
||||
int _shapeInfoLength = 0;
|
||||
public:
|
||||
explicit TadPack(ConstantDataBuffer &shapes, ConstantDataBuffer &offets, Nd4jLong numTads);
|
||||
explicit TadPack(const ConstantShapeBuffer &shapes, const ConstantOffsetsBuffer &offets, Nd4jLong numTads);
|
||||
TadPack() = default;
|
||||
~TadPack() = default;
|
||||
|
||||
|
|
|
@ -153,21 +153,38 @@ void NDArray::setIdentity() {
|
|||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
static void templatedSwap(void *xBuffer, void *yBuffer, Nd4jLong length) {
|
||||
static void templatedSwap(void *xBuffer, void *yBuffer, const Nd4jLong* xShapeInfo, const Nd4jLong* yShapeInfo, Nd4jLong length) {
|
||||
auto x = reinterpret_cast<T *>(xBuffer);
|
||||
auto y = reinterpret_cast<T *>(yBuffer);
|
||||
|
||||
const bool isSameOrders = shape::order(xShapeInfo) == shape::order(xShapeInfo);
|
||||
|
||||
const auto xEws = shape::elementWiseStride(xShapeInfo);
|
||||
const auto yEws = shape::elementWiseStride(yShapeInfo);
|
||||
|
||||
auto func = PRAGMA_THREADS_FOR {
|
||||
for (auto i = start; i < stop; i++) {
|
||||
auto temp = x[i];
|
||||
x[i] = y[i];
|
||||
y[i] = temp;
|
||||
if(isSameOrders && xEws > 0 && yEws > 0) {
|
||||
for(auto i = start; i < stop; i++)
|
||||
sd::math::nd4j_swap(x[i*xEws], y[i*yEws]);
|
||||
}
|
||||
else if(shape::haveSameShapeAndStrides(xShapeInfo, yShapeInfo)) {
|
||||
for(auto i = start; i < stop; i++) {
|
||||
const auto ind = shape::getIndexOffset(i, xShapeInfo);
|
||||
sd::math::nd4j_swap(x[ind], y[ind]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(auto i = start; i < stop; i++) {
|
||||
const auto xInd = shape::getIndexOffset(i, xShapeInfo);
|
||||
const auto yInd = shape::getIndexOffset(i, yShapeInfo);
|
||||
sd::math::nd4j_swap(x[xInd], y[yInd]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
samediff::Threads::parallel_for(func, 0, length);
|
||||
}
|
||||
BUILD_SINGLE_TEMPLATE(template void templatedSwap, (void *xBuffer, void *yBuffer, Nd4jLong length), LIBND4J_TYPES);
|
||||
BUILD_SINGLE_TEMPLATE(template void templatedSwap, (void *xBuffer, void *yBuffer, const Nd4jLong* xShapeInfo, const Nd4jLong* yShapeInfo, Nd4jLong length), LIBND4J_TYPES);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
void NDArray::swapUnsafe(NDArray& other) {
|
||||
|
@ -182,7 +199,7 @@ void NDArray::swapUnsafe(NDArray& other) {
|
|||
if(lengthOf() != other.lengthOf())
|
||||
throw std::runtime_error("NDArray::swapUnsafe method: input arrays should have the same length!");
|
||||
|
||||
BUILD_SINGLE_SELECTOR(xType, templatedSwap, (buffer(), other.buffer(), this->lengthOf()), LIBND4J_TYPES);
|
||||
BUILD_SINGLE_SELECTOR(xType, templatedSwap, (buffer(), other.buffer(), shapeInfo(), other.shapeInfo(), this->lengthOf()), LIBND4J_TYPES);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
@ -321,7 +338,7 @@ void NDArray::tile(const std::vector<Nd4jLong>& reps, NDArray& target) const {
|
|||
const int ews = target.ews();
|
||||
const auto targetLen = target.lengthOf();
|
||||
if(target.ordering() == 'c' && ews == 1) { // ews == 1 always here
|
||||
//#pragma omp parallel for simd if(targetLen > Environment::getInstance()->elementwiseThreshold()) schedule(guided)
|
||||
//#pragma omp parallel for simd if(targetLen > Environment::getInstance().elementwiseThreshold()) schedule(guided)
|
||||
for(Nd4jLong i=0; i<targetLen; ++i) {
|
||||
auto yOffset = shape::subArrayOffset(i, target.shapeInfo(), shapeInfo());
|
||||
BUILD_DOUBLE_SELECTOR(target.dataType(), dataType(), templatedDoubleAssign, (target.buffer(), i, buffer(), yOffset), LIBND4J_TYPES, LIBND4J_TYPES);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2018 Skymind, Inc.
|
||||
* Copyright (c) 2019-2020 Konduit K.K.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
|
@ -16,11 +15,15 @@
|
|||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author raver119@gmail.com
|
||||
// @author raver119@gmail.com
|
||||
//
|
||||
|
||||
#include "../specials_single.hpp"
|
||||
#include <array/CudaPointerDeallocator.h>
|
||||
|
||||
namespace sd {
|
||||
BUILD_SINGLE_TEMPLATE(template class SpecialMethods, , LIBND4J_TYPES_1);
|
||||
}
|
||||
|
||||
void CudaPointerDeallocator::release(void *ptr) {
|
||||
cudaFree(ptr);
|
||||
}
|
||||
|
||||
} // namespace sd
|
|
@ -70,16 +70,16 @@ void DataBuffer::allocateSpecial() {
|
|||
auto deviceId = sd::AffinityManager::currentDeviceId();
|
||||
|
||||
if (_workspace == nullptr)
|
||||
if (!sd::memory::MemoryCounter::getInstance()->validate(getLenInBytes()))
|
||||
throw sd::allocation_exception::build("Requested amount exceeds device limits", sd::memory::MemoryCounter::getInstance()->deviceLimit(deviceId), getLenInBytes());
|
||||
if (!sd::memory::MemoryCounter::getInstance().validate(getLenInBytes()))
|
||||
throw sd::allocation_exception::build("Requested amount exceeds device limits", sd::memory::MemoryCounter::getInstance().deviceLimit(deviceId), getLenInBytes());
|
||||
|
||||
|
||||
ALLOCATE_SPECIAL(_specialBuffer, _workspace, getLenInBytes(), int8_t);
|
||||
_isOwnerSpecial = true;
|
||||
|
||||
if (_workspace == nullptr) {
|
||||
sd::memory::MemoryCounter::getInstance()->countIn(deviceId, getLenInBytes());
|
||||
sd::memory::MemoryCounter::getInstance()->countIn(sd::memory::MemoryType::DEVICE, getLenInBytes());
|
||||
sd::memory::MemoryCounter::getInstance().countIn(deviceId, getLenInBytes());
|
||||
sd::memory::MemoryCounter::getInstance().countIn(sd::memory::MemoryType::DEVICE, getLenInBytes());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -135,8 +135,8 @@ void DataBuffer::deleteSpecial() {
|
|||
|
||||
// count out towards DataBuffer device, only if we're not in workspace
|
||||
if (_workspace == nullptr) {
|
||||
sd::memory::MemoryCounter::getInstance()->countOut(_deviceId, getLenInBytes());
|
||||
sd::memory::MemoryCounter::getInstance()->countOut(sd::memory::MemoryType::DEVICE, getLenInBytes());
|
||||
sd::memory::MemoryCounter::getInstance().countOut(_deviceId, getLenInBytes());
|
||||
sd::memory::MemoryCounter::getInstance().countOut(sd::memory::MemoryType::DEVICE, getLenInBytes());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ void* NDArray::platformBuffer() { return specialBuffer(); }
|
|||
void const* NDArray::platformBuffer() const { return specialBuffer(); }
|
||||
|
||||
Nd4jLong const* NDArray::platformShapeInfo() const { return specialShapeInfo(); }
|
||||
//Nd4jLong const* NDArray::platformShapeInfo() { return specialShapeInfo(); }
|
||||
//Nd4jLong const* NDArray::platform() { return special(); }
|
||||
|
||||
void NDArray::syncToDevice() const {
|
||||
auto currentDeviceId = AffinityManager::currentDeviceId();
|
||||
|
@ -225,7 +225,13 @@ void NDArray::swapUnsafe(NDArray& other) {
|
|||
if(lengthOf() != other.lengthOf())
|
||||
throw std::runtime_error("NDArray::swapUnsafe method: input arrays should have the same length!");
|
||||
|
||||
PointersManager manager(getContext(), "NDArray::swapUnsafe");
|
||||
|
||||
prepareSpecialUse({&other, this}, {&other, this});
|
||||
BUILD_SINGLE_SELECTOR(xType, templatedSwapUnsafe, (specialBuffer(), specialShapeInfo(), other.specialBuffer(), other.specialShapeInfo(), getContext()->getCudaStream()), LIBND4J_TYPES);
|
||||
registerSpecialUse({&other, this}, {&other, this});
|
||||
|
||||
manager.synchronize();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
@ -546,21 +552,18 @@ void NDArray::printCurrentBuffer(const bool host, const char* msg, const int pre
|
|||
if(specialBuffer() == nullptr || _length == 0)
|
||||
{ printf("NDArray::printSpecialBuffer: special buffer is nullptr !\n"); return; }
|
||||
|
||||
void* pHost = operator new(sizeof(T) * _length);
|
||||
const auto sizeOfBuffer = sizeOfT() * (getOffset(_length - 1) + 1);
|
||||
|
||||
if (ews() != 1) {
|
||||
for (uint i = 0; i < _length; i++)
|
||||
cudaMemcpyAsync(reinterpret_cast<T*>(pHost) + i, specialBufferWithOffset(i), sizeof(T), cudaMemcpyDeviceToHost, *(getContext()->getCudaStream()));
|
||||
}
|
||||
else
|
||||
cudaMemcpyAsync(pHost, specialBuffer(), sizeOfT() * _length, cudaMemcpyDeviceToHost, *getContext()->getCudaStream());
|
||||
void* pHost = operator new(sizeOfBuffer);
|
||||
|
||||
cudaMemcpyAsync(pHost, specialBuffer(), sizeOfBuffer, cudaMemcpyDeviceToHost, *getContext()->getCudaStream());
|
||||
|
||||
cudaError_t cudaResult = cudaStreamSynchronize(*getContext()->getCudaStream());
|
||||
if(cudaResult != 0)
|
||||
throw std::runtime_error("NDArray::printSpecialBuffer: cudaStreamSynchronize failed!");
|
||||
|
||||
for (uint i = 0; i < _length; i++)
|
||||
printf("%.*f, ", precision, (double)reinterpret_cast<T*>(pHost)[i]);
|
||||
printf("%.*f, ", precision, (double)reinterpret_cast<T*>(pHost)[getOffset(i)]);
|
||||
printf("\n");
|
||||
|
||||
operator delete(pHost);
|
||||
|
|
|
@ -18,29 +18,38 @@
|
|||
// @author raver119@gmail.com
|
||||
//
|
||||
|
||||
#include "../ConstantDataBuffer.h"
|
||||
#include <array/ConstantDataBuffer.h>
|
||||
#include <array/DataTypeUtils.h>
|
||||
|
||||
namespace sd {
|
||||
ConstantDataBuffer::ConstantDataBuffer(Nd4jPointer primary, Nd4jPointer special, Nd4jLong numEelements, Nd4jLong sizeOf) {
|
||||
_primaryBuffer = primary;
|
||||
_specialBuffer = special;
|
||||
_length = numEelements;
|
||||
_sizeOf = sizeOf;
|
||||
ConstantDataBuffer::ConstantDataBuffer(
|
||||
const std::shared_ptr<PointerWrapper>& primary,
|
||||
uint64_t numEelements,
|
||||
DataType dtype) : ConstantDataBuffer(primary, {}, numEelements, dtype) {
|
||||
//
|
||||
}
|
||||
|
||||
ConstantDataBuffer::ConstantDataBuffer(
|
||||
const std::shared_ptr<PointerWrapper>& primary,
|
||||
const std::shared_ptr<PointerWrapper>& special,
|
||||
uint64_t numEelements,
|
||||
DataType dtype) : _primaryBuffer(primary), _specialBuffer(special), _length(numEelements) {
|
||||
_sizeOf = DataTypeUtils::sizeOf(dtype);
|
||||
}
|
||||
|
||||
Nd4jPointer ConstantDataBuffer::primary() const {
|
||||
return _primaryBuffer;
|
||||
void* ConstantDataBuffer::primary() const {
|
||||
return _primaryBuffer->pointer();
|
||||
}
|
||||
|
||||
Nd4jPointer ConstantDataBuffer::special() const {
|
||||
return _specialBuffer;
|
||||
void* ConstantDataBuffer::special() const {
|
||||
return _specialBuffer ? _specialBuffer->pointer() : nullptr;
|
||||
}
|
||||
|
||||
Nd4jLong ConstantDataBuffer::sizeOf() const {
|
||||
uint8_t ConstantDataBuffer::sizeOf() const {
|
||||
return _sizeOf;
|
||||
}
|
||||
|
||||
Nd4jLong ConstantDataBuffer::length() const {
|
||||
uint64_t ConstantDataBuffer::length() const {
|
||||
return _length;
|
||||
}
|
||||
|
||||
|
@ -52,21 +61,21 @@ namespace sd {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
T* ConstantDataBuffer::primaryAsT() {
|
||||
return reinterpret_cast<T*>(_primaryBuffer);
|
||||
T* ConstantDataBuffer::primaryAsT() const {
|
||||
return reinterpret_cast<T*>(_primaryBuffer->pointer());
|
||||
}
|
||||
template ND4J_EXPORT float* ConstantDataBuffer::primaryAsT<float>();
|
||||
template ND4J_EXPORT double* ConstantDataBuffer::primaryAsT<double>();
|
||||
template ND4J_EXPORT int* ConstantDataBuffer::primaryAsT<int>();
|
||||
template ND4J_EXPORT Nd4jLong* ConstantDataBuffer::primaryAsT<Nd4jLong>();
|
||||
template ND4J_EXPORT float* ConstantDataBuffer::primaryAsT<float>() const;
|
||||
template ND4J_EXPORT double* ConstantDataBuffer::primaryAsT<double>() const;
|
||||
template ND4J_EXPORT int* ConstantDataBuffer::primaryAsT<int>() const;
|
||||
template ND4J_EXPORT Nd4jLong* ConstantDataBuffer::primaryAsT<Nd4jLong>() const;
|
||||
|
||||
template <typename T>
|
||||
T* ConstantDataBuffer::specialAsT() {
|
||||
return reinterpret_cast<T*>(_specialBuffer);
|
||||
T* ConstantDataBuffer::specialAsT() const {
|
||||
return reinterpret_cast<T*>(special());
|
||||
}
|
||||
template ND4J_EXPORT float* ConstantDataBuffer::specialAsT<float>();
|
||||
template ND4J_EXPORT double* ConstantDataBuffer::specialAsT<double>();
|
||||
template ND4J_EXPORT int* ConstantDataBuffer::specialAsT<int>();
|
||||
template ND4J_EXPORT Nd4jLong* ConstantDataBuffer::specialAsT<Nd4jLong>();
|
||||
template ND4J_EXPORT float* ConstantDataBuffer::specialAsT<float>() const;
|
||||
template ND4J_EXPORT double* ConstantDataBuffer::specialAsT<double>() const;
|
||||
template ND4J_EXPORT int* ConstantDataBuffer::specialAsT<int>() const;
|
||||
template ND4J_EXPORT Nd4jLong* ConstantDataBuffer::specialAsT<Nd4jLong>() const;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2019-2020 Konduit K.K.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License, Version 2.0 which is available at
|
||||
* https://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.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author raver119@gmail.com
|
||||
//
|
||||
|
||||
#include <array/ConstantOffsetsBuffer.h>
|
||||
|
||||
namespace sd {
|
||||
ConstantOffsetsBuffer::ConstantOffsetsBuffer(const std::shared_ptr<PointerWrapper> &primary) :
|
||||
ConstantOffsetsBuffer(primary, std::shared_ptr<PointerWrapper>(nullptr)) {
|
||||
//
|
||||
}
|
||||
|
||||
ConstantOffsetsBuffer::ConstantOffsetsBuffer(const std::shared_ptr<PointerWrapper> &primary,
|
||||
const std::shared_ptr<PointerWrapper> &special) {
|
||||
_primaryOffsets = primary;
|
||||
_specialOffsets = special;
|
||||
}
|
||||
|
||||
const Nd4jLong *ConstantOffsetsBuffer::primary() const {
|
||||
return reinterpret_cast<Nd4jLong*>(_primaryOffsets->pointer());
|
||||
}
|
||||
|
||||
const Nd4jLong *ConstantOffsetsBuffer::special() const {
|
||||
return _specialOffsets ? reinterpret_cast<Nd4jLong*>(_specialOffsets->pointer()) : nullptr;
|
||||
}
|
||||
|
||||
const Nd4jLong *ConstantOffsetsBuffer::platform() const {
|
||||
#ifdef __CUDABLAS__
|
||||
return special();
|
||||
#else
|
||||
return primary();
|
||||
#endif // CUDABLAS
|
||||
}
|
||||
|
||||
} // namespace sd
|
|
@ -0,0 +1,51 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2019-2020 Konduit K.K.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License, Version 2.0 which is available at
|
||||
* https://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.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author raver119@gmail.com
|
||||
//
|
||||
|
||||
#include <array/ConstantShapeBuffer.h>
|
||||
|
||||
namespace sd {
|
||||
ConstantShapeBuffer::ConstantShapeBuffer(const std::shared_ptr<PointerWrapper> &primary) :
|
||||
ConstantShapeBuffer(primary, std::shared_ptr<PointerWrapper>(nullptr)) {
|
||||
//
|
||||
}
|
||||
|
||||
ConstantShapeBuffer::ConstantShapeBuffer(const std::shared_ptr<PointerWrapper> &primary,
|
||||
const std::shared_ptr<PointerWrapper> &special) {
|
||||
_primaryShapeInfo = primary;
|
||||
_specialShapeInfo = special;
|
||||
}
|
||||
|
||||
const Nd4jLong *ConstantShapeBuffer::primary() const {
|
||||
return reinterpret_cast<Nd4jLong*>(_primaryShapeInfo->pointer());
|
||||
}
|
||||
|
||||
const Nd4jLong *ConstantShapeBuffer::special() const {
|
||||
return _specialShapeInfo ? reinterpret_cast<Nd4jLong*>(_specialShapeInfo->pointer()) : nullptr;
|
||||
}
|
||||
|
||||
const Nd4jLong *ConstantShapeBuffer::platform() const {
|
||||
#ifdef __CUDABLAS__
|
||||
return special();
|
||||
#else
|
||||
return primary();
|
||||
#endif // CUDABLAS
|
||||
}
|
||||
|
||||
} // namespace sd
|
|
@ -237,14 +237,14 @@ namespace sd {
|
|||
auto deviceId = sd::AffinityManager::currentDeviceId();
|
||||
// check if this allocation won't bring us above limit
|
||||
if (_workspace == nullptr) {
|
||||
if (Environment::getInstance()->isCPU()) {
|
||||
if (Environment::getInstance().isCPU()) {
|
||||
// on cpu backend we validate against device 0 for now
|
||||
if (!sd::memory::MemoryCounter::getInstance()->validate(getLenInBytes()))
|
||||
throw sd::allocation_exception::build("Requested amount exceeds HOST device limits", sd::memory::MemoryCounter::getInstance()->deviceLimit(deviceId), getLenInBytes());
|
||||
if (!sd::memory::MemoryCounter::getInstance().validate(getLenInBytes()))
|
||||
throw sd::allocation_exception::build("Requested amount exceeds HOST device limits", sd::memory::MemoryCounter::getInstance().deviceLimit(deviceId), getLenInBytes());
|
||||
} else {
|
||||
// in heterogenous mode we valdate against device group
|
||||
if (!sd::memory::MemoryCounter::getInstance()->validateGroup(sd::memory::MemoryType::HOST, getLenInBytes()))
|
||||
throw sd::allocation_exception::build("Requested amount exceeds HOST group limits", sd::memory::MemoryCounter::getInstance()->groupLimit(sd::memory::MemoryType::HOST), getLenInBytes());
|
||||
if (!sd::memory::MemoryCounter::getInstance().validateGroup(sd::memory::MemoryType::HOST, getLenInBytes()))
|
||||
throw sd::allocation_exception::build("Requested amount exceeds HOST group limits", sd::memory::MemoryCounter::getInstance().groupLimit(sd::memory::MemoryType::HOST), getLenInBytes());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,10 +253,10 @@ namespace sd {
|
|||
|
||||
// count in towards current deviceId if we're not in workspace mode
|
||||
if (_workspace == nullptr) {
|
||||
if (Environment::getInstance()->isCPU()) // we don't want this counter to be added to CUDA device
|
||||
sd::memory::MemoryCounter::getInstance()->countIn(deviceId, getLenInBytes());
|
||||
if (Environment::getInstance().isCPU()) // we don't want this counter to be added to CUDA device
|
||||
sd::memory::MemoryCounter::getInstance().countIn(deviceId, getLenInBytes());
|
||||
|
||||
sd::memory::MemoryCounter::getInstance()->countIn(sd::memory::MemoryType::HOST, getLenInBytes());
|
||||
sd::memory::MemoryCounter::getInstance().countIn(sd::memory::MemoryType::HOST, getLenInBytes());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -279,10 +279,10 @@ namespace sd {
|
|||
|
||||
// count out towards DataBuffer device, only if we're not in workspace
|
||||
if (_workspace == nullptr) {
|
||||
if (Environment::getInstance()->isCPU())
|
||||
sd::memory::MemoryCounter::getInstance()->countOut(_deviceId, getLenInBytes());
|
||||
if (Environment::getInstance().isCPU())
|
||||
sd::memory::MemoryCounter::getInstance().countOut(_deviceId, getLenInBytes());
|
||||
|
||||
sd::memory::MemoryCounter::getInstance()->countOut(sd::memory::MemoryType::HOST, getLenInBytes());
|
||||
sd::memory::MemoryCounter::getInstance().countOut(sd::memory::MemoryType::HOST, getLenInBytes());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2018 Skymind, Inc.
|
||||
* Copyright (c) 2019-2020 Konduit K.K.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
|
@ -16,11 +15,15 @@
|
|||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author raver119@gmail.com
|
||||
// @author raver119@gmail.com
|
||||
//
|
||||
|
||||
#include "../specials_single.hpp"
|
||||
#include <array/PointerDeallocator.h>
|
||||
|
||||
namespace sd {
|
||||
BUILD_SINGLE_TEMPLATE(template class SpecialMethods, , LIBND4J_TYPES_2);
|
||||
}
|
||||
|
||||
void PointerDeallocator::release(void *ptr) {
|
||||
// noop
|
||||
}
|
||||
|
||||
} // namespace sd
|
|
@ -0,0 +1,37 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2019-2020 Konduit K.K.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License, Version 2.0 which is available at
|
||||
* https://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.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author raver119@gmail.com
|
||||
//
|
||||
|
||||
#include <array/PointerWrapper.h>
|
||||
|
||||
namespace sd {
|
||||
PointerWrapper::PointerWrapper(void *ptr, const std::shared_ptr<PointerDeallocator> &deallocator): _pointer(ptr), _deallocator(deallocator) {
|
||||
//
|
||||
}
|
||||
|
||||
PointerWrapper::~PointerWrapper() {
|
||||
if (_deallocator.get() != nullptr)
|
||||
_deallocator->release(_pointer);
|
||||
}
|
||||
|
||||
void *PointerWrapper::pointer() const {
|
||||
return _pointer;
|
||||
}
|
||||
|
||||
} // namespace sd
|
|
@ -1,5 +1,4 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2018 Skymind, Inc.
|
||||
* Copyright (c) 2019-2020 Konduit K.K.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
|
@ -16,11 +15,15 @@
|
|||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author raver119@gmail.com
|
||||
// @author raver119@gmail.com
|
||||
//
|
||||
|
||||
#include "../specials_single.hpp"
|
||||
#include <array/PrimaryPointerDeallocator.h>
|
||||
|
||||
namespace sd {
|
||||
BUILD_SINGLE_TEMPLATE(template class SpecialMethods, , LIBND4J_TYPES_3);
|
||||
}
|
||||
|
||||
void PrimaryPointerDeallocator::release(void *ptr) {
|
||||
delete[] reinterpret_cast<int8_t*>(ptr);
|
||||
}
|
||||
|
||||
} // namespace sd
|
|
@ -23,26 +23,24 @@
|
|||
#include <helpers/shape.h>
|
||||
|
||||
namespace sd {
|
||||
TadPack::TadPack(ConstantDataBuffer &shapes, ConstantDataBuffer &offets, Nd4jLong numTads) {
|
||||
_tadShape = shapes;
|
||||
_tadOffsets = offets;
|
||||
TadPack::TadPack(const ConstantShapeBuffer &shapes, const ConstantOffsetsBuffer &offets, Nd4jLong numTads) : _tadShape(shapes), _tadOffsets(offets) {
|
||||
_numTads = numTads;
|
||||
}
|
||||
|
||||
const Nd4jLong* TadPack::primaryShapeInfo() const {
|
||||
return reinterpret_cast<Nd4jLong *>(_tadShape.primary());
|
||||
return _tadShape.primary();
|
||||
}
|
||||
|
||||
const Nd4jLong* TadPack::primaryOffsets() const {
|
||||
return reinterpret_cast<Nd4jLong *>(_tadOffsets.primary());
|
||||
return _tadOffsets.primary();
|
||||
}
|
||||
|
||||
const Nd4jLong* TadPack::specialShapeInfo() const {
|
||||
return reinterpret_cast<Nd4jLong *>(_tadShape.special());
|
||||
return _tadShape.special();
|
||||
}
|
||||
|
||||
const Nd4jLong* TadPack::specialOffsets() const {
|
||||
return reinterpret_cast<Nd4jLong *>(_tadOffsets.special());
|
||||
return _tadOffsets.special();
|
||||
}
|
||||
|
||||
Nd4jLong TadPack::numberOfTads() const {
|
||||
|
@ -50,11 +48,11 @@ namespace sd {
|
|||
}
|
||||
|
||||
const Nd4jLong* TadPack::platformShapeInfo() const {
|
||||
return sd::Environment::getInstance()->isCPU() ? primaryShapeInfo() : specialShapeInfo();
|
||||
return sd::Environment::getInstance().isCPU() ? primaryShapeInfo() : specialShapeInfo();
|
||||
}
|
||||
|
||||
const Nd4jLong* TadPack::platformOffsets() const {
|
||||
return sd::Environment::getInstance()->isCPU() ? primaryOffsets() : specialOffsets();
|
||||
return sd::Environment::getInstance().isCPU() ? primaryOffsets() : specialOffsets();
|
||||
}
|
||||
|
||||
int TadPack::shapeInfoLength() const {
|
||||
|
|
|
@ -35,9 +35,7 @@
|
|||
namespace samediff {
|
||||
class ND4J_EXPORT ThreadPool {
|
||||
private:
|
||||
static ThreadPool* _INSTANCE;
|
||||
|
||||
std::vector<std::thread*> _threads;
|
||||
std::vector<std::thread> _threads;
|
||||
std::vector<BlockingQueue<CallableWithArguments*>*> _queues;
|
||||
std::vector<CallableInterface*> _interfaces;
|
||||
|
||||
|
@ -48,7 +46,7 @@ namespace samediff {
|
|||
ThreadPool();
|
||||
~ThreadPool();
|
||||
public:
|
||||
static ThreadPool* getInstance();
|
||||
static ThreadPool& getInstance();
|
||||
|
||||
/**
|
||||
* This method returns list of pointers to threads ONLY if num_threads of threads were available upon request, returning empty list otherwise
|
||||
|
|
|
@ -107,7 +107,7 @@ namespace samediff {
|
|||
* @param increment
|
||||
* @return
|
||||
*/
|
||||
static int parallel_for(FUNC_1D function, int64_t start, int64_t stop, int64_t increment = 1, uint32_t numThreads = sd::Environment::getInstance()->maxMasterThreads());
|
||||
static int parallel_for(FUNC_1D function, int64_t start, int64_t stop, int64_t increment = 1, uint32_t numThreads = sd::Environment::getInstance().maxMasterThreads());
|
||||
|
||||
/**
|
||||
* This function executes 1 dimensional loop for a given number of threads
|
||||
|
@ -119,7 +119,7 @@ namespace samediff {
|
|||
* @param numThreads
|
||||
* @return
|
||||
*/
|
||||
static int parallel_tad(FUNC_1D function, int64_t start, int64_t stop, int64_t increment = 1, uint32_t numThreads = sd::Environment::getInstance()->maxMasterThreads());
|
||||
static int parallel_tad(FUNC_1D function, int64_t start, int64_t stop, int64_t increment = 1, uint32_t numThreads = sd::Environment::getInstance().maxMasterThreads());
|
||||
|
||||
/**
|
||||
* This method will execute function splitting 2 nested loops space with multiple threads
|
||||
|
@ -134,7 +134,7 @@ namespace samediff {
|
|||
* @param inc_y
|
||||
* @return
|
||||
*/
|
||||
static int parallel_for(FUNC_2D function, int64_t start_x, int64_t stop_x, int64_t inc_x, int64_t start_y, int64_t stop_y, int64_t inc_y, uint64_t numThreads = sd::Environment::getInstance()->maxMasterThreads(), bool debug = false);
|
||||
static int parallel_for(FUNC_2D function, int64_t start_x, int64_t stop_x, int64_t inc_x, int64_t start_y, int64_t stop_y, int64_t inc_y, uint64_t numThreads = sd::Environment::getInstance().maxMasterThreads(), bool debug = false);
|
||||
|
||||
/**
|
||||
* This method will execute function splitting 3 nested loops space with multiple threads
|
||||
|
@ -152,7 +152,7 @@ namespace samediff {
|
|||
* @param inc_z
|
||||
* @return
|
||||
*/
|
||||
static int parallel_for(FUNC_3D function, int64_t start_x, int64_t stop_x, int64_t inc_x, int64_t start_y, int64_t stop_y, int64_t inc_y, int64_t start_z, int64_t stop_z, int64_t inc_z, uint64_t numThreads = sd::Environment::getInstance()->maxMasterThreads());
|
||||
static int parallel_for(FUNC_3D function, int64_t start_x, int64_t stop_x, int64_t inc_x, int64_t start_y, int64_t stop_y, int64_t inc_y, int64_t start_z, int64_t stop_z, int64_t inc_z, uint64_t numThreads = sd::Environment::getInstance().maxMasterThreads());
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -160,18 +160,18 @@ namespace samediff {
|
|||
* @param numThreads
|
||||
* @return
|
||||
*/
|
||||
static int parallel_do(FUNC_DO function, uint64_t numThreads = sd::Environment::getInstance()->maxMasterThreads());
|
||||
static int parallel_do(FUNC_DO function, uint64_t numThreads = sd::Environment::getInstance().maxMasterThreads());
|
||||
|
||||
static int64_t parallel_long(FUNC_RL function, FUNC_AL aggregator, int64_t start, int64_t stop, int64_t increment = 1, uint64_t numThreads = sd::Environment::getInstance()->maxMasterThreads());
|
||||
static int64_t parallel_long(FUNC_RL function, FUNC_AL aggregator, int64_t start, int64_t stop, int64_t increment = 1, uint64_t numThreads = sd::Environment::getInstance().maxMasterThreads());
|
||||
|
||||
static double parallel_double(FUNC_RD function, FUNC_AD aggregator, int64_t start, int64_t stop, int64_t increment = 1, uint64_t numThreads = sd::Environment::getInstance()->maxMasterThreads());
|
||||
static double parallel_double(FUNC_RD function, FUNC_AD aggregator, int64_t start, int64_t stop, int64_t increment = 1, uint64_t numThreads = sd::Environment::getInstance().maxMasterThreads());
|
||||
|
||||
/**
|
||||
* This method will execute function in parallel preserving the parts to be aligned increment size
|
||||
* PLEASE NOTE: this function can use smaller number of threads than requested.
|
||||
*
|
||||
*/
|
||||
static int parallel_aligned_increment(FUNC_1D function, int64_t start, int64_t stop, int64_t increment, size_t type_size = sizeof(float), uint32_t req_numThreads = sd::Environment::getInstance()->maxMasterThreads());
|
||||
static int parallel_aligned_increment(FUNC_1D function, int64_t start, int64_t stop, int64_t increment, size_t type_size = sizeof(float), uint32_t req_numThreads = sd::Environment::getInstance().maxMasterThreads());
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -61,14 +61,19 @@ namespace sd {
|
|||
|
||||
}
|
||||
|
||||
LaunchContext* LaunchContext::defaultContext() {
|
||||
// TODO: we need it to be device-aware, but only once we add NUMA support for cpu
|
||||
if (LaunchContext::_contexts.empty()) {
|
||||
LaunchContext::_contexts.emplace_back(std::make_shared<LaunchContext>());
|
||||
}
|
||||
static std::mutex _lock;
|
||||
|
||||
// return context for current device
|
||||
return LaunchContext::_contexts[0].get();
|
||||
LaunchContext* LaunchContext::defaultContext() {
|
||||
{
|
||||
// synchronous block goes here
|
||||
std::lock_guard<std::mutex> lock(_lock);
|
||||
// TODO: we need it to be device-aware, but only once we add NUMA support for cpu
|
||||
if (LaunchContext::_contexts.empty())
|
||||
LaunchContext::_contexts.emplace_back(std::make_shared<LaunchContext>());
|
||||
}
|
||||
|
||||
// return context for current device
|
||||
return LaunchContext::_contexts[0].get();
|
||||
}
|
||||
|
||||
std::mutex* LaunchContext::deviceMutex() {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2018 Skymind, Inc.
|
||||
* Copyright (c) 2020 Konduit K.K.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License, Version 2.0 which is available at
|
||||
|
@ -15,7 +16,7 @@
|
|||
******************************************************************************/
|
||||
|
||||
//
|
||||
// Created by raver119 on 30.11.17.
|
||||
// @author raver119@gmail.com
|
||||
//
|
||||
|
||||
#include <execution/LaunchContext.h>
|
||||
|
@ -75,36 +76,37 @@ LaunchContext::LaunchContext() {
|
|||
}
|
||||
|
||||
LaunchContext* LaunchContext::defaultContext() {
|
||||
/**
|
||||
* This method returns LaunchContext, that has multiple entities within:
|
||||
* 1) temporary buffers. they must be per-thread
|
||||
* 2) CUDA stream. it must be either per-thread or per-device
|
||||
* 3) cuBLAS handle. it must be per-device
|
||||
*/
|
||||
auto deviceId = AffinityManager::currentDeviceId();
|
||||
/**
|
||||
* This method returns LaunchContext, that has multiple entities within:
|
||||
* 1) temporary buffers. they must be per-thread
|
||||
* 2) CUDA stream. it must be either per-thread or per-device
|
||||
* 3) cuBLAS handle. it must be per-device
|
||||
*/
|
||||
auto deviceId = AffinityManager::currentDeviceId();
|
||||
|
||||
{
|
||||
// we need this block synchronous, to avoid double initialization etc
|
||||
_mutex.lock();
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
if (LaunchContext::_contexts.empty()) {
|
||||
// create one context per device
|
||||
auto numDevices = AffinityManager::numberOfDevices();
|
||||
// create one context per device
|
||||
auto numDevices = AffinityManager::numberOfDevices();
|
||||
|
||||
_contexts.resize(numDevices);
|
||||
for (int e = 0; e < numDevices; e++) {
|
||||
_deviceMutexes[e] = new std::mutex();
|
||||
_contexts.resize(numDevices);
|
||||
for (int e = 0; e < numDevices; e++) {
|
||||
_deviceMutexes[e] = new std::mutex();
|
||||
|
||||
AffinityManager::setCurrentNativeDevice(e);
|
||||
AffinityManager::setCurrentNativeDevice(e);
|
||||
|
||||
LaunchContext::_contexts[e] = std::make_shared<LaunchContext>();
|
||||
}
|
||||
LaunchContext::_contexts[e] = std::make_shared<LaunchContext>();
|
||||
}
|
||||
|
||||
// don't forget to restore device back again
|
||||
AffinityManager::setCurrentNativeDevice(deviceId);
|
||||
// don't forget to restore device back again
|
||||
AffinityManager::setCurrentNativeDevice(deviceId);
|
||||
}
|
||||
_mutex.unlock();
|
||||
}
|
||||
|
||||
// return context for current device
|
||||
return LaunchContext::_contexts[deviceId].get();
|
||||
// return context for current device
|
||||
return LaunchContext::_contexts[deviceId].get();
|
||||
}
|
||||
|
||||
|
||||
|
@ -121,11 +123,11 @@ LaunchContext::LaunchContext() {
|
|||
};
|
||||
|
||||
void* LaunchContext::getCublasHandle() const {
|
||||
return CublasHelper::getInstance()->handle();
|
||||
return CublasHelper::getInstance().handle();
|
||||
};
|
||||
|
||||
void* LaunchContext::getCusolverHandle() const {
|
||||
return CublasHelper::getInstance()->solver();
|
||||
return CublasHelper::getInstance().solver();
|
||||
};
|
||||
|
||||
cudaStream_t* LaunchContext::getCudaStream() const {
|
||||
|
@ -175,7 +177,7 @@ LaunchContext::LaunchContext() {
|
|||
}
|
||||
|
||||
void* LaunchContext::getCuDnnHandle() const {
|
||||
return CublasHelper::getInstance()->cudnn();
|
||||
return CublasHelper::getInstance().cudnn();
|
||||
}
|
||||
|
||||
sd::ErrorReference* LaunchContext::errorReference() {
|
||||
|
|
|
@ -78,7 +78,7 @@ namespace samediff {
|
|||
ThreadPool::ThreadPool() {
|
||||
// TODO: number of threads must reflect number of cores for UMA system. In case of NUMA it should be per-device pool
|
||||
// FIXME: on mobile phones this feature must NOT be used
|
||||
_available = sd::Environment::getInstance()->maxThreads();
|
||||
_available = sd::Environment::getInstance().maxThreads();
|
||||
|
||||
_queues.resize(_available.load());
|
||||
_threads.resize(_available.load());
|
||||
|
@ -88,7 +88,7 @@ namespace samediff {
|
|||
for (int e = 0; e < _available.load(); e++) {
|
||||
_queues[e] = new BlockingQueue<CallableWithArguments*>(2);
|
||||
_interfaces[e] = new CallableInterface();
|
||||
_threads[e] = new std::thread(executionLoopWithInterface_, e, _interfaces[e]);
|
||||
_threads[e] = std::thread(executionLoopWithInterface_, e, _interfaces[e]);
|
||||
_tickets.push(new Ticket());
|
||||
// _threads[e] = new std::thread(executionLoop_, e, _queues[e]);
|
||||
|
||||
|
@ -125,19 +125,22 @@ namespace samediff {
|
|||
// stop each and every thread
|
||||
|
||||
// release queue and thread
|
||||
//delete _queues[e];
|
||||
//delete _threads[e];
|
||||
delete _queues[e];
|
||||
_threads[e].detach();
|
||||
//delete _interfaces[e];
|
||||
}
|
||||
|
||||
while (!_tickets.empty()) {
|
||||
auto t = _tickets.front();
|
||||
_tickets.pop();
|
||||
delete t;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static std::mutex _lmutex;
|
||||
|
||||
ThreadPool* ThreadPool::getInstance() {
|
||||
std::unique_lock<std::mutex> lock(_lmutex);
|
||||
if (!_INSTANCE)
|
||||
_INSTANCE = new ThreadPool();
|
||||
|
||||
return _INSTANCE;
|
||||
ThreadPool& ThreadPool::getInstance() {
|
||||
static ThreadPool instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void ThreadPool::release(int numThreads) {
|
||||
|
@ -188,7 +191,4 @@ namespace samediff {
|
|||
std::unique_lock<std::mutex> lock(_lock);
|
||||
_tickets.push(ticket);
|
||||
}
|
||||
|
||||
|
||||
ThreadPool* ThreadPool::_INSTANCE = 0;
|
||||
}
|
||||
|
|
|
@ -357,7 +357,7 @@ namespace samediff {
|
|||
return 1;
|
||||
}
|
||||
|
||||
auto ticket = ThreadPool::getInstance()->tryAcquire(numThreads);
|
||||
auto ticket = ThreadPool::getInstance().tryAcquire(numThreads);
|
||||
if (ticket != nullptr) {
|
||||
// if we got our threads - we'll run our jobs here
|
||||
auto span = delta / numThreads;
|
||||
|
@ -449,7 +449,7 @@ namespace samediff {
|
|||
// but we still mimic multithreaded execution
|
||||
return numThreads;
|
||||
} else {
|
||||
auto ticket = ThreadPool::getInstance()->tryAcquire(numThreads);
|
||||
auto ticket = ThreadPool::getInstance().tryAcquire(numThreads);
|
||||
if (ticket != nullptr) {
|
||||
|
||||
for (int e = 0; e < numThreads; e++) {
|
||||
|
@ -499,7 +499,7 @@ namespace samediff {
|
|||
return 1;
|
||||
}
|
||||
|
||||
auto ticket = ThreadPool::getInstance()->tryAcquire(numThreads);
|
||||
auto ticket = ThreadPool::getInstance().tryAcquire(numThreads);
|
||||
if (ticket != nullptr) {
|
||||
auto splitLoop = ThreadsHelper::pickLoop3d(numThreads, itersX, itersY, itersZ);
|
||||
|
||||
|
@ -526,7 +526,7 @@ namespace samediff {
|
|||
}
|
||||
|
||||
int Threads::parallel_do(FUNC_DO function, uint64_t numThreads) {
|
||||
auto ticket = ThreadPool::getInstance()->tryAcquire(numThreads - 1);
|
||||
auto ticket = ThreadPool::getInstance().tryAcquire(numThreads - 1);
|
||||
if (ticket != nullptr) {
|
||||
|
||||
// submit tasks one by one
|
||||
|
@ -565,7 +565,7 @@ namespace samediff {
|
|||
if (numThreads == 1)
|
||||
return function(0, start, stop, increment);
|
||||
|
||||
auto ticket = ThreadPool::getInstance()->tryAcquire(numThreads - 1);
|
||||
auto ticket = ThreadPool::getInstance().tryAcquire(numThreads - 1);
|
||||
if (ticket == nullptr)
|
||||
return function(0, start, stop, increment);
|
||||
|
||||
|
@ -609,7 +609,7 @@ namespace samediff {
|
|||
if (numThreads == 1)
|
||||
return function(0, start, stop, increment);
|
||||
|
||||
auto ticket = ThreadPool::getInstance()->tryAcquire(numThreads - 1);
|
||||
auto ticket = ThreadPool::getInstance().tryAcquire(numThreads - 1);
|
||||
if (ticket == nullptr)
|
||||
return function(0, start, stop, increment);
|
||||
|
||||
|
@ -668,7 +668,7 @@ namespace samediff {
|
|||
numThreads = static_cast<int>(std::ceil((double)delta / spand));
|
||||
auto span = static_cast<Nd4jLong>(spand);
|
||||
|
||||
auto ticket = samediff::ThreadPool::getInstance()->tryAcquire(numThreads);
|
||||
auto ticket = samediff::ThreadPool::getInstance().tryAcquire(numThreads);
|
||||
if (ticket != nullptr) {
|
||||
//tail_add is additional value of the last part
|
||||
//it could be negative or positive
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace samediff {
|
|||
|
||||
Ticket::Ticket() {
|
||||
_acquired = true;
|
||||
_interfaces.resize(sd::Environment::getInstance()->maxThreads());
|
||||
_interfaces.resize(sd::Environment::getInstance().maxThreads());
|
||||
}
|
||||
|
||||
bool Ticket::acquired() {
|
||||
|
@ -80,11 +80,11 @@ namespace samediff {
|
|||
_interfaces[e]->markAvailable();
|
||||
|
||||
// increment availability counter
|
||||
ThreadPool::getInstance()->release();
|
||||
ThreadPool::getInstance().release();
|
||||
}
|
||||
|
||||
// return this ticket back to the pool
|
||||
ThreadPool::getInstance()->release(this);
|
||||
ThreadPool::getInstance().release(this);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace sd {
|
|||
std::vector<sd::DataType> _dataTypes;
|
||||
|
||||
sd::ops::OpDescriptor* _opDescriptor;
|
||||
bool _useMKLDNN = sd::Environment::getInstance()->isUseMKLDNN();
|
||||
bool _useMKLDNN = sd::Environment::getInstance().isUseMKLDNN();
|
||||
|
||||
// target engine for execution
|
||||
samediff::Engine _engine = DEFAULT_ENGINE;
|
||||
|
|
|
@ -30,7 +30,6 @@ namespace sd {
|
|||
namespace graph {
|
||||
class ND4J_EXPORT GraphHolder {
|
||||
private:
|
||||
static GraphHolder *_INSTANCE;
|
||||
MAP_IMPL<Nd4jLong, Graph *> _graphF;
|
||||
|
||||
MAP_IMPL<Nd4jLong, SimpleReadWriteLock> _locks;
|
||||
|
@ -38,7 +37,7 @@ namespace sd {
|
|||
GraphHolder() = default;
|
||||
~GraphHolder() = default;
|
||||
public:
|
||||
static GraphHolder* getInstance();
|
||||
static GraphHolder& getInstance();
|
||||
|
||||
void registerGraph(Nd4jLong graphId, Graph *graph);
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#define LIBND4J_GRAPH_RNG_H
|
||||
|
||||
#include <types/u64.h>
|
||||
#include <types/u32.h>
|
||||
#include <system/pointercast.h>
|
||||
#include <system/op_boilerplate.h>
|
||||
#include <system/dll.h>
|
||||
|
@ -29,6 +30,7 @@
|
|||
#include <array/DataTypeUtils.h>
|
||||
#include <helpers/logger.h>
|
||||
#include <stdexcept>
|
||||
#include <math/templatemath.h>
|
||||
|
||||
#ifdef __CUDACC__
|
||||
#include <cuda.h>
|
||||
|
@ -79,9 +81,9 @@ namespace sd {
|
|||
*/
|
||||
static FORCEINLINE Nd4jLong currentMilliseconds();
|
||||
|
||||
|
||||
FORCEINLINE _CUDA_HD uint32_t xoroshiro32(Nd4jLong index);
|
||||
FORCEINLINE _CUDA_HD uint64_t xoroshiro64(Nd4jLong index);
|
||||
public:
|
||||
FORCEINLINE _CUDA_HD uint32_t xoroshiro32(uint64_t index);
|
||||
FORCEINLINE _CUDA_HD uint64_t xoroshiro64(uint64_t index);
|
||||
|
||||
/**
|
||||
* This method returns integer value between 0 and MAX_UINT
|
||||
|
@ -119,7 +121,7 @@ namespace sd {
|
|||
FORCEINLINE _CUDA_HD int relativeInt(Nd4jLong index);
|
||||
FORCEINLINE _CUDA_HD Nd4jLong relativeLong(Nd4jLong index);
|
||||
|
||||
FORCEINLINE _CUDA_HD void rewindH(Nd4jLong steps);
|
||||
FORCEINLINE _CUDA_HD void rewindH(uint64_t steps);
|
||||
|
||||
/**
|
||||
* These methods set up only node states, with non-changed root ones
|
||||
|
@ -172,6 +174,24 @@ namespace sd {
|
|||
return v;
|
||||
}
|
||||
|
||||
template <>
|
||||
_CUDA_HD FORCEINLINE float RandomGenerator::relativeT<float>(Nd4jLong index) {
|
||||
u32 u;
|
||||
u._u32 = (0x3f800000 | (this->xoroshiro32(index) >> 9));
|
||||
return u._f32 - 1.0f;
|
||||
}
|
||||
|
||||
template <>
|
||||
_CUDA_HD FORCEINLINE double RandomGenerator::relativeT<double>(Nd4jLong index) {
|
||||
#ifdef __DOUBLE_RNG__
|
||||
u64 u;
|
||||
u._ulong = ((UINT64_C(0x3FF) << 52) | (this->xoroshiro64(index) >> 12));
|
||||
return u._double - 1.0;
|
||||
#else
|
||||
return (double) relativeT<float>(index);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <>
|
||||
_CUDA_HD FORCEINLINE uint64_t RandomGenerator::relativeT<uint64_t>(Nd4jLong index) {
|
||||
return this->xoroshiro64(index);
|
||||
|
@ -184,16 +204,14 @@ namespace sd {
|
|||
|
||||
template <>
|
||||
_CUDA_HD FORCEINLINE int RandomGenerator::relativeT<int>(Nd4jLong index) {
|
||||
auto x = this->relativeT<uint32_t>(index);
|
||||
auto r = static_cast<int>(x % DataTypeUtils::max<int>());
|
||||
return r;
|
||||
auto r = relativeT<uint32_t>(index);
|
||||
return r <= DataTypeUtils::max<int>() ? r : r % DataTypeUtils::max<int>();
|
||||
}
|
||||
|
||||
template <>
|
||||
_CUDA_HD FORCEINLINE Nd4jLong RandomGenerator::relativeT<Nd4jLong>(Nd4jLong index) {
|
||||
auto x = this->relativeT<uint64_t>(index);
|
||||
auto r = static_cast<Nd4jLong>(x % DataTypeUtils::max<Nd4jLong>());
|
||||
return r;
|
||||
auto r = relativeT<uint64_t>(index);
|
||||
return r <= DataTypeUtils::max<Nd4jLong>() ? r : r % DataTypeUtils::max<Nd4jLong>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@ -220,24 +238,18 @@ namespace sd {
|
|||
template <typename T>
|
||||
_CUDA_HD FORCEINLINE T RandomGenerator::relativeT(Nd4jLong index) {
|
||||
// This is default implementation for floating point types
|
||||
#ifdef __DOUBLE_RNG__
|
||||
auto i = static_cast<double>(this->relativeT<uint64_t>(index));
|
||||
auto r = i / static_cast<double>(DataTypeUtils::max<uint64_t>());
|
||||
return static_cast<T>(r);
|
||||
#else
|
||||
auto i = static_cast<float>(this->relativeT<uint32_t>(index));
|
||||
auto r = i / static_cast<float>(DataTypeUtils::max<uint32_t>());
|
||||
return static_cast<T>(r);
|
||||
#endif
|
||||
return static_cast<T>(relativeT<float>(index));
|
||||
}
|
||||
|
||||
|
||||
_CUDA_HD FORCEINLINE int RandomGenerator::relativeInt(Nd4jLong index) {
|
||||
return relativeT<int>(index);
|
||||
auto r = relativeT<uint32_t>(index);
|
||||
return r <= DataTypeUtils::max<int>() ? r : r % DataTypeUtils::max<int>();
|
||||
}
|
||||
|
||||
_CUDA_HD FORCEINLINE Nd4jLong RandomGenerator::relativeLong(Nd4jLong index) {
|
||||
return relativeT<Nd4jLong>(index);
|
||||
auto r = relativeT<uint64_t>(index);
|
||||
return r <= DataTypeUtils::max<Nd4jLong>() ? r : r % DataTypeUtils::max<Nd4jLong>();
|
||||
}
|
||||
|
||||
//////
|
||||
|
@ -249,23 +261,12 @@ namespace sd {
|
|||
return (x << k) | (x >> (64 - k));
|
||||
}
|
||||
|
||||
_CUDA_HD FORCEINLINE uint32_t RandomGenerator::xoroshiro32(Nd4jLong index) {
|
||||
|
||||
auto s0 = _rootState._ulong;
|
||||
auto s1 = _nodeState._ulong;
|
||||
|
||||
// xor by idx
|
||||
s0 |= ((index + 2) * (s1 + 24243287));
|
||||
s1 ^= ((index + 2) * (s0 + 723829));
|
||||
|
||||
unsigned long val = 0;
|
||||
val = s1 ^ s0;
|
||||
int* pHalf = reinterpret_cast<int*>(&val);
|
||||
|
||||
return rotl(*pHalf * 0x9E3779BB, 5) * 5;
|
||||
static FORCEINLINE _CUDA_HD uint32_t next(uint32_t s0, uint32_t s1, uint32_t s2, uint32_t s3) {
|
||||
const uint32_t result = rotl(s0 + s3, 7) + s0;
|
||||
return result;
|
||||
}
|
||||
|
||||
_CUDA_HD FORCEINLINE uint64_t RandomGenerator::xoroshiro64(Nd4jLong index) {
|
||||
_CUDA_HD FORCEINLINE uint32_t RandomGenerator::xoroshiro32(uint64_t index) {
|
||||
auto s0 = _rootState._ulong;
|
||||
auto s1 = _nodeState._ulong;
|
||||
|
||||
|
@ -273,23 +274,29 @@ namespace sd {
|
|||
s0 |= ((index + 2) * (s1 + 24243287));
|
||||
s1 ^= ((index + 2) * (s0 + 723829));
|
||||
|
||||
// since we're not modifying state - do rotl step right here
|
||||
s1 ^= s0;
|
||||
s0 = rotl(s0, 55) ^ s1 ^ (s1 << 14);
|
||||
s1 = rotl(s1, 36);
|
||||
unsigned long val = 0;
|
||||
val = s1 ^ s0;
|
||||
int* pHalf = reinterpret_cast<int*>(&val);
|
||||
|
||||
return s0 + s1;
|
||||
return rotl(*pHalf * 0x9E3779BB, 5) * 5;
|
||||
}
|
||||
|
||||
_CUDA_HD FORCEINLINE void RandomGenerator::rewindH(Nd4jLong steps) {
|
||||
auto s0 = _nodeState._du32._v0;
|
||||
auto s1 = _nodeState._du32._v1;
|
||||
_CUDA_HD FORCEINLINE uint64_t RandomGenerator::xoroshiro64(uint64_t index) {
|
||||
uint64_t upper = ((uint64_t) xoroshiro32(index)) << 32;
|
||||
uint32_t lower = xoroshiro32(sd::math::nd4j_rotl<uint64_t>(index, 32));
|
||||
return upper + lower;
|
||||
}
|
||||
|
||||
s1 ^= s0;
|
||||
_nodeState._du32._v0 = rotl(s0, 26) ^ s1 ^ (s1 << 9); // a, b
|
||||
_nodeState._du32._v1 = rotl(s1, 13); // c
|
||||
_CUDA_HD FORCEINLINE void RandomGenerator::rewindH(uint64_t steps) {
|
||||
// we only update node state, if any
|
||||
auto s0 = _nodeState._du32._v0;
|
||||
auto s1 = _nodeState._du32._v1;
|
||||
|
||||
_nodeState._long ^= (steps ^ 0xdeadbeef);
|
||||
s1 ^= s0;
|
||||
_nodeState._du32._v0 = rotl(s0, 26) ^ s1 ^ (s1 << 9); // a, b
|
||||
_nodeState._du32._v1 = rotl(s1, 13); // c
|
||||
|
||||
_nodeState._long ^= (steps ^ 0xdeadbeef);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace sd {
|
|||
// FIXME!!
|
||||
outputAddr.second = e;
|
||||
|
||||
if (Environment::getInstance()->isDebugAndVerbose())
|
||||
if (Environment::getInstance().isDebugAndVerbose())
|
||||
nd4j_debug("Return input: <%i, %i>; Return output: <%i, %i>\n", inputAddr.first, inputAddr.second, outputAddr.first, outputAddr.second);
|
||||
|
||||
auto varIn = __variableSpace->getVariable(inputAddr);
|
||||
|
@ -45,7 +45,7 @@ namespace sd {
|
|||
// FIXME: this is obviously wrong, we should keep depth track for backprop here
|
||||
varOut->getNDArray()->assign(varIn->getNDArray());
|
||||
|
||||
if (Environment::getInstance()->isDebugAndVerbose())
|
||||
if (Environment::getInstance().isDebugAndVerbose())
|
||||
nd4j_debug("In after: [%f]; Out after: [%f]\n", varIn->getNDArray()->meanNumber().e<float>(0), varOut->getNDArray()->meanNumber().e<float>(0));
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ namespace sd {
|
|||
// now we should take result of the Scope run, and evaluate it
|
||||
auto result = __variableSpace->getVariable(lastNode)->getNDArray();
|
||||
|
||||
if (Environment::getInstance()->isDebugAndVerbose())
|
||||
if (Environment::getInstance().isDebugAndVerbose())
|
||||
result->printBuffer("Result of the last node:");
|
||||
|
||||
// if result evaluates to 0.0 - condition returned FALSE
|
||||
|
|
|
@ -236,7 +236,7 @@ namespace sd {
|
|||
|
||||
auto v = variable(p);
|
||||
|
||||
if (Environment::getInstance()->isDebugAndVerbose() && v != nullptr && v->getNDArray() != nullptr) {
|
||||
if (Environment::getInstance().isDebugAndVerbose() && v != nullptr && v->getNDArray() != nullptr) {
|
||||
auto array = v->getNDArray();
|
||||
std::string shape_ = ShapeUtils::shapeAsString(array);
|
||||
auto type = DataTypeUtils::asString(array->dataType());
|
||||
|
|
|
@ -166,7 +166,7 @@ namespace sd {
|
|||
// aNewShape[5] = 8192; // set type as FLOAT32 by default
|
||||
// aNewShape[6] = 1;
|
||||
// aNewShape[7] = 99;
|
||||
newShape = ConstantShapeHelper::getInstance()->createShapeInfo(DataType::FLOAT32, 'c', {1,1});
|
||||
newShape = ConstantShapeHelper::getInstance().createShapeInfo(DataType::FLOAT32, 'c', {1,1});
|
||||
} else {
|
||||
auto in = node->input()->at(0);
|
||||
|
||||
|
@ -184,7 +184,7 @@ namespace sd {
|
|||
//shape::TAD tad(oldShape, node->getDimensions()->data(), node->getDimensions()->size());
|
||||
auto numTads = shape::tadLength(oldShape, node->getDimensions()->data(), node->getDimensions()->size());
|
||||
Nd4jLong shape[2] = {1, (int) numTads};
|
||||
newShape = ConstantShapeHelper::getInstance()->createShapeInfo(ArrayOptions::dataType(oldShape), 'c', 2, shape);
|
||||
newShape = ConstantShapeHelper::getInstance().createShapeInfo(ArrayOptions::dataType(oldShape), 'c', 2, shape);
|
||||
}
|
||||
|
||||
std::pair<int, int> pairAddr(node->id(), 0);
|
||||
|
@ -805,7 +805,7 @@ namespace sd {
|
|||
// we're adding final nodes of the graph. those, not used as input anywhere
|
||||
nd4j_debug("Paring nodes... \n", "");
|
||||
|
||||
if (Environment::getInstance()->isDebugAndVerbose()) {
|
||||
if (Environment::getInstance().isDebugAndVerbose()) {
|
||||
// nd4j_printv("current _output", _output);
|
||||
}
|
||||
//_output.clear();
|
||||
|
@ -852,7 +852,7 @@ namespace sd {
|
|||
|
||||
if (std::find(_output.begin(), _output.end(), node->id()) == _output.end())
|
||||
_output.emplace_back(node->id());
|
||||
} else if (Environment::getInstance()->isDebugAndVerbose()) {
|
||||
} else if (Environment::getInstance().isDebugAndVerbose()) {
|
||||
nd4j_debug("Node [%i:<%s>] has %i outputs announced:\n", v, node->name()->c_str(), node->output()->size());
|
||||
printf("{");
|
||||
for (auto s : *node->output()) {
|
||||
|
@ -1202,7 +1202,7 @@ namespace sd {
|
|||
}
|
||||
break;
|
||||
default: {
|
||||
opNameStr = std::string(EnumUtils::_OpTypeToString(node->opType()))+"{" + ops::OpRegistrator::getInstance()->local_to_string<int>((int) node->opNum()) + "}";
|
||||
opNameStr = std::string(EnumUtils::_OpTypeToString(node->opType()))+"{" + ops::OpRegistrator::getInstance().local_to_string<int>((int) node->opNum()) + "}";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1250,7 +1250,7 @@ namespace sd {
|
|||
}
|
||||
break;
|
||||
default: {
|
||||
opNameStr = std::string(EnumUtils::_OpTypeToString(node->opType()))+"{" + ops::OpRegistrator::getInstance()->local_to_string<int>((int) node->opNum()) + "}";
|
||||
opNameStr = std::string(EnumUtils::_OpTypeToString(node->opType()))+"{" + ops::OpRegistrator::getInstance().local_to_string<int>((int) node->opNum()) + "}";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1447,7 +1447,7 @@ namespace sd {
|
|||
}
|
||||
|
||||
|
||||
hash = ops::HashHelper::getInstance()->getLongHash(localStamp);
|
||||
hash = ops::HashHelper::getInstance().getLongHash(localStamp);
|
||||
|
||||
nd4j_debug("Graph hash: %lld\n", hash);
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ namespace graph {
|
|||
|
||||
Context context(node->getContextPrototype(), variableSpace);
|
||||
|
||||
if (sd::Environment::getInstance()->isDebugAndVerbose()) {
|
||||
if (sd::Environment::getInstance().isDebugAndVerbose()) {
|
||||
//nd4j_debug("Input variables: %i\n", node->input()->size());
|
||||
printf(" Inputs: {");
|
||||
for (int e = 0; e < node->input()->size(); e++) {
|
||||
|
@ -215,10 +215,10 @@ Nd4jStatus GraphExecutioner::execute(Graph *graph, VariableSpace* variableSpace)
|
|||
}
|
||||
auto flowPath = __variableSpace->flowPath();
|
||||
|
||||
Nd4jLong tb0 = Environment::getInstance()->isProfiling() ? GraphProfile::currentTime() : 0L;
|
||||
Nd4jLong tb0 = Environment::getInstance().isProfiling() ? GraphProfile::currentTime() : 0L;
|
||||
graph->buildGraph();
|
||||
|
||||
auto footprintForward = sd::memory::MemoryRegistrator::getInstance()->getGraphMemoryFootprint(graph->hashCode());
|
||||
auto footprintForward = sd::memory::MemoryRegistrator::getInstance().getGraphMemoryFootprint(graph->hashCode());
|
||||
if (footprintForward > 0) {
|
||||
if (__variableSpace->launchContext()->getWorkspace() != nullptr) {
|
||||
// this method will work only if current workspace size is smaller then proposed value
|
||||
|
@ -228,10 +228,10 @@ Nd4jStatus GraphExecutioner::execute(Graph *graph, VariableSpace* variableSpace)
|
|||
}
|
||||
|
||||
// optionally saving graph build time
|
||||
if (Environment::getInstance()->isProfiling())
|
||||
if (Environment::getInstance().isProfiling())
|
||||
flowPath->profile()->setBuildTime(GraphProfile::relativeTime(tb0));
|
||||
|
||||
Nd4jLong timeStart = Environment::getInstance()->isProfiling() ? GraphProfile::currentTime() : 0L;
|
||||
Nd4jLong timeStart = Environment::getInstance().isProfiling() ? GraphProfile::currentTime() : 0L;
|
||||
|
||||
bool pe = graph->getExecutorConfiguration()->_executionMode == ExecutionMode_AUTO;
|
||||
|
||||
|
@ -259,10 +259,10 @@ Nd4jStatus GraphExecutioner::execute(Graph *graph, VariableSpace* variableSpace)
|
|||
|
||||
Node* node = graph->getOnion()->at(l)->at(n);
|
||||
|
||||
if (Environment::getInstance()->isProfiling())
|
||||
if (Environment::getInstance().isProfiling())
|
||||
flowPath->profile()->nodeById(node->id(), node->name()->c_str());
|
||||
|
||||
if (lastId != node->id() && Environment::getInstance()->isProfiling()) {
|
||||
if (lastId != node->id() && Environment::getInstance().isProfiling()) {
|
||||
if (lastId != -10000000)
|
||||
flowPath->profile()->nodeById(lastId)->setTotalTime(GraphProfile::relativeTime(nodeTime));
|
||||
|
||||
|
@ -458,7 +458,7 @@ Nd4jStatus GraphExecutioner::execute(Graph *graph, VariableSpace* variableSpace)
|
|||
// now we skip all branches except of this active one
|
||||
}
|
||||
|
||||
if (sd::Environment::getInstance()->isDebugAndVerbose()) {
|
||||
if (sd::Environment::getInstance().isDebugAndVerbose()) {
|
||||
|
||||
if (__variableSpace->getVariable(node->id())->hasNDArray()) {
|
||||
auto array = __variableSpace->getVariable(node->id())->getNDArray();
|
||||
|
@ -481,7 +481,7 @@ Nd4jStatus GraphExecutioner::execute(Graph *graph, VariableSpace* variableSpace)
|
|||
}
|
||||
|
||||
// optionally saving execution time
|
||||
if (Environment::getInstance()->isProfiling()) {
|
||||
if (Environment::getInstance().isProfiling()) {
|
||||
flowPath->profile()->nodeById(lastId)->setTotalTime(GraphProfile::relativeTime(nodeTime));
|
||||
flowPath->profile()->setExecutionTime(GraphProfile::relativeTime(timeStart));
|
||||
//flowPath->profile().printOut();
|
||||
|
@ -491,7 +491,7 @@ Nd4jStatus GraphExecutioner::execute(Graph *graph, VariableSpace* variableSpace)
|
|||
if (__variableSpace->launchContext()->getWorkspace() != nullptr) {
|
||||
auto m = __variableSpace->launchContext()->getWorkspace()->getAllocatedSize();
|
||||
auto h = graph->hashCode();
|
||||
sd::memory::MemoryRegistrator::getInstance()->setGraphMemoryFootprintIfGreater(h, m);
|
||||
sd::memory::MemoryRegistrator::getInstance().setGraphMemoryFootprintIfGreater(h, m);
|
||||
}
|
||||
|
||||
if (tempFlow) {
|
||||
|
@ -523,7 +523,7 @@ Nd4jStatus GraphExecutioner::execute(Graph *graph, VariableSpace* variableSpace)
|
|||
// converting FlatGraph to internal representation
|
||||
auto nativeGraph = new Graph(restoredGraph);
|
||||
|
||||
if (Environment::getInstance()->isDebugAndVerbose()) {
|
||||
if (Environment::getInstance().isDebugAndVerbose()) {
|
||||
nativeGraph->printOut();
|
||||
}
|
||||
|
||||
|
@ -742,7 +742,7 @@ Graph* GraphExecutioner::importFromTensorFlow(const char *fileName) {
|
|||
nd4j_verbose("Node id: [%i]; name: [%s]; opName: [%s]\n", n + 1, node.name().c_str(),
|
||||
node.op().c_str());
|
||||
|
||||
sd::ops::DeclarableOp *op = sd::ops::OpRegistrator::getInstance()->getOperationFloat(node.op().c_str());
|
||||
sd::ops::DeclarableOp *op = sd::ops::OpRegistrator::getInstance().getOperationFloat(node.op().c_str());
|
||||
|
||||
if (op == nullptr) {
|
||||
nd4j_verbose("Op wasn't found: %s\n", node.op().c_str());
|
||||
|
@ -859,7 +859,7 @@ flatbuffers::Offset<FlatResult> GraphExecutioner::execute(Graph *graph, flatbuff
|
|||
}
|
||||
}
|
||||
|
||||
if (Environment::getInstance()->isDebugAndVerbose())
|
||||
if (Environment::getInstance().isDebugAndVerbose())
|
||||
graph->printOut();
|
||||
|
||||
auto status = GraphExecutioner::execute(graph);
|
||||
|
|
|
@ -25,11 +25,9 @@
|
|||
|
||||
namespace sd {
|
||||
namespace graph {
|
||||
GraphHolder* GraphHolder::getInstance() {
|
||||
if (_INSTANCE == 0)
|
||||
_INSTANCE = new GraphHolder();
|
||||
|
||||
return _INSTANCE;
|
||||
GraphHolder& GraphHolder::getInstance() {
|
||||
static GraphHolder instance;
|
||||
return instance;
|
||||
};
|
||||
|
||||
void GraphHolder::registerGraph(Nd4jLong graphId, Graph* graph) {
|
||||
|
@ -126,7 +124,5 @@ namespace sd {
|
|||
|
||||
return res;
|
||||
}
|
||||
|
||||
GraphHolder* GraphHolder::_INSTANCE = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -636,7 +636,7 @@ namespace sd {
|
|||
block->setOpDescriptor(this->getCustomOp()->getOpDescriptor());
|
||||
}
|
||||
} else if (this->_opType == OpType_CUSTOM) {
|
||||
auto op = sd::ops::OpRegistrator::getInstance()->getOperation(this->opNum());
|
||||
auto op = sd::ops::OpRegistrator::getInstance().getOperation(this->opNum());
|
||||
if (op == nullptr) {
|
||||
nd4j_verbose("Can't find operation: %lld\n", this->opNum());
|
||||
throw std::runtime_error("Can't find requested operation");
|
||||
|
|
|
@ -364,8 +364,6 @@ namespace sd {
|
|||
|
||||
class BlasHelper {
|
||||
private:
|
||||
static BlasHelper* _instance;
|
||||
|
||||
bool _hasHgemv = false;
|
||||
bool _hasHgemm = false;
|
||||
bool _hasHgemmBatch = false;
|
||||
|
@ -404,7 +402,7 @@ namespace sd {
|
|||
CusolverDnDgesvd cusolverDnDgesvd;
|
||||
|
||||
public:
|
||||
static BlasHelper* getInstance();
|
||||
static BlasHelper& getInstance();
|
||||
|
||||
void initializeFunctions(Nd4jPointer *functions);
|
||||
void initializeDeviceFunctions(Nd4jPointer *functions);
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
namespace sd {
|
||||
class ND4J_EXPORT ConstantHelper {
|
||||
private:
|
||||
static ConstantHelper* _INSTANCE;
|
||||
ConstantHelper();
|
||||
|
||||
std::vector<MAP_IMPL<ConstantDescriptor, ConstantHolder*>> _cache;
|
||||
|
@ -48,9 +47,9 @@ namespace sd {
|
|||
|
||||
std::vector<Nd4jLong> _counters;
|
||||
public:
|
||||
~ConstantHelper() = default;
|
||||
~ConstantHelper();
|
||||
|
||||
static ConstantHelper* getInstance();
|
||||
static ConstantHelper& getInstance();
|
||||
static int getCurrentDevice();
|
||||
static int getNumberOfDevices();
|
||||
void* replicatePointer(void *src, size_t numBytes, memory::Workspace *workspace = nullptr);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <mutex>
|
||||
#include <vector>
|
||||
#include <array/ShapeDescriptor.h>
|
||||
#include <array/ConstantDataBuffer.h>
|
||||
#include <array/ConstantShapeBuffer.h>
|
||||
#include <memory/Workspace.h>
|
||||
#include <system/op_boilerplate.h>
|
||||
|
||||
|
@ -35,24 +35,22 @@ namespace sd {
|
|||
|
||||
class ND4J_EXPORT ConstantShapeHelper {
|
||||
private:
|
||||
static ConstantShapeHelper *_INSTANCE;
|
||||
|
||||
std::mutex _mutex;
|
||||
std::vector<MAP_IMPL<ShapeDescriptor, ConstantDataBuffer>> _cache;
|
||||
std::vector<MAP_IMPL<ShapeDescriptor, ConstantShapeBuffer>> _cache;
|
||||
|
||||
|
||||
ConstantShapeHelper();
|
||||
public:
|
||||
~ConstantShapeHelper() = default;
|
||||
|
||||
static ConstantShapeHelper* getInstance();
|
||||
static ConstantShapeHelper & getInstance();
|
||||
|
||||
|
||||
ConstantDataBuffer bufferForShapeInfo(sd::DataType dataType, char order, const std::vector<Nd4jLong> &shape);
|
||||
ConstantDataBuffer bufferForShapeInfo(const ShapeDescriptor &descriptor);
|
||||
ConstantDataBuffer bufferForShapeInfo(const Nd4jLong *shapeInfo);
|
||||
ConstantDataBuffer bufferForShapeInfo(sd::DataType dataType, char order, int rank, const Nd4jLong* shape);
|
||||
ConstantDataBuffer createShapeInfoWithUnitiesForBroadcast(const Nd4jLong* maxShapeInfo, const Nd4jLong* minShapeInfo, sd::memory::Workspace* workspace = nullptr, const std::vector<int> &dimensions = {});
|
||||
ConstantShapeBuffer& bufferForShapeInfo(sd::DataType dataType, char order, const std::vector<Nd4jLong> &shape);
|
||||
ConstantShapeBuffer& bufferForShapeInfo(const ShapeDescriptor &descriptor);
|
||||
ConstantShapeBuffer& bufferForShapeInfo(const Nd4jLong *shapeInfo);
|
||||
ConstantShapeBuffer& bufferForShapeInfo(sd::DataType dataType, char order, int rank, const Nd4jLong* shape);
|
||||
ConstantShapeBuffer& createShapeInfoWithUnitiesForBroadcast(const Nd4jLong* maxShapeInfo, const Nd4jLong* minShapeInfo, sd::memory::Workspace* workspace = nullptr, const std::vector<int> &dimensions = {});
|
||||
|
||||
|
||||
const Nd4jLong* emptyShapeInfo(sd::DataType dataType);
|
||||
|
|
|
@ -35,8 +35,6 @@
|
|||
namespace sd {
|
||||
class ND4J_EXPORT ConstantTadHelper {
|
||||
private:
|
||||
static ConstantTadHelper *_INSTANCE;
|
||||
|
||||
std::mutex _mutex;
|
||||
std::vector<MAP_IMPL<TadDescriptor, TadPack>> _cache;
|
||||
|
||||
|
@ -44,7 +42,7 @@ namespace sd {
|
|||
public:
|
||||
~ConstantTadHelper() = default;
|
||||
|
||||
static ConstantTadHelper* getInstance();
|
||||
static ConstantTadHelper & getInstance();
|
||||
|
||||
/**
|
||||
* These methods calculate Tensor-Along-Dimension(s) shape and offsets
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace sd {
|
|||
// cuda-specific debug functions
|
||||
#ifdef __CUDACC__
|
||||
static FORCEINLINE void checkErrorCode(cudaStream_t *stream, int opNum = 0) {
|
||||
if (Environment::getInstance()->isDebug()) {
|
||||
if (Environment::getInstance().isDebug()) {
|
||||
cudaError_t res = cudaStreamSynchronize(*stream);
|
||||
|
||||
if (res != 0) {
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2020 Konduit K.K.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License, Version 2.0 which is available at
|
||||
* https://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.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author Yurii Shyrma (iuriish@yahoo.com)
|
||||
//
|
||||
|
||||
#ifndef LIBND4J_EIGENVALSANDVECS_H
|
||||
#define LIBND4J_EIGENVALSANDVECS_H
|
||||
|
||||
#include <array/NDArray.h>
|
||||
|
||||
namespace sd {
|
||||
namespace ops {
|
||||
namespace helpers {
|
||||
|
||||
// this class calculates eigenvalues and eigenvectors of given input matrix
|
||||
template <typename T>
|
||||
class EigenValsAndVecs {
|
||||
|
||||
public:
|
||||
// suppose we got input square NxN matrix
|
||||
|
||||
NDArray _Vals; // {N,2} matrix of eigenvalues, 2 means real and imaginary part
|
||||
NDArray _Vecs; // {N,N,2} matrix, whose columns are the eigenvectors (complex), 2 means real and imaginary part
|
||||
|
||||
explicit EigenValsAndVecs(const NDArray& matrix);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
FORCEINLINE static void divideComplexNums(const T& a1, const T& b1, const T& a2, const T& b2, T& a3, T& b3) {
|
||||
|
||||
T norm2 = a2*a2 + b2*b2;
|
||||
|
||||
a3 = (a1*a2 + b1*b2) / norm2;
|
||||
b3 = (a2*b1 - a1*b2) / norm2;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
FORCEINLINE static void multiplyComplexNums(const T& a1, const T& b1, const T& a2, const T& b2, T& a3, T& b3) {
|
||||
|
||||
a3 = (a1*a2 - b1*b2);
|
||||
b3 = (a1*b2 + b1*a2);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
FORCEINLINE static void sqrtComplexNum(T& a, T& b) {
|
||||
|
||||
T norm = math::nd4j_sqrt<T,T>(a*a + b*b);
|
||||
|
||||
if(b < (T)0)
|
||||
b = -math::nd4j_sqrt<T,T>((T)0.5 * (norm - a));
|
||||
else
|
||||
b = math::nd4j_sqrt<T,T>((T)0.5 * (norm - a));
|
||||
a = math::nd4j_sqrt<T,T>((T)0.5 * (norm + a));
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void calcEigenVals(const NDArray& schurMatrixT); // calculates _Vals
|
||||
void calcPseudoEigenVecs(NDArray& schurMatrixT, NDArray& schurMatrixU); // makes changes both in schurMatrixT(NxN) and schurMatrixU(NxN), also calculates and stores pseudo-eigenvectors (real) in schurMatrixU columns
|
||||
void calcEigenVecs(const NDArray& schurMatrixU); // calculates _Vecs
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif //LIBND4J_EIGENVALSANDVECS_H
|
|
@ -1,6 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2018 Skymind, Inc.
|
||||
* Copyright (c) 2019 Konduit K.K.
|
||||
* Copyright (c) 2020 Konduit K.K.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License, Version 2.0 which is available at
|
||||
|
@ -19,6 +18,35 @@
|
|||
// @author Yurii Shyrma (iuriish@yahoo.com)
|
||||
//
|
||||
|
||||
#include "./IndexReductionLoops.hpp"
|
||||
#ifndef LIBND4J_FULLPIVLU_H
|
||||
#define LIBND4J_FULLPIVLU_H
|
||||
|
||||
BUILD_DOUBLE_TEMPLATE(template void sd::IndexReductionLoops, ::wrapIndexReduce(const int opNum, const void* vx, const Nd4jLong* xShapeInfo, void* z, const Nd4jLong* zShapeInfo, const Nd4jLong* tadShapeInfo, const Nd4jLong* tadOffsets, void* vextraParams), LIBND4J_TYPES_3, (sd::DataType::INT32, int32_t));
|
||||
#include <array/NDArray.h>
|
||||
|
||||
namespace sd {
|
||||
namespace ops {
|
||||
namespace helpers {
|
||||
|
||||
// class solves equation A*x = b for x, by procedure of LU decomposition of input matrix A with complete pivoting
|
||||
// LU decomposition of a matrix is:
|
||||
// A = P^-1 * L * U * Q^-1
|
||||
// L is unit-lower-triangular,
|
||||
// U is upper-triangular,
|
||||
// and P and Q are permutation matrices for rows and columns correspondingly
|
||||
|
||||
template <typename T>
|
||||
class FullPivLU {
|
||||
|
||||
public:
|
||||
|
||||
// A{M,K} * x{K,N} = b{M,N}
|
||||
static void solve(const NDArray& A, const NDArray& b, NDArray& x);
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif //LIBND4J_FULLPIVLU_H
|
|
@ -0,0 +1,102 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2020 Konduit K.K.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License, Version 2.0 which is available at
|
||||
* https://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.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author Yurii Shyrma (iuriish@yahoo.com)
|
||||
//
|
||||
|
||||
#ifndef LIBND4J_HESSENBERGANDSCHUR_H
|
||||
#define LIBND4J_HESSENBERGANDSCHUR_H
|
||||
|
||||
#include <array/NDArray.h>
|
||||
|
||||
namespace sd {
|
||||
namespace ops {
|
||||
namespace helpers {
|
||||
|
||||
// this class implements Hessenberg decomposition of square matrix using orthogonal similarity transformation
|
||||
// A = Q H Q^T
|
||||
// Q - orthogonal matrix
|
||||
// H - Hessenberg matrix
|
||||
template <typename T>
|
||||
class Hessenberg {
|
||||
// suppose we got input square NxN matrix
|
||||
|
||||
public:
|
||||
|
||||
NDArray _Q; // {N,N}
|
||||
NDArray _H; // {N,N}
|
||||
|
||||
explicit Hessenberg(const NDArray& matrix);
|
||||
|
||||
private:
|
||||
void evalData();
|
||||
};
|
||||
|
||||
|
||||
// this class implements real Schur decomposition of square matrix using orthogonal similarity transformation
|
||||
// A = U T U^T
|
||||
// T - real quasi-upper-triangular matrix - block upper triangular matrix where the blocks on the diagonal are 1×1 or 2×2 with complex eigenvalues
|
||||
// U - real orthogonal matrix
|
||||
|
||||
template <typename T>
|
||||
class Schur {
|
||||
// suppose we got input square NxN matrix
|
||||
|
||||
public:
|
||||
|
||||
NDArray _T; // {N,N}
|
||||
NDArray _U; // {N,N}
|
||||
|
||||
explicit Schur(const NDArray& matrix);
|
||||
|
||||
void splitTwoRows(const int ind, const T shift);
|
||||
|
||||
void calcShift(const int ind, const int iter, T& shift, NDArray& shiftInfo);
|
||||
|
||||
void initFrancisQR(const int ind1, const int ind2, const NDArray& shiftVec, int& ind3, NDArray& householderVec);
|
||||
|
||||
void doFrancisQR(const int ind1, const int ind2, const int ind3, const NDArray& householderVec);
|
||||
|
||||
void calcFromHessenberg();
|
||||
|
||||
private:
|
||||
|
||||
static const int _maxItersPerRow = 40;
|
||||
|
||||
void evalData(const NDArray& matrix);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
FORCEINLINE int getSmallSubdiagEntry(const int inInd) {
|
||||
|
||||
int outInd = inInd;
|
||||
while (outInd > 0) {
|
||||
T factor = math::nd4j_abs<T>(_T.t<T>(outInd-1, outInd-1)) + math::nd4j_abs<T>(_T.t<T>(outInd, outInd));
|
||||
if (math::nd4j_abs<T>(_T.t<T>(outInd, outInd-1)) <= DataTypeUtils::eps<T>() * factor)
|
||||
break;
|
||||
outInd--;
|
||||
}
|
||||
return outInd;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif //LIBND4J_HESSENBERGANDSCHUR_H
|
|
@ -206,7 +206,7 @@ LoopKind::Kind LoopKind::deduceKindOfLoopTadXZ(const Nd4jLong* xShapeInfo, const
|
|||
const bool tVectorOrC = shape::isCommonVector(tadShapeInfo, temp) || tOrder == 'c';
|
||||
const bool zVectorOrC = shape::isCommonVector(zShapeInfo, temp) || zOrder == 'c';;
|
||||
|
||||
if(shape::length(tadShapeInfo) * shape::length(zShapeInfo) <= Environment::getInstance()->elementwiseThreshold() && xEws == 1 && xOrder == 'c' && xRank == 2 &&
|
||||
if(shape::length(tadShapeInfo) * shape::length(zShapeInfo) <= Environment::getInstance().elementwiseThreshold() && xEws == 1 && xOrder == 'c' && xRank == 2 &&
|
||||
tEws > 1 && zEws == 1 && (allC || (tVectorOrC && zVectorOrC)))
|
||||
return SMALLARR2DX;
|
||||
if(tEws == 1 && zEws == 1 && (allC || (tVectorOrC && zVectorOrC)))
|
||||
|
|
|
@ -702,21 +702,21 @@ namespace sd {
|
|||
std::vector<Nd4jLong> zeroOffsets;
|
||||
|
||||
if (xLen == yLen) {
|
||||
tadPackX = sd::ConstantTadHelper::getInstance()->tadForDimensions(xShapeInfo, dims, dimsLen);
|
||||
tadPackY = sd::ConstantTadHelper::getInstance()->tadForDimensions(yShapeInfo, dims, dimsLen);
|
||||
tadPackX = sd::ConstantTadHelper::getInstance().tadForDimensions(xShapeInfo, dims, dimsLen);
|
||||
tadPackY = sd::ConstantTadHelper::getInstance().tadForDimensions(yShapeInfo, dims, dimsLen);
|
||||
xTadShapeInfo = tadPackX.primaryShapeInfo();
|
||||
yTadShapeInfo = tadPackY.primaryShapeInfo();
|
||||
xTadOffsets = tadPackX.primaryOffsets();
|
||||
yTadOffsets = tadPackY.primaryOffsets();
|
||||
}
|
||||
else if (yLen > xLen) {
|
||||
tadPackY = sd::ConstantTadHelper::getInstance()->tadForDimensions(yShapeInfo, dims, dimsLen);
|
||||
tadPackY = sd::ConstantTadHelper::getInstance().tadForDimensions(yShapeInfo, dims, dimsLen);
|
||||
xTadShapeInfo = xShapeInfo;
|
||||
yTadShapeInfo = tadPackY.primaryShapeInfo();
|
||||
yTadOffsets = tadPackY.primaryOffsets();
|
||||
}
|
||||
else {
|
||||
tadPackX = sd::ConstantTadHelper::getInstance()->tadForDimensions(xShapeInfo, dims, dimsLen);
|
||||
tadPackX = sd::ConstantTadHelper::getInstance().tadForDimensions(xShapeInfo, dims, dimsLen);
|
||||
yTadShapeInfo = yShapeInfo;
|
||||
xTadShapeInfo = tadPackX.primaryShapeInfo();
|
||||
xTadOffsets = tadPackX.primaryOffsets();
|
||||
|
|
|
@ -19,12 +19,13 @@
|
|||
//
|
||||
#ifndef LIBND4J_LOOPCOORDSHELPER_H
|
||||
#define LIBND4J_LOOPCOORDSHELPER_H
|
||||
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <system/pointercast.h>
|
||||
#include <system/op_boilerplate.h>
|
||||
#include <helpers/shape.h>
|
||||
namespace sd {
|
||||
|
||||
#if defined(__GNUC__)
|
||||
|
@ -125,7 +126,7 @@ namespace sd {
|
|||
}
|
||||
|
||||
|
||||
FORCEINLINE zip_size_t offset_from_coords(const Nd4jLong*& x_strides, const Nd4jLong*& z_strides, const Nd4jLong* coords, const Nd4jLong& rank) {
|
||||
FORCEINLINE zip_size_t offset_from_coords(const Nd4jLong* x_strides, const Nd4jLong* z_strides, const Nd4jLong* coords, const Nd4jLong& rank) {
|
||||
|
||||
zip_size_t offset = { 0,0 };
|
||||
size_t rank_4 = rank & -4;
|
||||
|
@ -435,6 +436,509 @@ namespace sd {
|
|||
return last_offset;
|
||||
}
|
||||
|
||||
|
||||
struct triple_size_t {
|
||||
size_t first;
|
||||
size_t second;
|
||||
size_t third;
|
||||
};
|
||||
|
||||
|
||||
template<bool Last_Index_Faster = true>
|
||||
FORCEINLINE triple_size_t inc_coords(const Nd4jLong* bases, const Nd4jLong* x_strides, const Nd4jLong* y_strides, const Nd4jLong* z_strides, Nd4jLong* coords, triple_size_t last_offset, const size_t rank, const size_t skip = 0) {
|
||||
|
||||
Nd4jLong val = 0;
|
||||
for (int i = rank - skip - 1; i >= 0; i--) {
|
||||
val = coords[i] + 1;
|
||||
if (likely(val < bases[i])) {
|
||||
coords[i] = val;
|
||||
last_offset.first += x_strides[i];
|
||||
last_offset.second += y_strides[i];
|
||||
last_offset.third += z_strides[i];
|
||||
break;
|
||||
}
|
||||
else {
|
||||
last_offset.first -= coords[i] * x_strides[i];
|
||||
last_offset.second -= coords[i] * y_strides[i];
|
||||
last_offset.third -= coords[i] * z_strides[i];
|
||||
coords[i] = 0;
|
||||
}
|
||||
}
|
||||
return last_offset;
|
||||
}
|
||||
|
||||
template<>
|
||||
FORCEINLINE triple_size_t inc_coords<false>(const Nd4jLong* bases, const Nd4jLong* x_strides, const Nd4jLong* y_strides, const Nd4jLong* z_strides, Nd4jLong* coords, triple_size_t last_offset, const size_t rank, const size_t skip) {
|
||||
|
||||
Nd4jLong val = 0;
|
||||
for (int i = skip; i < rank; i++) {
|
||||
val = coords[i] + 1;
|
||||
if (likely(val < bases[i])) {
|
||||
coords[i] = val;
|
||||
|
||||
last_offset.first += x_strides[i];
|
||||
last_offset.second += y_strides[i];
|
||||
last_offset.third += z_strides[i];
|
||||
break;
|
||||
}
|
||||
else {
|
||||
last_offset.first -= coords[i] * x_strides[i];
|
||||
last_offset.second -= coords[i] * y_strides[i];
|
||||
last_offset.third -= coords[i] * z_strides[i];
|
||||
coords[i] = 0;
|
||||
}
|
||||
}
|
||||
return last_offset;
|
||||
}
|
||||
|
||||
FORCEINLINE triple_size_t offset_from_coords(const Nd4jLong* x_strides, const Nd4jLong* y_strides, const Nd4jLong* z_strides, const Nd4jLong* coords, const Nd4jLong& rank) {
|
||||
|
||||
triple_size_t offset = { 0,0 ,0 };
|
||||
size_t rank_4 = rank & -4;
|
||||
for (int i = 0; i < rank_4; i += 4) {
|
||||
offset.first = offset.first
|
||||
+ coords[i] * x_strides[i]
|
||||
+ coords[i + 1] * x_strides[i + 1]
|
||||
+ coords[i + 2] * x_strides[i + 2]
|
||||
+ coords[i + 3] * x_strides[i + 3];
|
||||
offset.second = offset.second
|
||||
+ coords[i] * y_strides[i]
|
||||
+ coords[i + 1] * y_strides[i + 1]
|
||||
+ coords[i + 2] * y_strides[i + 2]
|
||||
+ coords[i + 3] * y_strides[i + 3];
|
||||
offset.third = offset.third
|
||||
+ coords[i] * z_strides[i]
|
||||
+ coords[i + 1] * z_strides[i + 1]
|
||||
+ coords[i + 2] * z_strides[i + 2]
|
||||
+ coords[i + 3] * z_strides[i + 3];
|
||||
}
|
||||
for (int i = rank_4; i < rank; i++) {
|
||||
offset.first += coords[i] * x_strides[i];
|
||||
offset.second += coords[i] * y_strides[i];
|
||||
offset.third += coords[i] * z_strides[i];
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
template<bool Last_Index_Faster = true>
|
||||
FORCEINLINE Nd4jLong getLength(const Nd4jLong* bases, int rank, int skip = 0)
|
||||
{
|
||||
if (skip < 0 || skip >= rank) skip = 0;
|
||||
Nd4jLong total = 1;
|
||||
for (int i = 0; i < rank - skip; i++) {
|
||||
total *= bases[i];
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
FORCEINLINE Nd4jLong getLength<false>(const Nd4jLong* bases, int rank, int skip)
|
||||
{
|
||||
if (skip < 0 || skip >= rank) skip = 0;
|
||||
Nd4jLong total = 1;
|
||||
for (int i = skip; i < rank; i++) {
|
||||
total *= bases[i];
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
|
||||
template<bool Last_Index_Faster = true>
|
||||
FORCEINLINE Nd4jLong getLength(const Nd4jLong* bases, int rank, int skip, Nd4jLong& outSkippedLength)
|
||||
{
|
||||
if (skip < 0 || skip >= rank) skip = 0;
|
||||
Nd4jLong total = 1;
|
||||
for (int i = 0; i < rank - skip; i++) {
|
||||
total *= bases[i];
|
||||
}
|
||||
if (skip > 0) {
|
||||
outSkippedLength = 1;
|
||||
for (int i = rank - skip; i < rank; i++) {
|
||||
outSkippedLength *= bases[i];
|
||||
}
|
||||
}
|
||||
else {
|
||||
outSkippedLength = 0;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
FORCEINLINE Nd4jLong getLength<false>(const Nd4jLong* bases, int rank, int skip, Nd4jLong& outSkippedLength)
|
||||
{
|
||||
if (skip < 0 || skip >= rank) skip = 0;
|
||||
if (skip > 0) {
|
||||
outSkippedLength = 1;
|
||||
for (int i = 0; i < skip; i++) {
|
||||
outSkippedLength *= bases[i];
|
||||
}
|
||||
}
|
||||
else {
|
||||
outSkippedLength = 0;
|
||||
}
|
||||
Nd4jLong total = 1;
|
||||
for (int i = skip; i < rank; i++) {
|
||||
total *= bases[i];
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
/*
|
||||
for ODR rule it willbe declared as inline
|
||||
rePartition for reductions and et cet
|
||||
Indices mentioned in the dimension list will be moved to the tail
|
||||
This way it will be splitted into two parts
|
||||
the first part will contain output part,the second tail part will be used for reductions and other purposes
|
||||
if squash is True then it will attempt to minimize the output ( for both orders) and the tail
|
||||
*/
|
||||
|
||||
FORCEINLINE void rePartition(char order, const std::vector<int>& dimensions, const size_t rank, const Nd4jLong* bases, const Nd4jLong* strides, Nd4jLong(&new_bases)[MAX_RANK], Nd4jLong(&new_strides)[MAX_RANK], int& first_begin, int& first_end, int& second_begin, int& second_end, bool first_squash = false, bool second_squash = true) {
|
||||
|
||||
bool indices[MAX_RANK] = {};
|
||||
int ind = 0;
|
||||
size_t second_rank;
|
||||
if (dimensions.size() == 0 || (dimensions.size() == 1 && dimensions.at(0) == sd::DataTypeUtils::max<int>())){
|
||||
first_end = 0;
|
||||
first_begin = 0;
|
||||
//treat it as the whole
|
||||
for (int i = 0; i < rank; i++) {
|
||||
new_bases[i] = bases[i];
|
||||
new_strides[i] = strides[i];
|
||||
}
|
||||
second_rank = rank;
|
||||
second_end = rank;
|
||||
second_begin = 0;
|
||||
|
||||
}
|
||||
else {
|
||||
for (int index : dimensions) {
|
||||
if (index < 0) index = rank + index;
|
||||
if (index >= 0 && index < rank) {
|
||||
indices[index] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//move output ones and
|
||||
for (int i = 0; i < rank; i++) {
|
||||
|
||||
if (!indices[i]) {
|
||||
|
||||
new_bases[ind] = bases[i];
|
||||
new_strides[ind] = strides[i];
|
||||
ind++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int first_rank = ind;
|
||||
|
||||
first_end = ind;
|
||||
first_begin = 0;
|
||||
//nd4j_printf("rffrr ss & %d ind-- %d %d\n", first_rank, first_begin, first_end);
|
||||
//squash output rank
|
||||
if (first_squash && first_rank > 1) {
|
||||
|
||||
if (order == 'c') {
|
||||
int uniq_ind = first_end-1;
|
||||
for (int i = first_end - 2; i >= first_begin; i--) {
|
||||
if (new_strides[i] == new_bases[uniq_ind] * new_strides[uniq_ind]) {
|
||||
new_bases[uniq_ind] = new_bases[i] * new_bases[uniq_ind];
|
||||
new_strides[uniq_ind] = new_strides[uniq_ind];
|
||||
--first_rank;
|
||||
}
|
||||
else {
|
||||
--uniq_ind;
|
||||
new_bases[uniq_ind] = new_bases[i];
|
||||
new_strides[uniq_ind] = new_strides[i];
|
||||
}
|
||||
}
|
||||
first_begin = first_end - first_rank;
|
||||
}
|
||||
else {
|
||||
//squash fortran
|
||||
int uniq_ind = 0;
|
||||
for (int i = 1; i < first_end; i++) {
|
||||
if (new_strides[i] == new_bases[uniq_ind] * new_strides[uniq_ind]) {
|
||||
new_bases[uniq_ind] = new_bases[i] * new_bases[uniq_ind];
|
||||
new_strides[uniq_ind] = new_strides[uniq_ind];
|
||||
--first_rank;
|
||||
}
|
||||
else {
|
||||
uniq_ind++;
|
||||
new_bases[uniq_ind] = new_bases[i];
|
||||
new_strides[uniq_ind] = new_strides[i];
|
||||
}
|
||||
}
|
||||
first_end = first_begin + first_rank;
|
||||
|
||||
}
|
||||
ind = first_end;
|
||||
}
|
||||
|
||||
//nd4j_printf("rffrr ss & %d ind-- %d %d\n", first_rank, first_begin, first_end);
|
||||
//move process indices
|
||||
for (int i = 0; i < rank; i++) {
|
||||
if (indices[i]) {
|
||||
new_bases[ind] = bases[i];
|
||||
new_strides[ind] = strides[i];
|
||||
ind++;
|
||||
}
|
||||
}
|
||||
|
||||
second_rank = ind - first_end;
|
||||
second_end = ind;
|
||||
second_begin = first_end;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (second_squash && second_rank > 1) {
|
||||
|
||||
if (order == 'c') {
|
||||
int uniq_ind = second_end - 1;
|
||||
for (int i = second_end - 2; i >= second_begin; i--) {
|
||||
if (new_strides[i] == new_bases[uniq_ind] * new_strides[uniq_ind]) {
|
||||
new_bases[uniq_ind] = new_bases[i] * new_bases[uniq_ind];
|
||||
new_strides[uniq_ind] = new_strides[uniq_ind];
|
||||
--second_rank;
|
||||
}
|
||||
else {
|
||||
--uniq_ind;
|
||||
new_bases[uniq_ind] = new_bases[i];
|
||||
new_strides[uniq_ind] = new_strides[i];
|
||||
}
|
||||
}
|
||||
second_begin = second_end - second_rank;
|
||||
}
|
||||
else {
|
||||
int uniq_ind = second_begin;
|
||||
for (int i = second_begin+1; i < second_end; i++) {
|
||||
if (new_strides[i] == new_bases[uniq_ind] * new_strides[uniq_ind]) {
|
||||
new_bases[uniq_ind] = new_bases[i] * new_bases[uniq_ind];
|
||||
new_strides[uniq_ind] = new_strides[uniq_ind];
|
||||
--second_rank;
|
||||
}
|
||||
else {
|
||||
uniq_ind++;
|
||||
new_bases[uniq_ind] = new_bases[i];
|
||||
new_strides[uniq_ind] = new_strides[i];
|
||||
}
|
||||
}
|
||||
second_end = second_begin + second_rank;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//basic CRTP static polymorphism classes for offset increments
|
||||
|
||||
template<typename Derived>
|
||||
struct CoordsBaseMovement {
|
||||
void init(const Nd4jLong* bases, const Nd4jLong* strides1, const Nd4jLong* strides2, int rank, int start = 0) {
|
||||
static_cast<Derived*>(this)->initImpl(bases, strides1, strides2, rank, start);
|
||||
}
|
||||
|
||||
void increment(int skipRank = 0) {
|
||||
static_cast<Derived*>(this)->incrementImpl(skipRank);
|
||||
}
|
||||
|
||||
Nd4jLong First() { return static_cast<Derived*>(this)->FirstImpl(); };
|
||||
Nd4jLong Second() { return static_cast<Derived*>(this)->SecondImpl(); };
|
||||
};
|
||||
|
||||
|
||||
struct ZipGenericCoordsRank1Stride1 : CoordsBaseMovement<ZipGenericCoordsRank1Stride1> {
|
||||
|
||||
size_t offset1;
|
||||
size_t offset2;
|
||||
|
||||
|
||||
void initImpl(const Nd4jLong* bases, const Nd4jLong* strides1, const Nd4jLong* strides2, int rank, int start = 0) {
|
||||
offset1 = start;
|
||||
offset2 = start;
|
||||
}
|
||||
|
||||
void incrementImpl(int skipRank = 0) {
|
||||
offset1 += 1;
|
||||
offset2 += 1;
|
||||
}
|
||||
|
||||
Nd4jLong FirstImpl() { return offset1; };
|
||||
Nd4jLong SecondImpl() { return offset2; };
|
||||
|
||||
};
|
||||
|
||||
struct ZipGenericCoordsRank1BothStrideN : CoordsBaseMovement<ZipGenericCoordsRank1BothStrideN> {
|
||||
size_t stride1;
|
||||
size_t stride2;
|
||||
size_t offset1;
|
||||
size_t offset2;
|
||||
|
||||
|
||||
void initImpl(const Nd4jLong* bases, const Nd4jLong* strides1, const Nd4jLong* strides2, int rank, int start = 0) {
|
||||
stride1 = strides1[0];
|
||||
stride2 = strides2[0];
|
||||
offset1 = start * stride1;
|
||||
offset2 = start * stride2;
|
||||
}
|
||||
|
||||
void incrementImpl(int skipRank = 0) {
|
||||
offset1 += stride1;
|
||||
offset2 += stride2;
|
||||
}
|
||||
|
||||
Nd4jLong FirstImpl() { return offset1; };
|
||||
Nd4jLong SecondImpl() { return offset2; };
|
||||
|
||||
};
|
||||
|
||||
template<int ConstRank, bool LastIndexFaster = true>
|
||||
struct ZipGenericCoordsConstMovementSecondStride1 : CoordsBaseMovement<ZipGenericCoordsConstMovementSecondStride1<ConstRank, LastIndexFaster>> {
|
||||
sd::CoordsState<ConstRank - 1> cst;
|
||||
Nd4jLong coords[MAX_RANK];
|
||||
size_t offset1;
|
||||
size_t offset2;
|
||||
int _rank;
|
||||
|
||||
void initImpl(const Nd4jLong* bases, const Nd4jLong* strides1, const Nd4jLong* strides2, int rank, int start = 0) {
|
||||
offset1 = sd::init_coords<ConstRank, 0, LastIndexFaster>(cst, start, bases, strides1);
|
||||
offset2 = start * 1;
|
||||
}
|
||||
|
||||
void incrementImpl(int skipRank = 0) {
|
||||
offset1 = sd::inc_coords<ConstRank, 0, LastIndexFaster>(cst, offset1);
|
||||
offset2 += 1;
|
||||
}
|
||||
|
||||
Nd4jLong FirstImpl() { return offset1; };
|
||||
Nd4jLong SecondImpl() { return offset2; };
|
||||
|
||||
};
|
||||
|
||||
template<int ConstRank, bool LastIndexFaster = true>
|
||||
struct ZipGenericCoordsConstMovementSecondStrideN : CoordsBaseMovement<ZipGenericCoordsConstMovementSecondStrideN<ConstRank, LastIndexFaster>> {
|
||||
sd::CoordsState<ConstRank - 1> cst;
|
||||
Nd4jLong _stride2;
|
||||
Nd4jLong coords[MAX_RANK];
|
||||
size_t offset1;
|
||||
size_t offset2;
|
||||
int _rank;
|
||||
|
||||
void initImpl(const Nd4jLong* bases, const Nd4jLong* strides1, const Nd4jLong* strides2, int rank, int start = 0) {
|
||||
_stride2 = strides2[0];
|
||||
offset1 = sd::init_coords<ConstRank, 0, LastIndexFaster>(cst, start, bases, strides1);
|
||||
offset2 = start * _stride2;
|
||||
}
|
||||
|
||||
void incrementImpl(int skipRank = 0) {
|
||||
offset1 = sd::inc_coords<ConstRank, 0, LastIndexFaster>(cst, offset1);
|
||||
offset2 += _stride2;
|
||||
}
|
||||
|
||||
Nd4jLong FirstImpl() { return offset1; };
|
||||
Nd4jLong SecondImpl() { return offset2; };
|
||||
|
||||
};
|
||||
|
||||
template<bool LastIndexFaster = true>
|
||||
struct ZipGenericCoordsMovementSecondStrideN : CoordsBaseMovement<ZipGenericCoordsMovementSecondStrideN<LastIndexFaster>> {
|
||||
const Nd4jLong* _bases;
|
||||
const Nd4jLong* _strides1;
|
||||
Nd4jLong _stride2;
|
||||
Nd4jLong coords[MAX_RANK];
|
||||
zip_size_t offset;
|
||||
int _rank;
|
||||
|
||||
void initImpl(const Nd4jLong* bases, const Nd4jLong* strides1, const Nd4jLong* strides2, int rank, int start = 0) {
|
||||
|
||||
_bases = bases;
|
||||
_strides1 = strides1;
|
||||
_stride2 = strides2[0];
|
||||
_rank = rank;
|
||||
if (start == 0) {
|
||||
for (int i = 0; i < MAX_RANK; i++) {
|
||||
coords[i] = 0;
|
||||
}
|
||||
offset = { 0,0 };
|
||||
|
||||
}
|
||||
else {
|
||||
if (LastIndexFaster) {
|
||||
sd::index2coords_C(start, rank, bases, (Nd4jLong*)&coords);
|
||||
}
|
||||
else {
|
||||
sd::index2coords_F(start, rank, bases, (Nd4jLong*)&coords);
|
||||
}
|
||||
offset.first = sd::offset_from_coords(strides1, (Nd4jLong*)&coords, rank);
|
||||
offset.second = start * _stride2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void incrementImpl(int skipRank = 0) {
|
||||
offset.first = inc_coords<LastIndexFaster>(_bases, _strides1, (Nd4jLong*)&coords, offset.first, _rank, skipRank);
|
||||
offset.second += _stride2;
|
||||
}
|
||||
|
||||
Nd4jLong FirstImpl() { return offset.first; };
|
||||
Nd4jLong SecondImpl() { return offset.second; };
|
||||
|
||||
};
|
||||
|
||||
template<bool LastIndexFaster = true>
|
||||
struct ZipGenericCoordsMovement : CoordsBaseMovement<ZipGenericCoordsMovement<LastIndexFaster>> {
|
||||
const Nd4jLong* _bases;
|
||||
const Nd4jLong* _strides1;
|
||||
const Nd4jLong* _strides2;
|
||||
Nd4jLong coords[MAX_RANK];
|
||||
zip_size_t offset;
|
||||
int _rank;
|
||||
|
||||
void initImpl(const Nd4jLong* bases, const Nd4jLong* strides1, const Nd4jLong* strides2, int rank, int start = 0) {
|
||||
|
||||
_bases = bases;
|
||||
_strides1 = strides1;
|
||||
_strides2 = strides2;
|
||||
_rank = rank;
|
||||
if (start == 0) {
|
||||
for (int i = 0; i < MAX_RANK; i++) {
|
||||
coords[i] = 0;
|
||||
}
|
||||
offset = { 0,0 };
|
||||
|
||||
}
|
||||
else {
|
||||
if (LastIndexFaster) {
|
||||
sd::index2coords_C(start, rank, bases, (Nd4jLong*)&coords);
|
||||
}
|
||||
else {
|
||||
sd::index2coords_F(start, rank, bases, (Nd4jLong*)&coords);
|
||||
}
|
||||
offset = sd::offset_from_coords(strides1, strides2, (Nd4jLong*)&coords, rank);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void incrementImpl(int skipRank = 0) {
|
||||
offset = inc_coords<LastIndexFaster>(_bases, _strides1, _strides2, (Nd4jLong*)&coords, offset, _rank, skipRank);
|
||||
}
|
||||
|
||||
Nd4jLong FirstImpl() { return offset.first; };
|
||||
Nd4jLong SecondImpl() { return offset.second; };
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -32,8 +32,6 @@
|
|||
namespace sd {
|
||||
class ND4J_EXPORT OpTracker {
|
||||
private:
|
||||
static OpTracker* _INSTANCE;
|
||||
|
||||
std::string _export;
|
||||
|
||||
int _operations = 0;
|
||||
|
@ -45,7 +43,7 @@ namespace sd {
|
|||
template <typename T>
|
||||
std::string local_to_string(T value);
|
||||
public:
|
||||
static OpTracker* getInstance();
|
||||
static OpTracker& getInstance();
|
||||
|
||||
int totalGroups();
|
||||
int totalOperations();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2018 Skymind, Inc.
|
||||
* Copyright (c) 2019-2020 Konduit K.K.
|
||||
* Copyright (c) 2020 Konduit K.K.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License, Version 2.0 which is available at
|
||||
|
@ -16,11 +15,31 @@
|
|||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author raver119@gmail.com
|
||||
// @author Yurii Shyrma (iuriish@yahoo.com)
|
||||
//
|
||||
|
||||
#include "../specials_double.hpp"
|
||||
#ifndef LIBND4J_SQRTM_H
|
||||
#define LIBND4J_SQRTM_H
|
||||
|
||||
#include <array/NDArray.h>
|
||||
|
||||
namespace sd {
|
||||
BUILD_DOUBLE_TEMPLATE(template class DoubleMethods, , LIBND4J_TYPES, LIBND4J_TYPES_3);
|
||||
}
|
||||
namespace ops {
|
||||
namespace helpers {
|
||||
|
||||
template <typename T>
|
||||
class Sqrtm {
|
||||
|
||||
|
||||
public:
|
||||
|
||||
static void calc(const NDArray& in, NDArray& out);
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif //LIBND4J_SQRTM_H
|
|
@ -44,6 +44,14 @@ namespace sd {
|
|||
return os.str();
|
||||
}
|
||||
|
||||
/**
|
||||
* These methods convert integer values to string with 0s and 1s
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
template <typename T>
|
||||
static std::string bitsToString(T value);
|
||||
|
||||
/**
|
||||
* This method just concatenates error message with a given graphId
|
||||
* @param message
|
||||
|
@ -137,6 +145,9 @@ namespace sd {
|
|||
* @return boolean status
|
||||
*/
|
||||
static bool u32StringToU8String(const std::u32string& u32, std::string& u8);
|
||||
|
||||
template <typename T>
|
||||
static std::string vectorToString(const std::vector<T> &vec);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -69,14 +69,14 @@ namespace sd {
|
|||
void executeOnce() override {
|
||||
PointersManager manager(LaunchContext::defaultContext(), "BroadcastBM");
|
||||
|
||||
auto packX = ConstantTadHelper::getInstance()->tadForDimensions(_x->shapeInfo(), _axis);
|
||||
auto packZ = ConstantTadHelper::getInstance()->tadForDimensions(_z->shapeInfo(), _axis);
|
||||
auto packX = ConstantTadHelper::getInstance().tadForDimensions(_x->shapeInfo(), _axis);
|
||||
auto packZ = ConstantTadHelper::getInstance().tadForDimensions(_z->shapeInfo(), _axis);
|
||||
|
||||
auto tadOnlyShapeInfo = Environment::getInstance()->isCPU() ? packX.primaryShapeInfo() : packX.specialShapeInfo();
|
||||
auto tadOffsets = Environment::getInstance()->isCPU() ? packX.primaryOffsets() : packX.specialOffsets();
|
||||
auto tadOnlyShapeInfo = Environment::getInstance().isCPU() ? packX.primaryShapeInfo() : packX.specialShapeInfo();
|
||||
auto tadOffsets = Environment::getInstance().isCPU() ? packX.primaryOffsets() : packX.specialOffsets();
|
||||
|
||||
auto tadOnlyShapeInfoZ = Environment::getInstance()->isCPU() ? packZ.primaryShapeInfo() : packZ.specialShapeInfo();
|
||||
auto tadOffsetsZ = Environment::getInstance()->isCPU() ? packZ.primaryOffsets() : packZ.specialOffsets();
|
||||
auto tadOnlyShapeInfoZ = Environment::getInstance().isCPU() ? packZ.primaryShapeInfo() : packZ.specialShapeInfo();
|
||||
auto tadOffsetsZ = Environment::getInstance().isCPU() ? packZ.primaryOffsets() : packZ.specialOffsets();
|
||||
|
||||
NativeOpExecutioner::execBroadcast(LaunchContext::defaultContext(), _opNum, _x->buffer(), _x->shapeInfo(), _x->specialBuffer(), _x->specialShapeInfo(), _y->buffer(), _y->shapeInfo(), _y->specialBuffer(), _y->specialShapeInfo(), _z->buffer(), _z->shapeInfo(), _z->specialBuffer(), _z->specialShapeInfo(), nullptr, _axis.size(),
|
||||
/*Nd4jLong **/ tadOnlyShapeInfo, /*Nd4jLong */ tadOffsets, /*Nd4jLong */ tadOnlyShapeInfoZ, /*Nd4jLong */ tadOffsetsZ);
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace sd {
|
|||
sd::graph::Context *_context = nullptr;
|
||||
public:
|
||||
DeclarableBenchmark(sd::ops::DeclarableOp &op, std::string name = 0) : OpBenchmark() {
|
||||
_op = &op; //ops::OpRegistrator::getInstance()->getOperation(op.getOpHash());
|
||||
_op = &op; //ops::OpRegistrator::getInstance().getOperation(op.getOpHash());
|
||||
_testName = name;
|
||||
}
|
||||
|
||||
|
|
|
@ -88,10 +88,10 @@ namespace sd {
|
|||
else
|
||||
NativeOpExecutioner::execReduceSameScalar(LaunchContext::defaultContext(), _opNum, _x->buffer(), _x->shapeInfo(), _x->specialBuffer(), _x->specialShapeInfo(), nullptr, _z->buffer(), _z->shapeInfo(), _z->specialBuffer(), _z->specialShapeInfo());
|
||||
else {
|
||||
auto pack = ConstantTadHelper::getInstance()->tadForDimensions(_x->shapeInfo(), _axis);
|
||||
auto pack = ConstantTadHelper::getInstance().tadForDimensions(_x->shapeInfo(), _axis);
|
||||
|
||||
auto tadOnlyShapeInfo = Environment::getInstance()->isCPU() ? pack.primaryShapeInfo() : pack.specialShapeInfo();
|
||||
auto tadOffsets = Environment::getInstance()->isCPU() ? pack.primaryOffsets() : pack.specialOffsets();
|
||||
auto tadOnlyShapeInfo = Environment::getInstance().isCPU() ? pack.primaryShapeInfo() : pack.specialShapeInfo();
|
||||
auto tadOffsets = Environment::getInstance().isCPU() ? pack.primaryOffsets() : pack.specialOffsets();
|
||||
|
||||
if (_opType == 0)
|
||||
NativeOpExecutioner::execReduceFloat(LaunchContext::defaultContext(), _opNum, _x->buffer(), _x->shapeInfo(), _x->specialBuffer(), _x->specialShapeInfo(), nullptr, _z->buffer(), _z->shapeInfo(), _z->specialBuffer(), _z->specialShapeInfo(), nullptr, _axis.size(), tadOnlyShapeInfo, tadOffsets);
|
||||
|
|
|
@ -32,13 +32,14 @@ namespace helpers {
|
|||
class BiDiagonalUp {
|
||||
|
||||
public:
|
||||
|
||||
|
||||
NDArray _HHmatrix; // 2D Householder matrix
|
||||
NDArray _HHbidiag; // vector which contains Householder coefficients
|
||||
NDArray _hhCoeffs; // vector of Householder coefficients
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
*
|
||||
* matrix - input matrix expected to be bi-diagonalized, remains unaffected
|
||||
*/
|
||||
BiDiagonalUp(const NDArray& matrix);
|
||||
|
@ -47,7 +48,7 @@ class BiDiagonalUp {
|
|||
* this method evaluates data (coeff, normX, tail) used in Householder transformation
|
||||
* formula for Householder matrix: P = identity_matrix - coeff * w * w^T
|
||||
* P * x = [normX, 0, 0 , 0, ...]
|
||||
* coeff - scalar
|
||||
* coeff - scalar
|
||||
* w = [1, w1, w2, w3, ...], "tail" is w except first unity element, that is "tail" = [w1, w2, w3, ...]
|
||||
* tail and coeff are stored in _HHmatrix
|
||||
* normX are stored in _HHbidiag
|
||||
|
@ -59,13 +60,13 @@ class BiDiagonalUp {
|
|||
|
||||
/**
|
||||
* this method evaluates product of Householder sequence matrices (transformations) acting on columns
|
||||
*
|
||||
*
|
||||
* type - type of sequence, type = 'u' (acting on columns) or type = 'v' (acting on rows)
|
||||
*/
|
||||
template <typename T>
|
||||
HHsequence makeHHsequence_(const char type) const;
|
||||
HHsequence makeHHsequence_(const char type);
|
||||
|
||||
HHsequence makeHHsequence(const char type) const;
|
||||
HHsequence makeHHsequence(const char type);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <loops/type_conversions.h>
|
||||
#include <system/type_boilerplate.h>
|
||||
#include <cstring>
|
||||
#include <array/PrimaryPointerDeallocator.h>
|
||||
|
||||
namespace sd {
|
||||
|
||||
|
@ -42,11 +43,17 @@ namespace sd {
|
|||
}
|
||||
}
|
||||
|
||||
ConstantHelper* ConstantHelper::getInstance() {
|
||||
if (!_INSTANCE)
|
||||
_INSTANCE = new sd::ConstantHelper();
|
||||
ConstantHelper::~ConstantHelper() {
|
||||
for (const auto &v:_cache) {
|
||||
for (const auto &c:v) {
|
||||
delete c.second;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _INSTANCE;
|
||||
ConstantHelper& ConstantHelper::getInstance() {
|
||||
static ConstantHelper instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void* ConstantHelper::replicatePointer(void *src, size_t numBytes, memory::Workspace *workspace) {
|
||||
|
@ -95,17 +102,17 @@ namespace sd {
|
|||
result = holder->getConstantDataBuffer(dataType);
|
||||
else {
|
||||
auto size = descriptor.length() * DataTypeUtils::sizeOf(dataType);
|
||||
auto cbuff = new int8_t[size];
|
||||
auto cbuff = std::make_shared<PointerWrapper>(new int8_t[size], std::make_shared<PrimaryPointerDeallocator>());
|
||||
_counters[deviceId] += size;
|
||||
|
||||
// create buffer with this dtype
|
||||
if (descriptor.isFloat()) {
|
||||
BUILD_DOUBLE_SELECTOR(sd::DataType::DOUBLE, dataType, sd::TypeCast::convertGeneric, (nullptr, const_cast<double *>(descriptor.floatValues().data()), descriptor.length(), cbuff), (sd::DataType::DOUBLE, double), LIBND4J_TYPES);
|
||||
BUILD_DOUBLE_SELECTOR(sd::DataType::DOUBLE, dataType, sd::TypeCast::convertGeneric, (nullptr, const_cast<double *>(descriptor.floatValues().data()), descriptor.length(), cbuff->pointer()), (sd::DataType::DOUBLE, double), LIBND4J_TYPES);
|
||||
} else if (descriptor.isInteger()) {
|
||||
BUILD_DOUBLE_SELECTOR(sd::DataType::INT64, dataType, sd::TypeCast::convertGeneric, (nullptr, const_cast<Nd4jLong *>(descriptor.integerValues().data()), descriptor.length(), cbuff), (sd::DataType::INT64, Nd4jLong), LIBND4J_TYPES);
|
||||
BUILD_DOUBLE_SELECTOR(sd::DataType::INT64, dataType, sd::TypeCast::convertGeneric, (nullptr, const_cast<Nd4jLong *>(descriptor.integerValues().data()), descriptor.length(), cbuff->pointer()), (sd::DataType::INT64, Nd4jLong), LIBND4J_TYPES);
|
||||
}
|
||||
|
||||
ConstantDataBuffer dataBuffer(cbuff, nullptr, descriptor.length(), DataTypeUtils::sizeOf(dataType));
|
||||
ConstantDataBuffer dataBuffer(cbuff, descriptor.length(), dataType);
|
||||
holder->addBuffer(dataBuffer, dataType);
|
||||
|
||||
result = holder->getConstantDataBuffer(dataType);
|
||||
|
@ -122,8 +129,6 @@ namespace sd {
|
|||
else
|
||||
return _counters[deviceId];
|
||||
}
|
||||
|
||||
sd::ConstantHelper* sd::ConstantHelper::_INSTANCE = 0;
|
||||
}
|
||||
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue