diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/async/copy.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/async/copy.h new file mode 100644 index 0000000000000000000000000000000000000000..72debb3b66715b284056aea1648fcaf5589afd70 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/async/copy.h @@ -0,0 +1,34 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +// The purpose of this header is to #include the async/copy.h header of the +// sequential, host, and device systems. It should be #included in any code +// which uses ADL to dispatch async copy. + +#pragma once + +#include + +//#include + +//#define __THRUST_HOST_SYSTEM_ASYNC_COPY_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/async/copy.h> +//#include __THRUST_HOST_SYSTEM_ASYNC_COPY_HEADER +//#undef __THRUST_HOST_SYSTEM_ASYNC_COPY_HEADER + +#define __THRUST_DEVICE_SYSTEM_ASYNC_COPY_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/async/copy.h> +#include __THRUST_DEVICE_SYSTEM_ASYNC_COPY_HEADER +#undef __THRUST_DEVICE_SYSTEM_ASYNC_COPY_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/async/for_each.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/async/for_each.h new file mode 100644 index 0000000000000000000000000000000000000000..08347f659279c487ac9ba5d29a6db3e4b9a6ddb9 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/async/for_each.h @@ -0,0 +1,34 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +// The purpose of this header is to #include the async/for_each.h header of the +// sequential, host, and device systems. It should be #included in any code +// which uses ADL to dispatch async for_each. + +#pragma once + +#include + +//#include + +//#define __THRUST_HOST_SYSTEM_ASYNC_FOR_EACH_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/async/for_each.h> +//#include __THRUST_HOST_SYSTEM_ASYNC_FOR_EACH_HEADER +//#undef __THRUST_HOST_SYSTEM_ASYNC_FOR_EACH_HEADER + +#define __THRUST_DEVICE_SYSTEM_ASYNC_FOR_EACH_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/async/for_each.h> +#include __THRUST_DEVICE_SYSTEM_ASYNC_FOR_EACH_HEADER +#undef __THRUST_DEVICE_SYSTEM_ASYNC_FOR_EACH_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/async/reduce.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/async/reduce.h new file mode 100644 index 0000000000000000000000000000000000000000..f13ab02fdca0b0fdf416f3bd117ee239e54df15c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/async/reduce.h @@ -0,0 +1,34 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +// The purpose of this header is to #include the async/reduce.h header of the +// sequential, host, and device systems. It should be #included in any code +// which uses ADL to dispatch async reduce. + +#pragma once + +#include + +//#include + +//#define __THRUST_HOST_SYSTEM_ASYNC_REDUCE_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/async/reduce.h> +//#include __THRUST_HOST_SYSTEM_ASYNC_REDUCE_HEADER +//#undef __THRUST_HOST_SYSTEM_ASYNC_REDUCE_HEADER + +#define __THRUST_DEVICE_SYSTEM_ASYNC_REDUCE_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/async/reduce.h> +#include __THRUST_DEVICE_SYSTEM_ASYNC_REDUCE_HEADER +#undef __THRUST_DEVICE_SYSTEM_ASYNC_REDUCE_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/async/scan.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/async/scan.h new file mode 100644 index 0000000000000000000000000000000000000000..a2a90618b487679be862d6dceee450a25b027523 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/async/scan.h @@ -0,0 +1,34 @@ +/* + * Copyright 2008-2020 NVIDIA Corporation + * + * 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. + */ + +// The purpose of this header is to #include the async/scan.h header of the +// sequential, host, and device systems. It should be #included in any code +// which uses ADL to dispatch async scans. + +#pragma once + +#include + +//#include + +//#define __THRUST_HOST_SYSTEM_ASYNC_SCAN_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/async/scan.h> +//#include __THRUST_HOST_SYSTEM_ASYNC_SCAN_HEADER +//#undef __THRUST_HOST_SYSTEM_ASYNC_SCAN_HEADER + +#define __THRUST_DEVICE_SYSTEM_ASYNC_SCAN_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/async/scan.h> +#include __THRUST_DEVICE_SYSTEM_ASYNC_SCAN_HEADER +#undef __THRUST_DEVICE_SYSTEM_ASYNC_SCAN_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/async/sort.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/async/sort.h new file mode 100644 index 0000000000000000000000000000000000000000..c3a83ad404f8943d52dbeeca9a183997d8dff7c3 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/async/sort.h @@ -0,0 +1,34 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +// The purpose of this header is to #include the async/sort.h header of the +// sequential, host, and device systems. It should be #included in any code +// which uses ADL to dispatch async sort. + +#pragma once + +#include + +//#include + +//#define __THRUST_HOST_SYSTEM_ASYNC_SORT_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/async/sort.h> +//#include __THRUST_HOST_SYSTEM_ASYNC_SORT_HEADER +//#undef __THRUST_HOST_SYSTEM_ASYNC_SORT_HEADER + +#define __THRUST_DEVICE_SYSTEM_ASYNC_SORT_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/async/sort.h> +#include __THRUST_DEVICE_SYSTEM_ASYNC_SORT_HEADER +#undef __THRUST_DEVICE_SYSTEM_ASYNC_SORT_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/async/transform.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/async/transform.h new file mode 100644 index 0000000000000000000000000000000000000000..abb2163ead0654a805deb3b31ca29f8c576ac9e9 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/async/transform.h @@ -0,0 +1,34 @@ +/* + * Copyright 2008-2018 NVIDIA Corporation + * + * 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 transform 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. + */ + +// The purpose of this header is to #include the async/transform.h header of the +// sequential, host, and device systems. It should be #included in any code +// which uses ADL to dispatch async transform. + +#pragma once + +#include + +//#include + +//#define __THRUST_HOST_SYSTEM_ASYNC_TRANSFORM_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/async/transform.h> +//#include __THRUST_HOST_SYSTEM_ASYNC_TRANSFORM_HEADER +//#undef __THRUST_HOST_SYSTEM_ASYNC_TRANSFORM_HEADER + +#define __THRUST_DEVICE_SYSTEM_ASYNC_TRANSFORM_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/async/transform.h> +#include __THRUST_DEVICE_SYSTEM_ASYNC_TRANSFORM_HEADER +#undef __THRUST_DEVICE_SYSTEM_ASYNC_TRANSFORM_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/per_device_resource.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/per_device_resource.h new file mode 100644 index 0000000000000000000000000000000000000000..721f49e03fd49c5db5b1094575a62630d0509fc1 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/per_device_resource.h @@ -0,0 +1,41 @@ +/* + * Copyright 2018 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// the purpose of this header is to #include the per_device_resource.h header +// of the sequential, host, and device systems. It should be #included in any +// code which uses adl to dispatch per_device_resource + +#include + +#if 0 +#include +#include +#include +#include +#endif + +#define __THRUST_HOST_SYSTEM_PER_DEVICE_RESOURCE_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/per_device_resource.h> +#include __THRUST_HOST_SYSTEM_PER_DEVICE_RESOURCE_HEADER +#undef __THRUST_HOST_SYSTEM_PER_DEVICE_RESOURCE_HEADER + +#define __THRUST_DEVICE_SYSTEM_PER_DEVICE_RESOURCE_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/per_device_resource.h> +#include __THRUST_DEVICE_SYSTEM_PER_DEVICE_RESOURCE_HEADER +#undef __THRUST_DEVICE_SYSTEM_PER_DEVICE_RESOURCE_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/reduce.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/reduce.h new file mode 100644 index 0000000000000000000000000000000000000000..8a9673b3f957e590c60d7667fc57d4f50069c409 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/reduce.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// the purpose of this header is to #include the reduce.h header +// of the sequential, host, and device systems. It should be #included in any +// code which uses adl to dispatch reduce + +#include + +// SCons can't see through the #defines below to figure out what this header +// includes, so we fake it out by specifying all possible files we might end up +// including inside an #if 0. +#if 0 +#include +#include +#include +#include +#endif + +#define __THRUST_HOST_SYSTEM_REDUCE_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/reduce.h> +#include __THRUST_HOST_SYSTEM_REDUCE_HEADER +#undef __THRUST_HOST_SYSTEM_REDUCE_HEADER + +#define __THRUST_DEVICE_SYSTEM_REDUCE_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/reduce.h> +#include __THRUST_DEVICE_SYSTEM_REDUCE_HEADER +#undef __THRUST_DEVICE_SYSTEM_REDUCE_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/reduce_by_key.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/reduce_by_key.h new file mode 100644 index 0000000000000000000000000000000000000000..0605f9befaf97bea651e2fde12c790fcd7103744 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/reduce_by_key.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// the purpose of this header is to #include the reduce_by_key.h header +// of the sequential, host, and device systems. It should be #included in any +// code which uses adl to dispatch reduce_by_key + +#include + +// SCons can't see through the #defines below to figure out what this header +// includes, so we fake it out by specifying all possible files we might end up +// including inside an #if 0. +#if 0 +#include +#include +#include +#include +#endif + +#define __THRUST_HOST_SYSTEM_REDUCE_BY_KEY_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/reduce_by_key.h> +#include __THRUST_HOST_SYSTEM_REDUCE_BY_KEY_HEADER +#undef __THRUST_HOST_SYSTEM_REDUCE_BY_KEY_HEADER + +#define __THRUST_DEVICE_SYSTEM_REDUCE_BY_KEY_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/reduce_by_key.h> +#include __THRUST_DEVICE_SYSTEM_REDUCE_BY_KEY_HEADER +#undef __THRUST_DEVICE_SYSTEM_REDUCE_BY_KEY_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/remove.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/remove.h new file mode 100644 index 0000000000000000000000000000000000000000..c281379d54ed74d0a55453b92a39557999f2ad01 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/remove.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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 fill 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. + */ + +#pragma once + +#include + +// the purpose of this header is to #include the remove.h header +// of the sequential, host, and device systems. It should be #included in any +// code which uses adl to dispatch remove + +#include + +// SCons can't see through the #defines below to figure out what this header +// includes, so we fake it out by specifying all possible files we might end up +// including inside an #if 0. +#if 0 +#include +#include +#include +#include +#endif + +#define __THRUST_HOST_SYSTEM_REMOVE_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/remove.h> +#include __THRUST_HOST_SYSTEM_REMOVE_HEADER +#undef __THRUST_HOST_SYSTEM_REMOVE_HEADER + +#define __THRUST_DEVICE_SYSTEM_REMOVE_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/remove.h> +#include __THRUST_DEVICE_SYSTEM_REMOVE_HEADER +#undef __THRUST_DEVICE_SYSTEM_REMOVE_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/replace.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/replace.h new file mode 100644 index 0000000000000000000000000000000000000000..d8fb5746f1ced28be6571c8535ce0d8615863234 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/replace.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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 fill 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. + */ + +#pragma once + +#include + +// the purpose of this header is to #include the replace.h header +// of the sequential, host, and device systems. It should be #included in any +// code which uses adl to dispatch replace + +#include + +// SCons can't see through the #defines below to figure out what this header +// includes, so we fake it out by specifying all possible files we might end up +// including inside an #if 0. +#if 0 +#include +#include +#include +#include +#endif + +#define __THRUST_HOST_SYSTEM_REPLACE_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/replace.h> +#include __THRUST_HOST_SYSTEM_REPLACE_HEADER +#undef __THRUST_HOST_SYSTEM_REPLACE_HEADER + +#define __THRUST_DEVICE_SYSTEM_REPLACE_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/replace.h> +#include __THRUST_DEVICE_SYSTEM_REPLACE_HEADER +#undef __THRUST_DEVICE_SYSTEM_REPLACE_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/reverse.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/reverse.h new file mode 100644 index 0000000000000000000000000000000000000000..f6bd8947ee4bf3715441e9516160082427aa1491 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/reverse.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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 fill 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. + */ + +#pragma once + +#include + +// the purpose of this header is to #include the reverse.h header +// of the sequential, host, and device systems. It should be #included in any +// code which uses adl to dispatch reverse + +#include + +// SCons can't see through the #defines below to figure out what this header +// includes, so we fake it out by specifying all possible files we might end up +// including inside an #if 0. +#if 0 +#include +#include +#include +#include +#endif + +#define __THRUST_HOST_SYSTEM_REVERSE_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/reverse.h> +#include __THRUST_HOST_SYSTEM_REVERSE_HEADER +#undef __THRUST_HOST_SYSTEM_REVERSE_HEADER + +#define __THRUST_DEVICE_SYSTEM_REVERSE_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/reverse.h> +#include __THRUST_DEVICE_SYSTEM_REVERSE_HEADER +#undef __THRUST_DEVICE_SYSTEM_REVERSE_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/scan.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/scan.h new file mode 100644 index 0000000000000000000000000000000000000000..a24910410589c68c6bb122be24a50c04e44a4204 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/scan.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// the purpose of this header is to #include the scan.h header +// of the host and device systems. It should be #included in any +// code which uses adl to dispatch scan + +#include + +// SCons can't see through the #defines below to figure out what this header +// includes, so we fake it out by specifying all possible files we might end up +// including inside an #if 0. +#if 0 +#include +#include +#include +#include +#endif + +#define __THRUST_HOST_SYSTEM_SCAN_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/scan.h> +#include __THRUST_HOST_SYSTEM_SCAN_HEADER +#undef __THRUST_HOST_SYSTEM_SCAN_HEADER + +#define __THRUST_DEVICE_SYSTEM_SCAN_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/scan.h> +#include __THRUST_DEVICE_SYSTEM_SCAN_HEADER +#undef __THRUST_DEVICE_SYSTEM_SCAN_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/scan_by_key.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/scan_by_key.h new file mode 100644 index 0000000000000000000000000000000000000000..94f73503cac55cb65419bfd81dc9e6c9e7e63c0c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/scan_by_key.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// the purpose of this header is to #include the scan_by_key.h header +// of the sequential, host, and device systems. It should be #included in any +// code which uses adl to dispatch scan_by_key + +#include + +// SCons can't see through the #defines below to figure out what this header +// includes, so we fake it out by specifying all possible files we might end up +// including inside an #if 0. +#if 0 +#include +#include +#include +#include +#endif + +#define __THRUST_HOST_SYSTEM_SCAN_BY_KEY_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/scan_by_key.h> +#include __THRUST_HOST_SYSTEM_SCAN_BY_KEY_HEADER +#undef __THRUST_HOST_SYSTEM_SCAN_BY_KEY_HEADER + +#define __THRUST_DEVICE_SYSTEM_SCAN_BY_KEY_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/scan_by_key.h> +#include __THRUST_DEVICE_SYSTEM_SCAN_BY_KEY_HEADER +#undef __THRUST_DEVICE_SYSTEM_SCAN_BY_KEY_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/scatter.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/scatter.h new file mode 100644 index 0000000000000000000000000000000000000000..d9f42b28b13cfa7928c54e76c950224b4bcfb66a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/scatter.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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 fill 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. + */ + +#pragma once + +#include + +// the purpose of this header is to #include the scatter.h header +// of the sequential, host, and device systems. It should be #included in any +// code which uses adl to dispatch scatter + +#include + +// SCons can't see through the #defines below to figure out what this header +// includes, so we fake it out by specifying all possible files we might end up +// including inside an #if 0. +#if 0 +#include +#include +#include +#include +#endif + +#define __THRUST_HOST_SYSTEM_SCATTER_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/scatter.h> +#include __THRUST_HOST_SYSTEM_SCATTER_HEADER +#undef __THRUST_HOST_SYSTEM_SCATTER_HEADER + +#define __THRUST_DEVICE_SYSTEM_SCATTER_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/scatter.h> +#include __THRUST_DEVICE_SYSTEM_SCATTER_HEADER +#undef __THRUST_DEVICE_SYSTEM_SCATTER_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/sequence.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/sequence.h new file mode 100644 index 0000000000000000000000000000000000000000..d3c2a20f47e6f7c7c7e79a8d348ab30a7a1eb7d8 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/sequence.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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 fill 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. + */ + +#pragma once + +#include + +// the purpose of this header is to #include the sequence.h header +// of the sequential, host, and device systems. It should be #included in any +// code which uses adl to dispatch sequence + +#include + +// SCons can't see through the #defines below to figure out what this header +// includes, so we fake it out by specifying all possible files we might end up +// including inside an #if 0. +#if 0 +#include +#include +#include +#include +#endif + +#define __THRUST_HOST_SYSTEM_SEQUENCE_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/sequence.h> +#include __THRUST_HOST_SYSTEM_SEQUENCE_HEADER +#undef __THRUST_HOST_SYSTEM_SEQUENCE_HEADER + +#define __THRUST_DEVICE_SYSTEM_SEQUENCE_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/sequence.h> +#include __THRUST_DEVICE_SYSTEM_SEQUENCE_HEADER +#undef __THRUST_DEVICE_SYSTEM_SEQUENCE_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/set_operations.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/set_operations.h new file mode 100644 index 0000000000000000000000000000000000000000..7d09355e12ad1beaf3ad6af34558d5a8692bd62a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/set_operations.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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 fill 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. + */ + +#pragma once + +#include + +// the purpose of this header is to #include the set_operations.h header +// of the sequential, host, and device systems. It should be #included in any +// code which uses adl to dispatch set_operations + +#include + +// SCons can't see through the #defines below to figure out what this header +// includes, so we fake it out by specifying all possible files we might end up +// including inside an #if 0. +#if 0 +#include +#include +#include +#include +#endif + +#define __THRUST_HOST_SYSTEM_SET_OPERATIONS_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/set_operations.h> +#include __THRUST_HOST_SYSTEM_SET_OPERATIONS_HEADER +#undef __THRUST_HOST_SYSTEM_SET_OPERATIONS_HEADER + +#define __THRUST_DEVICE_SYSTEM_SET_OPERATIONS_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/set_operations.h> +#include __THRUST_DEVICE_SYSTEM_SET_OPERATIONS_HEADER +#undef __THRUST_DEVICE_SYSTEM_SET_OPERATIONS_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/sort.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/sort.h new file mode 100644 index 0000000000000000000000000000000000000000..1f6118c90bf6345a1fd4d6eb2f05d2630911fa64 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/sort.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// the purpose of this header is to #include the sort.h header +// of the sequential, host, and device systems. It should be #included in any +// code which uses adl to dispatch sort + +#include + +// SCons can't see through the #defines below to figure out what this header +// includes, so we fake it out by specifying all possible files we might end up +// including inside an #if 0. +#if 0 +#include +#include +#include +#include +#endif + +#define __THRUST_HOST_SYSTEM_SORT_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/sort.h> +#include __THRUST_HOST_SYSTEM_SORT_HEADER +#undef __THRUST_HOST_SYSTEM_SORT_HEADER + +#define __THRUST_DEVICE_SYSTEM_SORT_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/sort.h> +#include __THRUST_DEVICE_SYSTEM_SORT_HEADER +#undef __THRUST_DEVICE_SYSTEM_SORT_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/swap_ranges.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/swap_ranges.h new file mode 100644 index 0000000000000000000000000000000000000000..1ca3719d96c1ed8de468a4b2ff4ab549bd4e88c0 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/swap_ranges.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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 fill 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. + */ + +#pragma once + +#include + +// the purpose of this header is to #include the swap_ranges.h header +// of the sequential, host, and device systems. It should be #included in any +// code which uses adl to dispatch swap_ranges + +#include + +// SCons can't see through the #defines below to figure out what this header +// includes, so we fake it out by specifying all possible files we might end up +// including inside an #if 0. +#if 0 +#include +#include +#include +#include +#endif + +#define __THRUST_HOST_SYSTEM_SWAP_RANGES_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/swap_ranges.h> +#include __THRUST_HOST_SYSTEM_SWAP_RANGES_HEADER +#undef __THRUST_HOST_SYSTEM_SWAP_RANGES_HEADER + +#define __THRUST_DEVICE_SYSTEM_SWAP_RANGES_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/swap_ranges.h> +#include __THRUST_DEVICE_SYSTEM_SWAP_RANGES_HEADER +#undef __THRUST_DEVICE_SYSTEM_SWAP_RANGES_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/tabulate.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/tabulate.h new file mode 100644 index 0000000000000000000000000000000000000000..6ae2b22a5cbd3d2705cf4b13757c050b7c6161cc --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/tabulate.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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 fill 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. + */ + +#pragma once + +#include + +// the purpose of this header is to #include the tabulate.h header +// of the sequential, host, and device systems. It should be #included in any +// code which uses adl to dispatch tabulate + +#include + +// SCons can't see through the #defines below to figure out what this header +// includes, so we fake it out by specifying all possible files we might end up +// including inside an #if 0. +#if 0 +#include +#include +#include +#include +#endif + +#define __THRUST_HOST_SYSTEM_TABULATE_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/tabulate.h> +#include __THRUST_HOST_SYSTEM_TABULATE_HEADER +#undef __THRUST_HOST_SYSTEM_TABULATE_HEADER + +#define __THRUST_DEVICE_SYSTEM_TABULATE_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/tabulate.h> +#include __THRUST_DEVICE_SYSTEM_TABULATE_HEADER +#undef __THRUST_DEVICE_SYSTEM_TABULATE_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/temporary_buffer.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/temporary_buffer.h new file mode 100644 index 0000000000000000000000000000000000000000..0cada5ee4b10a9fc36d19f80a276bb19ef7fff6d --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/temporary_buffer.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// the purpose of this header is to #include the temporary_buffer.h header +// of the sequential, host, and device systems. It should be #included in any +// code which uses adl to dispatch get_temporary_buffer or return_temporary_buffer + +#include + +// SCons can't see through the #defines below to figure out what this header +// includes, so we fake it out by specifying all possible files we might end up +// including inside an #if 0. +#if 0 +#include +#include +#include +#include +#endif + +#define __THRUST_HOST_SYSTEM_TEMPORARY_BUFFER_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/temporary_buffer.h> +#include __THRUST_HOST_SYSTEM_TEMPORARY_BUFFER_HEADER +#undef __THRUST_HOST_SYSTEM_TEMPORARY_BUFFER_HEADER + +#define __THRUST_DEVICE_SYSTEM_TEMPORARY_BUFFER_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/temporary_buffer.h> +#include __THRUST_DEVICE_SYSTEM_TEMPORARY_BUFFER_HEADER +#undef __THRUST_DEVICE_SYSTEM_TEMPORARY_BUFFER_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/transform.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/transform.h new file mode 100644 index 0000000000000000000000000000000000000000..b70333093fd48b6c23fa2e8ec3ab20a8e51cad9f --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/transform.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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 fill 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. + */ + +#pragma once + +#include + +// the purpose of this header is to #include the transform.h header +// of the sequential, host, and device systems. It should be #included in any +// code which uses adl to dispatch transform + +#include + +// SCons can't see through the #defines below to figure out what this header +// includes, so we fake it out by specifying all possible files we might end up +// including inside an #if 0. +#if 0 +#include +#include +#include +#include +#endif + +#define __THRUST_HOST_SYSTEM_TRANSFORM_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/transform.h> +#include __THRUST_HOST_SYSTEM_TRANSFORM_HEADER +#undef __THRUST_HOST_SYSTEM_TRANSFORM_HEADER + +#define __THRUST_DEVICE_SYSTEM_TRANSFORM_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/transform.h> +#include __THRUST_DEVICE_SYSTEM_TRANSFORM_HEADER +#undef __THRUST_DEVICE_SYSTEM_TRANSFORM_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/transform_reduce.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/transform_reduce.h new file mode 100644 index 0000000000000000000000000000000000000000..e3f9494dfa6e54bbfdeb2a51fabd8bebc2188e98 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/transform_reduce.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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 fill 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. + */ + +#pragma once + +#include + +// the purpose of this header is to #include the transform_reduce.h header +// of the sequential, host, and device systems. It should be #included in any +// code which uses adl to dispatch transform_reduce + +#include + +// SCons can't see through the #defines below to figure out what this header +// includes, so we fake it out by specifying all possible files we might end up +// including inside an #if 0. +#if 0 +#include +#include +#include +#include +#endif + +#define __THRUST_HOST_SYSTEM_TRANSFORM_REDUCE_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/transform_reduce.h> +#include __THRUST_HOST_SYSTEM_TRANSFORM_REDUCE_HEADER +#undef __THRUST_HOST_SYSTEM_TRANSFORM_REDUCE_HEADER + +#define __THRUST_DEVICE_SYSTEM_TRANSFORM_REDUCE_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/transform_reduce.h> +#include __THRUST_DEVICE_SYSTEM_TRANSFORM_REDUCE_HEADER +#undef __THRUST_DEVICE_SYSTEM_TRANSFORM_REDUCE_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/transform_scan.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/transform_scan.h new file mode 100644 index 0000000000000000000000000000000000000000..3a05c7eeed9afc549d9d6bd1e28a64e67b4a4578 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/transform_scan.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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 fill 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. + */ + +#pragma once + +#include + +// the purpose of this header is to #include the transform_scan.h header +// of the sequential, host, and device systems. It should be #included in any +// code which uses adl to dispatch transform_scan + +#include + +// SCons can't see through the #defines below to figure out what this header +// includes, so we fake it out by specifying all possible files we might end up +// including inside an #if 0. +#if 0 +#include +#include +#include +#include +#endif + +#define __THRUST_HOST_SYSTEM_TRANSFORM_SCAN_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/transform_scan.h> +#include __THRUST_HOST_SYSTEM_TRANSFORM_SCAN_HEADER +#undef __THRUST_HOST_SYSTEM_TRANSFORM_SCAN_HEADER + +#define __THRUST_DEVICE_SYSTEM_TRANSFORM_SCAN_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/transform_scan.h> +#include __THRUST_DEVICE_SYSTEM_TRANSFORM_SCAN_HEADER +#undef __THRUST_DEVICE_SYSTEM_TRANSFORM_SCAN_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/uninitialized_copy.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/uninitialized_copy.h new file mode 100644 index 0000000000000000000000000000000000000000..a13b18aa8d73dae57b450a0a53e2fb97de2165ea --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/uninitialized_copy.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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 fill 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. + */ + +#pragma once + +#include + +// the purpose of this header is to #include the uninitialized_copy.h header +// of the sequential, host, and device systems. It should be #included in any +// code which uses adl to dispatch uninitialized_copy + +#include + +// SCons can't see through the #defines below to figure out what this header +// includes, so we fake it out by specifying all possible files we might end up +// including inside an #if 0. +#if 0 +#include +#include +#include +#include +#endif + +#define __THRUST_HOST_SYSTEM_UNINITIALIZED_COPY_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/uninitialized_copy.h> +#include __THRUST_HOST_SYSTEM_UNINITIALIZED_COPY_HEADER +#undef __THRUST_HOST_SYSTEM_UNINITIALIZED_COPY_HEADER + +#define __THRUST_DEVICE_SYSTEM_UNINITIALIZED_COPY_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/uninitialized_copy.h> +#include __THRUST_DEVICE_SYSTEM_UNINITIALIZED_COPY_HEADER +#undef __THRUST_DEVICE_SYSTEM_UNINITIALIZED_COPY_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/uninitialized_fill.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/uninitialized_fill.h new file mode 100644 index 0000000000000000000000000000000000000000..98b57836e124dcd75fcd7a7fe75c0646ed3f76ba --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/uninitialized_fill.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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 fill 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. + */ + +#pragma once + +#include + +// the purpose of this header is to #include the uninitialized_fill.h header +// of the sequential, host, and device systems. It should be #included in any +// code which uses adl to dispatch uninitialized_fill + +#include + +// SCons can't see through the #defines below to figure out what this header +// includes, so we fake it out by specifying all possible files we might end up +// including inside an #if 0. +#if 0 +#include +#include +#include +#include +#endif + +#define __THRUST_HOST_SYSTEM_UNINITIALIZED_FILL_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/uninitialized_fill.h> +#include __THRUST_HOST_SYSTEM_UNINITIALIZED_FILL_HEADER +#undef __THRUST_HOST_SYSTEM_UNINITIALIZED_FILL_HEADER + +#define __THRUST_DEVICE_SYSTEM_UNINITIALIZED_FILL_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/uninitialized_fill.h> +#include __THRUST_DEVICE_SYSTEM_UNINITIALIZED_FILL_HEADER +#undef __THRUST_DEVICE_SYSTEM_UNINITIALIZED_FILL_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/unique.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/unique.h new file mode 100644 index 0000000000000000000000000000000000000000..4082f5299269e77aacbae174754d57977d45ebdd --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/unique.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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 fill 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. + */ + +#pragma once + +#include + +// the purpose of this header is to #include the unique.h header +// of the sequential, host, and device systems. It should be #included in any +// code which uses adl to dispatch unique + +#include + +// SCons can't see through the #defines below to figure out what this header +// includes, so we fake it out by specifying all possible files we might end up +// including inside an #if 0. +#if 0 +#include +#include +#include +#include +#endif + +#define __THRUST_HOST_SYSTEM_UNIQUE_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/unique.h> +#include __THRUST_HOST_SYSTEM_UNIQUE_HEADER +#undef __THRUST_HOST_SYSTEM_UNIQUE_HEADER + +#define __THRUST_DEVICE_SYSTEM_UNIQUE_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/unique.h> +#include __THRUST_DEVICE_SYSTEM_UNIQUE_HEADER +#undef __THRUST_DEVICE_SYSTEM_UNIQUE_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/unique_by_key.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/unique_by_key.h new file mode 100644 index 0000000000000000000000000000000000000000..dcf9acd42cd730a8f42bedb01407cf75137a86fb --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/adl/unique_by_key.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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 fill 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. + */ + +#pragma once + +#include + +// the purpose of this header is to #include the unique_by_key.h header +// of the sequential, host, and device systems. It should be #included in any +// code which uses adl to dispatch unique_by_key + +#include + +// SCons can't see through the #defines below to figure out what this header +// includes, so we fake it out by specifying all possible files we might end up +// including inside an #if 0. +#if 0 +#include +#include +#include +#include +#endif + +#define __THRUST_HOST_SYSTEM_UNIQUE_BY_KEY_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/unique_by_key.h> +#include __THRUST_HOST_SYSTEM_UNIQUE_BY_KEY_HEADER +#undef __THRUST_HOST_SYSTEM_UNIQUE_BY_KEY_HEADER + +#define __THRUST_DEVICE_SYSTEM_UNIQUE_BY_KEY_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/unique_by_key.h> +#include __THRUST_DEVICE_SYSTEM_UNIQUE_BY_KEY_HEADER +#undef __THRUST_DEVICE_SYSTEM_UNIQUE_BY_KEY_HEADER + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/adjacent_difference.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/adjacent_difference.h new file mode 100644 index 0000000000000000000000000000000000000000..43592e15b033816b94cdf7368c1840d6e6993744 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/adjacent_difference.h @@ -0,0 +1,57 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file adjacent_difference.h + * \brief Generic implementation of adjacent_difference. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ +OutputIterator adjacent_difference(thrust::execution_policy &exec, + InputIterator first, InputIterator last, + OutputIterator result); + + +template +__host__ __device__ +OutputIterator adjacent_difference(thrust::execution_policy &exec, + InputIterator first, InputIterator last, + OutputIterator result, + BinaryFunction binary_op); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/adjacent_difference.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/adjacent_difference.inl new file mode 100644 index 0000000000000000000000000000000000000000..504129328884ede8c00dec99dd41aa9cfcfa3156 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/adjacent_difference.inl @@ -0,0 +1,82 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ +OutputIterator adjacent_difference(thrust::execution_policy &exec, + InputIterator first, InputIterator last, + OutputIterator result) +{ + typedef typename thrust::iterator_traits::value_type InputType; + thrust::minus binary_op; + + return thrust::adjacent_difference(exec, first, last, result, binary_op); +} // end adjacent_difference() + + +template +__host__ __device__ +OutputIterator adjacent_difference(thrust::execution_policy &exec, + InputIterator first, InputIterator last, + OutputIterator result, + BinaryFunction binary_op) +{ + typedef typename thrust::iterator_traits::value_type InputType; + + if(first == last) + { + // empty range, nothing to do + return result; + } + else + { + // an in-place operation is requested, copy the input and call the entry point + // XXX a special-purpose kernel would be faster here since + // only block boundaries need to be copied + thrust::detail::temporary_array input_copy(exec, first, last); + + *result = *first; + thrust::transform(exec, input_copy.begin() + 1, input_copy.end(), input_copy.begin(), result + 1, binary_op); + } + + return result + (last - first); +} + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/advance.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/advance.h new file mode 100644 index 0000000000000000000000000000000000000000..4d6562e00faca41ab8d3f9d2c40df367e31faf6d --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/advance.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + +template +__host__ __device__ +void advance(InputIterator& i, Distance n); + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/advance.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/advance.inl new file mode 100644 index 0000000000000000000000000000000000000000..21555ebb03f4bbf86bba72667e1db388adae6e23 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/advance.inl @@ -0,0 +1,68 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ +namespace detail +{ + +__thrust_exec_check_disable__ +template +__host__ __device__ +void advance(InputIterator& i, Distance n, thrust::incrementable_traversal_tag) +{ + while(n) + { + ++i; + --n; + } // end while +} // end advance() + +__thrust_exec_check_disable__ +template +__host__ __device__ +void advance(InputIterator& i, Distance n, thrust::random_access_traversal_tag) +{ + i += n; +} // end advance() + +} // end detail + +template +__host__ __device__ +void advance(InputIterator& i, Distance n) +{ + // dispatch on iterator traversal + thrust::system::detail::generic::detail::advance(i, n, + typename thrust::iterator_traversal::type()); +} // end advance() + +} // end namespace detail +} // end namespace generic +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/binary_search.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/binary_search.h new file mode 100644 index 0000000000000000000000000000000000000000..6603f6c302f8f98e17071a471f640f7c034757a2 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/binary_search.h @@ -0,0 +1,173 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file binary_search.h + * \brief Generic implementations of binary search functions. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ +ForwardIterator lower_bound(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + const T& value); + +template +__host__ __device__ +ForwardIterator lower_bound(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + const T& value, + StrictWeakOrdering comp); + + +template +__host__ __device__ +ForwardIterator upper_bound(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + const T& value); + +template +__host__ __device__ +ForwardIterator upper_bound(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + const T& value, + StrictWeakOrdering comp); + + +template +__host__ __device__ +bool binary_search(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + const T& value); + +template +__host__ __device__ +bool binary_search(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + const T& value, + StrictWeakOrdering comp); + + +template +__host__ __device__ +OutputIterator lower_bound(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + InputIterator values_begin, + InputIterator values_end, + OutputIterator output); + + +template +__host__ __device__ +OutputIterator lower_bound(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + InputIterator values_begin, + InputIterator values_end, + OutputIterator output, + StrictWeakOrdering comp); + + +template +__host__ __device__ +OutputIterator upper_bound(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + InputIterator values_begin, + InputIterator values_end, + OutputIterator output); + + +template +__host__ __device__ +OutputIterator upper_bound(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + InputIterator values_begin, + InputIterator values_end, + OutputIterator output, + StrictWeakOrdering comp); + + +template +__host__ __device__ +OutputIterator binary_search(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + InputIterator values_begin, + InputIterator values_end, + OutputIterator output); + + +template +__host__ __device__ +OutputIterator binary_search(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + InputIterator values_begin, + InputIterator values_end, + OutputIterator output, + StrictWeakOrdering comp); + + +template +__host__ __device__ +thrust::pair +equal_range(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + const LessThanComparable &value); + + +template +__host__ __device__ +thrust::pair +equal_range(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + const LessThanComparable &value, + StrictWeakOrdering comp); + + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/binary_search.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/binary_search.inl new file mode 100644 index 0000000000000000000000000000000000000000..bc60bb8e50212e1e9d0880a64a01d3c67298d767 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/binary_search.inl @@ -0,0 +1,396 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace detail +{ + + +// XXX WAR circular #inclusion with this forward declaration +template class temporary_array; + + +} // end detail +namespace system +{ +namespace detail +{ +namespace generic +{ +namespace detail +{ + + +// short names to avoid nvcc bug +struct lbf +{ + template + __host__ __device__ + typename thrust::iterator_traits::difference_type + operator()(RandomAccessIterator begin, RandomAccessIterator end, const T& value, StrictWeakOrdering comp) + { + return thrust::system::detail::generic::scalar::lower_bound(begin, end, value, comp) - begin; + } +}; + + +struct ubf +{ + template + __host__ __device__ + typename thrust::iterator_traits::difference_type + operator()(RandomAccessIterator begin, RandomAccessIterator end, const T& value, StrictWeakOrdering comp) + { + return thrust::system::detail::generic::scalar::upper_bound(begin, end, value, comp) - begin; + } +}; + + +struct bsf +{ + template + __host__ __device__ + bool operator()(RandomAccessIterator begin, RandomAccessIterator end, const T& value, StrictWeakOrdering comp) + { + RandomAccessIterator iter = thrust::system::detail::generic::scalar::lower_bound(begin, end, value, comp); + + thrust::detail::wrapped_function wrapped_comp(comp); + + return iter != end && !wrapped_comp(value, *iter); + } +}; + + +template +struct binary_search_functor +{ + ForwardIterator begin; + ForwardIterator end; + StrictWeakOrdering comp; + BinarySearchFunction func; + + __host__ __device__ + binary_search_functor(ForwardIterator begin, ForwardIterator end, StrictWeakOrdering comp, BinarySearchFunction func) + : begin(begin), end(end), comp(comp), func(func) {} + + template + __host__ __device__ + void operator()(Tuple t) + { + thrust::get<1>(t) = func(begin, end, thrust::get<0>(t), comp); + } +}; // binary_search_functor + + +// Vector Implementation +template +__host__ __device__ +OutputIterator binary_search(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + InputIterator values_begin, + InputIterator values_end, + OutputIterator output, + StrictWeakOrdering comp, + BinarySearchFunction func) +{ + thrust::for_each(exec, + thrust::make_zip_iterator(thrust::make_tuple(values_begin, output)), + thrust::make_zip_iterator(thrust::make_tuple(values_end, output + thrust::distance(values_begin, values_end))), + detail::binary_search_functor(begin, end, comp, func)); + + return output + thrust::distance(values_begin, values_end); +} + + + +// Scalar Implementation +template +__host__ __device__ +OutputType binary_search(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + const T& value, + StrictWeakOrdering comp, + BinarySearchFunction func) +{ + // use the vectorized path to implement the scalar version + + // allocate device buffers for value and output + thrust::detail::temporary_array d_value(exec,1); + thrust::detail::temporary_array d_output(exec,1); + + { // copy value to device + typedef typename thrust::iterator_system::type value_in_system_t; + value_in_system_t value_in_system; + using thrust::system::detail::generic::select_system; + thrust::copy_n(select_system(thrust::detail::derived_cast(thrust::detail::strip_const(value_in_system)), + thrust::detail::derived_cast(thrust::detail::strip_const(exec))), + &value, 1, d_value.begin()); + } + + // perform the query + thrust::system::detail::generic::detail::binary_search(exec, begin, end, d_value.begin(), d_value.end(), d_output.begin(), comp, func); + + OutputType output; + { // copy result to host and return + typedef typename thrust::iterator_system::type result_out_system_t; + result_out_system_t result_out_system; + using thrust::system::detail::generic::select_system; + thrust::copy_n(select_system(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), + thrust::detail::derived_cast(thrust::detail::strip_const(result_out_system))), + d_output.begin(), 1, &output); + } + + return output; +} + + +// this functor differs from thrust::less +// because it allows the types of lhs & rhs to differ +// which is required by the binary search functions +// XXX use C++14 thrust::less<> when it's ready +struct binary_search_less +{ + template + __host__ __device__ + bool operator()(const T1& lhs, const T2& rhs) const + { + return lhs < rhs; + } +}; + + +} // end namespace detail + + +////////////////////// +// Scalar Functions // +////////////////////// + + +template +__host__ __device__ +ForwardIterator lower_bound(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + const T& value) +{ + namespace p = thrust::placeholders; + return thrust::lower_bound(exec, begin, end, value, detail::binary_search_less()); +} + +template +__host__ __device__ +ForwardIterator lower_bound(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + const T& value, + StrictWeakOrdering comp) +{ + typedef typename thrust::iterator_traits::difference_type difference_type; + + return begin + detail::binary_search(exec, begin, end, value, comp, detail::lbf()); +} + + +template +__host__ __device__ +ForwardIterator upper_bound(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + const T& value) +{ + namespace p = thrust::placeholders; + return thrust::upper_bound(exec, begin, end, value, detail::binary_search_less()); +} + + +template +__host__ __device__ +ForwardIterator upper_bound(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + const T& value, + StrictWeakOrdering comp) +{ + typedef typename thrust::iterator_traits::difference_type difference_type; + + return begin + detail::binary_search(exec, begin, end, value, comp, detail::ubf()); +} + + +template +__host__ __device__ +bool binary_search(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + const T& value) +{ + return thrust::binary_search(exec, begin, end, value, detail::binary_search_less()); +} + + +template +__host__ __device__ +bool binary_search(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + const T& value, + StrictWeakOrdering comp) +{ + return detail::binary_search(exec, begin, end, value, comp, detail::bsf()); +} + + +////////////////////// +// Vector Functions // +////////////////////// + + +template +__host__ __device__ +OutputIterator lower_bound(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + InputIterator values_begin, + InputIterator values_end, + OutputIterator output) +{ + namespace p = thrust::placeholders; + return thrust::lower_bound(exec, begin, end, values_begin, values_end, output, detail::binary_search_less()); +} + + +template +__host__ __device__ +OutputIterator lower_bound(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + InputIterator values_begin, + InputIterator values_end, + OutputIterator output, + StrictWeakOrdering comp) +{ + return detail::binary_search(exec, begin, end, values_begin, values_end, output, comp, detail::lbf()); +} + + +template +__host__ __device__ +OutputIterator upper_bound(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + InputIterator values_begin, + InputIterator values_end, + OutputIterator output) +{ + namespace p = thrust::placeholders; + return thrust::upper_bound(exec, begin, end, values_begin, values_end, output, detail::binary_search_less()); +} + + +template +__host__ __device__ +OutputIterator upper_bound(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + InputIterator values_begin, + InputIterator values_end, + OutputIterator output, + StrictWeakOrdering comp) +{ + return detail::binary_search(exec, begin, end, values_begin, values_end, output, comp, detail::ubf()); +} + + +template +__host__ __device__ +OutputIterator binary_search(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + InputIterator values_begin, + InputIterator values_end, + OutputIterator output) +{ + namespace p = thrust::placeholders; + return thrust::binary_search(exec, begin, end, values_begin, values_end, output, detail::binary_search_less()); +} + + +template +__host__ __device__ +OutputIterator binary_search(thrust::execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + InputIterator values_begin, + InputIterator values_end, + OutputIterator output, + StrictWeakOrdering comp) +{ + return detail::binary_search(exec, begin, end, values_begin, values_end, output, comp, detail::bsf()); +} + + +template +__host__ __device__ +thrust::pair +equal_range(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + const LessThanComparable &value) +{ + return thrust::equal_range(exec, first, last, value, detail::binary_search_less()); +} + + +template +__host__ __device__ +thrust::pair +equal_range(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + const T &value, + StrictWeakOrdering comp) +{ + ForwardIterator lb = thrust::lower_bound(exec, first, last, value, comp); + ForwardIterator ub = thrust::upper_bound(exec, first, last, value, comp); + return thrust::make_pair(lb, ub); +} + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/copy.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/copy.h new file mode 100644 index 0000000000000000000000000000000000000000..36ac71899de0d1bf9a83e44ffac58ed32b045549 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/copy.h @@ -0,0 +1,58 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + OutputIterator copy(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result); + + +template +__host__ __device__ + OutputIterator copy_n(thrust::execution_policy &exec, + InputIterator first, + Size n, + OutputIterator result); + + +} // end generic +} // end detail +} // end system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/copy.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/copy.inl new file mode 100644 index 0000000000000000000000000000000000000000..34d66baa6b2c518178090adb9679f2bf2273b6ec --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/copy.inl @@ -0,0 +1,80 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + OutputIterator copy(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result) +{ + typedef typename thrust::iterator_value::type T; + return thrust::transform(exec, first, last, result, thrust::identity()); +} // end copy() + + +template +__host__ __device__ + OutputIterator copy_n(thrust::execution_policy &exec, + InputIterator first, + Size n, + OutputIterator result) +{ + typedef typename thrust::iterator_value::type value_type; + typedef thrust::identity xfrm_type; + + typedef thrust::detail::unary_transform_functor functor_type; + + typedef thrust::tuple iterator_tuple; + typedef thrust::zip_iterator zip_iter; + + zip_iter zipped = thrust::make_zip_iterator(thrust::make_tuple(first,result)); + + return thrust::get<1>(thrust::for_each_n(exec, zipped, n, functor_type(xfrm_type())).get_iterator_tuple()); +} // end copy_n() + + +} // end generic +} // end detail +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/copy_if.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/copy_if.h new file mode 100644 index 0000000000000000000000000000000000000000..6a13edfdaf30d9a300978baa9a195b1bcd35c4a2 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/copy_if.h @@ -0,0 +1,63 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + OutputIterator copy_if(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + Predicate pred); + + +template +__host__ __device__ + OutputIterator copy_if(thrust::execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator result, + Predicate pred); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/copy_if.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/copy_if.inl new file mode 100644 index 0000000000000000000000000000000000000000..5a6edd72e18672d00c423becd1f0d9fe5e4d1747 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/copy_if.inl @@ -0,0 +1,160 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ +namespace detail +{ + + +template +__host__ __device__ +OutputIterator copy_if(thrust::execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator result, + Predicate pred) +{ + THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING(IndexType n = thrust::distance(first, last)); + + // compute {0,1} predicates + thrust::detail::temporary_array predicates(exec, n); + thrust::transform(exec, + stencil, + stencil + n, + predicates.begin(), + thrust::detail::predicate_to_integral(pred)); + + // scan {0,1} predicates + thrust::detail::temporary_array scatter_indices(exec, n); + thrust::exclusive_scan(exec, + predicates.begin(), + predicates.end(), + scatter_indices.begin(), + static_cast(0), + thrust::plus()); + + // scatter the true elements + thrust::scatter_if(exec, + first, + last, + scatter_indices.begin(), + predicates.begin(), + result, + thrust::identity()); + + // find the end of the new sequence + IndexType output_size = scatter_indices[n - 1] + predicates[n - 1]; + + return result + output_size; +} + + +} // end namespace detail + + +template +__host__ __device__ + OutputIterator copy_if(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + Predicate pred) +{ + // XXX it's potentially expensive to send [first,last) twice + // we should probably specialize this case for POD + // since we can safely keep the input in a temporary instead + // of doing two loads + return thrust::copy_if(exec, first, last, first, result, pred); +} // end copy_if() + + +template +__host__ __device__ + OutputIterator copy_if(thrust::execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator result, + Predicate pred) +{ + typedef typename thrust::iterator_traits::difference_type difference_type; + + // empty sequence + if(first == last) + return result; + + difference_type n = thrust::distance(first, last); + + // create an unsigned version of n (we know n is positive from the comparison above) + // to avoid a warning in the compare below + typename thrust::detail::make_unsigned::type unsigned_n(n); + + // use 32-bit indices when possible (almost always) + if(sizeof(difference_type) > sizeof(unsigned int) && unsigned_n > thrust::detail::integer_traits::const_max) + { + result = detail::copy_if(exec, first, last, stencil, result, pred); + } // end if + else + { + result = detail::copy_if(exec, first, last, stencil, result, pred); + } // end else + + return result; +} // end copy_if() + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/count.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/count.h new file mode 100644 index 0000000000000000000000000000000000000000..295d36e6b9dfb013f5b3fd64d91a0fdc62d0b7a6 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/count.h @@ -0,0 +1,50 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ +typename thrust::iterator_traits::difference_type +count(thrust::execution_policy &exec, InputIterator first, InputIterator last, const EqualityComparable& value); + + +template +__host__ __device__ +typename thrust::iterator_traits::difference_type +count_if(thrust::execution_policy &exec, InputIterator first, InputIterator last, Predicate pred); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/count.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/count.inl new file mode 100644 index 0000000000000000000000000000000000000000..dafc1c1df2a17f8d70a55583aa22cd65b06f7052 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/count.inl @@ -0,0 +1,82 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +struct count_if_transform +{ + __host__ __device__ + count_if_transform(Predicate _pred) : pred(_pred){} + + __thrust_exec_check_disable__ + __host__ __device__ + CountType operator()(const InputType& val) + { + if(pred(val)) + return 1; + else + return 0; + } // end operator() + + Predicate pred; +}; // end count_if_transform + + +template +__host__ __device__ +typename thrust::iterator_traits::difference_type +count(thrust::execution_policy &exec, InputIterator first, InputIterator last, const EqualityComparable& value) +{ + using thrust::placeholders::_1; + + return thrust::count_if(exec, first, last, _1 == value); +} // end count() + + +template +__host__ __device__ +typename thrust::iterator_traits::difference_type +count_if(thrust::execution_policy &exec, InputIterator first, InputIterator last, Predicate pred) +{ + typedef typename thrust::iterator_traits::value_type InputType; + typedef typename thrust::iterator_traits::difference_type CountType; + + thrust::system::detail::generic::count_if_transform unary_op(pred); + thrust::plus binary_op; + return thrust::transform_reduce(exec, first, last, unary_op, CountType(0), binary_op); +} // end count_if() + + +} // end generic +} // end detail +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/distance.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/distance.h new file mode 100644 index 0000000000000000000000000000000000000000..4627376b575cc3655a697f937a78069513f34086 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/distance.h @@ -0,0 +1,42 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + +template +inline __host__ __device__ + typename thrust::iterator_traits::difference_type + distance(InputIterator first, InputIterator last); + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/distance.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/distance.inl new file mode 100644 index 0000000000000000000000000000000000000000..46bad7ba74ea2be674d9595dc0510aa3d44438ed --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/distance.inl @@ -0,0 +1,80 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ +namespace detail +{ + + +__thrust_exec_check_disable__ +template +inline __host__ __device__ + typename thrust::iterator_traits::difference_type + distance(InputIterator first, InputIterator last, thrust::incrementable_traversal_tag) +{ + typename thrust::iterator_traits::difference_type result(0); + + while(first != last) + { + ++first; + ++result; + } // end while + + return result; +} // end advance() + + +__thrust_exec_check_disable__ +template +inline __host__ __device__ + typename thrust::iterator_traits::difference_type + distance(InputIterator first, InputIterator last, thrust::random_access_traversal_tag) +{ + return last - first; +} // end distance() + + +} // end detail + +__thrust_exec_check_disable__ +template +inline __host__ __device__ + typename thrust::iterator_traits::difference_type + distance(InputIterator first, InputIterator last) +{ + // dispatch on iterator traversal + return thrust::system::detail::generic::detail::distance(first, last, + typename thrust::iterator_traversal::type()); +} // end advance() + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/equal.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/equal.h new file mode 100644 index 0000000000000000000000000000000000000000..4afd88d001ffa4b507e80472d88ef572a2b470f2 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/equal.h @@ -0,0 +1,47 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ +bool equal(thrust::execution_policy &exec, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2); + + +template +__host__ __device__ +bool equal(thrust::execution_policy &exec, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate binary_pred); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/equal.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/equal.inl new file mode 100644 index 0000000000000000000000000000000000000000..c023070cdcb0867f8a3ff3140bb45b776d946081 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/equal.inl @@ -0,0 +1,59 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ +bool equal(thrust::execution_policy &exec, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2) +{ + typedef typename thrust::iterator_traits::value_type InputType1; + + return thrust::equal(exec, first1, last1, first2, thrust::detail::equal_to()); +} + + +// the == below could be a __host__ function in the case of std::vector::iterator::operator== +// we make this exception for equal and use __thrust_exec_check_disable__ because it is used in vector's implementation +__thrust_exec_check_disable__ +template +__host__ __device__ +bool equal(thrust::execution_policy &exec, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate binary_pred) +{ + return thrust::mismatch(exec, first1, last1, first2, binary_pred).first == last1; +} + + +} // end generic +} // end detail +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/extrema.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/extrema.h new file mode 100644 index 0000000000000000000000000000000000000000..e3b447958e0a937c32a2afc1dff743037533b27f --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/extrema.h @@ -0,0 +1,88 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file extrema.h + * \brief Generic device implementations of extrema functions. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ +ForwardIterator max_element(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last); + + +template +__host__ __device__ +ForwardIterator max_element(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate comp); + + +template +__host__ __device__ +ForwardIterator min_element(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last); + + +template +__host__ __device__ +ForwardIterator min_element(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate comp); + + +template +__host__ __device__ +thrust::pair minmax_element(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last); + + +template +__host__ __device__ +thrust::pair minmax_element(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate comp); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/extrema.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/extrema.inl new file mode 100644 index 0000000000000000000000000000000000000000..744d137de1d876b221fdacecb58db7dd23ac1381 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/extrema.inl @@ -0,0 +1,262 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file distance.h + * \brief Device implementations for distance. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ +namespace detail +{ + + +////////////// +// Functors // +////////////// +// + +// return the smaller/larger element making sure to prefer the +// first occurance of the minimum/maximum element +template +struct min_element_reduction +{ + BinaryPredicate comp; + + __host__ __device__ + min_element_reduction(BinaryPredicate comp) : comp(comp){} + + __host__ __device__ + thrust::tuple + operator()(const thrust::tuple& lhs, + const thrust::tuple& rhs ) + { + if(comp(thrust::get<0>(lhs), thrust::get<0>(rhs))) + return lhs; + if(comp(thrust::get<0>(rhs), thrust::get<0>(lhs))) + return rhs; + + // values are equivalent, prefer value with smaller index + if(thrust::get<1>(lhs) < thrust::get<1>(rhs)) + return lhs; + else + return rhs; + } // end operator()() +}; // end min_element_reduction + + +template +struct max_element_reduction +{ + BinaryPredicate comp; + + __host__ __device__ + max_element_reduction(BinaryPredicate comp) : comp(comp){} + + __host__ __device__ + thrust::tuple + operator()(const thrust::tuple& lhs, + const thrust::tuple& rhs ) + { + if(comp(thrust::get<0>(lhs), thrust::get<0>(rhs))) + return rhs; + if(comp(thrust::get<0>(rhs), thrust::get<0>(lhs))) + return lhs; + + // values are equivalent, prefer value with smaller index + if(thrust::get<1>(lhs) < thrust::get<1>(rhs)) + return lhs; + else + return rhs; + } // end operator()() +}; // end max_element_reduction + + +// return the smaller & larger element making sure to prefer the +// first occurance of the minimum/maximum element +template +struct minmax_element_reduction +{ + BinaryPredicate comp; + + __host__ __device__ + minmax_element_reduction(BinaryPredicate comp) : comp(comp){} + + __host__ __device__ + thrust::tuple< thrust::tuple, thrust::tuple > + operator()(const thrust::tuple< thrust::tuple, thrust::tuple >& lhs, + const thrust::tuple< thrust::tuple, thrust::tuple >& rhs ) + { + + return thrust::make_tuple(min_element_reduction(comp)(thrust::get<0>(lhs), thrust::get<0>(rhs)), + max_element_reduction(comp)(thrust::get<1>(lhs), thrust::get<1>(rhs))); + } // end operator()() +}; // end minmax_element_reduction + + +template +struct duplicate_tuple +{ + __host__ __device__ + thrust::tuple< thrust::tuple, thrust::tuple > + operator()(const thrust::tuple& t) + { + return thrust::make_tuple(t, t); + } +}; // end duplicate_tuple + + +} // end namespace detail + + +template +__host__ __device__ +ForwardIterator min_element(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last) +{ + typedef typename thrust::iterator_value::type value_type; + + return thrust::min_element(exec, first, last, thrust::less()); +} // end min_element() + + +template +__host__ __device__ +ForwardIterator min_element(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate comp) +{ + if (first == last) + return last; + + typedef typename thrust::iterator_traits::value_type InputType; + typedef typename thrust::iterator_traits::difference_type IndexType; + + thrust::tuple result = + thrust::reduce + (exec, + thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator(0))), + thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator(0))) + (last - first), + thrust::tuple(thrust::detail::get_iterator_value(derived_cast(exec), first), 0), + detail::min_element_reduction(comp)); + + return first + thrust::get<1>(result); +} // end min_element() + + +template +__host__ __device__ +ForwardIterator max_element(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last) +{ + typedef typename thrust::iterator_value::type value_type; + + return thrust::max_element(exec, first, last, thrust::less()); +} // end max_element() + + +template +__host__ __device__ +ForwardIterator max_element(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate comp) +{ + if (first == last) + return last; + + typedef typename thrust::iterator_traits::value_type InputType; + typedef typename thrust::iterator_traits::difference_type IndexType; + + thrust::tuple result = + thrust::reduce + (exec, + thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator(0))), + thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator(0))) + (last - first), + thrust::tuple(thrust::detail::get_iterator_value(derived_cast(exec),first), 0), + detail::max_element_reduction(comp)); + + return first + thrust::get<1>(result); +} // end max_element() + + +template +__host__ __device__ +thrust::pair minmax_element(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last) +{ + typedef typename thrust::iterator_value::type value_type; + + return thrust::minmax_element(exec, first, last, thrust::less()); +} // end minmax_element() + + +template +__host__ __device__ +thrust::pair minmax_element(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate comp) +{ + if (first == last) + return thrust::make_pair(last, last); + + typedef typename thrust::iterator_traits::value_type InputType; + typedef typename thrust::iterator_traits::difference_type IndexType; + + thrust::tuple< thrust::tuple, thrust::tuple > result = + thrust::transform_reduce + (exec, + thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator(0))), + thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator(0))) + (last - first), + detail::duplicate_tuple(), + detail::duplicate_tuple()( + thrust::tuple(thrust::detail::get_iterator_value(derived_cast(exec),first), 0)), + detail::minmax_element_reduction(comp)); + + return thrust::make_pair(first + thrust::get<1>(thrust::get<0>(result)), first + thrust::get<1>(thrust::get<1>(result))); +} // end minmax_element() + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/fill.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/fill.h new file mode 100644 index 0000000000000000000000000000000000000000..5a881359b56b0f5a08fe6d3196ad8e9f6404088b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/fill.h @@ -0,0 +1,61 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + OutputIterator fill_n(thrust::execution_policy &exec, + OutputIterator first, + Size n, + const T &value) +{ + // XXX consider using the placeholder expression _1 = value + return thrust::generate_n(exec, first, n, thrust::detail::fill_functor(value)); +} + +template +__host__ __device__ + void fill(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + const T &value) +{ + // XXX consider using the placeholder expression _1 = value + thrust::generate(exec, first, last, thrust::detail::fill_functor(value)); +} + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/find.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/find.h new file mode 100644 index 0000000000000000000000000000000000000000..6db441d02f726b9e79607b840b6b13006f362ea0 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/find.h @@ -0,0 +1,62 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ +InputIterator find(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + const T& value); + + +template +__host__ __device__ +InputIterator find_if(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + Predicate pred); + + +template +__host__ __device__ +InputIterator find_if_not(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + Predicate pred); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/find.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/find.inl new file mode 100644 index 0000000000000000000000000000000000000000..8bd619561e92a4848a1bb3a034eff143236dabfc --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/find.inl @@ -0,0 +1,151 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + + +// Contributed by Erich Elsen + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ +InputIterator find(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + const T& value) +{ + using thrust::placeholders::_1; + + return thrust::find_if(exec, first, last, _1 == value); +} // end find() + + +template +struct find_if_functor +{ + __host__ __device__ + TupleType operator()(const TupleType& lhs, const TupleType& rhs) const + { + // select the smallest index among true results + if(thrust::get<0>(lhs) && thrust::get<0>(rhs)) + { + return TupleType(true, (thrust::min)(thrust::get<1>(lhs), thrust::get<1>(rhs))); + } + else if(thrust::get<0>(lhs)) + { + return lhs; + } + else + { + return rhs; + } + } +}; + + +template +__host__ __device__ +InputIterator find_if(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + Predicate pred) +{ + typedef typename thrust::iterator_traits::difference_type difference_type; + typedef typename thrust::tuple result_type; + + // empty sequence + if(first == last) return last; + + const difference_type n = thrust::distance(first, last); + + // this implementation breaks up the sequence into separate intervals + // in an attempt to early-out as soon as a value is found + + // TODO incorporate sizeof(InputType) into interval_threshold and round to multiple of 32 + const difference_type interval_threshold = 1 << 20; + const difference_type interval_size = (thrust::min)(interval_threshold, n); + + // force transform_iterator output to bool + typedef thrust::transform_iterator XfrmIterator; + typedef thrust::tuple > IteratorTuple; + typedef thrust::zip_iterator ZipIterator; + + IteratorTuple iter_tuple = thrust::make_tuple(XfrmIterator(first, pred), + thrust::counting_iterator(0)); + + ZipIterator begin = thrust::make_zip_iterator(iter_tuple); + ZipIterator end = begin + n; + + for(ZipIterator interval_begin = begin; interval_begin < end; interval_begin += interval_size) + { + ZipIterator interval_end = interval_begin + interval_size; + if(end < interval_end) + { + interval_end = end; + } // end if + + result_type result = thrust::reduce(exec, + interval_begin, interval_end, + result_type(false,interval_end - begin), + find_if_functor()); + + // see if we found something + if(thrust::get<0>(result)) + { + return first + thrust::get<1>(result); + } + } + + //nothing was found if we reach here... + return first + n; +} + + +template +__host__ __device__ +InputIterator find_if_not(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + Predicate pred) +{ + return thrust::find_if(exec, first, last, thrust::detail::not1(pred)); +} // end find() + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/for_each.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/for_each.h new file mode 100644 index 0000000000000000000000000000000000000000..3c2ec12cd21ffb7ad24c87b21fb05a9d25c5fd29 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/for_each.h @@ -0,0 +1,77 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +/*! \file for_each.h + * \brief Generic implementation of for_each & for_each_n. + * It is an error to call these functions; they have no implementation. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ +InputIterator for_each(thrust::execution_policy &, + InputIterator first, + InputIterator , + UnaryFunction ) +{ + THRUST_STATIC_ASSERT_MSG( + (thrust::detail::depend_on_instantiation::value) + , "unimplemented for this system" + ); + return first; +} // end for_each() + + +template +__host__ __device__ +InputIterator for_each_n(thrust::execution_policy &, + InputIterator first, + Size , + UnaryFunction ) +{ + THRUST_STATIC_ASSERT_MSG( + (thrust::detail::depend_on_instantiation::value) + , "unimplemented for this system" + ); + return first; +} // end for_each_n() + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/gather.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/gather.h new file mode 100644 index 0000000000000000000000000000000000000000..5b6b41831135ea1eadcf818115b053445bcdccf1 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/gather.h @@ -0,0 +1,80 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + OutputIterator gather(thrust::execution_policy &exec, + InputIterator map_first, + InputIterator map_last, + RandomAccessIterator input_first, + OutputIterator result); + + +template +__host__ __device__ + OutputIterator gather_if(thrust::execution_policy &exec, + InputIterator1 map_first, + InputIterator1 map_last, + InputIterator2 stencil, + RandomAccessIterator input_first, + OutputIterator result); + + +template +__host__ __device__ + OutputIterator gather_if(thrust::execution_policy &exec, + InputIterator1 map_first, + InputIterator1 map_last, + InputIterator2 stencil, + RandomAccessIterator input_first, + OutputIterator result, + Predicate pred); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/gather.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/gather.inl new file mode 100644 index 0000000000000000000000000000000000000000..7ab550edf144c64c9772bbde2c11531afd7679d4 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/gather.inl @@ -0,0 +1,108 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + OutputIterator gather(thrust::execution_policy &exec, + InputIterator map_first, + InputIterator map_last, + RandomAccessIterator input_first, + OutputIterator result) +{ + return thrust::transform(exec, + thrust::make_permutation_iterator(input_first, map_first), + thrust::make_permutation_iterator(input_first, map_last), + result, + thrust::identity::type>()); +} // end gather() + + +template +__host__ __device__ + OutputIterator gather_if(thrust::execution_policy &exec, + InputIterator1 map_first, + InputIterator1 map_last, + InputIterator2 stencil, + RandomAccessIterator input_first, + OutputIterator result) +{ + typedef typename thrust::iterator_value::type StencilType; + return thrust::gather_if(exec, + map_first, + map_last, + stencil, + input_first, + result, + thrust::identity()); +} // end gather_if() + + +template +__host__ __device__ + OutputIterator gather_if(thrust::execution_policy &exec, + InputIterator1 map_first, + InputIterator1 map_last, + InputIterator2 stencil, + RandomAccessIterator input_first, + OutputIterator result, + Predicate pred) +{ + typedef typename thrust::iterator_value::type InputType; + return thrust::transform_if(exec, + thrust::make_permutation_iterator(input_first, map_first), + thrust::make_permutation_iterator(input_first, map_last), + stencil, + result, + thrust::identity(), + pred); +} // end gather_if() + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/generate.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/generate.h new file mode 100644 index 0000000000000000000000000000000000000000..a9846c5bed6b8d43999a025784759312c642b547 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/generate.h @@ -0,0 +1,56 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + +template +__host__ __device__ + void generate(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Generator gen); + +template +__host__ __device__ + OutputIterator generate_n(thrust::execution_policy &exec, + OutputIterator first, + Size n, + Generator gen); + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/generate.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/generate.inl new file mode 100644 index 0000000000000000000000000000000000000000..869e0f32bf4d05ad1c7e8d15eb32fd46f489c834 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/generate.inl @@ -0,0 +1,100 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + +template +__host__ __device__ + void generate(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Generator gen) +{ + // this static assert is necessary due to a workaround in generate_functor + // it takes a const reference to accept temporaries from proxy iterators + // and then const_casts the constness away + // + // this had the weird side effect of allowing generate (and fill, and whatever + // else is implemented in terms of generate) to fill through const iterators. + // this might become unnecessary once Thrust is C++11-and-above only, since the + // other solution is to take an rvalue reference in a second overload of + // operator() of the function object, but until we support pre-11, this is a + // nice solution that validates the const_cast and doesn't take away any + // functionality. + THRUST_STATIC_ASSERT_MSG( + !thrust::detail::is_const< + typename thrust::detail::remove_reference< + typename thrust::iterator_traits::reference + >::type + >::value + , "generating to `const` iterators is not allowed" + ); + thrust::for_each(exec, first, last, typename thrust::detail::generate_functor::type(gen)); +} // end generate() + +template +__host__ __device__ + OutputIterator generate_n(thrust::execution_policy &exec, + OutputIterator first, + Size n, + Generator gen) +{ + // this static assert is necessary due to a workaround in generate_functor + // it takes a const reference to accept temporaries from proxy iterators + // and then const_casts the constness away + // + // this had the weird side effect of allowing generate (and fill, and whatever + // else is implemented in terms of generate) to fill through const iterators. + // this might become unnecessary once Thrust is C++11-and-above only, since the + // other solution is to take an rvalue reference in a second overload of + // operator() of the function object, but until we support pre-11, this is a + // nice solution that validates the const_cast and doesn't take away any + // functionality. + THRUST_STATIC_ASSERT_MSG( + !thrust::detail::is_const< + typename thrust::detail::remove_reference< + typename thrust::iterator_traits::reference + >::type + >::value + , "generating to `const` iterators is not allowed" + ); + return thrust::for_each_n(exec, first, n, typename thrust::detail::generate_functor::type(gen)); +} // end generate() + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/inner_product.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/inner_product.h new file mode 100644 index 0000000000000000000000000000000000000000..62d10d31f588643d3a71ebcd069c4a72a05f12b5 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/inner_product.h @@ -0,0 +1,58 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + OutputType inner_product(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + OutputType init); + + +template +__host__ __device__ +OutputType inner_product(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + OutputType init, + BinaryFunction1 binary_op1, + BinaryFunction2 binary_op2); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/inner_product.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/inner_product.inl new file mode 100644 index 0000000000000000000000000000000000000000..5055ec10f665a7ea2387e9657762999b6dac14f3 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/inner_product.inl @@ -0,0 +1,73 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ +OutputType inner_product(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + OutputType init) +{ + thrust::plus binary_op1; + thrust::multiplies binary_op2; + return thrust::inner_product(exec, first1, last1, first2, init, binary_op1, binary_op2); +} // end inner_product() + + +template +__host__ __device__ +OutputType inner_product(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + OutputType init, + BinaryFunction1 binary_op1, + BinaryFunction2 binary_op2) +{ + typedef thrust::zip_iterator > ZipIter; + + ZipIter first = thrust::make_zip_iterator(thrust::make_tuple(first1,first2)); + + // only the first iterator in the tuple is relevant for the purposes of last + ZipIter last = thrust::make_zip_iterator(thrust::make_tuple(last1, first2)); + + return thrust::transform_reduce(exec, first, last, thrust::detail::zipped_binary_op(binary_op2), init, binary_op1); +} // end inner_product() + + +} // end generic +} // end detail +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/logical.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/logical.h new file mode 100644 index 0000000000000000000000000000000000000000..e261154e248757c6de78659ee2529d5314b23ec1 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/logical.h @@ -0,0 +1,62 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ +bool all_of(thrust::execution_policy &exec, InputIterator first, InputIterator last, Predicate pred) +{ + return thrust::find_if(exec, first, last, thrust::detail::not1(pred)) == last; +} + + +template +__host__ __device__ +bool any_of(thrust::execution_policy &exec, InputIterator first, InputIterator last, Predicate pred) +{ + return thrust::find_if(exec, first, last, pred) != last; +} + + +template +__host__ __device__ +bool none_of(thrust::execution_policy &exec, InputIterator first, InputIterator last, Predicate pred) +{ + return !thrust::any_of(exec, first, last, pred); +} + + +} // end generic +} // end detail +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/memory.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/memory.h new file mode 100644 index 0000000000000000000000000000000000000000..675cc73023c274cea1bd940266da3a14f2849b32 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/memory.h @@ -0,0 +1,70 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file generic/memory.h + * \brief Generic implementation of memory functions. + * Calling some of these is an error. They have no implementation. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + +template +__host__ __device__ +void malloc(thrust::execution_policy &, Size); + +template +__host__ __device__ +thrust::pointer malloc(thrust::execution_policy &s, std::size_t n); + +template +__host__ __device__ +void free(thrust::execution_policy &, Pointer); + +template +__host__ __device__ +void assign_value(tag, Pointer1, Pointer2); + +template +__host__ __device__ +void get_value(thrust::execution_policy &, Pointer); + +template +__host__ __device__ +void iter_swap(thrust::execution_policy&, Pointer1, Pointer2); + +} // end generic +} // end detail +} // end system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/memory.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/memory.inl new file mode 100644 index 0000000000000000000000000000000000000000..b857290985ce40be0811ed6a9858d0665dc6fa34 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/memory.inl @@ -0,0 +1,105 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + void malloc(thrust::execution_policy &, Size) +{ + THRUST_STATIC_ASSERT_MSG( + (thrust::detail::depend_on_instantiation::value) + , "unimplemented for this system" + ); +} + + +template +__host__ __device__ + thrust::pointer + malloc(thrust::execution_policy &exec, std::size_t n) +{ + thrust::pointer void_ptr = thrust::malloc(exec, sizeof(T) * n); + + return pointer(static_cast(void_ptr.get())); +} // end malloc() + + +template +__host__ __device__ + void free(thrust::execution_policy &, Pointer) +{ + THRUST_STATIC_ASSERT_MSG( + (thrust::detail::depend_on_instantiation::value) + , "unimplemented for this system" + ); +} + + +template +__host__ __device__ +void assign_value(thrust::execution_policy &, Pointer1, Pointer2) +{ + THRUST_STATIC_ASSERT_MSG( + (thrust::detail::depend_on_instantiation::value) + , "unimplemented for this system" + ); +} + + +template +__host__ __device__ +void get_value(thrust::execution_policy &, Pointer) +{ + THRUST_STATIC_ASSERT_MSG( + (thrust::detail::depend_on_instantiation::value) + , "unimplemented for this system" + ); +} + + +template +__host__ __device__ +void iter_swap(thrust::execution_policy &, Pointer1, Pointer2) +{ + THRUST_STATIC_ASSERT_MSG( + (thrust::detail::depend_on_instantiation::value) + , "unimplemented for this system" + ); +} + + +} // end generic +} // end detail +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/merge.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/merge.h new file mode 100644 index 0000000000000000000000000000000000000000..6e82464074e1dbeaddf60e9fa2ed1d67a85baa14 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/merge.h @@ -0,0 +1,90 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +// XXX calling this function is an error; there is no implementation +template +__host__ __device__ + OutputIterator merge(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result, + StrictWeakOrdering comp); + + +template +__host__ __device__ + OutputIterator merge(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result); + + +template +__host__ __device__ + thrust::pair + merge_by_key(thrust::execution_policy &exec, + InputIterator1 keys_first1, InputIterator1 keys_last1, + InputIterator2 keys_first2, InputIterator2 keys_last2, + InputIterator3 values_first1, InputIterator4 values_first2, + OutputIterator1 keys_result, + OutputIterator2 values_result, + Compare comp); + + +template +__host__ __device__ + thrust::pair + merge_by_key(thrust::execution_policy &exec, + InputIterator1 keys_first1, InputIterator1 keys_last1, + InputIterator2 keys_first2, InputIterator2 keys_last2, + InputIterator3 values_first1, InputIterator4 values_first2, + OutputIterator1 keys_result, + OutputIterator2 values_result); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/merge.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/merge.inl new file mode 100644 index 0000000000000000000000000000000000000000..03b77e6235b542840e9f3867e211fa07665ac34a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/merge.inl @@ -0,0 +1,130 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + OutputIterator merge(thrust::execution_policy &, + InputIterator1, + InputIterator1, + InputIterator2, + InputIterator2, + OutputIterator result, + StrictWeakOrdering) +{ + THRUST_STATIC_ASSERT_MSG( + (thrust::detail::depend_on_instantiation::value) + , "unimplemented for this system" + ); + return result; +} // end merge() + + +template +__host__ __device__ + OutputIterator merge(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result) +{ + typedef typename thrust::iterator_value::type value_type; + return thrust::merge(exec,first1,last1,first2,last2,result,thrust::less()); +} // end merge() + + +template +__host__ __device__ + thrust::pair + merge_by_key(thrust::execution_policy &exec, + InputIterator1 keys_first1, InputIterator1 keys_last1, + InputIterator2 keys_first2, InputIterator2 keys_last2, + InputIterator3 values_first1, InputIterator4 values_first2, + OutputIterator1 keys_result, + OutputIterator2 values_result, + Compare comp) +{ + typedef thrust::tuple iterator_tuple1; + typedef thrust::tuple iterator_tuple2; + typedef thrust::tuple iterator_tuple3; + + typedef thrust::zip_iterator zip_iterator1; + typedef thrust::zip_iterator zip_iterator2; + typedef thrust::zip_iterator zip_iterator3; + + zip_iterator1 zipped_first1 = thrust::make_zip_iterator(thrust::make_tuple(keys_first1, values_first1)); + zip_iterator1 zipped_last1 = thrust::make_zip_iterator(thrust::make_tuple(keys_last1, values_first1)); + + zip_iterator2 zipped_first2 = thrust::make_zip_iterator(thrust::make_tuple(keys_first2, values_first2)); + zip_iterator2 zipped_last2 = thrust::make_zip_iterator(thrust::make_tuple(keys_last2, values_first2)); + + zip_iterator3 zipped_result = thrust::make_zip_iterator(thrust::make_tuple(keys_result, values_result)); + + thrust::detail::compare_first comp_first(comp); + + iterator_tuple3 result = thrust::merge(exec, zipped_first1, zipped_last1, zipped_first2, zipped_last2, zipped_result, comp_first).get_iterator_tuple(); + + return thrust::make_pair(thrust::get<0>(result), thrust::get<1>(result)); +} // end merge_by_key() + + +template +__host__ __device__ + thrust::pair + merge_by_key(thrust::execution_policy &exec, + InputIterator1 keys_first1, InputIterator1 keys_last1, + InputIterator2 keys_first2, InputIterator2 keys_last2, + InputIterator3 values_first1, InputIterator4 values_first2, + OutputIterator1 keys_result, + OutputIterator2 values_result) +{ + typedef typename thrust::iterator_value::type value_type; + return thrust::merge_by_key(exec, keys_first1, keys_last1, keys_first2, keys_last2, values_first1, values_first2, keys_result, values_result, thrust::less()); +} // end merge_by_key() + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/mismatch.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/mismatch.h new file mode 100644 index 0000000000000000000000000000000000000000..4a71cd344142a7d95d24e5e998925002757ec5f6 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/mismatch.h @@ -0,0 +1,57 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + thrust::pair + mismatch(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2); + + +template +__host__ __device__ + thrust::pair + mismatch(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + BinaryPredicate pred); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/mismatch.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/mismatch.inl new file mode 100644 index 0000000000000000000000000000000000000000..f6b9674a1cc6c9c1caacefb3a49a7553f9573046 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/mismatch.inl @@ -0,0 +1,75 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + thrust::pair + mismatch(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2) +{ + using namespace thrust::placeholders; + + return thrust::mismatch(exec, first1, last1, first2, _1 == _2); +} // end mismatch() + + +template +__host__ __device__ + thrust::pair + mismatch(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + BinaryPredicate pred) +{ + // Contributed by Erich Elsen + typedef thrust::tuple IteratorTuple; + typedef thrust::zip_iterator ZipIterator; + + ZipIterator zipped_first = thrust::make_zip_iterator(thrust::make_tuple(first1,first2)); + ZipIterator zipped_last = thrust::make_zip_iterator(thrust::make_tuple(last1, first2)); + + ZipIterator result = thrust::find_if_not(exec, zipped_first, zipped_last, thrust::detail::tuple_binary_predicate(pred)); + + return thrust::make_pair(thrust::get<0>(result.get_iterator_tuple()), + thrust::get<1>(result.get_iterator_tuple())); +} // end mismatch() + + +} // end generic +} // end detail +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/partition.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/partition.h new file mode 100644 index 0000000000000000000000000000000000000000..113d6ecbc3d369aa173d3c675e221f9991c87674 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/partition.h @@ -0,0 +1,169 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file partition.h + * \brief Generic implementations of partition functions. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + ForwardIterator stable_partition(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Predicate pred); + +template +__host__ __device__ + ForwardIterator stable_partition(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + InputIterator stencil, + Predicate pred); + + +template +__host__ __device__ + thrust::pair + stable_partition_copy(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator1 out_true, + OutputIterator2 out_false, + Predicate pred); + + +template +__host__ __device__ + thrust::pair + stable_partition_copy(thrust::execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator1 out_true, + OutputIterator2 out_false, + Predicate pred); + + +template +__host__ __device__ + ForwardIterator partition(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Predicate pred); + + +template +__host__ __device__ + ForwardIterator partition(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + InputIterator stencil, + Predicate pred); + + +template +__host__ __device__ + thrust::pair + partition_copy(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator1 out_true, + OutputIterator2 out_false, + Predicate pred); + + +template +__host__ __device__ + thrust::pair + partition_copy(thrust::execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator1 out_true, + OutputIterator2 out_false, + Predicate pred); + + +template +__host__ __device__ + ForwardIterator partition_point(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Predicate pred); + + +template +__host__ __device__ + bool is_partitioned(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + Predicate pred); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/partition.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/partition.inl new file mode 100644 index 0000000000000000000000000000000000000000..ab56fdd575125485154513f03a38c3f677e00ad5 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/partition.inl @@ -0,0 +1,249 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + ForwardIterator stable_partition(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Predicate pred) +{ + typedef typename thrust::iterator_traits::value_type InputType; + + // copy input to temp buffer + thrust::detail::temporary_array temp(exec, first, last); + + // count the size of the true partition + typename thrust::iterator_difference::type num_true = thrust::count_if(exec, first,last,pred); + + // point to the beginning of the false partition + ForwardIterator out_false = first; + thrust::advance(out_false, num_true); + + return thrust::stable_partition_copy(exec, temp.begin(), temp.end(), first, out_false, pred).first; +} // end stable_partition() + + +template +__host__ __device__ + ForwardIterator stable_partition(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + InputIterator stencil, + Predicate pred) +{ + typedef typename thrust::iterator_traits::value_type InputType; + + // copy input to temp buffer + thrust::detail::temporary_array temp(exec, first, last); + + // count the size of the true partition + InputIterator stencil_last = stencil; + thrust::advance(stencil_last, temp.size()); + typename thrust::iterator_difference::type num_true = thrust::count_if(exec, stencil, stencil_last, pred); + + // point to the beginning of the false partition + ForwardIterator out_false = first; + thrust::advance(out_false, num_true); + + return thrust::stable_partition_copy(exec, temp.begin(), temp.end(), stencil, first, out_false, pred).first; +} // end stable_partition() + + +template +__host__ __device__ + thrust::pair + stable_partition_copy(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator1 out_true, + OutputIterator2 out_false, + Predicate pred) +{ + thrust::detail::unary_negate not_pred(pred); + + // remove_copy_if the true partition to out_true + OutputIterator1 end_of_true_partition = thrust::remove_copy_if(exec, first, last, out_true, not_pred); + + // remove_copy_if the false partition to out_false + OutputIterator2 end_of_false_partition = thrust::remove_copy_if(exec, first, last, out_false, pred); + + return thrust::make_pair(end_of_true_partition, end_of_false_partition); +} // end stable_partition_copy() + + +template +__host__ __device__ + thrust::pair + stable_partition_copy(thrust::execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator1 out_true, + OutputIterator2 out_false, + Predicate pred) +{ + thrust::detail::unary_negate not_pred(pred); + + // remove_copy_if the true partition to out_true + OutputIterator1 end_of_true_partition = thrust::remove_copy_if(exec, first, last, stencil, out_true, not_pred); + + // remove_copy_if the false partition to out_false + OutputIterator2 end_of_false_partition = thrust::remove_copy_if(exec, first, last, stencil, out_false, pred); + + return thrust::make_pair(end_of_true_partition, end_of_false_partition); +} // end stable_partition_copy() + + +template +__host__ __device__ + ForwardIterator partition(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Predicate pred) +{ + return thrust::stable_partition(exec, first, last, pred); +} // end partition() + + +template +__host__ __device__ + ForwardIterator partition(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + InputIterator stencil, + Predicate pred) +{ + return thrust::stable_partition(exec, first, last, stencil, pred); +} // end partition() + + +template +__host__ __device__ + thrust::pair + partition_copy(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator1 out_true, + OutputIterator2 out_false, + Predicate pred) +{ + return thrust::stable_partition_copy(exec,first,last,out_true,out_false,pred); +} // end partition_copy() + + +template +__host__ __device__ + thrust::pair + partition_copy(thrust::execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator1 out_true, + OutputIterator2 out_false, + Predicate pred) +{ + return thrust::stable_partition_copy(exec,first,last,stencil,out_true,out_false,pred); +} // end partition_copy() + + +template +__host__ __device__ + ForwardIterator partition_point(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Predicate pred) +{ + return thrust::find_if_not(exec, first, last, pred); +} // end partition_point() + + +template +__host__ __device__ + bool is_partitioned(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + Predicate pred) +{ + return thrust::is_sorted(exec, + thrust::make_transform_iterator(first, thrust::detail::not1(pred)), + thrust::make_transform_iterator(last, thrust::detail::not1(pred))); +} // end is_partitioned() + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/per_device_resource.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/per_device_resource.h new file mode 100644 index 0000000000000000000000000000000000000000..606f91f365817f2890effc44ea64ef9980302ea0 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/per_device_resource.h @@ -0,0 +1,46 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ +MR * get_per_device_resource(thrust::detail::execution_policy_base&) +{ + return mr::get_global_resource(); +} + + +} // end generic +} // end detail +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/reduce.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/reduce.h new file mode 100644 index 0000000000000000000000000000000000000000..f28b11a87bb7d3dd402198b3f1a680d3e5ba6d4f --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/reduce.h @@ -0,0 +1,58 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + typename thrust::iterator_traits::value_type + reduce(thrust::execution_policy &exec, InputIterator first, InputIterator last); + + +template +__host__ __device__ + T reduce(thrust::execution_policy &exec, InputIterator first, InputIterator last, T init); + + +template +__host__ __device__ + T reduce(thrust::execution_policy &exec, InputIterator first, InputIterator last, T init, BinaryFunction binary_op); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/reduce.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/reduce.inl new file mode 100644 index 0000000000000000000000000000000000000000..d673d0cf882c1ebb2f3fffb34ec863a40623f6b5 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/reduce.inl @@ -0,0 +1,80 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + typename thrust::iterator_traits::value_type + reduce(thrust::execution_policy &exec, InputIterator first, InputIterator last) +{ + typedef typename thrust::iterator_value::type InputType; + + // use InputType(0) as init by default + return thrust::reduce(exec, first, last, InputType(0)); +} // end reduce() + + +template +__host__ __device__ + T reduce(thrust::execution_policy &exec, InputIterator first, InputIterator last, T init) +{ + // use plus by default + return thrust::reduce(exec, first, last, init, thrust::plus()); +} // end reduce() + + +template +__host__ __device__ + OutputType reduce(thrust::execution_policy &, + RandomAccessIterator, + RandomAccessIterator, + OutputType, + BinaryFunction) +{ + THRUST_STATIC_ASSERT_MSG( + (thrust::detail::depend_on_instantiation::value) + , "unimplemented for this system" + ); + return OutputType(); +} // end reduce() + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/reduce_by_key.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/reduce_by_key.h new file mode 100644 index 0000000000000000000000000000000000000000..8ba47e11f0a90fe836d6a83e107e7c5db35f80e2 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/reduce_by_key.h @@ -0,0 +1,88 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + thrust::pair + reduce_by_key(thrust::execution_policy &exec, + InputIterator1 keys_first, + InputIterator1 keys_last, + InputIterator2 values_first, + OutputIterator1 keys_output, + OutputIterator2 values_output); + +template +__host__ __device__ + thrust::pair + reduce_by_key(thrust::execution_policy &exec, + InputIterator1 keys_first, + InputIterator1 keys_last, + InputIterator2 values_first, + OutputIterator1 keys_output, + OutputIterator2 values_output, + BinaryPredicate binary_pred); + +template +__host__ __device__ + thrust::pair + reduce_by_key(thrust::execution_policy &exec, + InputIterator1 keys_first, + InputIterator1 keys_last, + InputIterator2 values_first, + OutputIterator1 keys_output, + OutputIterator2 values_output, + BinaryPredicate binary_pred, + BinaryFunction binary_op); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/reduce_by_key.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/reduce_by_key.inl new file mode 100644 index 0000000000000000000000000000000000000000..2ea73fedaa190a87bd17189b8bfa1ce169388ac8 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/reduce_by_key.inl @@ -0,0 +1,193 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ +namespace detail +{ + + +template +struct reduce_by_key_functor +{ + AssociativeOperator binary_op; + + typedef typename thrust::tuple result_type; + + __host__ __device__ + reduce_by_key_functor(AssociativeOperator _binary_op) : binary_op(_binary_op) {} + + __host__ __device__ + result_type operator()(result_type a, result_type b) + { + return result_type(thrust::get<1>(b) ? thrust::get<0>(b) : binary_op(thrust::get<0>(a), thrust::get<0>(b)), + thrust::get<1>(a) | thrust::get<1>(b)); + } +}; + + +} // end namespace detail + + +template +__host__ __device__ + thrust::pair + reduce_by_key(thrust::execution_policy &exec, + InputIterator1 keys_first, + InputIterator1 keys_last, + InputIterator2 values_first, + OutputIterator1 keys_output, + OutputIterator2 values_output, + BinaryPredicate binary_pred, + BinaryFunction binary_op) +{ + typedef typename thrust::iterator_traits::difference_type difference_type; + + typedef unsigned int FlagType; // TODO use difference_type + + // Use the input iterator's value type per https://wg21.link/P0571 + using ValueType = typename thrust::iterator_value::type; + + if (keys_first == keys_last) + return thrust::make_pair(keys_output, values_output); + + // input size + difference_type n = keys_last - keys_first; + + InputIterator2 values_last = values_first + n; + + // compute head flags + thrust::detail::temporary_array head_flags(exec, n); + thrust::transform(exec, keys_first, keys_last - 1, keys_first + 1, head_flags.begin() + 1, thrust::detail::not2(binary_pred)); + head_flags[0] = 1; + + // compute tail flags + thrust::detail::temporary_array tail_flags(exec, n); //COPY INSTEAD OF TRANSFORM + thrust::transform(exec, keys_first, keys_last - 1, keys_first + 1, tail_flags.begin(), thrust::detail::not2(binary_pred)); + tail_flags[n-1] = 1; + + // scan the values by flag + thrust::detail::temporary_array scanned_values(exec, n); + thrust::detail::temporary_array scanned_tail_flags(exec, n); + + thrust::inclusive_scan + (exec, + thrust::make_zip_iterator(thrust::make_tuple(values_first, head_flags.begin())), + thrust::make_zip_iterator(thrust::make_tuple(values_last, head_flags.end())), + thrust::make_zip_iterator(thrust::make_tuple(scanned_values.begin(), scanned_tail_flags.begin())), + detail::reduce_by_key_functor(binary_op)); + + thrust::exclusive_scan(exec, tail_flags.begin(), tail_flags.end(), scanned_tail_flags.begin(), FlagType(0), thrust::plus()); + + // number of unique keys + FlagType N = scanned_tail_flags[n - 1] + 1; + + // scatter the keys and accumulated values + thrust::scatter_if(exec, keys_first, keys_last, scanned_tail_flags.begin(), head_flags.begin(), keys_output); + thrust::scatter_if(exec, scanned_values.begin(), scanned_values.end(), scanned_tail_flags.begin(), tail_flags.begin(), values_output); + + return thrust::make_pair(keys_output + N, values_output + N); +} // end reduce_by_key() + + +template +__host__ __device__ + thrust::pair + reduce_by_key(thrust::execution_policy &exec, + InputIterator1 keys_first, + InputIterator1 keys_last, + InputIterator2 values_first, + OutputIterator1 keys_output, + OutputIterator2 values_output) +{ + typedef typename thrust::iterator_value::type KeyType; + + // use equal_to as default BinaryPredicate + return thrust::reduce_by_key(exec, keys_first, keys_last, values_first, keys_output, values_output, thrust::equal_to()); +} // end reduce_by_key() + + +template +__host__ __device__ + thrust::pair + reduce_by_key(thrust::execution_policy &exec, + InputIterator1 keys_first, + InputIterator1 keys_last, + InputIterator2 values_first, + OutputIterator1 keys_output, + OutputIterator2 values_output, + BinaryPredicate binary_pred) +{ + typedef typename thrust::detail::eval_if< + thrust::detail::is_output_iterator::value, + thrust::iterator_value, + thrust::iterator_value + >::type T; + + // use plus as default BinaryFunction + return thrust::reduce_by_key(exec, + keys_first, keys_last, + values_first, + keys_output, + values_output, + binary_pred, + thrust::plus()); +} // end reduce_by_key() + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/remove.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/remove.h new file mode 100644 index 0000000000000000000000000000000000000000..37354ef805cc0ac857e13c289bec94400b1faf9d --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/remove.h @@ -0,0 +1,112 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file remove.h + * \brief Generic implementations of remove functions. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + ForwardIterator remove(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + const T &value); + + +template +__host__ __device__ + OutputIterator remove_copy(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + const T &value); + + +template +__host__ __device__ + ForwardIterator remove_if(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Predicate pred); + + +template +__host__ __device__ + ForwardIterator remove_if(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + InputIterator stencil, + Predicate pred); + + +template +__host__ __device__ + OutputIterator remove_copy_if(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + Predicate pred); + + +template +__host__ __device__ + OutputIterator remove_copy_if(thrust::execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator result, + Predicate pred); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/remove.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/remove.inl new file mode 100644 index 0000000000000000000000000000000000000000..e51a3caeee1b38875a591b0add43ad050450eb1b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/remove.inl @@ -0,0 +1,146 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + ForwardIterator remove(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + const T &value) +{ + thrust::detail::equal_to_value pred(value); + + // XXX consider using a placeholder here + return thrust::remove_if(exec, first, last, pred); +} // end remove() + + +template +__host__ __device__ + OutputIterator remove_copy(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + const T &value) +{ + thrust::detail::equal_to_value pred(value); + + // XXX consider using a placeholder here + return thrust::remove_copy_if(exec, first, last, result, pred); +} // end remove_copy() + + +template +__host__ __device__ + ForwardIterator remove_if(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Predicate pred) +{ + typedef typename thrust::iterator_traits::value_type InputType; + + // create temporary storage for an intermediate result + thrust::detail::temporary_array temp(exec, first, last); + + // remove into temp + return thrust::remove_copy_if(exec, temp.begin(), temp.end(), temp.begin(), first, pred); +} // end remove_if() + + +template +__host__ __device__ + ForwardIterator remove_if(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + InputIterator stencil, + Predicate pred) +{ + typedef typename thrust::iterator_traits::value_type InputType; + + // create temporary storage for an intermediate result + thrust::detail::temporary_array temp(exec, first, last); + + // remove into temp + return thrust::remove_copy_if(exec, temp.begin(), temp.end(), stencil, first, pred); +} // end remove_if() + + +template +__host__ __device__ + OutputIterator remove_copy_if(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + Predicate pred) +{ + return thrust::remove_copy_if(exec, first, last, first, result, pred); +} // end remove_copy_if() + + +template +__host__ __device__ + OutputIterator remove_copy_if(thrust::execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator result, + Predicate pred) +{ + return thrust::copy_if(exec, first, last, stencil, result, thrust::detail::not1(pred)); +} // end remove_copy_if() + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/replace.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/replace.h new file mode 100644 index 0000000000000000000000000000000000000000..0821d6c07db9ec922d5d3de667103bc4662d9960 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/replace.h @@ -0,0 +1,97 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + OutputIterator replace_copy_if(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + Predicate pred, + const T &new_value); + + +template +__host__ __device__ + OutputIterator replace_copy_if(thrust::execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator result, + Predicate pred, + const T &new_value); + + +template +__host__ __device__ + OutputIterator replace_copy(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + const T &old_value, + const T &new_value); + + +template +__host__ __device__ + void replace_if(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Predicate pred, + const T &new_value); + + +template +__host__ __device__ + void replace_if(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + InputIterator stencil, + Predicate pred, + const T &new_value); + + +template +__host__ __device__ + void replace(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + const T &old_value, + const T &new_value); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/replace.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/replace.inl new file mode 100644 index 0000000000000000000000000000000000000000..ed845dd458c9934ec8b1a6a80df617ceb2822920 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/replace.inl @@ -0,0 +1,179 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ +namespace detail +{ + + +// this functor receives x, and returns a new_value if predicate(x) is true; otherwise, +// it returns x +template + struct new_value_if +{ + __host__ __device__ + new_value_if(Predicate p, NewType nv):pred(p),new_value(nv){} + + template + __host__ __device__ + OutputType operator()(const InputType &x) const + { + return pred(x) ? new_value : x; + } // end operator()() + + // this version of operator()() works like the previous but + // feeds its second argument to pred + template + __host__ __device__ + OutputType operator()(const InputType &x, const PredicateArgumentType &y) + { + return pred(y) ? new_value : x; + } // end operator()() + + Predicate pred; + NewType new_value; +}; // end new_value_if + + +// this unary functor ignores its argument and returns a constant +template + struct constant_unary +{ + __host__ __device__ + constant_unary(T _c):c(_c){} + + template + __host__ __device__ + T operator()(U &) + { + return c; + } // end operator()() + + T c; +}; // end constant_unary + + +} // end detail + + +template +__host__ __device__ + OutputIterator replace_copy_if(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + Predicate pred, + const T &new_value) +{ + typedef typename thrust::iterator_traits::value_type OutputType; + + detail::new_value_if op(pred,new_value); + return thrust::transform(exec, first, last, result, op); +} // end replace_copy_if() + + +template +__host__ __device__ + OutputIterator replace_copy_if(thrust::execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator result, + Predicate pred, + const T &new_value) +{ + typedef typename thrust::iterator_traits::value_type OutputType; + + detail::new_value_if op(pred,new_value); + return thrust::transform(exec, first, last, stencil, result, op); +} // end replace_copy_if() + + +template +__host__ __device__ + OutputIterator replace_copy(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + const T &old_value, + const T &new_value) +{ + using thrust::placeholders::_1; + + return thrust::replace_copy_if(exec, first, last, result, _1 == old_value, new_value); +} // end replace_copy() + + +template +__host__ __device__ + void replace_if(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Predicate pred, + const T &new_value) +{ + detail::constant_unary f(new_value); + thrust::transform_if(exec, first, last, first, first, f, pred); +} // end replace_if() + + +template +__host__ __device__ + void replace_if(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + InputIterator stencil, + Predicate pred, + const T &new_value) +{ + detail::constant_unary f(new_value); + thrust::transform_if(exec, first, last, stencil, first, f, pred); +} // end replace_if() + + +template +__host__ __device__ + void replace(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + const T &old_value, + const T &new_value) +{ + using thrust::placeholders::_1; + + return thrust::replace_if(exec, first, last, _1 == old_value, new_value); +} // end replace() + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/reverse.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/reverse.h new file mode 100644 index 0000000000000000000000000000000000000000..65c77ae75024b20c87ff510df9646ddf0f6fcbcd --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/reverse.h @@ -0,0 +1,55 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + void reverse(thrust::execution_policy &exec, + BidirectionalIterator first, + BidirectionalIterator last); + + +template +__host__ __device__ + OutputIterator reverse_copy(thrust::execution_policy &exec, + BidirectionalIterator first, + BidirectionalIterator last, + OutputIterator result); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/reverse.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/reverse.inl new file mode 100644 index 0000000000000000000000000000000000000000..1ce6db38b988e26a907e5d3940e59018e5f04a7d --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/reverse.inl @@ -0,0 +1,76 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + void reverse(thrust::execution_policy &exec, + BidirectionalIterator first, + BidirectionalIterator last) +{ + typedef typename thrust::iterator_difference::type difference_type; + + // find the midpoint of [first,last) + difference_type N = thrust::distance(first, last); + BidirectionalIterator mid(first); + thrust::advance(mid, N / 2); + + // swap elements of [first,mid) with [last - 1, mid) + thrust::swap_ranges(exec, first, mid, thrust::make_reverse_iterator(last)); +} // end reverse() + + +template +__host__ __device__ + OutputIterator reverse_copy(thrust::execution_policy &exec, + BidirectionalIterator first, + BidirectionalIterator last, + OutputIterator result) +{ + return thrust::copy(exec, + thrust::make_reverse_iterator(last), + thrust::make_reverse_iterator(first), + result); +} // end reverse_copy() + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scalar/binary_search.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scalar/binary_search.h new file mode 100644 index 0000000000000000000000000000000000000000..3e019c2233e28b9bae9b3f5e54d3c5de7414a828 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scalar/binary_search.h @@ -0,0 +1,84 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN + +namespace system +{ + +namespace detail +{ + +namespace generic +{ + +namespace scalar +{ + +template +__host__ __device__ +RandomAccessIterator lower_bound_n(RandomAccessIterator first, + Size n, + const T &val, + BinaryPredicate comp); + +template +__host__ __device__ +RandomAccessIterator lower_bound(RandomAccessIterator first, RandomAccessIterator last, + const T &val, + BinaryPredicate comp); + +template +__host__ __device__ +RandomAccessIterator upper_bound_n(RandomAccessIterator first, + Size n, + const T &val, + BinaryPredicate comp); + +template +__host__ __device__ +RandomAccessIterator upper_bound(RandomAccessIterator first, RandomAccessIterator last, + const T &val, + BinaryPredicate comp); + +template +__host__ __device__ + pair + equal_range(RandomAccessIterator first, RandomAccessIterator last, + const T &val, + BinaryPredicate comp); + +template +__host__ __device__ +bool binary_search(RandomAccessIterator first, RandomAccessIterator last, const T &value, Compare comp); + +} // end scalar + +} // end generic + +} // end detail + +} // end system + +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scalar/binary_search.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scalar/binary_search.inl new file mode 100644 index 0000000000000000000000000000000000000000..61c71fba4df358e5be24202604005d1bafbf02fa --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scalar/binary_search.inl @@ -0,0 +1,157 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN + +namespace system +{ + +namespace detail +{ + +namespace generic +{ + +namespace scalar +{ + +template +__host__ __device__ +RandomAccessIterator lower_bound_n(RandomAccessIterator first, + Size n, + const T &val, + BinaryPredicate comp) +{ + // wrap comp + thrust::detail::wrapped_function< + BinaryPredicate, + bool + > wrapped_comp(comp); + + Size start = 0, i; + while(start < n) + { + i = start + (n - start) / 2; // Overflow-safe variant of (a+b)/2 + if(wrapped_comp(first[i], val)) + { + start = i + 1; + } + else + { + n = i; + } + } // end while + + return first + start; +} + +// XXX generalize these upon implementation of scalar::distance & scalar::advance + +template +__host__ __device__ +RandomAccessIterator lower_bound(RandomAccessIterator first, RandomAccessIterator last, + const T &val, + BinaryPredicate comp) +{ + typename thrust::iterator_difference::type n = last - first; + return lower_bound_n(first, n, val, comp); +} + +template +__host__ __device__ +RandomAccessIterator upper_bound_n(RandomAccessIterator first, + Size n, + const T &val, + BinaryPredicate comp) +{ + // wrap comp + thrust::detail::wrapped_function< + BinaryPredicate, + bool + > wrapped_comp(comp); + + Size start = 0, i; + while(start < n) + { + i = start + (n - start) / 2; // Overflow-safe variant of (a+b)/2 + if(wrapped_comp(val, first[i])) + { + n = i; + } + else + { + start = i + 1; + } + } // end while + + return first + start; +} + +template +__host__ __device__ +RandomAccessIterator upper_bound(RandomAccessIterator first, RandomAccessIterator last, + const T &val, + BinaryPredicate comp) +{ + typename thrust::iterator_difference::type n = last - first; + return upper_bound_n(first, n, val, comp); +} + +template +__host__ __device__ + pair + equal_range(RandomAccessIterator first, RandomAccessIterator last, + const T &val, + BinaryPredicate comp) +{ + RandomAccessIterator lb = thrust::system::detail::generic::scalar::lower_bound(first, last, val, comp); + return thrust::make_pair(lb, thrust::system::detail::generic::scalar::upper_bound(lb, last, val, comp)); +} + + +template +__host__ __device__ +bool binary_search(RandomAccessIterator first, RandomAccessIterator last, const T &value, Compare comp) +{ + RandomAccessIterator iter = thrust::system::detail::generic::scalar::lower_bound(first, last, value, comp); + + // wrap comp + thrust::detail::wrapped_function< + Compare, + bool + > wrapped_comp(comp); + + return iter != last && !wrapped_comp(value,*iter); +} + +} // end scalar + +} // end generic + +} // end detail + +} // end system + +THRUST_NAMESPACE_END + +#include diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scan.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scan.h new file mode 100644 index 0000000000000000000000000000000000000000..476441ab6f649d06532b03d10f1e84fd7be58c5b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scan.h @@ -0,0 +1,98 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + OutputIterator inclusive_scan(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result); + + +// XXX it is an error to call this function; it has no implementation +template +__host__ __device__ + OutputIterator inclusive_scan(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + BinaryFunction binary_op); + + +template +__host__ __device__ + OutputIterator exclusive_scan(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result); + + +template +__host__ __device__ + OutputIterator exclusive_scan(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + T init); + + +// XXX it is an error to call this function; it has no implementation +template +__host__ __device__ + OutputIterator exclusive_scan(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + T init, + BinaryFunction binary_op); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scan.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scan.inl new file mode 100644 index 0000000000000000000000000000000000000000..45a2aadd087b5e430b00f025747c16ae169f85cd --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scan.inl @@ -0,0 +1,127 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + OutputIterator inclusive_scan(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result) +{ + // assume plus as the associative operator + return thrust::inclusive_scan(exec, first, last, result, thrust::plus<>()); +} // end inclusive_scan() + + +template +__host__ __device__ + OutputIterator exclusive_scan(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result) +{ + // Use the input iterator's value type per https://wg21.link/P0571 + using ValueType = typename thrust::iterator_value::type; + return thrust::exclusive_scan(exec, first, last, result, ValueType{}); +} // end exclusive_scan() + + +template +__host__ __device__ + OutputIterator exclusive_scan(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + T init) +{ + // assume plus as the associative operator + return thrust::exclusive_scan(exec, first, last, result, init, thrust::plus<>()); +} // end exclusive_scan() + + +template +__host__ __device__ + OutputIterator inclusive_scan(thrust::execution_policy &, + InputIterator, + InputIterator, + OutputIterator result, + BinaryFunction) +{ + THRUST_STATIC_ASSERT_MSG( + (thrust::detail::depend_on_instantiation::value) + , "unimplemented for this system" + ); + return result; +} // end inclusive_scan + + +template +__host__ __device__ + OutputIterator exclusive_scan(thrust::execution_policy &, + InputIterator, + InputIterator, + OutputIterator result, + T, + BinaryFunction) +{ + THRUST_STATIC_ASSERT_MSG( + (thrust::detail::depend_on_instantiation::value) + , "unimplemented for this system" + ); + return result; +} // end exclusive_scan() + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scan_by_key.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scan_by_key.h new file mode 100644 index 0000000000000000000000000000000000000000..9e38ac933923a1991297dfa5acbe5cf7b60cb636 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scan_by_key.h @@ -0,0 +1,143 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file scan_by_key.h + * \brief Generic implementations of key-value scans. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + OutputIterator inclusive_scan_by_key(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + OutputIterator result); + + +template +__host__ __device__ + OutputIterator inclusive_scan_by_key(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + OutputIterator result, + BinaryPredicate binary_pred); + + +template +__host__ __device__ + OutputIterator inclusive_scan_by_key(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + OutputIterator result, + BinaryPredicate binary_pred, + AssociativeOperator binary_op); + + +template +__host__ __device__ + OutputIterator exclusive_scan_by_key(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + OutputIterator result); + + +template +__host__ __device__ + OutputIterator exclusive_scan_by_key(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + OutputIterator result, + T init); + + +template +__host__ __device__ + OutputIterator exclusive_scan_by_key(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + OutputIterator result, + T init, + BinaryPredicate binary_pred); + + +template +__host__ __device__ + OutputIterator exclusive_scan_by_key(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + OutputIterator result, + T init, + BinaryPredicate binary_pred, + AssociativeOperator binary_op); + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scan_by_key.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scan_by_key.inl new file mode 100644 index 0000000000000000000000000000000000000000..0e3100224a4dd22017c9f392d1f89ab76e6c6b24 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scan_by_key.inl @@ -0,0 +1,245 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ +namespace detail +{ + + +template +struct segmented_scan_functor +{ + AssociativeOperator binary_op; + + typedef typename thrust::tuple result_type; + + __host__ __device__ + segmented_scan_functor(AssociativeOperator _binary_op) : binary_op(_binary_op) {} + + __host__ __device__ + result_type operator()(result_type a, result_type b) + { + return result_type(thrust::get<1>(b) ? thrust::get<0>(b) : binary_op(thrust::get<0>(a), thrust::get<0>(b)), + thrust::get<1>(a) | thrust::get<1>(b)); + } +}; + + +} // end namespace detail + + +template +__host__ __device__ + OutputIterator inclusive_scan_by_key(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + OutputIterator result) +{ + return thrust::inclusive_scan_by_key(exec, first1, last1, first2, result, thrust::equal_to<>()); +} + + +template +__host__ __device__ + OutputIterator inclusive_scan_by_key(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + OutputIterator result, + BinaryPredicate binary_pred) +{ + return thrust::inclusive_scan_by_key(exec, first1, last1, first2, result, binary_pred, thrust::plus<>()); +} + + +template +__host__ __device__ + OutputIterator inclusive_scan_by_key(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + OutputIterator result, + BinaryPredicate binary_pred, + AssociativeOperator binary_op) +{ + using OutputType = typename thrust::iterator_traits::value_type; + using HeadFlagType = thrust::detail::uint8_t; + + const size_t n = last1 - first1; + + if(n != 0) + { + // compute head flags + thrust::detail::temporary_array flags(exec, n); + flags[0] = 1; thrust::transform(exec, first1, last1 - 1, first1 + 1, flags.begin() + 1, thrust::detail::not2(binary_pred)); + + // scan key-flag tuples, + // For additional details refer to Section 2 of the following paper + // S. Sengupta, M. Harris, and M. Garland. "Efficient parallel scan algorithms for GPUs" + // NVIDIA Technical Report NVR-2008-003, December 2008 + // http://mgarland.org/files/papers/nvr-2008-003.pdf + thrust::inclusive_scan(exec, + thrust::make_zip_iterator(thrust::make_tuple(first2, flags.begin())), + thrust::make_zip_iterator(thrust::make_tuple(first2, flags.begin())) + n, + thrust::make_zip_iterator(thrust::make_tuple(result, flags.begin())), + detail::segmented_scan_functor(binary_op)); + } + + return result + n; +} + + +template +__host__ __device__ + OutputIterator exclusive_scan_by_key(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + OutputIterator result) +{ + typedef typename thrust::iterator_traits::value_type InitType; + return thrust::exclusive_scan_by_key(exec, first1, last1, first2, result, InitType{}); +} + + +template +__host__ __device__ + OutputIterator exclusive_scan_by_key(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + OutputIterator result, + T init) +{ + return thrust::exclusive_scan_by_key(exec, first1, last1, first2, result, init, thrust::equal_to<>()); +} + + +template +__host__ __device__ + OutputIterator exclusive_scan_by_key(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + OutputIterator result, + T init, + BinaryPredicate binary_pred) +{ + return thrust::exclusive_scan_by_key(exec, first1, last1, first2, result, init, binary_pred, thrust::plus<>()); +} + + +template +__host__ __device__ + OutputIterator exclusive_scan_by_key(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + OutputIterator result, + T init, + BinaryPredicate binary_pred, + AssociativeOperator binary_op) +{ + using OutputType = T; + using HeadFlagType = thrust::detail::uint8_t; + + const size_t n = last1 - first1; + + if(n != 0) + { + InputIterator2 last2 = first2 + n; + + // compute head flags + thrust::detail::temporary_array flags(exec, n); + flags[0] = 1; thrust::transform(exec, first1, last1 - 1, first1 + 1, flags.begin() + 1, thrust::detail::not2(binary_pred)); + + // shift input one to the right and initialize segments with init + thrust::detail::temporary_array temp(exec, n); + thrust::replace_copy_if(exec, first2, last2 - 1, flags.begin() + 1, temp.begin() + 1, thrust::negate(), init); + temp[0] = init; + + // scan key-flag tuples, + // For additional details refer to Section 2 of the following paper + // S. Sengupta, M. Harris, and M. Garland. "Efficient parallel scan algorithms for GPUs" + // NVIDIA Technical Report NVR-2008-003, December 2008 + // http://mgarland.org/files/papers/nvr-2008-003.pdf + thrust::inclusive_scan(exec, + thrust::make_zip_iterator(thrust::make_tuple(temp.begin(), flags.begin())), + thrust::make_zip_iterator(thrust::make_tuple(temp.begin(), flags.begin())) + n, + thrust::make_zip_iterator(thrust::make_tuple(result, flags.begin())), + detail::segmented_scan_functor(binary_op)); + } + + return result + n; +} + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scatter.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scatter.h new file mode 100644 index 0000000000000000000000000000000000000000..6bb7949efa46a01baf81a4ab869a42cb8ec863ab --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scatter.h @@ -0,0 +1,80 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + void scatter(thrust::execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 map, + RandomAccessIterator output); + + +template +__host__ __device__ + void scatter_if(thrust::execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 map, + InputIterator3 stencil, + RandomAccessIterator output); + + +template +__host__ __device__ + void scatter_if(thrust::execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 map, + InputIterator3 stencil, + RandomAccessIterator output, + Predicate pred); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scatter.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scatter.inl new file mode 100644 index 0000000000000000000000000000000000000000..5b479870897db4465a5484977e4acbcf223356a0 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/scatter.inl @@ -0,0 +1,97 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + void scatter(thrust::execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 map, + RandomAccessIterator output) +{ + thrust::transform(exec, + first, + last, + thrust::make_permutation_iterator(output, map), + thrust::identity::type>()); +} // end scatter() + + +template +__host__ __device__ + void scatter_if(thrust::execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 map, + InputIterator3 stencil, + RandomAccessIterator output) +{ + // default predicate is identity + typedef typename thrust::iterator_value::type StencilType; + thrust::scatter_if(exec, first, last, map, stencil, output, thrust::identity()); +} // end scatter_if() + + +template +__host__ __device__ + void scatter_if(thrust::execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 map, + InputIterator3 stencil, + RandomAccessIterator output, + Predicate pred) +{ + typedef typename thrust::iterator_value::type InputType; + thrust::transform_if(exec, first, last, stencil, thrust::make_permutation_iterator(output, map), thrust::identity(), pred); +} // end scatter_if() + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/select_system.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/select_system.h new file mode 100644 index 0000000000000000000000000000000000000000..7619b80e5ad1fcb15f4852563b11ca58d90fe754 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/select_system.h @@ -0,0 +1,124 @@ + +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + +template + struct select_system1_exists; + +template + struct select_system2_exists; + +template + struct select_system3_exists; + +template + struct select_system4_exists; + +template + struct select_system5_exists; + +template + struct select_system6_exists; + +template +__host__ __device__ + typename thrust::detail::disable_if< + select_system1_exists::value, + System & + >::type + select_system(thrust::execution_policy &system); + +template +__host__ __device__ + typename thrust::detail::enable_if_defined< + thrust::detail::minimum_system + >::type + &select_system(thrust::execution_policy &system1, + thrust::execution_policy &system2); + +template +__host__ __device__ + typename thrust::detail::lazy_disable_if< + select_system3_exists::value, + thrust::detail::minimum_system + >::type + &select_system(thrust::execution_policy &system1, + thrust::execution_policy &system2, + thrust::execution_policy &system3); + +template +__host__ __device__ + typename thrust::detail::lazy_disable_if< + select_system4_exists::value, + thrust::detail::minimum_system + >::type + &select_system(thrust::execution_policy &system1, + thrust::execution_policy &system2, + thrust::execution_policy &system3, + thrust::execution_policy &system4); + +template +__host__ __device__ + typename thrust::detail::lazy_disable_if< + select_system5_exists::value, + thrust::detail::minimum_system + >::type + &select_system(thrust::execution_policy &system1, + thrust::execution_policy &system2, + thrust::execution_policy &system3, + thrust::execution_policy &system4, + thrust::execution_policy &system5); + +template +__host__ __device__ + typename thrust::detail::lazy_disable_if< + select_system6_exists::value, + thrust::detail::minimum_system + >::type + &select_system(thrust::execution_policy &system1, + thrust::execution_policy &system2, + thrust::execution_policy &system3, + thrust::execution_policy &system4, + thrust::execution_policy &system5, + thrust::execution_policy &system6); + +// Map a single any_system_tag to device_system_tag. +inline __host__ __device__ +thrust::device_system_tag select_system(thrust::any_system_tag); + +} // end generic +} // end detail +} // end system +THRUST_NAMESPACE_END + +#include diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/select_system.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/select_system.inl new file mode 100644 index 0000000000000000000000000000000000000000..b69d17c45075aae3867aae6ab554c72166a5ff67 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/select_system.inl @@ -0,0 +1,178 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ +namespace select_system_detail +{ + + +// min_system case 1: both systems have the same type, just return the first one +template +__host__ __device__ +System &min_system(thrust::execution_policy &system1, + thrust::execution_policy &) +{ + return thrust::detail::derived_cast(system1); +} // end min_system() + + +// min_system case 2: systems have differing type and the first type is considered the minimum +template +__host__ __device__ +typename thrust::detail::enable_if< + thrust::detail::is_same< + System1, + typename thrust::detail::minimum_system::type + >::value, + System1 & +>::type + min_system(thrust::execution_policy &system1, thrust::execution_policy &) +{ + return thrust::detail::derived_cast(system1); +} // end min_system() + + +// min_system case 3: systems have differing type and the second type is considered the minimum +template +__host__ __device__ +typename thrust::detail::enable_if< + thrust::detail::is_same< + System2, + typename thrust::detail::minimum_system::type + >::value, + System2 & + >::type + min_system(thrust::execution_policy &, thrust::execution_policy &system2) +{ + return thrust::detail::derived_cast(system2); +} // end min_system() + + +} // end select_system_detail + + +template +__host__ __device__ + typename thrust::detail::disable_if< + select_system1_exists::value, + System & + >::type + select_system(thrust::execution_policy &system) +{ + return thrust::detail::derived_cast(system); +} // end select_system() + + +template +__host__ __device__ + typename thrust::detail::enable_if_defined< + thrust::detail::minimum_system + >::type + &select_system(thrust::execution_policy &system1, + thrust::execution_policy &system2) +{ + return select_system_detail::min_system(system1,system2); +} // end select_system() + + +template +__host__ __device__ + typename thrust::detail::lazy_disable_if< + select_system3_exists::value, + thrust::detail::minimum_system + >::type + &select_system(thrust::execution_policy &system1, + thrust::execution_policy &system2, + thrust::execution_policy &system3) +{ + return select_system(select_system(system1,system2), system3); +} // end select_system() + + +template +__host__ __device__ + typename thrust::detail::lazy_disable_if< + select_system4_exists::value, + thrust::detail::minimum_system + >::type + &select_system(thrust::execution_policy &system1, + thrust::execution_policy &system2, + thrust::execution_policy &system3, + thrust::execution_policy &system4) +{ + return select_system(select_system(system1,system2,system3), system4); +} // end select_system() + + +template +__host__ __device__ + typename thrust::detail::lazy_disable_if< + select_system5_exists::value, + thrust::detail::minimum_system + >::type + &select_system(thrust::execution_policy &system1, + thrust::execution_policy &system2, + thrust::execution_policy &system3, + thrust::execution_policy &system4, + thrust::execution_policy &system5) +{ + return select_system(select_system(system1,system2,system3,system4), system5); +} // end select_system() + + +template +__host__ __device__ + typename thrust::detail::lazy_disable_if< + select_system6_exists::value, + thrust::detail::minimum_system + >::type + &select_system(thrust::execution_policy &system1, + thrust::execution_policy &system2, + thrust::execution_policy &system3, + thrust::execution_policy &system4, + thrust::execution_policy &system5, + thrust::execution_policy &system6) +{ + return select_system(select_system(system1,system2,system3,system4,system5), system6); +} // end select_system() + + +// map a single any_system_tag to device_system_tag +inline __host__ __device__ +thrust::device_system_tag select_system(thrust::any_system_tag) +{ + return thrust::device_system_tag(); +} // end select_system() + + +} // end generic +} // end detail +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/select_system_exists.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/select_system_exists.h new file mode 100644 index 0000000000000000000000000000000000000000..29d05781d9ec347e1c0aa4f325e608250e16a81b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/select_system_exists.h @@ -0,0 +1,167 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file generic/type_traits.h + * \brief Introspection for free functions defined in generic. + */ + +#pragma once + +#include + +THRUST_NAMESPACE_BEGIN + +// forward declaration of any_system_tag for any_conversion below +struct any_system_tag; + +namespace system +{ +namespace detail +{ + +// we must define these traits outside of generic's namespace +namespace generic_type_traits_ns +{ + +typedef char yes; +typedef char (&no)[2]; + +struct any_conversion +{ + template any_conversion(const T &); + + // add this extra constructor to disambiguate conversion from any_system_tag + any_conversion(const any_system_tag &); +}; + +namespace select_system_exists_ns +{ + no select_system(const any_conversion &); + no select_system(const any_conversion &, const any_conversion &); + no select_system(const any_conversion &, const any_conversion &, const any_conversion &); + no select_system(const any_conversion &, const any_conversion &, const any_conversion &, const any_conversion &); + no select_system(const any_conversion &, const any_conversion &, const any_conversion &, const any_conversion &, const any_conversion &); + no select_system(const any_conversion &, const any_conversion &, const any_conversion &, const any_conversion &, const any_conversion &, const any_conversion &); + + template yes check(const T &); + + no check(no); + + template + struct select_system1_exists + { + static Tag &tag; + + static const bool value = sizeof(check(select_system(tag))) == sizeof(yes); + }; + + template + struct select_system2_exists + { + static Tag1 &tag1; + static Tag2 &tag2; + + static const bool value = sizeof(check(select_system(tag1,tag2))) == sizeof(yes); + }; + + template + struct select_system3_exists + { + static Tag1 &tag1; + static Tag2 &tag2; + static Tag3 &tag3; + + static const bool value = sizeof(check(select_system(tag1,tag2,tag3))) == sizeof(yes); + }; + + template + struct select_system4_exists + { + static Tag1 &tag1; + static Tag2 &tag2; + static Tag3 &tag3; + static Tag4 &tag4; + + static const bool value = sizeof(check(select_system(tag1,tag2,tag3,tag4))) == sizeof(yes); + }; + + template + struct select_system5_exists + { + static Tag1 &tag1; + static Tag2 &tag2; + static Tag3 &tag3; + static Tag4 &tag4; + static Tag5 &tag5; + + static const bool value = sizeof(check(select_system(tag1,tag2,tag3,tag4,tag5))) == sizeof(yes); + }; + + template + struct select_system6_exists + { + static Tag1 &tag1; + static Tag2 &tag2; + static Tag3 &tag3; + static Tag4 &tag4; + static Tag5 &tag5; + static Tag6 &tag6; + + static const bool value = sizeof(check(select_system(tag1,tag2,tag3,tag4,tag5,tag6))) == sizeof(yes); + }; +} // end select_system_exists_ns + +} // end generic_type_traits_ns + +namespace generic +{ + +template + struct select_system1_exists + : generic_type_traits_ns::select_system_exists_ns::select_system1_exists +{}; + +template + struct select_system2_exists + : generic_type_traits_ns::select_system_exists_ns::select_system2_exists +{}; + +template + struct select_system3_exists + : generic_type_traits_ns::select_system_exists_ns::select_system3_exists +{}; + +template + struct select_system4_exists + : generic_type_traits_ns::select_system_exists_ns::select_system4_exists +{}; + +template + struct select_system5_exists + : generic_type_traits_ns::select_system_exists_ns::select_system5_exists +{}; + +template + struct select_system6_exists + : generic_type_traits_ns::select_system_exists_ns::select_system6_exists +{}; + +} // end generic +} // end detail +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/sequence.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/sequence.h new file mode 100644 index 0000000000000000000000000000000000000000..26bf17bb8ba2ba60803cef7735132d074d0a1c11 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/sequence.h @@ -0,0 +1,63 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + void sequence(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last); + + +template +__host__ __device__ + void sequence(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + T init); + + +template +__host__ __device__ + void sequence(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + T init, + T step); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/sequence.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/sequence.inl new file mode 100644 index 0000000000000000000000000000000000000000..0e11dd75d77e80deb30906497d6e03808c93df40 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/sequence.inl @@ -0,0 +1,106 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + void sequence(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last) +{ + typedef typename thrust::iterator_traits::value_type T; + + thrust::sequence(exec, first, last, T(0)); +} // end sequence() + + +template +__host__ __device__ + void sequence(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + T init) +{ + thrust::sequence(exec, first, last, init, T(1)); +} // end sequence() + +namespace detail +{ +template +struct compute_sequence_value +{ + T init; + T step; + + __thrust_exec_check_disable__ + __host__ __device__ + T operator()(std::size_t i) const + { + return init + step * i; + } +}; +template +struct compute_sequence_value::value>::type> +{ + T init; + T step; + + __thrust_exec_check_disable__ + __host__ __device__ + T operator()(std::size_t i) const + { + return init + step * static_cast(i); + } +}; +} + +template +__host__ __device__ + void sequence(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + T init, + T step) +{ + + thrust::tabulate(exec, + first, + last, + detail::compute_sequence_value{std::move(init), + std::move(step)}); +} // end sequence() + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/set_operations.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/set_operations.h new file mode 100644 index 0000000000000000000000000000000000000000..37665d78dd9cf1832909fe2bfaeaceacc4bfa5e9 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/set_operations.h @@ -0,0 +1,318 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ +OutputIterator set_difference(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result); + + +// XXX it is an error to call this function; it has no implementation +template +__host__ __device__ +OutputIterator set_difference(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result, + StrictWeakOrdering comp); + + +template +__host__ __device__ +thrust::pair + set_difference_by_key(thrust::execution_policy &exec, + InputIterator1 keys_first1, + InputIterator1 keys_last1, + InputIterator2 keys_first2, + InputIterator2 keys_last2, + InputIterator3 values_first1, + InputIterator4 values_first2, + OutputIterator1 keys_result, + OutputIterator2 values_result); + + +template +__host__ __device__ +thrust::pair + set_difference_by_key(thrust::execution_policy &exec, + InputIterator1 keys_first1, + InputIterator1 keys_last1, + InputIterator2 keys_first2, + InputIterator2 keys_last2, + InputIterator3 values_first1, + InputIterator4 values_first2, + OutputIterator1 keys_result, + OutputIterator2 values_result, + StrictWeakOrdering comp); + + +template +__host__ __device__ +OutputIterator set_intersection(thrust::execution_policy &system, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result); + + +// XXX it is an error to call this function; it has no implementation +template +__host__ __device__ +OutputIterator set_intersection(thrust::execution_policy &system, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result, + StrictWeakOrdering comp); + + +template +__host__ __device__ +thrust::pair + set_intersection_by_key(thrust::execution_policy &system, + InputIterator1 keys_first1, + InputIterator1 keys_last1, + InputIterator2 keys_first2, + InputIterator2 keys_last2, + InputIterator3 values_first1, + OutputIterator1 keys_result, + OutputIterator2 values_result); + + +template +__host__ __device__ +thrust::pair + set_intersection_by_key(thrust::execution_policy &system, + InputIterator1 keys_first1, + InputIterator1 keys_last1, + InputIterator2 keys_first2, + InputIterator2 keys_last2, + InputIterator3 values_first1, + OutputIterator1 keys_result, + OutputIterator2 values_result, + StrictWeakOrdering comp); + + +template +__host__ __device__ +OutputIterator set_symmetric_difference(thrust::execution_policy &system, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result); + + +// XXX it is an error to call this function; it has no implementation +template +__host__ __device__ +OutputIterator set_symmetric_difference(thrust::execution_policy &system, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result, + StrictWeakOrdering comp); + + +template +__host__ __device__ +thrust::pair + set_symmetric_difference_by_key(thrust::execution_policy &system, + InputIterator1 keys_first1, + InputIterator1 keys_last1, + InputIterator2 keys_first2, + InputIterator2 keys_last2, + InputIterator3 values_first1, + InputIterator4 values_first2, + OutputIterator1 keys_result, + OutputIterator2 values_result); + + +template +__host__ __device__ +thrust::pair + set_symmetric_difference_by_key(thrust::execution_policy &system, + InputIterator1 keys_first1, + InputIterator1 keys_last1, + InputIterator2 keys_first2, + InputIterator2 keys_last2, + InputIterator3 values_first1, + InputIterator4 values_first2, + OutputIterator1 keys_result, + OutputIterator2 values_result, + StrictWeakOrdering comp); + + +template +__host__ __device__ +OutputIterator set_union(thrust::execution_policy &system, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result); + + +// XXX it is an error to call this function; it has no implementation +template +__host__ __device__ +OutputIterator set_union(thrust::execution_policy &system, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result, + StrictWeakOrdering comp); + + +template +__host__ __device__ +thrust::pair + set_union_by_key(thrust::execution_policy &system, + InputIterator1 keys_first1, + InputIterator1 keys_last1, + InputIterator2 keys_first2, + InputIterator2 keys_last2, + InputIterator3 values_first1, + InputIterator4 values_first2, + OutputIterator1 keys_result, + OutputIterator2 values_result); + + +template +__host__ __device__ +thrust::pair + set_union_by_key(thrust::execution_policy &system, + InputIterator1 keys_first1, + InputIterator1 keys_last1, + InputIterator2 keys_first2, + InputIterator2 keys_last2, + InputIterator3 values_first1, + InputIterator4 values_first2, + OutputIterator1 keys_result, + OutputIterator2 values_result, + StrictWeakOrdering comp); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/set_operations.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/set_operations.inl new file mode 100644 index 0000000000000000000000000000000000000000..4363be5c0d8a4453e1662f923277d6be315927c3 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/set_operations.inl @@ -0,0 +1,476 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ +OutputIterator set_difference(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result) +{ + typedef typename thrust::iterator_value::type value_type; + return thrust::set_difference(exec, first1, last1, first2, last2, result, thrust::less()); +} // end set_difference() + + +template +__host__ __device__ +thrust::pair + set_difference_by_key(thrust::execution_policy &exec, + InputIterator1 keys_first1, + InputIterator1 keys_last1, + InputIterator2 keys_first2, + InputIterator2 keys_last2, + InputIterator3 values_first1, + InputIterator4 values_first2, + OutputIterator1 keys_result, + OutputIterator2 values_result) +{ + typedef typename thrust::iterator_value::type value_type; + return thrust::set_difference_by_key(exec, keys_first1, keys_last1, keys_first2, keys_last2, values_first1, values_first2, keys_result, values_result, thrust::less()); +} // end set_difference_by_key() + + +template +__host__ __device__ +thrust::pair + set_difference_by_key(thrust::execution_policy &exec, + InputIterator1 keys_first1, + InputIterator1 keys_last1, + InputIterator2 keys_first2, + InputIterator2 keys_last2, + InputIterator3 values_first1, + InputIterator4 values_first2, + OutputIterator1 keys_result, + OutputIterator2 values_result, + StrictWeakOrdering comp) +{ + typedef thrust::tuple iterator_tuple1; + typedef thrust::tuple iterator_tuple2; + typedef thrust::tuple iterator_tuple3; + + typedef thrust::zip_iterator zip_iterator1; + typedef thrust::zip_iterator zip_iterator2; + typedef thrust::zip_iterator zip_iterator3; + + zip_iterator1 zipped_first1 = thrust::make_zip_iterator(thrust::make_tuple(keys_first1, values_first1)); + zip_iterator1 zipped_last1 = thrust::make_zip_iterator(thrust::make_tuple(keys_last1, values_first1)); + + zip_iterator2 zipped_first2 = thrust::make_zip_iterator(thrust::make_tuple(keys_first2, values_first2)); + zip_iterator2 zipped_last2 = thrust::make_zip_iterator(thrust::make_tuple(keys_last2, values_first2)); + + zip_iterator3 zipped_result = thrust::make_zip_iterator(thrust::make_tuple(keys_result, values_result)); + + thrust::detail::compare_first comp_first(comp); + + iterator_tuple3 result = thrust::set_difference(exec, zipped_first1, zipped_last1, zipped_first2, zipped_last2, zipped_result, comp_first).get_iterator_tuple(); + + return thrust::make_pair(thrust::get<0>(result), thrust::get<1>(result)); +} // end set_difference_by_key() + + +template +__host__ __device__ +OutputIterator set_intersection(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result) +{ + typedef typename thrust::iterator_value::type value_type; + return thrust::set_intersection(exec, first1, last1, first2, last2, result, thrust::less()); +} // end set_intersection() + + +template +__host__ __device__ +thrust::pair + set_intersection_by_key(thrust::execution_policy &exec, + InputIterator1 keys_first1, + InputIterator1 keys_last1, + InputIterator2 keys_first2, + InputIterator2 keys_last2, + InputIterator3 values_first1, + OutputIterator1 keys_result, + OutputIterator2 values_result) +{ + typedef typename thrust::iterator_value::type value_type; + return thrust::set_intersection_by_key(exec, keys_first1, keys_last1, keys_first2, keys_last2, values_first1, keys_result, values_result, thrust::less()); +} // end set_intersection_by_key() + + +template +__host__ __device__ +thrust::pair + set_intersection_by_key(thrust::execution_policy &exec, + InputIterator1 keys_first1, + InputIterator1 keys_last1, + InputIterator2 keys_first2, + InputIterator2 keys_last2, + InputIterator3 values_first1, + OutputIterator1 keys_result, + OutputIterator2 values_result, + StrictWeakOrdering comp) +{ + typedef typename thrust::iterator_value::type value_type1; + typedef thrust::constant_iterator constant_iterator; + + typedef thrust::tuple iterator_tuple1; + typedef thrust::tuple iterator_tuple2; + typedef thrust::tuple iterator_tuple3; + + typedef thrust::zip_iterator zip_iterator1; + typedef thrust::zip_iterator zip_iterator2; + typedef thrust::zip_iterator zip_iterator3; + + // fabricate a values_first2 by repeating a default-constructed value_type1 + // XXX assumes value_type1 is default-constructible + constant_iterator values_first2 = thrust::make_constant_iterator(value_type1()); + + zip_iterator1 zipped_first1 = thrust::make_zip_iterator(thrust::make_tuple(keys_first1, values_first1)); + zip_iterator1 zipped_last1 = thrust::make_zip_iterator(thrust::make_tuple(keys_last1, values_first1)); + + zip_iterator2 zipped_first2 = thrust::make_zip_iterator(thrust::make_tuple(keys_first2, values_first2)); + zip_iterator2 zipped_last2 = thrust::make_zip_iterator(thrust::make_tuple(keys_last2, values_first2)); + + zip_iterator3 zipped_result = thrust::make_zip_iterator(thrust::make_tuple(keys_result, values_result)); + + thrust::detail::compare_first comp_first(comp); + + iterator_tuple3 result = thrust::set_intersection(exec, zipped_first1, zipped_last1, zipped_first2, zipped_last2, zipped_result, comp_first).get_iterator_tuple(); + + return thrust::make_pair(thrust::get<0>(result), thrust::get<1>(result)); +} // end set_intersection_by_key() + + +template +__host__ __device__ +OutputIterator set_symmetric_difference(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result) +{ + typedef typename thrust::iterator_value::type value_type; + return thrust::set_symmetric_difference(exec, first1, last1, first2, last2, result, thrust::less()); +} // end set_symmetric_difference() + + +template +__host__ __device__ +thrust::pair + set_symmetric_difference_by_key(thrust::execution_policy &exec, + InputIterator1 keys_first1, + InputIterator1 keys_last1, + InputIterator2 keys_first2, + InputIterator2 keys_last2, + InputIterator3 values_first1, + InputIterator4 values_first2, + OutputIterator1 keys_result, + OutputIterator2 values_result) +{ + typedef typename thrust::iterator_value::type value_type; + return thrust::set_symmetric_difference_by_key(exec, keys_first1, keys_last1, keys_first2, keys_last2, values_first1, values_first2, keys_result, values_result, thrust::less()); +} // end set_symmetric_difference_by_key() + + +template +__host__ __device__ +thrust::pair + set_symmetric_difference_by_key(thrust::execution_policy &exec, + InputIterator1 keys_first1, + InputIterator1 keys_last1, + InputIterator2 keys_first2, + InputIterator2 keys_last2, + InputIterator3 values_first1, + InputIterator4 values_first2, + OutputIterator1 keys_result, + OutputIterator2 values_result, + StrictWeakOrdering comp) +{ + typedef thrust::tuple iterator_tuple1; + typedef thrust::tuple iterator_tuple2; + typedef thrust::tuple iterator_tuple3; + + typedef thrust::zip_iterator zip_iterator1; + typedef thrust::zip_iterator zip_iterator2; + typedef thrust::zip_iterator zip_iterator3; + + zip_iterator1 zipped_first1 = thrust::make_zip_iterator(thrust::make_tuple(keys_first1, values_first1)); + zip_iterator1 zipped_last1 = thrust::make_zip_iterator(thrust::make_tuple(keys_last1, values_first1)); + + zip_iterator2 zipped_first2 = thrust::make_zip_iterator(thrust::make_tuple(keys_first2, values_first2)); + zip_iterator2 zipped_last2 = thrust::make_zip_iterator(thrust::make_tuple(keys_last2, values_first2)); + + zip_iterator3 zipped_result = thrust::make_zip_iterator(thrust::make_tuple(keys_result, values_result)); + + thrust::detail::compare_first comp_first(comp); + + iterator_tuple3 result = thrust::set_symmetric_difference(exec, zipped_first1, zipped_last1, zipped_first2, zipped_last2, zipped_result, comp_first).get_iterator_tuple(); + + return thrust::make_pair(thrust::get<0>(result), thrust::get<1>(result)); +} // end set_symmetric_difference_by_key() + + +template +__host__ __device__ +OutputIterator set_union(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result) +{ + typedef typename thrust::iterator_value::type value_type; + return thrust::set_union(exec, first1, last1, first2, last2, result, thrust::less()); +} // end set_union() + + +template +__host__ __device__ +thrust::pair + set_union_by_key(thrust::execution_policy &exec, + InputIterator1 keys_first1, + InputIterator1 keys_last1, + InputIterator2 keys_first2, + InputIterator2 keys_last2, + InputIterator3 values_first1, + InputIterator4 values_first2, + OutputIterator1 keys_result, + OutputIterator2 values_result) +{ + typedef typename thrust::iterator_value::type value_type; + return thrust::set_union_by_key(exec, keys_first1, keys_last1, keys_first2, keys_last2, values_first1, values_first2, keys_result, values_result, thrust::less()); +} // end set_union_by_key() + + +template +__host__ __device__ +thrust::pair + set_union_by_key(thrust::execution_policy &exec, + InputIterator1 keys_first1, + InputIterator1 keys_last1, + InputIterator2 keys_first2, + InputIterator2 keys_last2, + InputIterator3 values_first1, + InputIterator4 values_first2, + OutputIterator1 keys_result, + OutputIterator2 values_result, + StrictWeakOrdering comp) +{ + typedef thrust::tuple iterator_tuple1; + typedef thrust::tuple iterator_tuple2; + typedef thrust::tuple iterator_tuple3; + + typedef thrust::zip_iterator zip_iterator1; + typedef thrust::zip_iterator zip_iterator2; + typedef thrust::zip_iterator zip_iterator3; + + zip_iterator1 zipped_first1 = thrust::make_zip_iterator(thrust::make_tuple(keys_first1, values_first1)); + zip_iterator1 zipped_last1 = thrust::make_zip_iterator(thrust::make_tuple(keys_last1, values_first1)); + + zip_iterator2 zipped_first2 = thrust::make_zip_iterator(thrust::make_tuple(keys_first2, values_first2)); + zip_iterator2 zipped_last2 = thrust::make_zip_iterator(thrust::make_tuple(keys_last2, values_first2)); + + zip_iterator3 zipped_result = thrust::make_zip_iterator(thrust::make_tuple(keys_result, values_result)); + + thrust::detail::compare_first comp_first(comp); + + iterator_tuple3 result = thrust::set_union(exec, zipped_first1, zipped_last1, zipped_first2, zipped_last2, zipped_result, comp_first).get_iterator_tuple(); + + return thrust::make_pair(thrust::get<0>(result), thrust::get<1>(result)); +} // end set_union_by_key() + + +template +__host__ __device__ +OutputIterator set_difference(thrust::execution_policy &, + InputIterator1, + InputIterator1, + InputIterator2, + InputIterator2, + OutputIterator result, + StrictWeakOrdering) +{ + THRUST_STATIC_ASSERT_MSG( + (thrust::detail::depend_on_instantiation::value) + , "unimplemented for this system" + ); + return result; +} // end set_difference() + + +template +__host__ __device__ +OutputIterator set_intersection(thrust::execution_policy &, + InputIterator1, + InputIterator1, + InputIterator2, + InputIterator2, + OutputIterator result, + StrictWeakOrdering) +{ + THRUST_STATIC_ASSERT_MSG( + (thrust::detail::depend_on_instantiation::value) + , "unimplemented for this system" + ); + return result; +} // end set_intersection() + + +template +__host__ __device__ +OutputIterator set_symmetric_difference(thrust::execution_policy &, + InputIterator1, + InputIterator1, + InputIterator2, + InputIterator2, + OutputIterator result, + StrictWeakOrdering) +{ + THRUST_STATIC_ASSERT_MSG( + (thrust::detail::depend_on_instantiation::value) + , "unimplemented for this system" + ); + return result; +} // end set_symmetric_difference() + + +template +__host__ __device__ +OutputIterator set_union(thrust::execution_policy &, + InputIterator1, + InputIterator1, + InputIterator2, + InputIterator2, + OutputIterator result, + StrictWeakOrdering) +{ + THRUST_STATIC_ASSERT_MSG( + (thrust::detail::depend_on_instantiation::value) + , "unimplemented for this system" + ); + return result; +} // end set_union() + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/shuffle.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/shuffle.h new file mode 100644 index 0000000000000000000000000000000000000000..8f8e21afdf90023989db7c4b59963da1eb3e2938 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/shuffle.h @@ -0,0 +1,54 @@ +/* + * Copyright 2008-2020 NVIDIA Corporation + * + * 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. + */ + +/*! \file shuffle.h + * \brief Generic implementations of shuffle functions. + */ + +#pragma once + + +#include +#include + +#if THRUST_CPP_DIALECT >= 2011 + +#include + +THRUST_NAMESPACE_BEGIN +namespace system { +namespace detail { +namespace generic { + +template +__host__ __device__ void shuffle( + thrust::execution_policy& exec, RandomIterator first, + RandomIterator last, URBG&& g); + +template +__host__ __device__ void shuffle_copy( + thrust::execution_policy& exec, RandomIterator first, + RandomIterator last, OutputIterator result, URBG&& g); + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + +#endif diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/shuffle.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/shuffle.inl new file mode 100644 index 0000000000000000000000000000000000000000..baece51bee69a09842339844d41ccbabf576d6ed --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/shuffle.inl @@ -0,0 +1,190 @@ +/* + * Copyright 2008-20120 NVIDIA Corporation + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +THRUST_NAMESPACE_BEGIN +namespace system { +namespace detail { +namespace generic { + +// An implementation of a Feistel cipher for operating on 64 bit keys +class feistel_bijection { + struct round_state { + std::uint32_t left; + std::uint32_t right; + }; + + public: + template + __host__ __device__ feistel_bijection(std::uint64_t m, URBG&& g) { + std::uint64_t total_bits = get_cipher_bits(m); + // Half bits rounded down + left_side_bits = total_bits / 2; + left_side_mask = (1ull << left_side_bits) - 1; + // Half the bits rounded up + right_side_bits = total_bits - left_side_bits; + right_side_mask = (1ull << right_side_bits) - 1; + + for (std::uint32_t i = 0; i < num_rounds; i++) { + key[i] = g(); + } + } + + __host__ __device__ std::uint64_t nearest_power_of_two() const { + return 1ull << (left_side_bits + right_side_bits); + } + + __host__ __device__ std::uint64_t operator()(const std::uint64_t val) const { + std::uint32_t state[2] = { static_cast( val >> right_side_bits ), static_cast( val & right_side_mask ) }; + for( std::uint32_t i = 0; i < num_rounds; i++ ) + { + std::uint32_t hi, lo; + constexpr std::uint64_t M0 = UINT64_C( 0xD2B74407B1CE6E93 ); + mulhilo( M0, state[0], hi, lo ); + lo = ( lo << ( right_side_bits - left_side_bits ) ) | state[1] >> left_side_bits; + state[0] = ( ( hi ^ key[i] ) ^ state[1] ) & left_side_mask; + state[1] = lo & right_side_mask; + } + // Combine the left and right sides together to get result + return static_cast(state[0] << right_side_bits) | static_cast(state[1]); + } + + private: + // Perform 64 bit multiplication and save result in two 32 bit int + static __host__ __device__ void mulhilo( std::uint64_t a, std::uint64_t b, std::uint32_t& hi, std::uint32_t& lo ) + { + std::uint64_t product = a * b; + hi = static_cast( product >> 32 ); + lo = static_cast( product ); + } + + // Find the nearest power of two + static __host__ __device__ std::uint64_t get_cipher_bits(std::uint64_t m) { + if (m <= 16) return 4; + std::uint64_t i = 0; + m--; + while (m != 0) { + i++; + m >>= 1; + } + return i; + } + + static constexpr std::uint32_t num_rounds = 24; + std::uint64_t right_side_bits; + std::uint64_t left_side_bits; + std::uint64_t right_side_mask; + std::uint64_t left_side_mask; + std::uint32_t key[num_rounds]; +}; + +struct key_flag_tuple { + std::uint64_t key; + std::uint64_t flag; +}; + +// scan only flags +struct key_flag_scan_op { + __host__ __device__ key_flag_tuple operator()(const key_flag_tuple& a, + const key_flag_tuple& b) { + return {b.key, a.flag + b.flag}; + } +}; + +struct construct_key_flag_op { + std::uint64_t m; + feistel_bijection bijection; + __host__ __device__ construct_key_flag_op(std::uint64_t m, + feistel_bijection bijection) + : m(m), bijection(bijection) {} + __host__ __device__ key_flag_tuple operator()(std::uint64_t idx) { + auto gather_key = bijection(idx); + return key_flag_tuple{gather_key, (gather_key < m) ? 1ull : 0ull}; + } +}; + +template +struct write_output_op { + std::uint64_t m; + InputIterT in; + OutputIterT out; + // flag contains inclusive scan of valid keys + // perform gather using valid keys + __thrust_exec_check_disable__ + __host__ __device__ std::size_t operator()(key_flag_tuple x) { + if (x.key < m) { + // -1 because inclusive scan + out[x.flag - 1] = in[x.key]; + } + return 0; // Discarded + } +}; + +template +__host__ __device__ void shuffle( + thrust::execution_policy& exec, RandomIterator first, + RandomIterator last, URBG&& g) { + using InputType = typename thrust::iterator_value_t; + + // copy input to temp buffer + thrust::detail::temporary_array temp(exec, first, + last); + thrust::shuffle_copy(exec, temp.begin(), temp.end(), first, g); +} + +template +__host__ __device__ void shuffle_copy( + thrust::execution_policy& exec, RandomIterator first, + RandomIterator last, OutputIterator result, URBG&& g) { + // m is the length of the input + // we have an available bijection of length n via a feistel cipher + std::size_t m = last - first; + feistel_bijection bijection(m, g); + std::uint64_t n = bijection.nearest_power_of_two(); + + // perform stream compaction over length n bijection to get length m + // pseudorandom bijection over the original input + thrust::counting_iterator indices(0); + thrust::transform_iterator + key_flag_it(indices, construct_key_flag_op(m, bijection)); + write_output_op write_functor{m, first, + result}; + auto gather_output_it = thrust::make_transform_output_iterator( + thrust::discard_iterator(), write_functor); + // the feistel_bijection outputs a stream of permuted indices in range [0,n) + // flag each value < m and compact it, so we have a set of permuted indices in + // range [0,m) each thread gathers an input element according to its + // pseudorandom permuted index + thrust::inclusive_scan(exec, key_flag_it, key_flag_it + n, gather_output_it, + key_flag_scan_op()); +} + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/sort.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/sort.h new file mode 100644 index 0000000000000000000000000000000000000000..cd8d455624c830a17fcde3615255bc2ecf4cc277 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/sort.h @@ -0,0 +1,153 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + void sort(thrust::execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator last); + + +template +__host__ __device__ + void sort(thrust::execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator last, + StrictWeakOrdering comp); + + +template +__host__ __device__ + void sort_by_key(thrust::execution_policy &exec, + RandomAccessIterator1 keys_first, + RandomAccessIterator1 keys_last, + RandomAccessIterator2 values_first); + + +template +__host__ __device__ + void sort_by_key(thrust::execution_policy &exec, + RandomAccessIterator1 keys_first, + RandomAccessIterator1 keys_last, + RandomAccessIterator2 values_first, + StrictWeakOrdering comp); + + +template +__host__ __device__ + void stable_sort(thrust::execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator last); + + +// XXX it is an error to call this function; it has no implementation +template +__host__ __device__ + void stable_sort(thrust::execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator last, + StrictWeakOrdering comp); + + +template +__host__ __device__ + void stable_sort_by_key(thrust::execution_policy &exec, + RandomAccessIterator1 keys_first, + RandomAccessIterator1 keys_last, + RandomAccessIterator2 values_first); + + +// XXX it is an error to call this function; it has no implementation +template +__host__ __device__ + void stable_sort_by_key(thrust::execution_policy &exec, + RandomAccessIterator1 keys_first, + RandomAccessIterator1 keys_last, + RandomAccessIterator2 values_first, + StrictWeakOrdering comp); + + +template +__host__ __device__ + bool is_sorted(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last); + + +template +__host__ __device__ + bool is_sorted(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Compare comp); + + +template +__host__ __device__ + ForwardIterator is_sorted_until(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last); + + +template +__host__ __device__ + ForwardIterator is_sorted_until(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Compare comp); + + +} // end generic +} // end detail +} // end system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/sort.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/sort.inl new file mode 100644 index 0000000000000000000000000000000000000000..632cab435ea9adedb621aca105e1644c8bdd3a35 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/sort.inl @@ -0,0 +1,219 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + void sort(thrust::execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator last) +{ + typedef typename thrust::iterator_value::type value_type; + thrust::sort(exec, first, last, thrust::less()); +} // end sort() + + +template +__host__ __device__ + void sort(thrust::execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator last, + StrictWeakOrdering comp) +{ + // implement with stable_sort + thrust::stable_sort(exec, first, last, comp); +} // end sort() + + +template +__host__ __device__ + void sort_by_key(thrust::execution_policy &exec, + RandomAccessIterator1 keys_first, + RandomAccessIterator1 keys_last, + RandomAccessIterator2 values_first) +{ + typedef typename thrust::iterator_value::type value_type; + thrust::sort_by_key(exec, keys_first, keys_last, values_first, thrust::less()); +} // end sort_by_key() + + +template +__host__ __device__ + void sort_by_key(thrust::execution_policy &exec, + RandomAccessIterator1 keys_first, + RandomAccessIterator1 keys_last, + RandomAccessIterator2 values_first, + StrictWeakOrdering comp) +{ + // implement with stable_sort_by_key + thrust::stable_sort_by_key(exec, keys_first, keys_last, values_first, comp); +} // end sort_by_key() + + +template +__host__ __device__ + void stable_sort(thrust::execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator last) +{ + typedef typename thrust::iterator_value::type value_type; + thrust::stable_sort(exec, first, last, thrust::less()); +} // end stable_sort() + + +template +__host__ __device__ + void stable_sort_by_key(thrust::execution_policy &exec, + RandomAccessIterator1 keys_first, + RandomAccessIterator1 keys_last, + RandomAccessIterator2 values_first) +{ + typedef typename iterator_value::type value_type; + thrust::stable_sort_by_key(exec, keys_first, keys_last, values_first, thrust::less()); +} // end stable_sort_by_key() + + +template +__host__ __device__ + bool is_sorted(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last) +{ + return thrust::is_sorted_until(exec, first, last) == last; +} // end is_sorted() + + +template +__host__ __device__ + bool is_sorted(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Compare comp) +{ + return thrust::is_sorted_until(exec, first, last, comp) == last; +} // end is_sorted() + + +template +__host__ __device__ + ForwardIterator is_sorted_until(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last) +{ + typedef typename thrust::iterator_value::type InputType; + + return thrust::is_sorted_until(exec, first, last, thrust::less()); +} // end is_sorted_until() + + +template +__host__ __device__ + ForwardIterator is_sorted_until(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Compare comp) +{ + if(thrust::distance(first,last) < 2) return last; + + typedef thrust::tuple IteratorTuple; + typedef thrust::zip_iterator ZipIterator; + + ForwardIterator first_plus_one = first; + thrust::advance(first_plus_one, 1); + + ZipIterator zipped_first = thrust::make_zip_iterator(thrust::make_tuple(first_plus_one, first)); + ZipIterator zipped_last = thrust::make_zip_iterator(thrust::make_tuple(last, first)); + + return thrust::get<0>(thrust::find_if(exec, zipped_first, zipped_last, thrust::detail::tuple_binary_predicate(comp)).get_iterator_tuple()); +} // end is_sorted_until() + + +template +__host__ __device__ + void stable_sort(thrust::execution_policy &, + RandomAccessIterator, + RandomAccessIterator, + StrictWeakOrdering) +{ + THRUST_STATIC_ASSERT_MSG( + (thrust::detail::depend_on_instantiation::value) + , "unimplemented for this system" + ); +} // end stable_sort() + + +template +__host__ __device__ + void stable_sort_by_key(thrust::execution_policy &, + RandomAccessIterator1, + RandomAccessIterator1, + RandomAccessIterator2, + StrictWeakOrdering) +{ + THRUST_STATIC_ASSERT_MSG( + (thrust::detail::depend_on_instantiation::value) + , "unimplemented for this system" + ); +} // end stable_sort_by_key() + + +} // end generic +} // end detail +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/swap_ranges.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/swap_ranges.h new file mode 100644 index 0000000000000000000000000000000000000000..edb5acf31fb2665ca48f99e0444c40272109f399 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/swap_ranges.h @@ -0,0 +1,46 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + +template +__host__ __device__ + ForwardIterator2 swap_ranges(thrust::execution_policy &exec, + ForwardIterator1 first1, + ForwardIterator1 last1, + ForwardIterator2 first2); + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/swap_ranges.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/swap_ranges.inl new file mode 100644 index 0000000000000000000000000000000000000000..ea42df35bcde90b6bb57e4220a82f8ae9a523bc6 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/swap_ranges.inl @@ -0,0 +1,79 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ +namespace detail +{ + + +// XXX define this here rather than in internal_functional.h +// to avoid circular dependence between swap.h & internal_functional.h +struct swap_pair_elements +{ + template + __host__ __device__ + void operator()(Tuple t) + { + // use unqualified swap to allow ADL to catch any user-defined swap + using thrust::swap; + swap(thrust::get<0>(t), thrust::get<1>(t)); + } +}; // end swap_pair_elements + + +} // end detail + + +template +__host__ __device__ + ForwardIterator2 swap_ranges(thrust::execution_policy &exec, + ForwardIterator1 first1, + ForwardIterator1 last1, + ForwardIterator2 first2) +{ + typedef thrust::tuple IteratorTuple; + typedef thrust::zip_iterator ZipIterator; + + ZipIterator result = thrust::for_each(exec, + thrust::make_zip_iterator(thrust::make_tuple(first1, first2)), + thrust::make_zip_iterator(thrust::make_tuple(last1, first2)), + detail::swap_pair_elements()); + return thrust::get<1>(result.get_iterator_tuple()); +} // end swap_ranges() + + +} // end generic +} // end detail +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/tabulate.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/tabulate.h new file mode 100644 index 0000000000000000000000000000000000000000..041093e82e622f206e3e635e7baf1992db1cc948 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/tabulate.h @@ -0,0 +1,48 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + void tabulate(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + UnaryOperation unary_op); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/tabulate.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/tabulate.inl new file mode 100644 index 0000000000000000000000000000000000000000..0fd2121c149bb232ed36c413815077ceb9a084dd --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/tabulate.inl @@ -0,0 +1,61 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + void tabulate(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + UnaryOperation unary_op) +{ + typedef typename iterator_difference::type difference_type; + + // by default, counting_iterator uses a 64b difference_type on 32b platforms to avoid overflowing its counter. + // this causes problems when a zip_iterator is created in transform's implementation -- ForwardIterator is + // incremented by a 64b difference_type and some compilers warn + // to avoid this, specify the counting_iterator's difference_type to be the same as ForwardIterator's. + thrust::counting_iterator iter(0); + + thrust::transform(exec, iter, iter + thrust::distance(first, last), first, unary_op); +} // end tabulate() + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/tag.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/tag.h new file mode 100644 index 0000000000000000000000000000000000000000..48f0947974f7fb80c990e1e6714bc5c24a9df569 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/tag.h @@ -0,0 +1,47 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file generic/tag.h + * \brief Implementation of the generic backend's tag. + */ + +#pragma once + +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + +// tag exists only to make the generic entry points the least priority match +// during ADL. tag should not be derived from and is constructible from anything +struct tag +{ + template + __host__ __device__ inline + tag(const T &) {} +}; + +} // end generic +} // end detail +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/temporary_buffer.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/temporary_buffer.h new file mode 100644 index 0000000000000000000000000000000000000000..6b7e01ff24bd11d1f9d2a9cc2b19f78d2c1d75c3 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/temporary_buffer.h @@ -0,0 +1,57 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + thrust::pair, typename thrust::pointer::difference_type> + get_temporary_buffer(thrust::execution_policy &exec, typename thrust::pointer::difference_type n); + + +__thrust_exec_check_disable__ +template +__host__ __device__ + void return_temporary_buffer(thrust::execution_policy &exec, Pointer p, std::ptrdiff_t n); + + +__thrust_exec_check_disable__ +template +__host__ __device__ + void return_temporary_buffer(thrust::execution_policy &exec, Pointer p); + + +} // end generic +} // end detail +} // end system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/temporary_buffer.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/temporary_buffer.inl new file mode 100644 index 0000000000000000000000000000000000000000..254c48cb915618d869a3fa1f36572293268f889b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/temporary_buffer.inl @@ -0,0 +1,86 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + thrust::pair, typename thrust::pointer::difference_type> + get_temporary_buffer(thrust::execution_policy &exec, typename thrust::pointer::difference_type n) +{ + thrust::pointer ptr = thrust::malloc(exec, n); + + // check for a failed malloc + if(!ptr.get()) + { + n = 0; + } // end if + + return thrust::make_pair(ptr, n); +} // end get_temporary_buffer() + + +__thrust_exec_check_disable__ +template +__host__ __device__ + void return_temporary_buffer(thrust::execution_policy &exec, Pointer p, std::ptrdiff_t) +{ + // If we are here, no user customization of the three-argument signature with + // a size parameter of `return_temporary_buffer` was found. There may be an + // old two-argument signature `return_temporary_buffer` though, so we make + // another ADL call to try and find one. + // + // The interface layer downcast and then did ADL dispatch - there were no + // matches for DerivedPolicy (aka no one customized the three-argument + // signature), so this overload got found an implicit upcast to + // `execution_policy` was done. Now, we're looking for a + // customization of the two-argument signature so we need to downcast again. + return_temporary_buffer(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), p); +} // end return_temporary_buffer() + + +__thrust_exec_check_disable__ +template +__host__ __device__ + void return_temporary_buffer(thrust::execution_policy &exec, Pointer p) +{ + // If we are here, no user customization of either the old two-argument + // signature or the new three-argument signature with a size parameter of + // `return_temporary_buffer` was found. + thrust::free(exec, p); +} // end return_temporary_buffer() + + +} // end generic +} // end detail +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/transform.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/transform.h new file mode 100644 index 0000000000000000000000000000000000000000..30e032696bc2e0c0afeb1c065984472c94c9fe0d --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/transform.h @@ -0,0 +1,105 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + +template +__host__ __device__ + OutputIterator transform(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + UnaryFunction op); + +template +__host__ __device__ + OutputIterator transform(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + OutputIterator result, + BinaryFunction op); + +template +__host__ __device__ + ForwardIterator transform_if(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + ForwardIterator result, + UnaryFunction unary_op, + Predicate pred); + +template +__host__ __device__ + ForwardIterator transform_if(thrust::execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + ForwardIterator result, + UnaryFunction unary_op, + Predicate pred); + +template +__host__ __device__ + ForwardIterator transform_if(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator3 stencil, + ForwardIterator result, + BinaryFunction binary_op, + Predicate pred); + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/transform.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/transform.inl new file mode 100644 index 0000000000000000000000000000000000000000..122c42580b0b0d62b173fb6eb7df2ccf85e7b4b3 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/transform.inl @@ -0,0 +1,191 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + OutputIterator transform(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + UnaryFunction op) +{ + typedef thrust::detail::unary_transform_functor UnaryTransformFunctor; + + // make an iterator tuple + typedef thrust::tuple IteratorTuple; + typedef thrust::zip_iterator ZipIterator; + + ZipIterator zipped_result = + thrust::for_each(exec, + thrust::make_zip_iterator(thrust::make_tuple(first,result)), + thrust::make_zip_iterator(thrust::make_tuple(last,result)), + UnaryTransformFunctor(op)); + + return thrust::get<1>(zipped_result.get_iterator_tuple()); +} // end transform() + + +template +__host__ __device__ + OutputIterator transform(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + OutputIterator result, + BinaryFunction op) +{ + // given the minimal system, determine the binary transform functor we need + typedef thrust::detail::binary_transform_functor BinaryTransformFunctor; + + // make an iterator tuple + typedef thrust::tuple IteratorTuple; + typedef thrust::zip_iterator ZipIterator; + + ZipIterator zipped_result = + thrust::for_each(exec, + thrust::make_zip_iterator(thrust::make_tuple(first1,first2,result)), + thrust::make_zip_iterator(thrust::make_tuple(last1,first2,result)), + BinaryTransformFunctor(op)); + + return thrust::get<2>(zipped_result.get_iterator_tuple()); +} // end transform() + + +template +__host__ __device__ + ForwardIterator transform_if(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + ForwardIterator result, + UnaryFunction unary_op, + Predicate pred) +{ + typedef thrust::detail::unary_transform_if_functor UnaryTransformIfFunctor; + + // make an iterator tuple + typedef thrust::tuple IteratorTuple; + typedef thrust::zip_iterator ZipIterator; + + ZipIterator zipped_result = + thrust::for_each(exec, + thrust::make_zip_iterator(thrust::make_tuple(first,result)), + thrust::make_zip_iterator(thrust::make_tuple(last,result)), + UnaryTransformIfFunctor(unary_op,pred)); + + return thrust::get<1>(zipped_result.get_iterator_tuple()); +} // end transform_if() + + +template +__host__ __device__ + ForwardIterator transform_if(thrust::execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + ForwardIterator result, + UnaryFunction unary_op, + Predicate pred) +{ + typedef thrust::detail::unary_transform_if_with_stencil_functor UnaryTransformIfFunctor; + + // make an iterator tuple + typedef thrust::tuple IteratorTuple; + typedef thrust::zip_iterator ZipIterator; + + ZipIterator zipped_result = + thrust::for_each(exec, + thrust::make_zip_iterator(thrust::make_tuple(first,stencil,result)), + thrust::make_zip_iterator(thrust::make_tuple(last,stencil,result)), + UnaryTransformIfFunctor(unary_op,pred)); + + return thrust::get<2>(zipped_result.get_iterator_tuple()); +} // end transform_if() + + +template +__host__ __device__ + ForwardIterator transform_if(thrust::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator3 stencil, + ForwardIterator result, + BinaryFunction binary_op, + Predicate pred) +{ + typedef thrust::detail::binary_transform_if_functor BinaryTransformIfFunctor; + + // make an iterator tuple + typedef thrust::tuple IteratorTuple; + typedef thrust::zip_iterator ZipIterator; + + ZipIterator zipped_result = + thrust::for_each(exec, + thrust::make_zip_iterator(thrust::make_tuple(first1,first2,stencil,result)), + thrust::make_zip_iterator(thrust::make_tuple(last1,first2,stencil,result)), + BinaryTransformIfFunctor(binary_op,pred)); + + return thrust::get<3>(zipped_result.get_iterator_tuple()); +} // end transform_if() + + +} // end generic +} // end detail +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/transform_reduce.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/transform_reduce.h new file mode 100644 index 0000000000000000000000000000000000000000..af510296e1ceb5dc4acf9660dbf44f8374118c94 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/transform_reduce.h @@ -0,0 +1,52 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + OutputType transform_reduce(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + UnaryFunction unary_op, + OutputType init, + BinaryFunction binary_op); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/transform_reduce.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/transform_reduce.inl new file mode 100644 index 0000000000000000000000000000000000000000..539c3b22c0475d3cd7caa267da471e823508be3b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/transform_reduce.inl @@ -0,0 +1,57 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + OutputType transform_reduce(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + UnaryFunction unary_op, + OutputType init, + BinaryFunction binary_op) +{ + thrust::transform_iterator xfrm_first(first, unary_op); + thrust::transform_iterator xfrm_last(last, unary_op); + + return thrust::reduce(exec, xfrm_first, xfrm_last, init, binary_op); +} // end transform_reduce() + + +} // end generic +} // end detail +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/transform_scan.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/transform_scan.h new file mode 100644 index 0000000000000000000000000000000000000000..05054c965a0110f0e195b8a076171cc5c42301d9 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/transform_scan.h @@ -0,0 +1,67 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + OutputIterator transform_inclusive_scan(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + UnaryFunction unary_op, + BinaryFunction binary_op); + +template +__host__ __device__ + OutputIterator transform_exclusive_scan(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + UnaryFunction unary_op, + T init, + AssociativeOperator binary_op); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/transform_scan.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/transform_scan.inl new file mode 100644 index 0000000000000000000000000000000000000000..c9c976687318bf15372a17bbf1b85600d520a985 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/transform_scan.inl @@ -0,0 +1,92 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + OutputIterator transform_inclusive_scan(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + UnaryFunction unary_op, + BinaryFunction binary_op) +{ + // Use the input iterator's value type per https://wg21.link/P0571 + using InputType = typename thrust::iterator_value::type; + using ResultType = thrust::detail::invoke_result_t; + using ValueType = thrust::remove_cvref_t; + + thrust::transform_iterator _first(first, unary_op); + thrust::transform_iterator _last(last, unary_op); + + return thrust::inclusive_scan(exec, _first, _last, result, binary_op); +} // end transform_inclusive_scan() + + +template +__host__ __device__ + OutputIterator transform_exclusive_scan(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + UnaryFunction unary_op, + InitialValueType init, + AssociativeOperator binary_op) +{ + // Use the initial value type per https://wg21.link/P0571 + using ValueType = thrust::remove_cvref_t; + + thrust::transform_iterator _first(first, unary_op); + thrust::transform_iterator _last(last, unary_op); + + return thrust::exclusive_scan(exec, _first, _last, result, init, binary_op); +} // end transform_exclusive_scan() + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/uninitialized_copy.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/uninitialized_copy.h new file mode 100644 index 0000000000000000000000000000000000000000..bac5bcf9609244777a6da64e7e46af7a1b821f34 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/uninitialized_copy.h @@ -0,0 +1,56 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + +template +__host__ __device__ + ForwardIterator uninitialized_copy(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + ForwardIterator result); + +template +__host__ __device__ + ForwardIterator uninitialized_copy_n(thrust::execution_policy &exec, + InputIterator first, + Size n, + ForwardIterator result); + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/uninitialized_copy.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/uninitialized_copy.inl new file mode 100644 index 0000000000000000000000000000000000000000..679d1f6bae8c5650bf8d4383ac09987c6fcaec7b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/uninitialized_copy.inl @@ -0,0 +1,194 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ +namespace detail +{ + +template + struct uninitialized_copy_functor +{ + template + __host__ __device__ + void operator()(Tuple t) + { + const InputType &in = thrust::get<0>(t); + OutputType &out = thrust::get<1>(t); + + ::new(static_cast(&out)) OutputType(in); + } // end operator()() +}; // end uninitialized_copy_functor + + +// non-trivial copy constructor path +template +__host__ __device__ + ForwardIterator uninitialized_copy(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + ForwardIterator result, + thrust::detail::false_type) // has_trivial_copy_constructor +{ + // zip up the iterators + typedef thrust::tuple IteratorTuple; + typedef thrust::zip_iterator ZipIterator; + + ZipIterator begin = thrust::make_zip_iterator(thrust::make_tuple(first,result)); + ZipIterator end = begin; + + // get a zip_iterator pointing to the end + const typename thrust::iterator_difference::type n = thrust::distance(first,last); + thrust::advance(end, n); + + // create a functor + typedef typename iterator_traits::value_type InputType; + typedef typename iterator_traits::value_type OutputType; + + detail::uninitialized_copy_functor f; + + // do the for_each + thrust::for_each(exec, begin, end, f); + + // return the end of the output range + return thrust::get<1>(end.get_iterator_tuple()); +} // end uninitialized_copy() + + +// trivial copy constructor path +template +__host__ __device__ + ForwardIterator uninitialized_copy(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + ForwardIterator result, + thrust::detail::true_type) // has_trivial_copy_constructor +{ + return thrust::copy(exec, first, last, result); +} // end uninitialized_copy() + + +// non-trivial copy constructor path +template +__host__ __device__ + ForwardIterator uninitialized_copy_n(thrust::execution_policy &exec, + InputIterator first, + Size n, + ForwardIterator result, + thrust::detail::false_type) // has_trivial_copy_constructor +{ + // zip up the iterators + typedef thrust::tuple IteratorTuple; + typedef thrust::zip_iterator ZipIterator; + + ZipIterator zipped_first = thrust::make_zip_iterator(thrust::make_tuple(first,result)); + + // create a functor + typedef typename iterator_traits::value_type InputType; + typedef typename iterator_traits::value_type OutputType; + + detail::uninitialized_copy_functor f; + + // do the for_each_n + ZipIterator zipped_last = thrust::for_each_n(exec, zipped_first, n, f); + + // return the end of the output range + return thrust::get<1>(zipped_last.get_iterator_tuple()); +} // end uninitialized_copy_n() + + +// trivial copy constructor path +template +__host__ __device__ + ForwardIterator uninitialized_copy_n(thrust::execution_policy &exec, + InputIterator first, + Size n, + ForwardIterator result, + thrust::detail::true_type) // has_trivial_copy_constructor +{ + return thrust::copy_n(exec, first, n, result); +} // end uninitialized_copy_n() + + +} // end detail + + +template +__host__ __device__ + ForwardIterator uninitialized_copy(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + ForwardIterator result) +{ + typedef typename iterator_traits::value_type ResultType; + + typedef typename thrust::detail::has_trivial_copy_constructor::type ResultTypeHasTrivialCopyConstructor; + + return thrust::system::detail::generic::detail::uninitialized_copy(exec, first, last, result, ResultTypeHasTrivialCopyConstructor()); +} // end uninitialized_copy() + + +template +__host__ __device__ + ForwardIterator uninitialized_copy_n(thrust::execution_policy &exec, + InputIterator first, + Size n, + ForwardIterator result) +{ + typedef typename iterator_traits::value_type ResultType; + + typedef typename thrust::detail::has_trivial_copy_constructor::type ResultTypeHasTrivialCopyConstructor; + + return thrust::system::detail::generic::detail::uninitialized_copy_n(exec, first, n, result, ResultTypeHasTrivialCopyConstructor()); +} // end uninitialized_copy_n() + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/uninitialized_fill.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/uninitialized_fill.h new file mode 100644 index 0000000000000000000000000000000000000000..4f5404508c0aa6217cc53ebad283b8adc4da2a29 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/uninitialized_fill.h @@ -0,0 +1,56 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + +template +__host__ __device__ + void uninitialized_fill(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + const T &x); + +template +__host__ __device__ + ForwardIterator uninitialized_fill_n(thrust::execution_policy &exec, + ForwardIterator first, + Size n, + const T &x); + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/uninitialized_fill.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/uninitialized_fill.inl new file mode 100644 index 0000000000000000000000000000000000000000..06241494548cdfc8e0caf66fa3018e7944ba1e6c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/uninitialized_fill.inl @@ -0,0 +1,135 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ +namespace detail +{ + +template +__host__ __device__ + void uninitialized_fill(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + const T &x, + thrust::detail::true_type) // has_trivial_copy_constructor +{ + thrust::fill(exec, first, last, x); +} // end uninitialized_fill() + +template +__host__ __device__ + void uninitialized_fill(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + const T &x, + thrust::detail::false_type) // has_trivial_copy_constructor +{ + typedef typename iterator_traits::value_type ValueType; + + thrust::for_each(exec, first, last, thrust::detail::uninitialized_fill_functor(x)); +} // end uninitialized_fill() + +template +__host__ __device__ + ForwardIterator uninitialized_fill_n(thrust::execution_policy &exec, + ForwardIterator first, + Size n, + const T &x, + thrust::detail::true_type) // has_trivial_copy_constructor +{ + return thrust::fill_n(exec, first, n, x); +} // end uninitialized_fill() + +template +__host__ __device__ + ForwardIterator uninitialized_fill_n(thrust::execution_policy &exec, + ForwardIterator first, + Size n, + const T &x, + thrust::detail::false_type) // has_trivial_copy_constructor +{ + typedef typename iterator_traits::value_type ValueType; + + return thrust::for_each_n(exec, first, n, thrust::detail::uninitialized_fill_functor(x)); +} // end uninitialized_fill() + +} // end detail + +template +__host__ __device__ + void uninitialized_fill(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + const T &x) +{ + typedef typename iterator_traits::value_type ValueType; + + typedef thrust::detail::has_trivial_copy_constructor ValueTypeHasTrivialCopyConstructor; + + thrust::system::detail::generic::detail::uninitialized_fill(exec, first, last, x, + ValueTypeHasTrivialCopyConstructor()); +} // end uninitialized_fill() + +template +__host__ __device__ + ForwardIterator uninitialized_fill_n(thrust::execution_policy &exec, + ForwardIterator first, + Size n, + const T &x) +{ + typedef typename iterator_traits::value_type ValueType; + + typedef thrust::detail::has_trivial_copy_constructor ValueTypeHasTrivialCopyConstructor; + + return thrust::system::detail::generic::detail::uninitialized_fill_n(exec, first, n, x, + ValueTypeHasTrivialCopyConstructor()); +} // end uninitialized_fill() + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/unique.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/unique.h new file mode 100644 index 0000000000000000000000000000000000000000..ce3bff884b3df43e8b4b789e9e56f67dd3aaf6e4 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/unique.h @@ -0,0 +1,97 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ +ForwardIterator unique(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last); + + +template +__host__ __device__ +ForwardIterator unique(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate binary_pred); + + +template +__host__ __device__ +OutputIterator unique_copy(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator output); + + +template +__host__ __device__ +OutputIterator unique_copy(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator output, + BinaryPredicate binary_pred); + + +template +__host__ __device__ +typename thrust::iterator_traits::difference_type + unique_count(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last); + + +template +__host__ __device__ +typename thrust::iterator_traits::difference_type + unique_count(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate binary_pred); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/unique.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/unique.inl new file mode 100644 index 0000000000000000000000000000000000000000..bb66e3585d2843cbdd62de28f4550808187c1d84 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/unique.inl @@ -0,0 +1,139 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + ForwardIterator unique(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last) +{ + typedef typename thrust::iterator_traits::value_type InputType; + + return thrust::unique(exec, first, last, thrust::equal_to()); +} // end unique() + + +template +__host__ __device__ + ForwardIterator unique(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate binary_pred) +{ + typedef typename thrust::iterator_traits::value_type InputType; + + thrust::detail::temporary_array input(exec, first, last); + + return thrust::unique_copy(exec, input.begin(), input.end(), first, binary_pred); +} // end unique() + + +template +__host__ __device__ + OutputIterator unique_copy(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator output) +{ + typedef typename thrust::iterator_value::type value_type; + return thrust::unique_copy(exec, first,last,output,thrust::equal_to()); +} // end unique_copy() + + +template +__host__ __device__ + OutputIterator unique_copy(thrust::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator output, + BinaryPredicate binary_pred) +{ + thrust::detail::head_flags stencil(first, last, binary_pred); + + using namespace thrust::placeholders; + + return thrust::copy_if(exec, first, last, stencil.begin(), output, _1); +} // end unique_copy() + + +template +__host__ __device__ + typename thrust::iterator_traits::difference_type + unique_count(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate binary_pred) +{ + thrust::detail::head_flags stencil(first, last, binary_pred); + + using namespace thrust::placeholders; + + return thrust::count_if(exec, stencil.begin(), stencil.end(), _1); +} // end unique_copy() + + +template +__host__ __device__ + typename thrust::iterator_traits::difference_type + unique_count(thrust::execution_policy &exec, + ForwardIterator first, + ForwardIterator last) +{ + typedef typename thrust::iterator_value::type value_type; + return thrust::unique_count(exec, first, last, thrust::equal_to()); +} // end unique_copy() + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/unique_by_key.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/unique_by_key.h new file mode 100644 index 0000000000000000000000000000000000000000..0ea9e7cc84523ddf7fa08897fde374b2f31d3fe0 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/unique_by_key.h @@ -0,0 +1,94 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ + thrust::pair + unique_by_key(thrust::execution_policy &exec, + ForwardIterator1 keys_first, + ForwardIterator1 keys_last, + ForwardIterator2 values_first); + + +template +__host__ __device__ + thrust::pair + unique_by_key(thrust::execution_policy &exec, + ForwardIterator1 keys_first, + ForwardIterator1 keys_last, + ForwardIterator2 values_first, + BinaryPredicate binary_pred); + + +template +__host__ __device__ + thrust::pair + unique_by_key_copy(thrust::execution_policy &exec, + InputIterator1 keys_first, + InputIterator1 keys_last, + InputIterator2 values_first, + OutputIterator1 keys_output, + OutputIterator2 values_output); + + +template +__host__ __device__ + thrust::pair + unique_by_key_copy(thrust::execution_policy &exec, + InputIterator1 keys_first, + InputIterator1 keys_last, + InputIterator2 values_first, + OutputIterator1 keys_output, + OutputIterator2 values_output, + BinaryPredicate binary_pred); + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/unique_by_key.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/unique_by_key.inl new file mode 100644 index 0000000000000000000000000000000000000000..ffcf1dd0c741902027d00e51ccf3d7b62e3c1397 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/generic/unique_by_key.inl @@ -0,0 +1,139 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace generic +{ + + +template +__host__ __device__ +thrust::pair +unique_by_key(thrust::execution_policy &exec, + ForwardIterator1 keys_first, + ForwardIterator1 keys_last, + ForwardIterator2 values_first) +{ + typedef typename thrust::iterator_traits::value_type KeyType; + return thrust::unique_by_key(exec, keys_first, keys_last, values_first, thrust::equal_to()); +} // end unique_by_key() + + +template +__host__ __device__ +thrust::pair +unique_by_key(thrust::execution_policy &exec, + ForwardIterator1 keys_first, + ForwardIterator1 keys_last, + ForwardIterator2 values_first, + BinaryPredicate binary_pred) +{ + typedef typename thrust::iterator_traits::value_type InputType1; + typedef typename thrust::iterator_traits::value_type InputType2; + + ForwardIterator2 values_last = values_first + (keys_last - keys_first); + + thrust::detail::temporary_array keys(exec, keys_first, keys_last); + thrust::detail::temporary_array vals(exec, values_first, values_last); + + return thrust::unique_by_key_copy(exec, keys.begin(), keys.end(), vals.begin(), keys_first, values_first, binary_pred); +} // end unique_by_key() + + +template +__host__ __device__ +thrust::pair +unique_by_key_copy(thrust::execution_policy &exec, + InputIterator1 keys_first, + InputIterator1 keys_last, + InputIterator2 values_first, + OutputIterator1 keys_output, + OutputIterator2 values_output) +{ + typedef typename thrust::iterator_traits::value_type KeyType; + return thrust::unique_by_key_copy(exec, keys_first, keys_last, values_first, keys_output, values_output, thrust::equal_to()); +} // end unique_by_key_copy() + + +template +__host__ __device__ +thrust::pair +unique_by_key_copy(thrust::execution_policy &exec, + InputIterator1 keys_first, + InputIterator1 keys_last, + InputIterator2 values_first, + OutputIterator1 keys_output, + OutputIterator2 values_output, + BinaryPredicate binary_pred) +{ + typedef typename thrust::iterator_traits::difference_type difference_type; + + difference_type n = thrust::distance(keys_first, keys_last); + + thrust::detail::head_flags stencil(keys_first, keys_last, binary_pred); + + using namespace thrust::placeholders; + thrust::zip_iterator< thrust::tuple > result = + thrust::copy_if(exec, + thrust::make_zip_iterator(thrust::make_tuple(keys_first, values_first)), + thrust::make_zip_iterator(thrust::make_tuple(keys_first, values_first)) + n, + stencil.begin(), + thrust::make_zip_iterator(thrust::make_tuple(keys_output, values_output)), + _1); + + difference_type output_size = result - thrust::make_zip_iterator(thrust::make_tuple(keys_output, values_output)); + + return thrust::make_pair(keys_output + output_size, values_output + output_size); +} // end unique_by_key_copy() + + +} // end namespace generic +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/internal/decompose.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/internal/decompose.h new file mode 100644 index 0000000000000000000000000000000000000000..58af7c55144c225e6f6f0cf72500547f59db581a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/internal/decompose.h @@ -0,0 +1,113 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace internal +{ + + template + class index_range + { + public: + typedef IndexType index_type; + + __host__ __device__ + index_range(index_type begin, index_type end) : m_begin(begin), m_end(end) {} + + __host__ __device__ + index_type begin(void) const { return m_begin; } + + __host__ __device__ + index_type end(void) const { return m_end; } + + __host__ __device__ + index_type size(void) const { return m_end - m_begin; } + + private: + index_type m_begin; + index_type m_end; + }; + + template + class uniform_decomposition + { + public: + typedef IndexType index_type; + typedef index_range range_type; + + __host__ __device__ + uniform_decomposition(index_type N, index_type granularity, index_type max_intervals) + : m_N(N), + m_intervals((N + granularity - 1) / granularity), + m_threshold(0), + m_small_interval(granularity), + m_large_interval(0) + { + if(m_intervals > max_intervals) + { + m_small_interval = granularity * (m_intervals / max_intervals); + m_large_interval = m_small_interval + granularity; + m_threshold = m_intervals % max_intervals; + m_intervals = max_intervals; + } + } + + __host__ __device__ + index_range operator[](const index_type& i) const + { + if (i < m_threshold) + { + index_type begin = m_large_interval * i; + index_type end = begin + m_large_interval; + return range_type(begin, end); + } + else + { + index_type begin = m_large_interval * m_threshold + m_small_interval * (i - m_threshold); + index_type end = (begin + m_small_interval < m_N) ? begin + m_small_interval : m_N; + return range_type(begin, end); + } + } + + __host__ __device__ + index_type size(void) const + { + return m_intervals; + } + + private: + + index_type m_N; + index_type m_intervals; + index_type m_threshold; + index_type m_small_interval; + index_type m_large_interval; + }; + + +} // end namespace internal +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/adjacent_difference.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/adjacent_difference.h new file mode 100644 index 0000000000000000000000000000000000000000..4a9dad82c93d6f314ee82eedd50aaf7a3970c104 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/adjacent_difference.h @@ -0,0 +1,73 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file adjacent_difference.h + * \brief Sequential implementation of adjacent_difference. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +__thrust_exec_check_disable__ +template +__host__ __device__ +OutputIterator adjacent_difference(sequential::execution_policy &, + InputIterator first, + InputIterator last, + OutputIterator result, + BinaryFunction binary_op) +{ + typedef typename thrust::iterator_traits::value_type InputType; + + if(first == last) + return result; + + InputType curr = *first; + + *result = curr; + + while(++first != last) + { + InputType next = *first; + *(++result) = binary_op(next, curr); + curr = next; + } + + return ++result; +} + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/assign_value.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/assign_value.h new file mode 100644 index 0000000000000000000000000000000000000000..0eb145d135a2f65258a93e96d411c5acc8252bb5 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/assign_value.h @@ -0,0 +1,42 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + +template +__host__ __device__ + void assign_value(sequential::execution_policy &, Pointer1 dst, Pointer2 src) +{ + *thrust::raw_pointer_cast(dst) = *thrust::raw_pointer_cast(src); +} // end assign_value() + +} // end sequential +} // end detail +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/binary_search.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/binary_search.h new file mode 100644 index 0000000000000000000000000000000000000000..2da5080f4f8511fc88590885ff4c4f3f8c06c76e --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/binary_search.h @@ -0,0 +1,158 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file binary_search.h + * \brief Sequential implementation of binary search algorithms. + */ + +#pragma once + +#include + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +__thrust_exec_check_disable__ +template +__host__ __device__ +ForwardIterator lower_bound(sequential::execution_policy &, + ForwardIterator first, + ForwardIterator last, + const T& val, + StrictWeakOrdering comp) +{ + // wrap comp + thrust::detail::wrapped_function< + StrictWeakOrdering, + bool + > wrapped_comp(comp); + + typedef typename thrust::iterator_difference::type difference_type; + + difference_type len = thrust::distance(first, last); + + while(len > 0) + { + difference_type half = len >> 1; + ForwardIterator middle = first; + + thrust::advance(middle, half); + + if(wrapped_comp(*middle, val)) + { + first = middle; + ++first; + len = len - half - 1; + } + else + { + len = half; + } + } + + return first; +} + + +__thrust_exec_check_disable__ +template +__host__ __device__ +ForwardIterator upper_bound(sequential::execution_policy &, + ForwardIterator first, + ForwardIterator last, + const T& val, + StrictWeakOrdering comp) +{ + // wrap comp + thrust::detail::wrapped_function< + StrictWeakOrdering, + bool + > wrapped_comp(comp); + + typedef typename thrust::iterator_difference::type difference_type; + + difference_type len = thrust::distance(first, last); + + while(len > 0) + { + difference_type half = len >> 1; + ForwardIterator middle = first; + + thrust::advance(middle, half); + + if(wrapped_comp(val, *middle)) + { + len = half; + } + else + { + first = middle; + ++first; + len = len - half - 1; + } + } + + return first; +} + + +__thrust_exec_check_disable__ +template +__host__ __device__ +bool binary_search(sequential::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + const T& val, + StrictWeakOrdering comp) +{ + ForwardIterator iter = sequential::lower_bound(exec, first, last, val, comp); + + // wrap comp + thrust::detail::wrapped_function< + StrictWeakOrdering, + bool + > wrapped_comp(comp); + + return iter != last && !wrapped_comp(val,*iter); +} + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/copy.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/copy.h new file mode 100644 index 0000000000000000000000000000000000000000..0dd2cdad5c36e5b167e6e2858293e47ca87fe743 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/copy.h @@ -0,0 +1,62 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +/*! \file copy.h + * \brief Sequential implementations of copy algorithms. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +template +__host__ __device__ + OutputIterator copy(sequential::execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result); + + +template +__host__ __device__ + OutputIterator copy_n(sequential::execution_policy &exec, + InputIterator first, + Size n, + OutputIterator result); + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/copy.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/copy.inl new file mode 100644 index 0000000000000000000000000000000000000000..850f20f1eaa52d5deb454890dad5e626d9561f99 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/copy.inl @@ -0,0 +1,146 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ +namespace copy_detail +{ + + +// returns the raw pointer associated with a Pointer-like thing +template +__host__ __device__ + typename thrust::detail::pointer_traits::raw_pointer + get(Pointer ptr) +{ + return thrust::detail::pointer_traits::get(ptr); +} + + +__thrust_exec_check_disable__ +template +__host__ __device__ + OutputIterator copy(InputIterator first, + InputIterator last, + OutputIterator result, + thrust::detail::true_type) // is_indirectly_trivially_relocatable_to +{ + typedef typename thrust::iterator_difference::type Size; + + const Size n = last - first; + thrust::system::detail::sequential::trivial_copy_n(get(&*first), n, get(&*result)); + return result + n; +} // end copy() + + +__thrust_exec_check_disable__ +template +__host__ __device__ + OutputIterator copy(InputIterator first, + InputIterator last, + OutputIterator result, + thrust::detail::false_type) // is_indirectly_trivially_relocatable_to +{ + return thrust::system::detail::sequential::general_copy(first,last,result); +} // end copy() + + +__thrust_exec_check_disable__ +template +__host__ __device__ + OutputIterator copy_n(InputIterator first, + Size n, + OutputIterator result, + thrust::detail::true_type) // is_indirectly_trivially_relocatable_to +{ + thrust::system::detail::sequential::trivial_copy_n(get(&*first), n, get(&*result)); + return result + n; +} // end copy_n() + + +__thrust_exec_check_disable__ +template +__host__ __device__ + OutputIterator copy_n(InputIterator first, + Size n, + OutputIterator result, + thrust::detail::false_type) // is_indirectly_trivially_relocatable_to +{ + return thrust::system::detail::sequential::general_copy_n(first,n,result); +} // end copy_n() + + +} // end namespace copy_detail + + +__thrust_exec_check_disable__ +template +__host__ __device__ + OutputIterator copy(sequential::execution_policy &, + InputIterator first, + InputIterator last, + OutputIterator result) +{ + return thrust::system::detail::sequential::copy_detail::copy(first, last, result, + typename thrust::is_indirectly_trivially_relocatable_to::type()); +} // end copy() + + +__thrust_exec_check_disable__ +template +__host__ __device__ + OutputIterator copy_n(sequential::execution_policy &, + InputIterator first, + Size n, + OutputIterator result) +{ + return thrust::system::detail::sequential::copy_detail::copy_n(first, n, result, + typename thrust::is_indirectly_trivially_relocatable_to::type()); +} // end copy_n() + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/copy_backward.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/copy_backward.h new file mode 100644 index 0000000000000000000000000000000000000000..d127ac80db244b8ee86bd50eb19f593dfb730283 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/copy_backward.h @@ -0,0 +1,53 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +__thrust_exec_check_disable__ +template +__host__ __device__ +BidirectionalIterator2 copy_backward(BidirectionalIterator1 first, + BidirectionalIterator1 last, + BidirectionalIterator2 result) +{ + while (first != last) + { + --last; + --result; + *result = *last; + } + + return result; +} + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/copy_if.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/copy_if.h new file mode 100644 index 0000000000000000000000000000000000000000..3c00956deb314cfa204ab477a05cae0f28e98221 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/copy_if.h @@ -0,0 +1,72 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +/*! \file copy_if.h + * \brief Sequential implementation of copy_if. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +__thrust_exec_check_disable__ +template +__host__ __device__ + OutputIterator copy_if(sequential::execution_policy &, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator result, + Predicate pred) +{ + thrust::detail::wrapped_function wrapped_pred(pred); + + while(first != last) + { + if(wrapped_pred(*stencil)) + { + *result = *first; + ++result; + } // end if + + ++first; + ++stencil; + } // end while + + return result; +} // end copy_if() + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/count.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/count.h new file mode 100644 index 0000000000000000000000000000000000000000..ed3cadffe364db5a6b63407a2d35ddd9d18b0a3b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/count.h @@ -0,0 +1,22 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special count functions + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/equal.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/equal.h new file mode 100644 index 0000000000000000000000000000000000000000..9d31e70f6fdaedcb3215a737888a6c5ac11621ab --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/equal.h @@ -0,0 +1,22 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special equal functions + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/execution_policy.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/execution_policy.h new file mode 100644 index 0000000000000000000000000000000000000000..99d78fc27f0b45d5c275d62080a1f80557551956 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/execution_policy.h @@ -0,0 +1,75 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +// this awkward sequence of definitions arises +// from the desire both for tag to derive +// from execution_policy and for execution_policy +// to convert to tag (when execution_policy is not +// an ancestor of tag) + +// forward declaration of tag +struct tag; + +// forward declaration of execution_policy +template struct execution_policy; + +// specialize execution_policy for tag +template<> + struct execution_policy + : thrust::execution_policy +{}; + +// tag's definition comes before the generic definition of execution_policy +struct tag : execution_policy +{ + __host__ __device__ constexpr tag() {} +}; + +// allow conversion to tag when it is not a successor +template + struct execution_policy + : thrust::execution_policy +{ + // allow conversion to tag + inline operator tag () const + { + return tag(); + } +}; + + +THRUST_INLINE_CONSTANT tag seq; + + +} // end sequential +} // end detail +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/extrema.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/extrema.h new file mode 100644 index 0000000000000000000000000000000000000000..5e5c62da6946444f16b7b11e842fbc1522b74f4c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/extrema.h @@ -0,0 +1,138 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file extrema.h + * \brief Sequential implementations of extrema functions. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +__thrust_exec_check_disable__ +template +__host__ __device__ +ForwardIterator min_element(sequential::execution_policy &, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate comp) +{ + // wrap comp + thrust::detail::wrapped_function< + BinaryPredicate, + bool + > wrapped_comp(comp); + + ForwardIterator imin = first; + + for(; first != last; ++first) + { + if(wrapped_comp(*first, *imin)) + { + imin = first; + } + } + + return imin; +} + + +__thrust_exec_check_disable__ +template +__host__ __device__ +ForwardIterator max_element(sequential::execution_policy &, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate comp) +{ + // wrap comp + thrust::detail::wrapped_function< + BinaryPredicate, + bool + > wrapped_comp(comp); + + ForwardIterator imax = first; + + for(; first != last; ++first) + { + if(wrapped_comp(*imax, *first)) + { + imax = first; + } + } + + return imax; +} + + +__thrust_exec_check_disable__ +template +__host__ __device__ +thrust::pair minmax_element(sequential::execution_policy &, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate comp) +{ + // wrap comp + thrust::detail::wrapped_function< + BinaryPredicate, + bool + > wrapped_comp(comp); + + ForwardIterator imin = first; + ForwardIterator imax = first; + + for(; first != last; ++first) + { + if(wrapped_comp(*first, *imin)) + { + imin = first; + } + + if(wrapped_comp(*imax, *first)) + { + imax = first; + } + } + + return thrust::make_pair(imin, imax); +} + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/fill.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/fill.h new file mode 100644 index 0000000000000000000000000000000000000000..20c636096c25e9a2d951ad2f50a4de72d0d1b968 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/fill.h @@ -0,0 +1,22 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special fill functions + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/find.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/find.h new file mode 100644 index 0000000000000000000000000000000000000000..54c238c715829b6270c2280efcf1f86cad5436bd --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/find.h @@ -0,0 +1,70 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file find.h + * \brief Sequential implementation of find_if. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +__thrust_exec_check_disable__ +template +__host__ __device__ +InputIterator find_if(execution_policy &, + InputIterator first, + InputIterator last, + Predicate pred) +{ + // wrap pred + thrust::detail::wrapped_function< + Predicate, + bool + > wrapped_pred(pred); + + while(first != last) + { + if (wrapped_pred(*first)) + return first; + + ++first; + } + + // return first so zip_iterator works correctly + return first; +} + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/for_each.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/for_each.h new file mode 100644 index 0000000000000000000000000000000000000000..7058c56f28ed05f41ca1a689163eb5fff48f999c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/for_each.h @@ -0,0 +1,94 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file for_each.h + * \brief Sequential implementations of for_each functions. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +__thrust_exec_check_disable__ +template +__host__ __device__ +InputIterator for_each(sequential::execution_policy &, + InputIterator first, + InputIterator last, + UnaryFunction f) +{ + // wrap f + thrust::detail::wrapped_function< + UnaryFunction, + void + > wrapped_f(f); + + for(; first != last; ++first) + { + wrapped_f(*first); + } + + return first; +} // end for_each() + + +template +__host__ __device__ +InputIterator for_each_n(sequential::execution_policy &, + InputIterator first, + Size n, + UnaryFunction f) +{ + // wrap f + thrust::detail::wrapped_function< + UnaryFunction, + void + > wrapped_f(f); + + for(Size i = 0; i != n; i++) + { + // we can dereference an OutputIterator if f does not + // try to use the reference for anything besides assignment + wrapped_f(*first); + ++first; + } + + return first; +} // end for_each_n() + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/gather.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/gather.h new file mode 100644 index 0000000000000000000000000000000000000000..a5657585eae6cb63adb21ea6b2444cad2fba2c4e --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/gather.h @@ -0,0 +1,22 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special gather functions + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/general_copy.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/general_copy.h new file mode 100644 index 0000000000000000000000000000000000000000..6ea87bbacbed77e113a7a1cdf18e31e3c80fb89a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/general_copy.h @@ -0,0 +1,146 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +/*! \file general_copy.h + * \brief Sequential copy algorithms for general iterators. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ +namespace general_copy_detail +{ + + +template +struct lazy_is_assignable + : thrust::detail::is_assignable< + typename T1::type, + typename T2::type + > +{}; + + +// sometimes OutputIterator's reference type is reported as void +// in that case, just assume that we're able to assign to it OK +template +struct reference_is_assignable + : thrust::detail::eval_if< + thrust::detail::is_same< + typename thrust::iterator_reference::type, void + >::value, + thrust::detail::true_type, + lazy_is_assignable< + thrust::iterator_reference, + thrust::iterator_reference + > + >::type +{}; + + +// introduce an iterator assign helper to deal with assignments from +// a wrapped reference + +__thrust_exec_check_disable__ +template +inline __host__ __device__ +typename thrust::detail::enable_if< + reference_is_assignable::value +>::type +iter_assign(OutputIterator dst, InputIterator src) +{ + *dst = *src; +} + + +__thrust_exec_check_disable__ +template +inline __host__ __device__ +typename thrust::detail::disable_if< + reference_is_assignable::value +>::type +iter_assign(OutputIterator dst, InputIterator src) +{ + typedef typename thrust::iterator_value::type value_type; + + // insert a temporary and hope for the best + *dst = static_cast(*src); +} + + +} // end general_copy_detail + + +__thrust_exec_check_disable__ +template +__host__ __device__ + OutputIterator general_copy(InputIterator first, + InputIterator last, + OutputIterator result) +{ + for(; first != last; ++first, ++result) + { + // gcc 4.2 crashes while instantiating iter_assign +#if (THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_GCC) && (THRUST_GCC_VERSION < 40300) + *result = *first; +#else + general_copy_detail::iter_assign(result, first); +#endif + } + + return result; +} // end general_copy() + + +__thrust_exec_check_disable__ +template +__host__ __device__ + OutputIterator general_copy_n(InputIterator first, + Size n, + OutputIterator result) +{ + for(; n > Size(0); ++first, ++result, --n) + { + // gcc 4.2 crashes while instantiating iter_assign +#if (THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_GCC) && (THRUST_GCC_VERSION < 40300) + *result = *first; +#else + general_copy_detail::iter_assign(result, first); +#endif + } + + return result; +} // end general_copy_n() + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/generate.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/generate.h new file mode 100644 index 0000000000000000000000000000000000000000..ac38be51617dc0cd61008035bc3e64a7544ac0c1 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/generate.h @@ -0,0 +1,22 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special generate functions + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/get_value.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/get_value.h new file mode 100644 index 0000000000000000000000000000000000000000..90752d8671a33076c440f1eebd235ad5b110d67a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/get_value.h @@ -0,0 +1,45 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +template +__host__ __device__ + typename thrust::iterator_value::type + get_value(sequential::execution_policy &, Pointer ptr) +{ + return *thrust::raw_pointer_cast(ptr); +} // end get_value() + + +} // end sequential +} // end detail +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/inner_product.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/inner_product.h new file mode 100644 index 0000000000000000000000000000000000000000..e6b3c0ae174718d7dc5e6a2e64cee509634c96c0 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/inner_product.h @@ -0,0 +1,22 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special inner_product functions + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/insertion_sort.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/insertion_sort.h new file mode 100644 index 0000000000000000000000000000000000000000..9acccd8e92ec39d61f3321d479fb64984a8cd8fe --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/insertion_sort.h @@ -0,0 +1,152 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +__thrust_exec_check_disable__ +template +__host__ __device__ +void insertion_sort(RandomAccessIterator first, + RandomAccessIterator last, + StrictWeakOrdering comp) +{ + typedef typename thrust::iterator_value::type value_type; + + if(first == last) return; + + // wrap comp + thrust::detail::wrapped_function< + StrictWeakOrdering, + bool + > wrapped_comp(comp); + + for(RandomAccessIterator i = first + 1; i != last; ++i) + { + value_type tmp = *i; + + if(wrapped_comp(tmp, *first)) + { + // tmp is the smallest value encountered so far + sequential::copy_backward(first, i, i + 1); + + *first = tmp; + } + else + { + // tmp is not the smallest value, can avoid checking for j == first + RandomAccessIterator j = i; + RandomAccessIterator k = i - 1; + + while(wrapped_comp(tmp, *k)) + { + *j = *k; + j = k; + --k; + } + + *j = tmp; + } + } +} + + +__thrust_exec_check_disable__ +template +__host__ __device__ +void insertion_sort_by_key(RandomAccessIterator1 first1, + RandomAccessIterator1 last1, + RandomAccessIterator2 first2, + StrictWeakOrdering comp) +{ + typedef typename thrust::iterator_value::type value_type1; + typedef typename thrust::iterator_value::type value_type2; + + if(first1 == last1) return; + + // wrap comp + thrust::detail::wrapped_function< + StrictWeakOrdering, + bool + > wrapped_comp(comp); + + RandomAccessIterator1 i1 = first1 + 1; + RandomAccessIterator2 i2 = first2 + 1; + + for(; i1 != last1; ++i1, ++i2) + { + value_type1 tmp1 = *i1; + value_type2 tmp2 = *i2; + + if(wrapped_comp(tmp1, *first1)) + { + // tmp is the smallest value encountered so far + sequential::copy_backward(first1, i1, i1 + 1); + sequential::copy_backward(first2, i2, i2 + 1); + + *first1 = tmp1; + *first2 = tmp2; + } + else + { + // tmp is not the smallest value, can avoid checking for j == first + RandomAccessIterator1 j1 = i1; + RandomAccessIterator1 k1 = i1 - 1; + + RandomAccessIterator2 j2 = i2; + RandomAccessIterator2 k2 = i2 - 1; + + while(wrapped_comp(tmp1, *k1)) + { + *j1 = *k1; + *j2 = *k2; + + j1 = k1; + j2 = k2; + + --k1; + --k2; + } + + *j1 = tmp1; + *j2 = tmp2; + } + } +} + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/iter_swap.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/iter_swap.h new file mode 100644 index 0000000000000000000000000000000000000000..7a5c481fc03f7191995239905c9f637985d86ebe --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/iter_swap.h @@ -0,0 +1,46 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +template +__host__ __device__ + void iter_swap(sequential::execution_policy &, Pointer1 a, Pointer2 b) +{ + using thrust::swap; + swap(*thrust::raw_pointer_cast(a), *thrust::raw_pointer_cast(b)); +} // end iter_swap() + + +} // end sequential +} // end detail +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/logical.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/logical.h new file mode 100644 index 0000000000000000000000000000000000000000..ee4586273566707b780b50a7ba13e2a3a038ac6e --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/logical.h @@ -0,0 +1,22 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special logical functions + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/malloc_and_free.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/malloc_and_free.h new file mode 100644 index 0000000000000000000000000000000000000000..b250140e083cd7c6ad36573f01b6703a917e2fa0 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/malloc_and_free.h @@ -0,0 +1,53 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include // for malloc & free +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +template +inline __host__ __device__ +void *malloc(execution_policy &, std::size_t n) +{ + return std::malloc(n); +} // end mallc() + + +template +inline __host__ __device__ +void free(sequential::execution_policy &, Pointer ptr) +{ + std::free(thrust::raw_pointer_cast(ptr)); +} // end mallc() + + +} // end sequential +} // end detail +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/merge.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/merge.h new file mode 100644 index 0000000000000000000000000000000000000000..a45e18004d4ee7c322231a409a4596899da0e4ee --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/merge.h @@ -0,0 +1,79 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file merge.h + * \brief Sequential implementation of merge algorithms. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +template +__host__ __device__ +OutputIterator merge(sequential::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result, + StrictWeakOrdering comp); + + +template +__host__ __device__ +thrust::pair + merge_by_key(sequential::execution_policy &exec, + InputIterator1 keys_first1, + InputIterator1 keys_last1, + InputIterator2 keys_first2, + InputIterator2 keys_last2, + InputIterator3 values_first1, + InputIterator4 values_first2, + OutputIterator1 keys_result, + OutputIterator2 values_result, + StrictWeakOrdering comp); + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/merge.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/merge.inl new file mode 100644 index 0000000000000000000000000000000000000000..08d7c0b0d4e138c098b7d268fb012cafdd6d2a65 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/merge.inl @@ -0,0 +1,154 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +__thrust_exec_check_disable__ +template +__host__ __device__ +OutputIterator merge(sequential::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result, + StrictWeakOrdering comp) +{ + // wrap comp + thrust::detail::wrapped_function< + StrictWeakOrdering, + bool + > wrapped_comp(comp); + + while(first1 != last1 && first2 != last2) + { + if(wrapped_comp(*first2, *first1)) + { + *result = *first2; + ++first2; + } // end if + else + { + *result = *first1; + ++first1; + } // end else + + ++result; + } // end while + + return thrust::copy(exec, first2, last2, thrust::copy(exec, first1, last1, result)); +} // end merge() + + +__thrust_exec_check_disable__ +template +__host__ __device__ +thrust::pair + merge_by_key(sequential::execution_policy &, + InputIterator1 keys_first1, + InputIterator1 keys_last1, + InputIterator2 keys_first2, + InputIterator2 keys_last2, + InputIterator3 values_first1, + InputIterator4 values_first2, + OutputIterator1 keys_result, + OutputIterator2 values_result, + StrictWeakOrdering comp) +{ + // wrap comp + thrust::detail::wrapped_function< + StrictWeakOrdering, + bool + > wrapped_comp(comp); + + while(keys_first1 != keys_last1 && keys_first2 != keys_last2) + { + if(!wrapped_comp(*keys_first2, *keys_first1)) + { + // *keys_first1 <= *keys_first2 + *keys_result = *keys_first1; + *values_result = *values_first1; + ++keys_first1; + ++values_first1; + } + else + { + // *keys_first1 > keys_first2 + *keys_result = *keys_first2; + *values_result = *values_first2; + ++keys_first2; + ++values_first2; + } + + ++keys_result; + ++values_result; + } + + while(keys_first1 != keys_last1) + { + *keys_result = *keys_first1; + *values_result = *values_first1; + ++keys_first1; + ++values_first1; + ++keys_result; + ++values_result; + } + + while(keys_first2 != keys_last2) + { + *keys_result = *keys_first2; + *values_result = *values_first2; + ++keys_first2; + ++values_first2; + ++keys_result; + ++values_result; + } + + return thrust::make_pair(keys_result, values_result); +} + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/mismatch.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/mismatch.h new file mode 100644 index 0000000000000000000000000000000000000000..e6094d261a0f10e388885c1eadcd7083b6448e09 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/mismatch.h @@ -0,0 +1,22 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special mismatch functions + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/partition.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/partition.h new file mode 100644 index 0000000000000000000000000000000000000000..43d5b0e2378cf25d01bd7f923d810456770f389a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/partition.h @@ -0,0 +1,340 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file partition.h + * \brief Sequential implementations of partition functions. + */ + +#pragma once + +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace detail +{ + + +// XXX WAR an unfortunate circular #inclusion problem +template class temporary_array; + + +} // end detail + +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +__thrust_exec_check_disable__ +template +__host__ __device__ +void iter_swap(ForwardIterator1 iter1, ForwardIterator2 iter2) +{ + // XXX this isn't correct because it doesn't use thrust::swap + using namespace thrust::detail; + + typedef typename thrust::iterator_value::type T; + + T temp = *iter1; + *iter1 = *iter2; + *iter2 = temp; +} + + +__thrust_exec_check_disable__ +template +__host__ __device__ + ForwardIterator partition(sequential::execution_policy &, + ForwardIterator first, + ForwardIterator last, + Predicate pred) +{ + if(first == last) + return first; + + // wrap pred + thrust::detail::wrapped_function< + Predicate, + bool + > wrapped_pred(pred); + + while(wrapped_pred(*first)) + { + if(++first == last) + return first; + } + + ForwardIterator next = first; + + while(++next != last) + { + if(wrapped_pred(*next)) + { + // Fully qualify name to disambiguate overloads found via ADL. + THRUST_NS_QUALIFIER::system::detail::sequential::iter_swap(first, next); + ++first; + } + } + + return first; +} + + +__thrust_exec_check_disable__ +template +__host__ __device__ + ForwardIterator partition(sequential::execution_policy &, + ForwardIterator first, + ForwardIterator last, + InputIterator stencil_first, + Predicate pred) +{ + if(first == last) + return first; + + // wrap pred + thrust::detail::wrapped_function< + Predicate, + bool + > wrapped_pred(pred); + + while(wrapped_pred(*stencil_first)) + { + ++stencil_first; + if(++first == last) + { + return first; + } + } + + ForwardIterator next = first; + + // advance stencil to next element as well + ++stencil_first; + + while(++next != last) + { + if(wrapped_pred(*stencil_first)) + { + // Fully qualify name to disambiguate overloads found via ADL. + THRUST_NS_QUALIFIER::system::detail::sequential::iter_swap(first, next); + ++first; + } + + ++stencil_first; + } + + return first; +} + + +__thrust_exec_check_disable__ +template +__host__ __device__ + ForwardIterator stable_partition(sequential::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Predicate pred) +{ + // wrap pred + thrust::detail::wrapped_function< + Predicate, + bool + > wrapped_pred(pred); + + typedef typename thrust::iterator_value::type T; + + typedef thrust::detail::temporary_array TempRange; + typedef typename TempRange::iterator TempIterator; + + TempRange temp(exec, first, last); + + for(TempIterator iter = temp.begin(); iter != temp.end(); ++iter) + { + if(wrapped_pred(*iter)) + { + *first = *iter; + ++first; + } + } + + ForwardIterator middle = first; + + for(TempIterator iter = temp.begin(); iter != temp.end(); ++iter) + { + if(!wrapped_pred(*iter)) + { + *first = *iter; + ++first; + } + } + + return middle; +} + + +__thrust_exec_check_disable__ +template +__host__ __device__ + ForwardIterator stable_partition(sequential::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + InputIterator stencil, + Predicate pred) +{ + // wrap pred + thrust::detail::wrapped_function< + Predicate, + bool + > wrapped_pred(pred); + + typedef typename thrust::iterator_value::type T; + + typedef thrust::detail::temporary_array TempRange; + typedef typename TempRange::iterator TempIterator; + + TempRange temp(exec, first, last); + + InputIterator stencil_iter = stencil; + for(TempIterator iter = temp.begin(); iter != temp.end(); ++iter, ++stencil_iter) + { + if(wrapped_pred(*stencil_iter)) + { + *first = *iter; + ++first; + } + } + + ForwardIterator middle = first; + stencil_iter = stencil; + + for(TempIterator iter = temp.begin(); iter != temp.end(); ++iter, ++stencil_iter) + { + if(!wrapped_pred(*stencil_iter)) + { + *first = *iter; + ++first; + } + } + + return middle; +} + + +__thrust_exec_check_disable__ +template +__host__ __device__ + thrust::pair + stable_partition_copy(sequential::execution_policy &, + InputIterator first, + InputIterator last, + OutputIterator1 out_true, + OutputIterator2 out_false, + Predicate pred) +{ + // wrap pred + thrust::detail::wrapped_function< + Predicate, + bool + > wrapped_pred(pred); + + for(; first != last; ++first) + { + if(wrapped_pred(*first)) + { + *out_true = *first; + ++out_true; + } // end if + else + { + *out_false = *first; + ++out_false; + } // end else + } + + return thrust::make_pair(out_true, out_false); +} + + +__thrust_exec_check_disable__ +template +__host__ __device__ + thrust::pair + stable_partition_copy(sequential::execution_policy &, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator1 out_true, + OutputIterator2 out_false, + Predicate pred) +{ + // wrap pred + thrust::detail::wrapped_function< + Predicate, + bool + > wrapped_pred(pred); + + for(; first != last; ++first, ++stencil) + { + if(wrapped_pred(*stencil)) + { + *out_true = *first; + ++out_true; + } // end if + else + { + *out_false = *first; + ++out_false; + } // end else + } + + return thrust::make_pair(out_true, out_false); +} + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/per_device_resource.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/per_device_resource.h new file mode 100644 index 0000000000000000000000000000000000000000..1b8d61f92169e0e09c3821e59218f0dcbb70cbe5 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/per_device_resource.h @@ -0,0 +1,22 @@ +/* + * Copyright 2018 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special per device resource functions + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/reduce.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/reduce.h new file mode 100644 index 0000000000000000000000000000000000000000..a532f71b246604ece46107ce9c0f13717d346b70 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/reduce.h @@ -0,0 +1,72 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file reduce.h + * \brief Sequential implementation of reduce algorithm. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +__thrust_exec_check_disable__ +template +__host__ __device__ + OutputType reduce(sequential::execution_policy &, + InputIterator begin, + InputIterator end, + OutputType init, + BinaryFunction binary_op) +{ + // wrap binary_op + thrust::detail::wrapped_function< + BinaryFunction, + OutputType + > wrapped_binary_op(binary_op); + + // initialize the result + OutputType result = init; + + while(begin != end) + { + result = wrapped_binary_op(result, *begin); + ++begin; + } // end while + + return result; +} + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/reduce_by_key.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/reduce_by_key.h new file mode 100644 index 0000000000000000000000000000000000000000..ef17ac5b0eaccc5dbcdfefa00b38ab08e25ec025 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/reduce_by_key.h @@ -0,0 +1,102 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +__thrust_exec_check_disable__ +template +__host__ __device__ + thrust::pair + reduce_by_key(sequential::execution_policy &, + InputIterator1 keys_first, + InputIterator1 keys_last, + InputIterator2 values_first, + OutputIterator1 keys_output, + OutputIterator2 values_output, + BinaryPredicate binary_pred, + BinaryFunction binary_op) +{ + typedef typename thrust::iterator_traits::value_type InputKeyType; + typedef typename thrust::iterator_traits::value_type InputValueType; + + // Use the input iterator's value type per https://wg21.link/P0571 + using TemporaryType = typename thrust::iterator_value::type; + + if(keys_first != keys_last) + { + InputKeyType temp_key = *keys_first; + TemporaryType temp_value = *values_first; + + for(++keys_first, ++values_first; + keys_first != keys_last; + ++keys_first, ++values_first) + { + InputKeyType key = *keys_first; + InputValueType value = *values_first; + + if(binary_pred(temp_key, key)) + { + temp_value = binary_op(temp_value, value); + } + else + { + *keys_output = temp_key; + *values_output = temp_value; + + ++keys_output; + ++values_output; + + temp_key = key; + temp_value = value; + } + } + + *keys_output = temp_key; + *values_output = temp_value; + + ++keys_output; + ++values_output; + } + + return thrust::make_pair(keys_output, values_output); +} + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/remove.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/remove.h new file mode 100644 index 0000000000000000000000000000000000000000..df564f15b03cf1c11d969808ae0440c1a6ddc79e --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/remove.h @@ -0,0 +1,201 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file remove.h + * \brief Sequential implementations of remove functions. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +__thrust_exec_check_disable__ +template +__host__ __device__ + ForwardIterator remove_if(sequential::execution_policy &, + ForwardIterator first, + ForwardIterator last, + Predicate pred) +{ + // wrap pred + thrust::detail::wrapped_function< + Predicate, + bool + > wrapped_pred(pred); + + // advance iterators until wrapped_pred(*first) is true or we reach the end of input + while(first != last && !wrapped_pred(*first)) + ++first; + + if(first == last) + return first; + + // result always trails first + ForwardIterator result = first; + + ++first; + + while(first != last) + { + if(!wrapped_pred(*first)) + { + *result = *first; + ++result; + } + ++first; + } + + return result; +} + + +__thrust_exec_check_disable__ +template +__host__ __device__ + ForwardIterator remove_if(sequential::execution_policy &, + ForwardIterator first, + ForwardIterator last, + InputIterator stencil, + Predicate pred) +{ + // wrap pred + thrust::detail::wrapped_function< + Predicate, + bool + > wrapped_pred(pred); + + // advance iterators until wrapped_pred(*stencil) is true or we reach the end of input + while(first != last && !wrapped_pred(*stencil)) + { + ++first; + ++stencil; + } + + if(first == last) + return first; + + // result always trails first + ForwardIterator result = first; + + ++first; + ++stencil; + + while(first != last) + { + if(!wrapped_pred(*stencil)) + { + *result = *first; + ++result; + } + ++first; + ++stencil; + } + + return result; +} + + +__thrust_exec_check_disable__ +template +__host__ __device__ + OutputIterator remove_copy_if(sequential::execution_policy &, + InputIterator first, + InputIterator last, + OutputIterator result, + Predicate pred) +{ + // wrap pred + thrust::detail::wrapped_function< + Predicate, + bool + > wrapped_pred(pred); + + while (first != last) + { + if (!wrapped_pred(*first)) + { + *result = *first; + ++result; + } + + ++first; + } + + return result; +} + + +__thrust_exec_check_disable__ +template +__host__ __device__ + OutputIterator remove_copy_if(sequential::execution_policy &, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator result, + Predicate pred) +{ + // wrap pred + thrust::detail::wrapped_function< + Predicate, + bool + > wrapped_pred(pred); + + while (first != last) + { + if (!wrapped_pred(*stencil)) + { + *result = *first; + ++result; + } + + ++first; + ++stencil; + } + + return result; +} + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/replace.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/replace.h new file mode 100644 index 0000000000000000000000000000000000000000..f5c8e83857175ff54bc97f6d3909518d2ff4c295 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/replace.h @@ -0,0 +1,22 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special replace functions + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/reverse.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/reverse.h new file mode 100644 index 0000000000000000000000000000000000000000..f80974e8a8d752c575a554018cd42e94600d3ab5 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/reverse.h @@ -0,0 +1,22 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special reverse functions + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/scan.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/scan.h new file mode 100644 index 0000000000000000000000000000000000000000..c5fce247582163d9e38a3031ff3076bc04dfa884 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/scan.h @@ -0,0 +1,121 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file scan.h + * \brief Sequential implementations of scan functions. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +__thrust_exec_check_disable__ +template +__host__ __device__ + OutputIterator inclusive_scan(sequential::execution_policy &, + InputIterator first, + InputIterator last, + OutputIterator result, + BinaryFunction binary_op) +{ + using namespace thrust::detail; + + // Use the input iterator's value type per https://wg21.link/P0571 + using ValueType = typename thrust::iterator_value::type; + + // wrap binary_op + thrust::detail::wrapped_function< + BinaryFunction, + ValueType + > wrapped_binary_op(binary_op); + + if(first != last) + { + ValueType sum = *first; + + *result = *first; + + for(++first, ++result; first != last; ++first, ++result) + *result = sum = wrapped_binary_op(sum,*first); + } + + return result; +} + + +__thrust_exec_check_disable__ +template +__host__ __device__ + OutputIterator exclusive_scan(sequential::execution_policy &, + InputIterator first, + InputIterator last, + OutputIterator result, + InitialValueType init, + BinaryFunction binary_op) +{ + using namespace thrust::detail; + + // Use the initial value type per https://wg21.link/P0571 + using ValueType = InitialValueType; + + if(first != last) + { + ValueType tmp = *first; // temporary value allows in-situ scan + ValueType sum = init; + + *result = sum; + sum = binary_op(sum, tmp); + + for(++first, ++result; first != last; ++first, ++result) + { + tmp = *first; + *result = sum; + sum = binary_op(sum, tmp); + } + } + + return result; +} + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/scan_by_key.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/scan_by_key.h new file mode 100644 index 0000000000000000000000000000000000000000..c428c1050e8ce19a50a9fc7745d0ac436c73b6e0 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/scan_by_key.h @@ -0,0 +1,149 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file scan_by_key.h + * \brief Sequential implementation of scan_by_key functions. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +__thrust_exec_check_disable__ +template +__host__ __device__ + OutputIterator inclusive_scan_by_key(sequential::execution_policy &, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + OutputIterator result, + BinaryPredicate binary_pred, + BinaryFunction binary_op) +{ + using KeyType = typename thrust::iterator_traits::value_type; + using ValueType = typename thrust::iterator_traits::value_type; + + // wrap binary_op + thrust::detail::wrapped_function< + BinaryFunction, + ValueType + > wrapped_binary_op(binary_op); + + if(first1 != last1) + { + KeyType prev_key = *first1; + ValueType prev_value = *first2; + + *result = prev_value; + + for(++first1, ++first2, ++result; + first1 != last1; + ++first1, ++first2, ++result) + { + KeyType key = *first1; + + if(binary_pred(prev_key, key)) + *result = prev_value = wrapped_binary_op(prev_value,*first2); + else + *result = prev_value = *first2; + + prev_key = key; + } + } + + return result; +} + + +__thrust_exec_check_disable__ +template +__host__ __device__ + OutputIterator exclusive_scan_by_key(sequential::execution_policy &, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + OutputIterator result, + T init, + BinaryPredicate binary_pred, + BinaryFunction binary_op) +{ + using KeyType = typename thrust::iterator_traits::value_type; + using ValueType = T; + + if(first1 != last1) + { + KeyType temp_key = *first1; + ValueType temp_value = *first2; + + ValueType next = init; + + // first one is init + *result = next; + + next = binary_op(next, temp_value); + + for(++first1, ++first2, ++result; + first1 != last1; + ++first1, ++first2, ++result) + { + KeyType key = *first1; + + // use temp to permit in-place scans + temp_value = *first2; + + if (!binary_pred(temp_key, key)) + next = init; // reset sum + + *result = next; + next = binary_op(next, temp_value); + + temp_key = key; + } + } + + return result; +} + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/scatter.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/scatter.h new file mode 100644 index 0000000000000000000000000000000000000000..d6817b4cb26b5cd1c1df763cba26bfed74ad47f1 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/scatter.h @@ -0,0 +1,22 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special scatter functions + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/sequence.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/sequence.h new file mode 100644 index 0000000000000000000000000000000000000000..0c090f96f348f0443a0a76e6372a0e07a72ea5a1 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/sequence.h @@ -0,0 +1,22 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special sequence functions + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/set_operations.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/set_operations.h new file mode 100644 index 0000000000000000000000000000000000000000..678754b45dd6f03457be0b7c2e283d201972bb13 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/set_operations.h @@ -0,0 +1,223 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file set_operations.h + * \brief Sequential implementation of set operation functions. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +__thrust_exec_check_disable__ +template +__host__ __device__ + OutputIterator set_difference(sequential::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result, + StrictWeakOrdering comp) +{ + // wrap comp + thrust::detail::wrapped_function< + StrictWeakOrdering, + bool + > wrapped_comp(comp); + + while(first1 != last1 && first2 != last2) + { + if(wrapped_comp(*first1,*first2)) + { + *result = *first1; + ++first1; + ++result; + } // end if + else if(wrapped_comp(*first2,*first1)) + { + ++first2; + } // end else if + else + { + ++first1; + ++first2; + } // end else + } // end while + + return thrust::copy(exec, first1, last1, result); +} // end set_difference() + + +__thrust_exec_check_disable__ +template +__host__ __device__ + OutputIterator set_intersection(sequential::execution_policy &, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result, + StrictWeakOrdering comp) +{ + // wrap comp + thrust::detail::wrapped_function< + StrictWeakOrdering, + bool + > wrapped_comp(comp); + + while(first1 != last1 && first2 != last2) + { + if(wrapped_comp(*first1,*first2)) + { + ++first1; + } // end if + else if(wrapped_comp(*first2,*first1)) + { + ++first2; + } // end else if + else + { + *result = *first1; + ++first1; + ++first2; + ++result; + } // end else + } // end while + + return result; +} // end set_intersection() + + +__thrust_exec_check_disable__ +template +__host__ __device__ + OutputIterator set_symmetric_difference(sequential::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result, + StrictWeakOrdering comp) +{ + // wrap comp + thrust::detail::wrapped_function< + StrictWeakOrdering, + bool + > wrapped_comp(comp); + + while(first1 != last1 && first2 != last2) + { + if(wrapped_comp(*first1,*first2)) + { + *result = *first1; + ++first1; + ++result; + } // end if + else if(wrapped_comp(*first2,*first1)) + { + *result = *first2; + ++first2; + ++result; + } // end else if + else + { + ++first1; + ++first2; + } // end else + } // end while + + return thrust::copy(exec, first2, last2, thrust::copy(exec, first1, last1, result)); +} // end set_symmetric_difference() + + +__thrust_exec_check_disable__ +template +__host__ __device__ + OutputIterator set_union(sequential::execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result, + StrictWeakOrdering comp) +{ + // wrap comp + thrust::detail::wrapped_function< + StrictWeakOrdering, + bool + > wrapped_comp(comp); + + while(first1 != last1 && first2 != last2) + { + if(wrapped_comp(*first1,*first2)) + { + *result = *first1; + ++first1; + } // end if + else if(wrapped_comp(*first2,*first1)) + { + *result = *first2; + ++first2; + } // end else if + else + { + *result = *first1; + ++first1; + ++first2; + } // end else + + ++result; + } // end while + + return thrust::copy(exec, first2, last2, thrust::copy(exec, first1, last1, result)); +} // end set_union() + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/sort.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/sort.h new file mode 100644 index 0000000000000000000000000000000000000000..34cc7a8ba89508e6d8de6fb8fc12cf59a83f3923 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/sort.h @@ -0,0 +1,63 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +/*! \file sort.h + * \brief Sequential implementations of sort algorithms. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +template +__host__ __device__ +void stable_sort(sequential::execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator last, + StrictWeakOrdering comp); + + +template +__host__ __device__ +void stable_sort_by_key(sequential::execution_policy &exec, + RandomAccessIterator1 first1, + RandomAccessIterator1 last1, + RandomAccessIterator2 first2, + StrictWeakOrdering comp); + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/sort.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/sort.inl new file mode 100644 index 0000000000000000000000000000000000000000..241a860aff577d6857c9eb373807e25e32c679b0 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/sort.inl @@ -0,0 +1,208 @@ +/* + * Copyright 2008-2021 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +#include +#include +#include +#include +#include + +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ +namespace sort_detail +{ + + +//////////////////// +// Primitive Sort // +//////////////////// + + +template +struct needs_reverse + : thrust::detail::integral_constant< + bool, + thrust::detail::is_same >::value + > +{}; + + +template +__host__ __device__ +void stable_sort(sequential::execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator last, + StrictWeakOrdering, + thrust::detail::true_type) +{ + thrust::system::detail::sequential::stable_primitive_sort(exec, first, last); + + // if comp is greater then reverse the keys + typedef typename thrust::iterator_traits::value_type KeyType; + + if(needs_reverse::value) + { + thrust::reverse(exec, first, last); + } +} + + +template +__host__ __device__ +void stable_sort_by_key(sequential::execution_policy &exec, + RandomAccessIterator1 first1, + RandomAccessIterator1 last1, + RandomAccessIterator2 first2, + StrictWeakOrdering, + thrust::detail::true_type) +{ + // if comp is greater then reverse the keys and values + typedef typename thrust::iterator_traits::value_type KeyType; + + // note, we also have to reverse the (unordered) input to preserve stability + if(needs_reverse::value) + { + thrust::reverse(exec, first1, last1); + thrust::reverse(exec, first2, first2 + (last1 - first1)); + } + + thrust::system::detail::sequential::stable_primitive_sort_by_key(exec, first1, last1, first2); + + if(needs_reverse::value) + { + thrust::reverse(exec, first1, last1); + thrust::reverse(exec, first2, first2 + (last1 - first1)); + } +} + + +//////////////// +// Merge Sort // +//////////////// + + +template +__host__ __device__ +void stable_sort(sequential::execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator last, + StrictWeakOrdering comp, + thrust::detail::false_type) +{ + thrust::system::detail::sequential::stable_merge_sort(exec, first, last, comp); +} + + +template +__host__ __device__ +void stable_sort_by_key(sequential::execution_policy &exec, + RandomAccessIterator1 first1, + RandomAccessIterator1 last1, + RandomAccessIterator2 first2, + StrictWeakOrdering comp, + thrust::detail::false_type) +{ + thrust::system::detail::sequential::stable_merge_sort_by_key(exec, first1, last1, first2, comp); +} + + +template +struct use_primitive_sort + : thrust::detail::and_< + thrust::detail::is_arithmetic, + thrust::detail::or_< + thrust::detail::is_same >, + thrust::detail::is_same > + > + > +{}; + + +} // end namespace sort_detail + + +template +__host__ __device__ +void stable_sort(sequential::execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator last, + StrictWeakOrdering comp) +{ + + // the compilation time of stable_primitive_sort is too expensive to use within a single CUDA thread + NV_IF_TARGET(NV_IS_HOST, ( + using KeyType = thrust::iterator_value_t; + sort_detail::use_primitive_sort use_primitive_sort; + sort_detail::stable_sort(exec, first, last, comp, use_primitive_sort); + ), ( // NV_IS_DEVICE: + thrust::detail::false_type use_primitive_sort; + sort_detail::stable_sort(exec, first, last, comp, use_primitive_sort); + )); +} + + +template +__host__ __device__ +void stable_sort_by_key(sequential::execution_policy &exec, + RandomAccessIterator1 first1, + RandomAccessIterator1 last1, + RandomAccessIterator2 first2, + StrictWeakOrdering comp) +{ + + // the compilation time of stable_primitive_sort_by_key is too expensive to use within a single CUDA thread + NV_IF_TARGET(NV_IS_HOST, ( + using KeyType = thrust::iterator_value_t; + sort_detail::use_primitive_sort use_primitive_sort; + sort_detail::stable_sort_by_key(exec, first1, last1, first2, comp, use_primitive_sort); + ), ( // NV_IS_DEVICE: + thrust::detail::false_type use_primitive_sort; + sort_detail::stable_sort_by_key(exec, first1, last1, first2, comp, use_primitive_sort); + )); +} + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/stable_merge_sort.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/stable_merge_sort.h new file mode 100644 index 0000000000000000000000000000000000000000..64aa2bf96cec0271e927e48a029aee0e8b590e4b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/stable_merge_sort.h @@ -0,0 +1,59 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +template +__host__ __device__ +void stable_merge_sort(sequential::execution_policy &exec, + RandomAccessIterator begin, + RandomAccessIterator end, + StrictWeakOrdering comp); + + +template +__host__ __device__ +void stable_merge_sort_by_key(sequential::execution_policy &exec, + RandomAccessIterator1 keys_begin, + RandomAccessIterator1 keys_end, + RandomAccessIterator2 values_begin, + StrictWeakOrdering comp); + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/stable_merge_sort.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/stable_merge_sort.inl new file mode 100644 index 0000000000000000000000000000000000000000..02f384afba1b103f3d17dcf54d4357753dc43d03 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/stable_merge_sort.inl @@ -0,0 +1,393 @@ +/* + * Copyright 2008-2021 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +#include +#include +#include +#include +#include + +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ +namespace stable_merge_sort_detail +{ + + +template +__host__ __device__ +void inplace_merge(sequential::execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator middle, + RandomAccessIterator last, + StrictWeakOrdering comp) +{ + typedef typename thrust::iterator_value::type value_type; + + thrust::detail::temporary_array a(exec, first, middle); + thrust::detail::temporary_array b(exec, middle, last); + + thrust::merge(exec, a.begin(), a.end(), b.begin(), b.end(), first, comp); +} + + +template +__host__ __device__ +void inplace_merge_by_key(sequential::execution_policy &exec, + RandomAccessIterator1 first1, + RandomAccessIterator1 middle1, + RandomAccessIterator1 last1, + RandomAccessIterator2 first2, + StrictWeakOrdering comp) +{ + typedef typename thrust::iterator_value::type value_type1; + typedef typename thrust::iterator_value::type value_type2; + + RandomAccessIterator2 middle2 = first2 + (middle1 - first1); + RandomAccessIterator2 last2 = first2 + (last1 - first1); + + thrust::detail::temporary_array lhs1(exec, first1, middle1); + thrust::detail::temporary_array rhs1(exec, middle1, last1); + thrust::detail::temporary_array lhs2(exec, first2, middle2); + thrust::detail::temporary_array rhs2(exec, middle2, last2); + + thrust::merge_by_key(exec, + lhs1.begin(), lhs1.end(), + rhs1.begin(), rhs1.end(), + lhs2.begin(), rhs2.begin(), + first1, first2, + comp); +} + + +template +__host__ __device__ +void insertion_sort_each(RandomAccessIterator first, + RandomAccessIterator last, + Size partition_size, + StrictWeakOrdering comp) +{ + if(partition_size > 1) + { + for(; first < last; first += partition_size) + { + RandomAccessIterator partition_last = (thrust::min)(last, first + partition_size); + + thrust::system::detail::sequential::insertion_sort(first, partition_last, comp); + } // end for + } // end if +} // end insertion_sort_each() + + +template +__host__ __device__ +void insertion_sort_each_by_key(RandomAccessIterator1 keys_first, + RandomAccessIterator1 keys_last, + RandomAccessIterator2 values_first, + Size partition_size, + StrictWeakOrdering comp) +{ + if(partition_size > 1) + { + for(; keys_first < keys_last; keys_first += partition_size, values_first += partition_size) + { + RandomAccessIterator1 keys_partition_last = (thrust::min)(keys_last, keys_first + partition_size); + + thrust::system::detail::sequential::insertion_sort_by_key(keys_first, keys_partition_last, values_first, comp); + } // end for + } // end if +} // end insertion_sort_each() + + +template +__host__ __device__ +void merge_adjacent_partitions(sequential::execution_policy &exec, + RandomAccessIterator1 first, + RandomAccessIterator1 last, + Size partition_size, + RandomAccessIterator2 result, + StrictWeakOrdering comp) +{ + for(; first < last; first += 2 * partition_size, result += 2 * partition_size) + { + RandomAccessIterator1 interval_middle = (thrust::min)(last, first + partition_size); + RandomAccessIterator1 interval_last = (thrust::min)(last, interval_middle + partition_size); + + thrust::merge(exec, + first, interval_middle, + interval_middle, interval_last, + result, + comp); + } // end for +} // end merge_adjacent_partitions() + + +template +__host__ __device__ +void merge_adjacent_partitions_by_key(sequential::execution_policy &exec, + RandomAccessIterator1 keys_first, + RandomAccessIterator1 keys_last, + RandomAccessIterator2 values_first, + Size partition_size, + RandomAccessIterator3 keys_result, + RandomAccessIterator4 values_result, + StrictWeakOrdering comp) +{ + Size stride = 2 * partition_size; + + for(; + keys_first < keys_last; + keys_first += stride, values_first += stride, keys_result += stride, values_result += stride) + { + RandomAccessIterator1 keys_interval_middle = (thrust::min)(keys_last, keys_first + partition_size); + RandomAccessIterator1 keys_interval_last = (thrust::min)(keys_last, keys_interval_middle + partition_size); + + RandomAccessIterator2 values_first2 = values_first + (keys_interval_middle - keys_first); + + thrust::merge_by_key(exec, + keys_first, keys_interval_middle, + keys_interval_middle, keys_interval_last, + values_first, + values_first2, + keys_result, + values_result, + comp); + } // end for +} // end merge_adjacent_partitions() + + +template +__host__ __device__ +void iterative_stable_merge_sort(sequential::execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator last, + StrictWeakOrdering comp) +{ + typedef typename thrust::iterator_value::type value_type; + typedef typename thrust::iterator_difference::type difference_type; + + difference_type n = last - first; + + thrust::detail::temporary_array temp(exec, n); + + // insertion sort each 32 element partition + difference_type partition_size = 32; + insertion_sort_each(first, last, partition_size, comp); + + // ping indicates whether or not the latest data is in the source range [first, last) + bool ping = true; + + // merge adjacent partitions until the partition size covers the entire range + for(; + partition_size < n; + partition_size *= 2, ping = !ping) + { + if(ping) + { + merge_adjacent_partitions(exec, first, last, partition_size, temp.begin(), comp); + } // end if + else + { + merge_adjacent_partitions(exec, temp.begin(), temp.end(), partition_size, first, comp); + } // end else + } // end for m + + if(!ping) + { + thrust::copy(exec, temp.begin(), temp.end(), first); + } // end if +} // end iterative_stable_merge_sort() + + +template +__host__ __device__ +void iterative_stable_merge_sort_by_key(sequential::execution_policy &exec, + RandomAccessIterator1 keys_first, + RandomAccessIterator1 keys_last, + RandomAccessIterator2 values_first, + StrictWeakOrdering comp) +{ + typedef typename thrust::iterator_value::type value_type1; + typedef typename thrust::iterator_value::type value_type2; + typedef typename thrust::iterator_difference::type difference_type; + + difference_type n = keys_last - keys_first; + + thrust::detail::temporary_array keys_temp(exec, n); + thrust::detail::temporary_array values_temp(exec, n); + + // insertion sort each 32 element partition + difference_type partition_size = 32; + insertion_sort_each_by_key(keys_first, keys_last, values_first, partition_size, comp); + + // ping indicates whether or not the latest data is in the source range [first, last) + bool ping = true; + + // merge adjacent partitions until the partition size covers the entire range + for(; + partition_size < n; + partition_size *= 2, ping = !ping) + { + if(ping) + { + merge_adjacent_partitions_by_key(exec, keys_first, keys_last, values_first, partition_size, keys_temp.begin(), values_temp.begin(), comp); + } // end if + else + { + merge_adjacent_partitions_by_key(exec, keys_temp.begin(), keys_temp.end(), values_temp.begin(), partition_size, keys_first, values_first, comp); + } // end else + } // end for m + + if(!ping) + { + thrust::copy(exec, keys_temp.begin(), keys_temp.end(), keys_first); + thrust::copy(exec, values_temp.begin(), values_temp.end(), values_first); + } // end if +} // end iterative_stable_merge_sort() + + +template +__host__ __device__ +void recursive_stable_merge_sort(sequential::execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator last, + StrictWeakOrdering comp) +{ + if(last - first <= 32) + { + thrust::system::detail::sequential::insertion_sort(first, last, comp); + } // end if + else + { + RandomAccessIterator middle = first + (last - first) / 2; + + stable_merge_sort_detail::recursive_stable_merge_sort(exec, first, middle, comp); + stable_merge_sort_detail::recursive_stable_merge_sort(exec, middle, last, comp); + stable_merge_sort_detail::inplace_merge(exec, first, middle, last, comp); + } // end else +} // end recursive_stable_merge_sort() + + +template +__host__ __device__ +void recursive_stable_merge_sort_by_key(sequential::execution_policy &exec, + RandomAccessIterator1 first1, + RandomAccessIterator1 last1, + RandomAccessIterator2 first2, + StrictWeakOrdering comp) +{ + if(last1 - first1 <= 32) + { + thrust::system::detail::sequential::insertion_sort_by_key(first1, last1, first2, comp); + } // end if + else + { + RandomAccessIterator1 middle1 = first1 + (last1 - first1) / 2; + RandomAccessIterator2 middle2 = first2 + (last1 - first1) / 2; + + stable_merge_sort_detail::recursive_stable_merge_sort_by_key(exec, first1, middle1, first2, comp); + stable_merge_sort_detail::recursive_stable_merge_sort_by_key(exec, middle1, last1, middle2, comp); + stable_merge_sort_detail::inplace_merge_by_key(exec, first1, middle1, last1, first2, comp); + } // end else +} // end recursive_stable_merge_sort_by_key() + + +} // end namespace stable_merge_sort_detail + + +template +__host__ __device__ +void stable_merge_sort(sequential::execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator last, + StrictWeakOrdering comp) +{ + NV_IF_TARGET(NV_IS_DEVICE, ( + // avoid recursion in CUDA threads + stable_merge_sort_detail::iterative_stable_merge_sort(exec, first, last, comp); + ), ( + stable_merge_sort_detail::recursive_stable_merge_sort(exec, first, last, comp); + )); +} + + +template +__host__ __device__ +void stable_merge_sort_by_key(sequential::execution_policy &exec, + RandomAccessIterator1 first1, + RandomAccessIterator1 last1, + RandomAccessIterator2 first2, + StrictWeakOrdering comp) +{ + NV_IF_TARGET(NV_IS_DEVICE, ( + // avoid recursion in CUDA threads + stable_merge_sort_detail::iterative_stable_merge_sort_by_key(exec, first1, last1, first2, comp); + ), ( + stable_merge_sort_detail::recursive_stable_merge_sort_by_key(exec, first1, last1, first2, comp); + )); +} + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/stable_primitive_sort.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/stable_primitive_sort.h new file mode 100644 index 0000000000000000000000000000000000000000..acbb81217bd979eb81ac53f0a6799bce59c6c509 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/stable_primitive_sort.h @@ -0,0 +1,55 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +template +__host__ __device__ +void stable_primitive_sort(sequential::execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator last); + + +template +__host__ __device__ +void stable_primitive_sort_by_key(sequential::execution_policy &exec, + RandomAccessIterator1 keys_first, + RandomAccessIterator1 keys_last, + RandomAccessIterator2 values_first); + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/stable_primitive_sort.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/stable_primitive_sort.inl new file mode 100644 index 0000000000000000000000000000000000000000..9897d6798da21521d6786d6c2676ce294f028549 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/stable_primitive_sort.inl @@ -0,0 +1,160 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ +namespace stable_primitive_sort_detail +{ + + +template + struct enable_if_bool_sort + : thrust::detail::enable_if< + thrust::detail::is_same< + bool, + typename thrust::iterator_value::type + >::value + > +{}; + + +template + struct disable_if_bool_sort + : thrust::detail::disable_if< + thrust::detail::is_same< + bool, + typename thrust::iterator_value::type + >::value + > +{}; + + + +template + typename enable_if_bool_sort::type +__host__ __device__ + stable_primitive_sort(sequential::execution_policy &exec, + RandomAccessIterator first, RandomAccessIterator last) +{ + // use stable_partition if we're sorting bool + // stable_partition puts true values first, so we need to logical_not + sequential::stable_partition(exec, first, last, thrust::logical_not()); +} + + +template + typename disable_if_bool_sort::type +__host__ __device__ + stable_primitive_sort(sequential::execution_policy &exec, + RandomAccessIterator first, RandomAccessIterator last) +{ + // call stable_radix_sort + sequential::stable_radix_sort(exec,first,last); +} + + +struct logical_not_first +{ + template + __host__ __device__ + bool operator()(Tuple t) + { + return !thrust::get<0>(t); + } +}; + + +template + typename enable_if_bool_sort::type +__host__ __device__ + stable_primitive_sort_by_key(sequential::execution_policy &exec, + RandomAccessIterator1 keys_first, RandomAccessIterator1 keys_last, + RandomAccessIterator2 values_first) +{ + // use stable_partition if we're sorting bool + // stable_partition puts true values first, so we need to logical_not + sequential::stable_partition(exec, + thrust::make_zip_iterator(thrust::make_tuple(keys_first, values_first)), + thrust::make_zip_iterator(thrust::make_tuple(keys_last, values_first)), + logical_not_first()); +} + + +template + typename disable_if_bool_sort::type +__host__ __device__ + stable_primitive_sort_by_key(sequential::execution_policy &exec, + RandomAccessIterator1 keys_first, RandomAccessIterator1 keys_last, + RandomAccessIterator2 values_first) +{ + // call stable_radix_sort_by_key + sequential::stable_radix_sort_by_key(exec, keys_first, keys_last, values_first); +} + + +} // end stable_primitive_sort_detail + + +template +__host__ __device__ +void stable_primitive_sort(sequential::execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator last) +{ + stable_primitive_sort_detail::stable_primitive_sort(exec, first,last); +} + + +template +__host__ __device__ +void stable_primitive_sort_by_key(sequential::execution_policy &exec, + RandomAccessIterator1 keys_first, + RandomAccessIterator1 keys_last, + RandomAccessIterator2 values_first) +{ + stable_primitive_sort_detail::stable_primitive_sort_by_key(exec, keys_first, keys_last, values_first); +} + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/stable_radix_sort.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/stable_radix_sort.h new file mode 100644 index 0000000000000000000000000000000000000000..1e9713a2cc9ba718491fb09c7214a8434f167b17 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/stable_radix_sort.h @@ -0,0 +1,55 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +template +__host__ __device__ +void stable_radix_sort(sequential::execution_policy &exec, + RandomAccessIterator begin, + RandomAccessIterator end); + + +template +__host__ __device__ +void stable_radix_sort_by_key(sequential::execution_policy &exec, + RandomAccessIterator1 keys_begin, + RandomAccessIterator1 keys_end, + RandomAccessIterator2 values_begin); + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/stable_radix_sort.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/stable_radix_sort.inl new file mode 100644 index 0000000000000000000000000000000000000000..83d95ebfd49900144a276bc05897d189bf1e88b1 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/stable_radix_sort.inl @@ -0,0 +1,597 @@ +/* + * Copyright 2008-2021 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ +namespace radix_sort_detail +{ + + +template +struct RadixEncoder : public thrust::identity +{}; + + +template <> +struct RadixEncoder : public thrust::unary_function +{ + __host__ __device__ + unsigned char operator()(char x) const + { + if(std::numeric_limits::is_signed) + { + return static_cast(x) ^ static_cast(1) << (8 * sizeof(unsigned char) - 1); + } + else + { + return x; + } + } +}; + +template <> +struct RadixEncoder : public thrust::unary_function +{ + __host__ __device__ + unsigned char operator()(signed char x) const + { + return static_cast(x) ^ static_cast(1) << (8 * sizeof(unsigned char) - 1); + } +}; + +template <> +struct RadixEncoder : public thrust::unary_function +{ + __host__ __device__ + unsigned short operator()(short x) const + { + return static_cast(x) ^ static_cast(1) << (8 * sizeof(unsigned short) - 1); + } +}; + +template <> +struct RadixEncoder : public thrust::unary_function +{ + __host__ __device__ + unsigned long operator()(long x) const + { + return x ^ static_cast(1) << (8 * sizeof(unsigned int) - 1); + } +}; + +template <> +struct RadixEncoder : public thrust::unary_function +{ + __host__ __device__ + unsigned long operator()(long x) const + { + return x ^ static_cast(1) << (8 * sizeof(unsigned long) - 1); + } +}; + +template <> +struct RadixEncoder : public thrust::unary_function +{ + __host__ __device__ + unsigned long long operator()(long long x) const + { + return x ^ static_cast(1) << (8 * sizeof(unsigned long long) - 1); + } +}; + +// ideally we'd use uint32 here and uint64 below +template <> +struct RadixEncoder : public thrust::unary_function +{ + __host__ __device__ + thrust::detail::uint32_t operator()(float x) const + { + union { float f; thrust::detail::uint32_t i; } u; + u.f = x; + thrust::detail::uint32_t mask = -static_cast(u.i >> 31) | (static_cast(1) << 31); + return u.i ^ mask; + } +}; + +template <> +struct RadixEncoder : public thrust::unary_function +{ + __host__ __device__ + thrust::detail::uint64_t operator()(double x) const + { + union { double f; thrust::detail::uint64_t i; } u; + u.f = x; + thrust::detail::uint64_t mask = -static_cast(u.i >> 63) | (static_cast(1) << 63); + return u.i ^ mask; + } +}; + + +// this functor returns a key's to its histogram bucket count and post-increments the bucket +template + struct bucket_functor +{ + typedef RadixEncoder Encoder; + typedef typename Encoder::result_type EncodedType; + typedef size_t result_type; + static const EncodedType BitMask = static_cast((1 << RadixBits) - 1); + + Encoder encode; + EncodedType bit_shift; + size_t *histogram; + + __host__ __device__ + bucket_functor(EncodedType bit_shift, size_t *histogram) + : encode(), + bit_shift(bit_shift), + histogram(histogram) + {} + + inline __host__ __device__ + size_t operator()(KeyType key) + { + const EncodedType x = encode(key); + + // note that we mutate the histogram here + return histogram[(x >> bit_shift) & BitMask]++; + } +}; + + +template +inline __host__ __device__ +void radix_shuffle_n(sequential::execution_policy &exec, + RandomAccessIterator1 first, + const size_t n, + RandomAccessIterator2 result, + Integer bit_shift, + size_t *histogram) +{ + typedef typename thrust::iterator_value::type KeyType; + + // note that we are going to mutate the histogram during this sequential scatter + thrust::scatter(exec, + first, first + n, + thrust::make_transform_iterator(first, bucket_functor(bit_shift, histogram)), + result); +} + + +template +__host__ __device__ +void radix_shuffle_n(sequential::execution_policy &exec, + RandomAccessIterator1 keys_first, + RandomAccessIterator2 values_first, + const size_t n, + RandomAccessIterator3 keys_result, + RandomAccessIterator4 values_result, + Integer bit_shift, + size_t *histogram) +{ + typedef typename thrust::iterator_value::type KeyType; + + // note that we are going to mutate the histogram during this sequential scatter + thrust::scatter(exec, + thrust::make_zip_iterator(thrust::make_tuple(keys_first, values_first)), + thrust::make_zip_iterator(thrust::make_tuple(keys_first + n, values_first + n)), + thrust::make_transform_iterator(keys_first, bucket_functor(bit_shift, histogram)), + thrust::make_zip_iterator(thrust::make_tuple(keys_result, values_result))); +} + + +template +__host__ __device__ +void radix_sort(sequential::execution_policy &exec, + RandomAccessIterator1 keys1, + RandomAccessIterator2 keys2, + RandomAccessIterator3 vals1, + RandomAccessIterator4 vals2, + const size_t N) +{ + typedef typename thrust::iterator_value::type KeyType; + + typedef RadixEncoder Encoder; + typedef typename Encoder::result_type EncodedType; + + const unsigned int NumHistograms = (8 * sizeof(EncodedType) + (RadixBits - 1)) / RadixBits; + const unsigned int HistogramSize = 1 << RadixBits; + + const EncodedType BitMask = static_cast((1 << RadixBits) - 1); + + Encoder encode; + + // storage for histograms + size_t histograms[NumHistograms][HistogramSize] = {{0}}; + + // see which passes can be eliminated + bool skip_shuffle[NumHistograms] = {false}; + + // false if most recent data is stored in (keys1,vals1) + bool flip = false; + + // compute histograms + for(size_t i = 0; i < N; i++) + { + const EncodedType x = encode(keys1[i]); + + for(unsigned int j = 0; j < NumHistograms; j++) + { + const auto BitShift = static_cast(RadixBits * j); + histograms[j][(x >> BitShift) & BitMask]++; + } + } + + // scan histograms + for(unsigned int i = 0; i < NumHistograms; i++) + { + size_t sum = 0; + + for(unsigned int j = 0; j < HistogramSize; j++) + { + size_t bin = histograms[i][j]; + + if(bin == N) + skip_shuffle[i] = true; + + histograms[i][j] = sum; + + sum = sum + bin; + } + } + + // shuffle keys and (optionally) values + for(unsigned int i = 0; i < NumHistograms; i++) + { + const EncodedType BitShift = static_cast(RadixBits * i); + + if(!skip_shuffle[i]) + { + if(flip) + { + if(HasValues) + { + radix_shuffle_n(exec, keys2, vals2, N, keys1, vals1, BitShift, histograms[i]); + } + else + { + radix_shuffle_n(exec, keys2, N, keys1, BitShift, histograms[i]); + } + } + else + { + if(HasValues) + { + radix_shuffle_n(exec, keys1, vals1, N, keys2, vals2, BitShift, histograms[i]); + } + else + { + radix_shuffle_n(exec, keys1, N, keys2, BitShift, histograms[i]); + } + } + + flip = (flip) ? false : true; + } + } + + // ensure final values are in (keys1,vals1) + if(flip) + { + thrust::copy(exec, keys2, keys2 + N, keys1); + + if(HasValues) + { + thrust::copy(exec, vals2, vals2 + N, vals1); + } + } +} + + +// Select best radix sort parameters based on sizeof(T) and input size +// These particular values were determined through empirical testing on a Core i7 950 CPU +template +struct radix_sort_dispatcher +{ +}; + +template <> +struct radix_sort_dispatcher<1> +{ + template + __host__ __device__ + void operator()(sequential::execution_policy &exec, + RandomAccessIterator1 keys1, RandomAccessIterator2 keys2, + const size_t N) + { + radix_sort_detail::radix_sort<8,false>(exec, keys1, keys2, static_cast(0), static_cast(0), N); + } + + template + __host__ __device__ + void operator()(sequential::execution_policy &exec, + RandomAccessIterator1 keys1, RandomAccessIterator2 keys2, + RandomAccessIterator3 vals1, RandomAccessIterator4 vals2, + const size_t N) + { + radix_sort_detail::radix_sort<8,true>(exec, keys1, keys2, vals1, vals2, N); + } +}; + + +template <> +struct radix_sort_dispatcher<2> +{ + template + __host__ __device__ + void operator()(sequential::execution_policy &exec, + RandomAccessIterator1 keys1, RandomAccessIterator2 keys2, + const size_t N) + { +#ifdef __QNX__ + // XXX war for nvbug 200193674 + const bool condition = true; +#else + const bool condition = N < (1 << 16); +#endif + if (condition) + { + radix_sort_detail::radix_sort<8,false>(exec, keys1, keys2, static_cast(0), static_cast(0), N); + } + else + { + radix_sort_detail::radix_sort<16,false>(exec, keys1, keys2, static_cast(0), static_cast(0), N); + } + } + + + template + __host__ __device__ + void operator()(sequential::execution_policy &exec, + RandomAccessIterator1 keys1, RandomAccessIterator2 keys2, + RandomAccessIterator3 vals1, RandomAccessIterator4 vals2, + const size_t N) + { +#ifdef __QNX__ + // XXX war for nvbug 200193674 + const bool condition = true; +#else + const bool condition = N < (1 << 15); +#endif + if (condition) + { + radix_sort_detail::radix_sort<8,true>(exec, keys1, keys2, vals1, vals2, N); + } + else + { + radix_sort_detail::radix_sort<16,true>(exec, keys1, keys2, vals1, vals2, N); + } + } +}; + + +template <> +struct radix_sort_dispatcher<4> +{ + template + __host__ __device__ + void operator()(sequential::execution_policy &exec, + RandomAccessIterator1 keys1, RandomAccessIterator2 keys2, + const size_t N) + { + if(N < (1 << 22)) + { + radix_sort_detail::radix_sort<8,false>(exec, keys1, keys2, static_cast(0), static_cast(0), N); + } + else + { + radix_sort_detail::radix_sort<4,false>(exec, keys1, keys2, static_cast(0), static_cast(0), N); + } + } + + template + __host__ __device__ + void operator()(sequential::execution_policy &exec, + RandomAccessIterator1 keys1, RandomAccessIterator2 keys2, + RandomAccessIterator3 vals1, RandomAccessIterator4 vals2, + const size_t N) + { + if(N < (1 << 22)) + { + radix_sort_detail::radix_sort<8,true>(exec, keys1, keys2, vals1, vals2, N); + } + else + { + radix_sort_detail::radix_sort<3,true>(exec, keys1, keys2, vals1, vals2, N); + } + } +}; + + +template <> +struct radix_sort_dispatcher<8> +{ + template + __host__ __device__ + void operator()(sequential::execution_policy &exec, + RandomAccessIterator1 keys1, RandomAccessIterator2 keys2, + const size_t N) + { + if(N < (1 << 21)) + { + radix_sort_detail::radix_sort<8,false>(exec, keys1, keys2, static_cast(0), static_cast(0), N); + } + else + { + radix_sort_detail::radix_sort<4,false>(exec, keys1, keys2, static_cast(0), static_cast(0), N); + } + } + + template + __host__ __device__ + void operator()(sequential::execution_policy &exec, + RandomAccessIterator1 keys1, RandomAccessIterator2 keys2, + RandomAccessIterator3 vals1, RandomAccessIterator4 vals2, + const size_t N) + { + if(N < (1 << 21)) + { + radix_sort_detail::radix_sort<8,true>(exec, keys1, keys2, vals1, vals2, N); + } + else + { + radix_sort_detail::radix_sort<3,true>(exec, keys1, keys2, vals1, vals2, N); + } + } +}; + + +template +__host__ __device__ +void radix_sort(sequential::execution_policy &exec, + RandomAccessIterator1 keys1, + RandomAccessIterator2 keys2, + const size_t N) +{ + typedef typename thrust::iterator_value::type KeyType; + radix_sort_dispatcher()(exec, keys1, keys2, N); +} + + +template +__host__ __device__ +void radix_sort(sequential::execution_policy &exec, + RandomAccessIterator1 keys1, + RandomAccessIterator2 keys2, + RandomAccessIterator3 vals1, + RandomAccessIterator4 vals2, + const size_t N) +{ + typedef typename thrust::iterator_value::type KeyType; + radix_sort_dispatcher()(exec, keys1, keys2, vals1, vals2, N); +} + + +} // namespace radix_sort_detail + + +template +__host__ __device__ +void stable_radix_sort(sequential::execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator last) +{ + typedef typename thrust::iterator_value::type KeyType; + + size_t N = last - first; + + thrust::detail::temporary_array temp(exec, N); + + radix_sort_detail::radix_sort(exec, first, temp.begin(), N); +} + + +template +__host__ __device__ +void stable_radix_sort_by_key(sequential::execution_policy &exec, + RandomAccessIterator1 first1, + RandomAccessIterator1 last1, + RandomAccessIterator2 first2) +{ + typedef typename thrust::iterator_value::type KeyType; + typedef typename thrust::iterator_value::type ValueType; + + size_t N = last1 - first1; + + thrust::detail::temporary_array temp1(exec, N); + thrust::detail::temporary_array temp2(exec, N); + + radix_sort_detail::radix_sort(exec, first1, temp1.begin(), first2, temp2.begin(), N); +} + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/swap_ranges.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/swap_ranges.h new file mode 100644 index 0000000000000000000000000000000000000000..497497d6a15286aa69371038ca204619e1a404e1 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/swap_ranges.h @@ -0,0 +1,22 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special swap_ranges functions + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/tabulate.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/tabulate.h new file mode 100644 index 0000000000000000000000000000000000000000..926cdec15a0e639b0d3523a3bd523a7d6547da9e --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/tabulate.h @@ -0,0 +1,22 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special tabulate functions + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/temporary_buffer.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/temporary_buffer.h new file mode 100644 index 0000000000000000000000000000000000000000..2adfaf2810c67462e41f271e43ad0aff9cfbf75f --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/temporary_buffer.h @@ -0,0 +1,22 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special temporary buffer functions + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/transform.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/transform.h new file mode 100644 index 0000000000000000000000000000000000000000..30305c152879af82583c7bffd6b5bb4b4fe7ac2e --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/transform.h @@ -0,0 +1,22 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special transform functions + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/transform_reduce.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/transform_reduce.h new file mode 100644 index 0000000000000000000000000000000000000000..8d2a1b3850dea55c3c8440aa7e22fdb6d002d151 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/transform_reduce.h @@ -0,0 +1,22 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special transform_reduce functions + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/transform_scan.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/transform_scan.h new file mode 100644 index 0000000000000000000000000000000000000000..c6ae90664ad9538e73febfde86c334011de417c8 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/transform_scan.h @@ -0,0 +1,22 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special version of this algorithm + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/trivial_copy.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/trivial_copy.h new file mode 100644 index 0000000000000000000000000000000000000000..ea55c8fd2019f711b08ea2024dd73487e8246c5f --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/trivial_copy.h @@ -0,0 +1,61 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +/*! \file trivial_copy.h + * \brief Sequential copy algorithms for plain-old-data. + */ + +#pragma once + +#include +#include +#include + +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +template +__host__ __device__ + T *trivial_copy_n(const T *first, + std::ptrdiff_t n, + T *result) +{ + T* return_value = NULL; + + NV_IF_TARGET(NV_IS_HOST, ( + std::memmove(result, first, n * sizeof(T)); + return_value = result + n; + ), ( // NV_IS_DEVICE: + return_value = thrust::system::detail::sequential::general_copy_n(first, n, result); + )); + + return return_value; +} // end trivial_copy_n() + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/uninitialized_copy.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/uninitialized_copy.h new file mode 100644 index 0000000000000000000000000000000000000000..c6ae90664ad9538e73febfde86c334011de417c8 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/uninitialized_copy.h @@ -0,0 +1,22 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special version of this algorithm + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/uninitialized_fill.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/uninitialized_fill.h new file mode 100644 index 0000000000000000000000000000000000000000..65e59fae5dce223c35403adc364a3e1748687923 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/uninitialized_fill.h @@ -0,0 +1,22 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special unintialized_fill functions + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/unique.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/unique.h new file mode 100644 index 0000000000000000000000000000000000000000..c4fe5268a337da89466585b11fa43591aa231571 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/unique.h @@ -0,0 +1,130 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file unique.h + * \brief Sequential implementations of unique algorithms. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +__thrust_exec_check_disable__ +template +__host__ __device__ + OutputIterator unique_copy(sequential::execution_policy &, + InputIterator first, + InputIterator last, + OutputIterator output, + BinaryPredicate binary_pred) +{ + typedef typename thrust::iterator_traits::value_type T; + + if(first != last) + { + T prev = *first; + + for(++first; first != last; ++first) + { + T temp = *first; + + if (!binary_pred(prev, temp)) + { + *output = prev; + + ++output; + + prev = temp; + } + } + + *output = prev; + ++output; + } + + return output; +} // end unique_copy() + + +template +__host__ __device__ + ForwardIterator unique(sequential::execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate binary_pred) +{ + // sequential unique_copy permits in-situ operation + return sequential::unique_copy(exec, first, last, first, binary_pred); +} // end unique() + + +template +__host__ __device__ + typename thrust::iterator_traits::difference_type + unique_count(sequential::execution_policy &, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate binary_pred) +{ + typedef typename thrust::iterator_traits::value_type T; + typename thrust::iterator_traits::difference_type count{}; + + if(first != last) + { + count++; + T prev = *first; + + for(++first; first != last; ++first) + { + T temp = *first; + + if (!binary_pred(prev, temp)) + { + count++; + prev = temp; + } + } + } + + return count; +} // end unique() + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/unique_by_key.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/unique_by_key.h new file mode 100644 index 0000000000000000000000000000000000000000..d30cc7c71530aedb7565916e2ca549bcf9d34e54 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/detail/sequential/unique_by_key.h @@ -0,0 +1,115 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file unique_by_key.h + * \brief Sequential implementations of unique_by_key algorithms. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace detail +{ +namespace sequential +{ + + +__thrust_exec_check_disable__ +template +__host__ __device__ + thrust::pair + unique_by_key_copy(sequential::execution_policy &, + InputIterator1 keys_first, + InputIterator1 keys_last, + InputIterator2 values_first, + OutputIterator1 keys_output, + OutputIterator2 values_output, + BinaryPredicate binary_pred) +{ + typedef typename thrust::iterator_traits::value_type InputKeyType; + typedef typename thrust::iterator_traits::value_type OutputValueType; + + if(keys_first != keys_last) + { + InputKeyType temp_key = *keys_first; + OutputValueType temp_value = *values_first; + + for(++keys_first, ++values_first; + keys_first != keys_last; + ++keys_first, ++values_first) + { + InputKeyType key = *keys_first; + OutputValueType value = *values_first; + + if(!binary_pred(temp_key, key)) + { + *keys_output = temp_key; + *values_output = temp_value; + + ++keys_output; + ++values_output; + + temp_key = key; + temp_value = value; + } + } + + *keys_output = temp_key; + *values_output = temp_value; + + ++keys_output; + ++values_output; + } + + return thrust::make_pair(keys_output, values_output); +} // end unique_by_key_copy() + + +template +__host__ __device__ + thrust::pair + unique_by_key(sequential::execution_policy &exec, + ForwardIterator1 keys_first, + ForwardIterator1 keys_last, + ForwardIterator2 values_first, + BinaryPredicate binary_pred) +{ + // sequential unique_by_key_copy() permits in-situ operation + return sequential::unique_by_key_copy(exec, keys_first, keys_last, values_first, keys_first, values_first, binary_pred); +} // end unique_by_key() + + +} // end namespace sequential +} // end namespace detail +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/adjacent_difference.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/adjacent_difference.h new file mode 100644 index 0000000000000000000000000000000000000000..622ee61bafdd8c80a7b6feb5083a536837fb9452 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/adjacent_difference.h @@ -0,0 +1,49 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + +template + OutputIterator adjacent_difference(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + BinaryFunction binary_op) +{ + // omp prefers generic::adjacent_difference to cpp::adjacent_difference + return thrust::system::detail::generic::adjacent_difference(exec, first, last, result, binary_op); +} // end adjacent_difference() + +} // end detail +} // end omp +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/assign_value.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/assign_value.h new file mode 100644 index 0000000000000000000000000000000000000000..cf244a02193211b9b4e4f07a6bc9b975d50e5388 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/assign_value.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits assign_value +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/binary_search.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/binary_search.h new file mode 100644 index 0000000000000000000000000000000000000000..1ed700bd8c87d1124bc04de9be1080c0bb6aa6cd --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/binary_search.h @@ -0,0 +1,72 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + + +template +ForwardIterator lower_bound(execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + const T& value, + StrictWeakOrdering comp) +{ + // omp prefers generic::lower_bound to cpp::lower_bound + return thrust::system::detail::generic::lower_bound(exec, begin, end, value, comp); +} + + +template +ForwardIterator upper_bound(execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + const T& value, + StrictWeakOrdering comp) +{ + // omp prefers generic::upper_bound to cpp::upper_bound + return thrust::system::detail::generic::upper_bound(exec, begin, end, value, comp); +} + + +template +bool binary_search(execution_policy &exec, + ForwardIterator begin, + ForwardIterator end, + const T& value, + StrictWeakOrdering comp) +{ + // omp prefers generic::binary_search to cpp::binary_search + return thrust::system::detail::generic::binary_search(exec, begin, end, value, comp); +} + + +} // end detail +} // end omp +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/copy.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/copy.h new file mode 100644 index 0000000000000000000000000000000000000000..ae7b1eed777f04c75cdab17a70bc288d79e38035 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/copy.h @@ -0,0 +1,56 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + + +template +OutputIterator copy(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result); + + +template +OutputIterator copy_n(execution_policy &exec, + InputIterator first, + Size n, + OutputIterator result); + + +} // end namespace detail +} // end namespace omp +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/copy.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/copy.inl new file mode 100644 index 0000000000000000000000000000000000000000..47f606dda63bb733657d8797d8702acf155c1182 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/copy.inl @@ -0,0 +1,136 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include + + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ +namespace dispatch +{ + + +template + OutputIterator copy(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + thrust::incrementable_traversal_tag) +{ + return thrust::system::detail::sequential::copy(exec, first, last, result); +} // end copy() + + +template + OutputIterator copy(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + thrust::random_access_traversal_tag) +{ + return thrust::system::detail::generic::copy(exec, first, last, result); +} // end copy() + + +template + OutputIterator copy_n(execution_policy &exec, + InputIterator first, + Size n, + OutputIterator result, + thrust::incrementable_traversal_tag) +{ + return thrust::system::detail::sequential::copy_n(exec, first, n, result); +} // end copy_n() + + +template + OutputIterator copy_n(execution_policy &exec, + InputIterator first, + Size n, + OutputIterator result, + thrust::random_access_traversal_tag) +{ + return thrust::system::detail::generic::copy_n(exec, first, n, result); +} // end copy_n() + + +} // end dispatch + + +template +OutputIterator copy(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result) +{ + typedef typename thrust::iterator_traversal::type traversal1; + typedef typename thrust::iterator_traversal::type traversal2; + + typedef typename thrust::detail::minimum_type::type traversal; + + // dispatch on minimum traversal + return thrust::system::omp::detail::dispatch::copy(exec, first, last, result, traversal()); +} // end copy() + + + +template +OutputIterator copy_n(execution_policy &exec, + InputIterator first, + Size n, + OutputIterator result) +{ + typedef typename thrust::iterator_traversal::type traversal1; + typedef typename thrust::iterator_traversal::type traversal2; + + typedef typename thrust::detail::minimum_type::type traversal; + + // dispatch on minimum traversal + return thrust::system::omp::detail::dispatch::copy_n(exec, first, n, result, traversal()); +} // end copy_n() + + +} // end namespace detail +} // end namespace omp +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/copy_if.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/copy_if.h new file mode 100644 index 0000000000000000000000000000000000000000..b33fd96df1270d4f94b67d31af1fdecd6fe4c323 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/copy_if.h @@ -0,0 +1,50 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + + +template + OutputIterator copy_if(execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator result, + Predicate pred); + + +} // end detail +} // end omp +} // end system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/copy_if.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/copy_if.inl new file mode 100644 index 0000000000000000000000000000000000000000..8e597d4fcc5d0dd1592ae5482821c2202979625f --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/copy_if.inl @@ -0,0 +1,53 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + + +template + OutputIterator copy_if(execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator result, + Predicate pred) +{ + // omp prefers generic::copy_if to cpp::copy_if + return thrust::system::detail::generic::copy_if(exec, first, last, stencil, result, pred); +} // end copy_if() + + +} // end detail +} // end omp +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/count.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/count.h new file mode 100644 index 0000000000000000000000000000000000000000..fde1728b77261d75c561b9042ec365281d78cee9 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/count.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits count +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/default_decomposition.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/default_decomposition.h new file mode 100644 index 0000000000000000000000000000000000000000..2fe0a24fd74dd4f8ba8122c59a6106505af3bc9a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/default_decomposition.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file default_decomposition.h + * \brief Return a decomposition that is appropriate for the OpenMP backend. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + +template +thrust::system::detail::internal::uniform_decomposition default_decomposition(IndexType n); + +} // end namespace detail +} // end namespace omp +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/default_decomposition.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/default_decomposition.inl new file mode 100644 index 0000000000000000000000000000000000000000..0698d53fbdcca8cf5682caef9e9cb26752c4d57b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/default_decomposition.inl @@ -0,0 +1,61 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include + +// don't attempt to #include this file without omp support +#if (THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE == THRUST_TRUE) +#include +#endif // omp support + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + +template +thrust::system::detail::internal::uniform_decomposition default_decomposition(IndexType n) +{ + // we're attempting to launch an omp kernel, assert we're compiling with omp support + // ======================================================================== + // X Note to the user: If you've found this line due to a compiler error, X + // X you need to OpenMP support in your compiler. X + // ======================================================================== + THRUST_STATIC_ASSERT_MSG( + (thrust::detail::depend_on_instantiation< + IndexType, (THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE == THRUST_TRUE) + >::value) + , "OpenMP compiler support is not enabled" + ); + +#if (THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE == THRUST_TRUE) + return thrust::system::detail::internal::uniform_decomposition(n, 1, omp_get_num_procs()); +#else + return thrust::system::detail::internal::uniform_decomposition(n, 1, 1); +#endif +} + +} // end namespace detail +} // end namespace omp +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/equal.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/equal.h new file mode 100644 index 0000000000000000000000000000000000000000..13398fc9db5a02ba7cd7d2141f106fa59ba2a941 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/equal.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits equal +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/execution_policy.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/execution_policy.h new file mode 100644 index 0000000000000000000000000000000000000000..f9b45312be839618126a5a0a46bcafdeaf33fbef --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/execution_policy.h @@ -0,0 +1,106 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +// put the canonical tag in the same ns as the backend's entry points +namespace omp +{ +namespace detail +{ + +// this awkward sequence of definitions arise +// from the desire both for tag to derive +// from execution_policy and for execution_policy +// to convert to tag (when execution_policy is not +// an ancestor of tag) + +// forward declaration of tag +struct tag; + +// forward declaration of execution_policy +template struct execution_policy; + +// specialize execution_policy for tag +template<> + struct execution_policy + : thrust::system::cpp::detail::execution_policy +{}; + +// tag's definition comes before the +// generic definition of execution_policy +struct tag : execution_policy {}; + +// allow conversion to tag when it is not a successor +template + struct execution_policy + : thrust::system::cpp::detail::execution_policy +{ + typedef tag tag_type; + operator tag() const { return tag(); } +}; + + +// overloads of select_system + +// XXX select_system(tbb, omp) & select_system(omp, tbb) are ambiguous +// because both convert to cpp without these overloads, which we +// arbitrarily define in the omp backend + +template +inline __host__ __device__ + System1 select_system(execution_policy s, thrust::system::tbb::detail::execution_policy) +{ + return thrust::detail::derived_cast(s); +} // end select_system() + + +template +inline __host__ __device__ + System2 select_system(thrust::system::tbb::detail::execution_policy, execution_policy s) +{ + return thrust::detail::derived_cast(s); +} // end select_system() + + +} // end detail + +// alias execution_policy and tag here +using thrust::system::omp::detail::execution_policy; +using thrust::system::omp::detail::tag; + +} // end omp +} // end system + +// alias items at top-level +namespace omp +{ + +using thrust::system::omp::execution_policy; +using thrust::system::omp::tag; + +} // end omp +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/extrema.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/extrema.h new file mode 100644 index 0000000000000000000000000000000000000000..bde4e5f80cf52b3e433607b427e23cf5de245594 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/extrema.h @@ -0,0 +1,66 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + +template +ForwardIterator max_element(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate comp) +{ + // omp prefers generic::max_element to cpp::max_element + return thrust::system::detail::generic::max_element(exec, first, last, comp); +} // end max_element() + +template +ForwardIterator min_element(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate comp) +{ + // omp prefers generic::min_element to cpp::min_element + return thrust::system::detail::generic::min_element(exec, first, last, comp); +} // end min_element() + +template +thrust::pair minmax_element(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate comp) +{ + // omp prefers generic::minmax_element to cpp::minmax_element + return thrust::system::detail::generic::minmax_element(exec, first, last, comp); +} // end minmax_element() + +} // end detail +} // end omp +} // end system +THRUST_NAMESPACE_END + + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/fill.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/fill.h new file mode 100644 index 0000000000000000000000000000000000000000..6665a264873f6a0a775de0aa670ee7567d899ad9 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/fill.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits fill +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/find.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/find.h new file mode 100644 index 0000000000000000000000000000000000000000..d2abac95e3025958d9f92e825d20b92d4ef07021 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/find.h @@ -0,0 +1,50 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file find.h + * \brief OpenMP implementation of find_if. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + +template +InputIterator find_if(execution_policy &exec, + InputIterator first, + InputIterator last, + Predicate pred) +{ + // omp prefers generic::find_if to cpp::find_if + return thrust::system::detail::generic::find_if(exec, first, last, pred); +} + +} // end namespace detail +} // end namespace omp +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/for_each.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/for_each.h new file mode 100644 index 0000000000000000000000000000000000000000..a2030f3746423d5f03b997cbe35e969fbf63edf3 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/for_each.h @@ -0,0 +1,59 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file for_each.h + * \brief Defines the interface for a function that executes a + * function or functional for each value in a given range. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + +template + RandomAccessIterator for_each(execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator last, + UnaryFunction f); + +template + RandomAccessIterator for_each_n(execution_policy &exec, + RandomAccessIterator first, + Size n, + UnaryFunction f); + +} // end namespace detail +} // end namespace omp +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/for_each.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/for_each.inl new file mode 100644 index 0000000000000000000000000000000000000000..4246d538070ae8d0d5b13d5a98ee18a7576022ba --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/for_each.inl @@ -0,0 +1,92 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + +template +RandomAccessIterator for_each_n(execution_policy &, + RandomAccessIterator first, + Size n, + UnaryFunction f) +{ + // we're attempting to launch an omp kernel, assert we're compiling with omp support + // ======================================================================== + // X Note to the user: If you've found this line due to a compiler error, X + // X you need to enable OpenMP support in your compiler. X + // ======================================================================== + THRUST_STATIC_ASSERT_MSG( + (thrust::detail::depend_on_instantiation< + RandomAccessIterator, (THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE == THRUST_TRUE) + >::value) + , "OpenMP compiler support is not enabled" + ); + + if (n <= 0) return first; //empty range + + // create a wrapped function for f + thrust::detail::wrapped_function wrapped_f(f); + + // use a signed type for the iteration variable or suffer the consequences of warnings + typedef typename thrust::iterator_difference::type DifferenceType; + DifferenceType signed_n = n; + + THRUST_PRAGMA_OMP(parallel for) + for(DifferenceType i = 0; + i < signed_n; + ++i) + { + RandomAccessIterator temp = first + i; + wrapped_f(*temp); + } + + return first + n; +} // end for_each_n() + +template + RandomAccessIterator for_each(execution_policy &s, + RandomAccessIterator first, + RandomAccessIterator last, + UnaryFunction f) +{ + return omp::detail::for_each_n(s, first, thrust::distance(first,last), f); +} // end for_each() + +} // end namespace detail +} // end namespace omp +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/gather.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/gather.h new file mode 100644 index 0000000000000000000000000000000000000000..098e0f4fbad4001632ed02ee9e9b39aa17e54ea0 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/gather.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits gather +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/generate.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/generate.h new file mode 100644 index 0000000000000000000000000000000000000000..f907b6acc079577642c446d6f0736073defc44b8 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/generate.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits generate +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/get_value.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/get_value.h new file mode 100644 index 0000000000000000000000000000000000000000..23a11a8574f77f95bc6ca96d0cd8ff6de8c71c7e --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/get_value.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits get_value +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/inner_product.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/inner_product.h new file mode 100644 index 0000000000000000000000000000000000000000..e8cf941a1dc3df1a6a516eee54f92fa610fd35cc --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/inner_product.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits inner_product +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/iter_swap.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/iter_swap.h new file mode 100644 index 0000000000000000000000000000000000000000..a096739947c8854afe003e6bf498d89683854ff1 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/iter_swap.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits iter_swap +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/logical.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/logical.h new file mode 100644 index 0000000000000000000000000000000000000000..4199063183dbc38b79c7707bb8301e5ca8aa6ad5 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/logical.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits logical +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/malloc_and_free.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/malloc_and_free.h new file mode 100644 index 0000000000000000000000000000000000000000..01ab1e6dbe1732da1f8606b7a9121c1b404edb6f --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/malloc_and_free.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits malloc and free +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/memory.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/memory.inl new file mode 100644 index 0000000000000000000000000000000000000000..db9b4f07b80c6dd808cabb6d77109e8f1c4cb426 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/memory.inl @@ -0,0 +1,86 @@ +/* + * Copyright 2008-2018 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include + +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + +// XXX circular #inclusion problems cause the compiler to believe that cpp::malloc +// is not defined +// WAR the problem by using adl to call cpp::malloc, which requires it to depend +// on a template parameter +template + pointer malloc_workaround(Tag t, std::size_t n) +{ + return pointer(malloc(t, n)); +} // end malloc_workaround() + +// XXX circular #inclusion problems cause the compiler to believe that cpp::free +// is not defined +// WAR the problem by using adl to call cpp::free, which requires it to depend +// on a template parameter +template + void free_workaround(Tag t, pointer ptr) +{ + free(t, ptr.get()); +} // end free_workaround() + +} // end detail + +inline pointer malloc(std::size_t n) +{ + // XXX this is how we'd like to implement this function, + // if not for circular #inclusion problems: + // + // return pointer(thrust::system::cpp::malloc(n)) + // + return detail::malloc_workaround(cpp::tag(), n); +} // end malloc() + +template +pointer malloc(std::size_t n) +{ + pointer raw_ptr = thrust::system::omp::malloc(sizeof(T) * n); + return pointer(reinterpret_cast(raw_ptr.get())); +} // end malloc() + +inline void free(pointer ptr) +{ + // XXX this is how we'd like to implement this function, + // if not for circular #inclusion problems: + // + // thrust::system::cpp::free(ptr) + // + detail::free_workaround(cpp::tag(), ptr); +} // end free() + +} // end omp +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/merge.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/merge.h new file mode 100644 index 0000000000000000000000000000000000000000..6a7bf6a7f80e0156a069a87793f99f324a9dd603 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/merge.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits merge +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/mismatch.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/mismatch.h new file mode 100644 index 0000000000000000000000000000000000000000..b5c6b2c4bdd1cc242c87d7526a42e21bf4b1561c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/mismatch.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits mismatch +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/par.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/par.h new file mode 100644 index 0000000000000000000000000000000000000000..b81a5d4894d3d4f3544a3defedbdd8758f2ca355 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/par.h @@ -0,0 +1,61 @@ +/* + * Copyright 2008-2018 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + + +struct par_t : thrust::system::omp::detail::execution_policy, + thrust::detail::allocator_aware_execution_policy< + thrust::system::omp::detail::execution_policy> +{ + __host__ __device__ + constexpr par_t() : thrust::system::omp::detail::execution_policy() {} +}; + + +} // end detail + + +static const detail::par_t par; + + +} // end omp +} // end system + + +// alias par here +namespace omp +{ + + +using thrust::system::omp::par; + + +} // end omp +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/partition.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/partition.h new file mode 100644 index 0000000000000000000000000000000000000000..7a6f4a93447b171e284530a8b6cfd5a3b76d793c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/partition.h @@ -0,0 +1,90 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file reduce.h + * \brief OpenMP implementation of reduce algorithms. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + + +template + ForwardIterator stable_partition(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Predicate pred); + +template + ForwardIterator stable_partition(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + InputIterator stencil, + Predicate pred); + +template + thrust::pair + stable_partition_copy(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator1 out_true, + OutputIterator2 out_false, + Predicate pred); + +template + thrust::pair + stable_partition_copy(execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator1 out_true, + OutputIterator2 out_false, + Predicate pred); + + +} // end namespace detail +} // end namespace omp +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/partition.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/partition.inl new file mode 100644 index 0000000000000000000000000000000000000000..ba0a09eafb06743ffd335563db504875047956bd --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/partition.inl @@ -0,0 +1,107 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file reduce.h + * \brief OpenMP implementation of reduce algorithms. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + + +template + ForwardIterator stable_partition(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Predicate pred) +{ + // omp prefers generic::stable_partition to cpp::stable_partition + return thrust::system::detail::generic::stable_partition(exec, first, last, pred); +} // end stable_partition() + + +template + ForwardIterator stable_partition(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + InputIterator stencil, + Predicate pred) +{ + // omp prefers generic::stable_partition to cpp::stable_partition + return thrust::system::detail::generic::stable_partition(exec, first, last, stencil, pred); +} // end stable_partition() + + +template + thrust::pair + stable_partition_copy(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator1 out_true, + OutputIterator2 out_false, + Predicate pred) +{ + // omp prefers generic::stable_partition_copy to cpp::stable_partition_copy + return thrust::system::detail::generic::stable_partition_copy(exec, first, last, out_true, out_false, pred); +} // end stable_partition_copy() + + +template + thrust::pair + stable_partition_copy(execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator1 out_true, + OutputIterator2 out_false, + Predicate pred) +{ + // omp prefers generic::stable_partition_copy to cpp::stable_partition_copy + return thrust::system::detail::generic::stable_partition_copy(exec, first, last, stencil, out_true, out_false, pred); +} // end stable_partition_copy() + + +} // end namespace detail +} // end namespace omp +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/per_device_resource.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/per_device_resource.h new file mode 100644 index 0000000000000000000000000000000000000000..1b8d61f92169e0e09c3821e59218f0dcbb70cbe5 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/per_device_resource.h @@ -0,0 +1,22 @@ +/* + * Copyright 2018 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special per device resource functions + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/pragma_omp.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/pragma_omp.h new file mode 100644 index 0000000000000000000000000000000000000000..a8eeae23449a0cd812708cb7641f87f00c1d9827 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/pragma_omp.h @@ -0,0 +1,56 @@ +/****************************************************************************** +* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the NVIDIA CORPORATION nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +******************************************************************************/ + +#pragma once + +#include + +#if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC +// MSVC ICEs when using the standard C++11 `_Pragma` operator with OpenMP +// directives. +// WAR this by using the MSVC-extension `__pragma`. See this link for more info: +// https://developercommunity.visualstudio.com/t/Using-C11s-_Pragma-with-OpenMP-dire/1590628 +#define THRUST_PRAGMA_OMP_IMPL(directive) __pragma(directive) +#else // Not MSVC: +#define THRUST_PRAGMA_OMP_IMPL(directive) _Pragma(#directive) +#endif + +// For internal use only -- THRUST_PRAGMA_OMP is used to switch between +// different flavors of openmp pragmas. Pragmas are not emitted when OpenMP is +// not available. +// +// Usage: +// Replace: #pragma omp parallel for +// With : THRUST_PRAGMA_OMP(parallel for) +// +#if defined(_NVHPC_STDPAR_OPENMP) && _NVHPC_STDPAR_OPENMP == 1 +#define THRUST_PRAGMA_OMP(directive) THRUST_PRAGMA_OMP_IMPL(omp_stdpar directive) +#elif defined(_OPENMP) +#define THRUST_PRAGMA_OMP(directive) THRUST_PRAGMA_OMP_IMPL(omp directive) +#else +#define THRUST_PRAGMA_OMP(directive) +#endif diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/reduce.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/reduce.h new file mode 100644 index 0000000000000000000000000000000000000000..5e5f2106ef7d3435e3436453140830437479939e --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/reduce.h @@ -0,0 +1,53 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file reduce.h + * \brief OpenMP implementation of reduce algorithms. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + + +template + OutputType reduce(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputType init, + BinaryFunction binary_op); + + +} // end namespace detail +} // end namespace omp +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/reduce.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/reduce.inl new file mode 100644 index 0000000000000000000000000000000000000000..6a5723780b4af8adcb0444953d8f51cdb9e6f369 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/reduce.inl @@ -0,0 +1,73 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + + +template + OutputType reduce(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputType init, + BinaryFunction binary_op) +{ + typedef typename thrust::iterator_difference::type difference_type; + + const difference_type n = thrust::distance(first,last); + + // determine first and second level decomposition + thrust::system::detail::internal::uniform_decomposition decomp1 = thrust::system::omp::detail::default_decomposition(n); + thrust::system::detail::internal::uniform_decomposition decomp2(decomp1.size() + 1, 1, 1); + + // allocate storage for the initializer and partial sums + // XXX use select_system for Tag + thrust::detail::temporary_array partial_sums(exec, decomp1.size() + 1); + + // set first element of temp array to init + partial_sums[0] = init; + + // accumulate partial sums (first level reduction) + thrust::system::omp::detail::reduce_intervals(exec, first, partial_sums.begin() + 1, binary_op, decomp1); + + // reduce partial sums (second level reduction) + thrust::system::omp::detail::reduce_intervals(exec, partial_sums.begin(), partial_sums.begin(), binary_op, decomp2); + + return partial_sums[0]; +} // end reduce() + + +} // end detail +} // end omp +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/reduce_by_key.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/reduce_by_key.h new file mode 100644 index 0000000000000000000000000000000000000000..005616de5f1adb5c29b165a666b2dfbbd6c4ddb7 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/reduce_by_key.h @@ -0,0 +1,60 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file reduce.h + * \brief OpenMP implementation of reduce algorithms. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + + +template + thrust::pair + reduce_by_key(execution_policy &exec, + InputIterator1 keys_first, + InputIterator1 keys_last, + InputIterator2 values_first, + OutputIterator1 keys_output, + OutputIterator2 values_output, + BinaryPredicate binary_pred, + BinaryFunction binary_op); + + +} // end namespace detail +} // end namespace omp +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/reduce_by_key.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/reduce_by_key.inl new file mode 100644 index 0000000000000000000000000000000000000000..4088d06345e975c9be9e5707c44d11c05df7d152 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/reduce_by_key.inl @@ -0,0 +1,58 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + +template + thrust::pair + reduce_by_key(execution_policy &exec, + InputIterator1 keys_first, + InputIterator1 keys_last, + InputIterator2 values_first, + OutputIterator1 keys_output, + OutputIterator2 values_output, + BinaryPredicate binary_pred, + BinaryFunction binary_op) +{ + // omp prefers generic::reduce_by_key to cpp::reduce_by_key + return thrust::system::detail::generic::reduce_by_key(exec, keys_first, keys_last, values_first, keys_output, values_output, binary_pred, binary_op); +} // end reduce_by_key() + + +} // end detail +} // end omp +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/reduce_intervals.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/reduce_intervals.h new file mode 100644 index 0000000000000000000000000000000000000000..1c69fc621eff869b740d049e9a171588f668def7 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/reduce_intervals.h @@ -0,0 +1,52 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file reduce_intervals.h + * \brief OpenMP implementations of reduce_intervals algorithms. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + +template +void reduce_intervals(execution_policy &exec, + InputIterator input, + OutputIterator output, + BinaryFunction binary_op, + Decomposition decomp); + +} // end namespace detail +} // end namespace omp +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/reduce_intervals.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/reduce_intervals.inl new file mode 100644 index 0000000000000000000000000000000000000000..2668a7b6059defb809f9752a61c8fd449fe9dbde --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/reduce_intervals.inl @@ -0,0 +1,95 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + +template +void reduce_intervals(execution_policy &, + InputIterator input, + OutputIterator output, + BinaryFunction binary_op, + Decomposition decomp) +{ + // we're attempting to launch an omp kernel, assert we're compiling with omp support + // ======================================================================== + // X Note to the user: If you've found this line due to a compiler error, X + // X you need to enable OpenMP support in your compiler. X + // ======================================================================== + THRUST_STATIC_ASSERT_MSG( + (thrust::detail::depend_on_instantiation< + InputIterator, (THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE == THRUST_TRUE) + >::value) + , "OpenMP compiler support is not enabled" + ); + +#if (THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE == THRUST_TRUE) + typedef typename thrust::iterator_value::type OutputType; + + // wrap binary_op + thrust::detail::wrapped_function wrapped_binary_op(binary_op); + + typedef thrust::detail::intptr_t index_type; + + index_type n = static_cast(decomp.size()); + + THRUST_PRAGMA_OMP(parallel for) + for(index_type i = 0; i < n; i++) + { + InputIterator begin = input + decomp[i].begin(); + InputIterator end = input + decomp[i].end(); + + if (begin != end) + { + OutputType sum = thrust::raw_reference_cast(*begin); + + ++begin; + + while (begin != end) + { + sum = wrapped_binary_op(sum, *begin); + ++begin; + } + + OutputIterator tmp = output + i; + *tmp = sum; + } + } +#endif // THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE +} + +} // end namespace detail +} // end namespace omp +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/remove.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/remove.h new file mode 100644 index 0000000000000000000000000000000000000000..9b2d46e75c67a8cef030f7582cedbf0573133b85 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/remove.h @@ -0,0 +1,80 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + +template + ForwardIterator remove_if(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Predicate pred); + + +template + ForwardIterator remove_if(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + InputIterator stencil, + Predicate pred); + + +template + OutputIterator remove_copy_if(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + Predicate pred); + + +template + OutputIterator remove_copy_if(execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator result, + Predicate pred); + + +} // end namespace detail +} // end namespace omp +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/remove.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/remove.inl new file mode 100644 index 0000000000000000000000000000000000000000..5330f140725cd47e229afe42d2b07493f6a3d300 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/remove.inl @@ -0,0 +1,93 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + +template + ForwardIterator remove_if(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Predicate pred) +{ + // omp prefers generic::remove_if to cpp::remove_if + return thrust::system::detail::generic::remove_if(exec, first, last, pred); +} + + +template + ForwardIterator remove_if(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + InputIterator stencil, + Predicate pred) +{ + // omp prefers generic::remove_if to cpp::remove_if + return thrust::system::detail::generic::remove_if(exec, first, last, stencil, pred); +} + + +template + OutputIterator remove_copy_if(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + Predicate pred) +{ + // omp prefers generic::remove_copy_if to cpp::remove_copy_if + return thrust::system::detail::generic::remove_copy_if(exec, first, last, result, pred); +} + +template + OutputIterator remove_copy_if(execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator result, + Predicate pred) +{ + // omp prefers generic::remove_copy_if to cpp::remove_copy_if + return thrust::system::detail::generic::remove_copy_if(exec, first, last, stencil, result, pred); +} + +} // end namespace detail +} // end namespace omp +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/replace.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/replace.h new file mode 100644 index 0000000000000000000000000000000000000000..95c5a14ba3df120019c9a5b6ed638db3f2555a5b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/replace.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits this algorithm +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/reverse.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/reverse.h new file mode 100644 index 0000000000000000000000000000000000000000..1f3e0325e257c301215e62c690837433ae24c30c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/reverse.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits reverse +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/scan.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/scan.h new file mode 100644 index 0000000000000000000000000000000000000000..f47dbbc3087c613f36de65f704505340bb8a85b0 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/scan.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits scan +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/scan_by_key.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/scan_by_key.h new file mode 100644 index 0000000000000000000000000000000000000000..7f6b42d54410703e7ba96123e9ea0655bbc79ef9 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/scan_by_key.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits this algorithm +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/scatter.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/scatter.h new file mode 100644 index 0000000000000000000000000000000000000000..95c5a14ba3df120019c9a5b6ed638db3f2555a5b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/scatter.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits this algorithm +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/sequence.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/sequence.h new file mode 100644 index 0000000000000000000000000000000000000000..c33b2d4333ce2ded0ffe73c23c20a80c5a35b928 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/sequence.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits sequence +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/set_operations.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/set_operations.h new file mode 100644 index 0000000000000000000000000000000000000000..421fa8a4bd955706497d0c9b30614035ccbbc46f --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/set_operations.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits set_operations +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/sort.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/sort.h new file mode 100644 index 0000000000000000000000000000000000000000..cf0b8c6d63687436ef479dcfc4e9a75c7928c582 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/sort.h @@ -0,0 +1,54 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + +template +void stable_sort(execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator last, + StrictWeakOrdering comp); + +template +void stable_sort_by_key(execution_policy &exec, + RandomAccessIterator1 keys_first, + RandomAccessIterator1 keys_last, + RandomAccessIterator2 values_first, + StrictWeakOrdering comp); + +} // end namespace detail +} // end namespace omp +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/sort.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/sort.inl new file mode 100644 index 0000000000000000000000000000000000000000..a0867ca4d3ebcca5e82b1062c2b88346e4fdc3cb --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/sort.inl @@ -0,0 +1,267 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// don't attempt to #include this file without omp support +#if (THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE == THRUST_TRUE) +#include +#endif // omp support + +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ +namespace sort_detail +{ + + +template +void inplace_merge(execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator middle, + RandomAccessIterator last, + StrictWeakOrdering comp) +{ + typedef typename thrust::iterator_value::type value_type; + + thrust::detail::temporary_array a(exec, first, middle); + thrust::detail::temporary_array b(exec, middle, last); + + thrust::merge(thrust::seq, a.begin(), a.end(), b.begin(), b.end(), first, comp); +} + + +template +void inplace_merge_by_key(execution_policy &exec, + RandomAccessIterator1 first1, + RandomAccessIterator1 middle1, + RandomAccessIterator1 last1, + RandomAccessIterator2 first2, + StrictWeakOrdering comp) +{ + typedef typename thrust::iterator_value::type value_type1; + typedef typename thrust::iterator_value::type value_type2; + + RandomAccessIterator2 middle2 = first2 + (middle1 - first1); + RandomAccessIterator2 last2 = first2 + (last1 - first1); + + thrust::detail::temporary_array lhs1(exec, first1, middle1); + thrust::detail::temporary_array rhs1(exec, middle1, last1); + thrust::detail::temporary_array lhs2(exec, first2, middle2); + thrust::detail::temporary_array rhs2(exec, middle2, last2); + + thrust::merge_by_key(thrust::seq, + lhs1.begin(), lhs1.end(), + rhs1.begin(), rhs1.end(), + lhs2.begin(), rhs2.begin(), + first1, first2, + comp); +} + + +} // end sort_detail + + +template +void stable_sort(execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator last, + StrictWeakOrdering comp) +{ + // we're attempting to launch an omp kernel, assert we're compiling with omp support + // ======================================================================== + // X Note to the user: If you've found this line due to a compiler error, X + // X you need to enable OpenMP support in your compiler. X + // ======================================================================== + THRUST_STATIC_ASSERT_MSG( + (thrust::detail::depend_on_instantiation< + RandomAccessIterator, (THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE == THRUST_TRUE) + >::value) + , "OpenMP compiler support is not enabled" + ); + + // Avoid issues on compilers that don't provide `omp_get_num_threads()`. +#if (THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE == THRUST_TRUE) + typedef typename thrust::iterator_difference::type IndexType; + + if(first == last) + return; + + THRUST_PRAGMA_OMP(parallel) + { + thrust::system::detail::internal::uniform_decomposition decomp(last - first, 1, omp_get_num_threads()); + + // process id + IndexType p_i = omp_get_thread_num(); + + // every thread sorts its own tile + if(p_i < decomp.size()) + { + thrust::stable_sort(thrust::seq, + first + decomp[p_i].begin(), + first + decomp[p_i].end(), + comp); + } + + THRUST_PRAGMA_OMP(barrier) + + // XXX For some reason, MSVC 2015 yields an error unless we include this meaningless semicolon here + ; + + IndexType nseg = decomp.size(); + IndexType h = 2; + + // keep track of which sub-range we're processing + IndexType a=p_i, b=p_i, c=p_i+1; + + while(nseg>1) + { + if(c >= decomp.size()) + c = decomp.size() - 1; + + if((p_i % h) == 0 && c > b) + { + sort_detail::inplace_merge(exec, + first + decomp[a].begin(), + first + decomp[b].end(), + first + decomp[c].end(), + comp); + + b = c; + c += h; + } + + nseg = (nseg + 1) / 2; + h *= 2; + + THRUST_PRAGMA_OMP(barrier) + } + } +#endif // THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE +} + + +template +void stable_sort_by_key(execution_policy &exec, + RandomAccessIterator1 keys_first, + RandomAccessIterator1 keys_last, + RandomAccessIterator2 values_first, + StrictWeakOrdering comp) +{ + // we're attempting to launch an omp kernel, assert we're compiling with omp support + // ======================================================================== + // X Note to the user: If you've found this line due to a compiler error, X + // X you need to enable OpenMP support in your compiler. X + // ======================================================================== + THRUST_STATIC_ASSERT_MSG( + (thrust::detail::depend_on_instantiation< + RandomAccessIterator1, (THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE == THRUST_TRUE) + >::value) + , "OpenMP compiler support is not enabled" + ); + + // Avoid issues on compilers that don't provide `omp_get_num_threads()`. +#if (THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE == THRUST_TRUE) + typedef typename thrust::iterator_difference::type IndexType; + + if(keys_first == keys_last) + return; + + THRUST_PRAGMA_OMP(parallel) + { + thrust::system::detail::internal::uniform_decomposition decomp(keys_last - keys_first, 1, omp_get_num_threads()); + + // process id + IndexType p_i = omp_get_thread_num(); + + // every thread sorts its own tile + if(p_i < decomp.size()) + { + thrust::stable_sort_by_key(thrust::seq, + keys_first + decomp[p_i].begin(), + keys_first + decomp[p_i].end(), + values_first + decomp[p_i].begin(), + comp); + } + + THRUST_PRAGMA_OMP(barrier) + + // XXX For some reason, MSVC 2015 yields an error unless we include this meaningless semicolon here + ; + + IndexType nseg = decomp.size(); + IndexType h = 2; + + // keep track of which sub-range we're processing + IndexType a=p_i, b=p_i, c=p_i+1; + + while(nseg>1) + { + if(c >= decomp.size()) + c = decomp.size() - 1; + + if((p_i % h) == 0 && c > b) + { + sort_detail::inplace_merge_by_key(exec, + keys_first + decomp[a].begin(), + keys_first + decomp[b].end(), + keys_first + decomp[c].end(), + values_first + decomp[a].begin(), + comp); + + b = c; + c += h; + } + + nseg = (nseg + 1) / 2; + h *= 2; + + THRUST_PRAGMA_OMP(barrier) + } + } +#endif // THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE +} + + +} // end namespace detail +} // end namespace omp +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/swap_ranges.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/swap_ranges.h new file mode 100644 index 0000000000000000000000000000000000000000..8c3338b1baf58a3628245072f4f4700dcd3bc025 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/swap_ranges.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// omp inherits swap_ranges +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/tabulate.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/tabulate.h new file mode 100644 index 0000000000000000000000000000000000000000..ea135c707064b7195e4a78efc15849ba431e9068 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/tabulate.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits tabulate +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/temporary_buffer.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/temporary_buffer.h new file mode 100644 index 0000000000000000000000000000000000000000..2adfaf2810c67462e41f271e43ad0aff9cfbf75f --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/temporary_buffer.h @@ -0,0 +1,22 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special temporary buffer functions + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/transform.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/transform.h new file mode 100644 index 0000000000000000000000000000000000000000..20d606dfbeec6d376a138db500ec368d94efa748 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/transform.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// omp inherits transform +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/transform_reduce.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/transform_reduce.h new file mode 100644 index 0000000000000000000000000000000000000000..a8736bd75d06e54d9158baeb2504162d75312885 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/transform_reduce.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits transform_reduce +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/transform_scan.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/transform_scan.h new file mode 100644 index 0000000000000000000000000000000000000000..75b075b6b16f063a1c5cda8893911d3f3c533f2d --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/transform_scan.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits transform_scan +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/uninitialized_copy.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/uninitialized_copy.h new file mode 100644 index 0000000000000000000000000000000000000000..bda06ac13e9ca1d14ee5e047986884f5207d3d2b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/uninitialized_copy.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits uninitialized_copy +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/uninitialized_fill.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/uninitialized_fill.h new file mode 100644 index 0000000000000000000000000000000000000000..764de876233a012e5a9de9113c5fb2dac7a22499 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/uninitialized_fill.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits uninitialized_fill +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/unique.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/unique.h new file mode 100644 index 0000000000000000000000000000000000000000..cf8025665acee615e51d31b854f9626546ccb296 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/unique.h @@ -0,0 +1,68 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + + +template + ForwardIterator unique(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate binary_pred); + + +template + OutputIterator unique_copy(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator output, + BinaryPredicate binary_pred); + + +template + typename thrust::iterator_traits::difference_type + unique_count(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate binary_pred); + + +} // end namespace detail +} // end namespace omp +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/unique.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/unique.inl new file mode 100644 index 0000000000000000000000000000000000000000..9a93fb1358407090e1885024b408ca86b822094d --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/unique.inl @@ -0,0 +1,79 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + + +template + ForwardIterator unique(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate binary_pred) +{ + // omp prefers generic::unique to cpp::unique + return thrust::system::detail::generic::unique(exec,first,last,binary_pred); +} // end unique() + + +template + OutputIterator unique_copy(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator output, + BinaryPredicate binary_pred) +{ + // omp prefers generic::unique_copy to cpp::unique_copy + return thrust::system::detail::generic::unique_copy(exec,first,last,output,binary_pred); +} // end unique_copy() + + +template + typename thrust::iterator_traits::difference_type + unique_count(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate binary_pred) +{ + // omp prefers generic::unique_count to cpp::unique_count + return thrust::system::detail::generic::unique_count(exec,first,last,binary_pred); +} // end unique_count() + + +} // end namespace detail +} // end namespace omp +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/unique_by_key.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/unique_by_key.h new file mode 100644 index 0000000000000000000000000000000000000000..43859b64e89fbbf297fc63e34a3d8dace58bc58a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/unique_by_key.h @@ -0,0 +1,66 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + + +template + thrust::pair + unique_by_key(execution_policy &exec, + ForwardIterator1 keys_first, + ForwardIterator1 keys_last, + ForwardIterator2 values_first, + BinaryPredicate binary_pred); + + +template + thrust::pair + unique_by_key_copy(execution_policy &exec, + InputIterator1 keys_first, + InputIterator1 keys_last, + InputIterator2 values_first, + OutputIterator1 keys_output, + OutputIterator2 values_output, + BinaryPredicate binary_pred); + + +} // end namespace detail +} // end namespace omp +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/unique_by_key.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/unique_by_key.inl new file mode 100644 index 0000000000000000000000000000000000000000..6610c8a0080e5f7642632d4901fe39100f80db8b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/detail/unique_by_key.inl @@ -0,0 +1,73 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + + +template + thrust::pair + unique_by_key(execution_policy &exec, + ForwardIterator1 keys_first, + ForwardIterator1 keys_last, + ForwardIterator2 values_first, + BinaryPredicate binary_pred) +{ + // omp prefers generic::unique_by_key to cpp::unique_by_key + return thrust::system::detail::generic::unique_by_key(exec,keys_first,keys_last,values_first,binary_pred); +} // end unique_by_key() + + +template + thrust::pair + unique_by_key_copy(execution_policy &exec, + InputIterator1 keys_first, + InputIterator1 keys_last, + InputIterator2 values_first, + OutputIterator1 keys_output, + OutputIterator2 values_output, + BinaryPredicate binary_pred) +{ + // omp prefers generic::unique_by_key_copy to cpp::unique_by_key_copy + return thrust::system::detail::generic::unique_by_key_copy(exec,keys_first,keys_last,values_first,keys_output,values_output,binary_pred); +} // end unique_by_key_copy() + + +} // end namespace detail +} // end namespace omp +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/execution_policy.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/execution_policy.h new file mode 100644 index 0000000000000000000000000000000000000000..c027d6be67d3d269415acf3e53f60cb61201688f --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/execution_policy.h @@ -0,0 +1,155 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +/*! \file thrust/system/omp/execution_policy.h + * \brief Execution policies for Thrust's OpenMP system. + */ + +#include + +// get the execution policies definitions first +#include + +// get the definition of par +#include + +// now get all the algorithm definitions + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +// define these entities here for the purpose of Doxygenating them +// they are actually defined elsewhere +#if 0 +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ + + +/*! \addtogroup execution_policies + * \{ + */ + + +/*! \p thrust::omp::execution_policy is the base class for all Thrust parallel execution + * policies which are derived from Thrust's OpenMP backend system. + */ +template +struct execution_policy : thrust::execution_policy +{}; + + +/*! \p omp::tag is a type representing Thrust's standard C++ backend system in C++'s type system. + * Iterators "tagged" with a type which is convertible to \p omp::tag assert that they may be + * "dispatched" to algorithm implementations in the \p omp system. + */ +struct tag : thrust::system::omp::execution_policy { unspecified }; + + +/*! \p thrust::omp::par is the parallel execution policy associated with Thrust's OpenMP + * backend system. + * + * Instead of relying on implicit algorithm dispatch through iterator system tags, users may + * directly target Thrust's OpenMP backend system by providing \p thrust::omp::par as an algorithm + * parameter. + * + * Explicit dispatch can be useful in avoiding the introduction of data copies into containers such + * as \p thrust::omp::vector. + * + * The type of \p thrust::omp::par is implementation-defined. + * + * The following code snippet demonstrates how to use \p thrust::omp::par to explicitly dispatch an + * invocation of \p thrust::for_each to the OpenMP backend system: + * + * \code + * #include + * #include + * #include + * + * struct printf_functor + * { + * __host__ __device__ + * void operator()(int x) + * { + * printf("%d\n", x); + * } + * }; + * ... + * int vec[3]; + * vec[0] = 0; vec[1] = 1; vec[2] = 2; + * + * thrust::for_each(thrust::omp::par, vec.begin(), vec.end(), printf_functor()); + * + * // 0 1 2 is printed to standard output in some unspecified order + * \endcode + */ +static const unspecified par; + + +/*! \} + */ + + +} // end cpp +} // end system +THRUST_NAMESPACE_END +#endif + + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/memory.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/memory.h new file mode 100644 index 0000000000000000000000000000000000000000..31f407c4c6f2666ee2da965413b73492fe41420c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/memory.h @@ -0,0 +1,101 @@ +/* + * Copyright 2008-2018 NVIDIA Corporation + * + * 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. + */ + +/*! \file thrust/system/omp/memory.h + * \brief Managing memory associated with Thrust's OpenMP system. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system { namespace omp +{ + +/*! Allocates an area of memory available to Thrust's omp system. + * \param n Number of bytes to allocate. + * \return A omp::pointer pointing to the beginning of the newly + * allocated memory. A null omp::pointer is returned if + * an error occurs. + * \note The omp::pointer returned by this function must be + * deallocated with \p omp::free. + * \see omp::free + * \see std::malloc + */ +inline pointer malloc(std::size_t n); + +/*! Allocates a typed area of memory available to Thrust's omp system. + * \param n Number of elements to allocate. + * \return A omp::pointer pointing to the beginning of the newly + * allocated memory. A null omp::pointer is returned if + * an error occurs. + * \note The omp::pointer returned by this function must be + * deallocated with \p omp::free. + * \see omp::free + * \see std::malloc + */ +template +inline pointer malloc(std::size_t n); + +/*! Deallocates an area of memory previously allocated by omp::malloc. + * \param ptr A omp::pointer pointing to the beginning of an area + * of memory previously allocated with omp::malloc. + * \see omp::malloc + * \see std::free + */ +inline void free(pointer ptr); + +/*! \p omp::allocator is the default allocator used by the \p omp system's + * containers such as omp::vector if no user-specified allocator is + * provided. \p omp::allocator allocates (deallocates) storage with \p + * omp::malloc (\p omp::free). + */ +template +using allocator = thrust::mr::stateless_resource_allocator< + T, thrust::system::omp::memory_resource +>; + +/*! \p omp::universal_allocator allocates memory that can be used by the \p omp + * system and host systems. + */ +template +using universal_allocator = thrust::mr::stateless_resource_allocator< + T, thrust::system::omp::universal_memory_resource +>; + +}} // namespace system::omp + +/*! \namespace thrust::omp + * \brief \p thrust::omp is a top-level alias for thrust::system::omp. + */ +namespace omp +{ +using thrust::system::omp::malloc; +using thrust::system::omp::free; +using thrust::system::omp::allocator; +using thrust::system::omp::universal_allocator; +} // namespace omp + +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/memory_resource.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/memory_resource.h new file mode 100644 index 0000000000000000000000000000000000000000..d8eed0c0f9e6f16f1dc8c0f6ae13cb26b077eb32 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/memory_resource.h @@ -0,0 +1,69 @@ +/* + * Copyright 2018-2020 NVIDIA Corporation + * + * 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. + */ + +/*! \file omp/memory_resource.h + * \brief Memory resources for the OpenMP system. + */ + +#pragma once + +#include +#include +#include + +#include + +THRUST_NAMESPACE_BEGIN +namespace system { namespace omp +{ + +//! \cond +namespace detail +{ + typedef thrust::mr::fancy_pointer_resource< + thrust::mr::new_delete_resource, + thrust::omp::pointer + > native_resource; + + typedef thrust::mr::fancy_pointer_resource< + thrust::mr::new_delete_resource, + thrust::omp::universal_pointer + > universal_native_resource; +} // namespace detail +//! \endcond + +/*! \addtogroup memory_resources Memory Resources + * \ingroup memory_management + * \{ + */ + +/*! The memory resource for the OpenMP system. Uses \p mr::new_delete_resource + * and tags it with \p omp::pointer. + */ +typedef detail::native_resource memory_resource; +/*! The unified memory resource for the OpenMP system. Uses + * \p mr::new_delete_resource and tags it with \p omp::universal_pointer. + */ +typedef detail::universal_native_resource universal_memory_resource; +/*! An alias for \p omp::universal_memory_resource. */ +typedef detail::native_resource universal_host_pinned_memory_resource; + +/*! \} + */ + +}} // namespace system::omp + +THRUST_NAMESPACE_END diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/pointer.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/pointer.h new file mode 100644 index 0000000000000000000000000000000000000000..2be42e4fcf6c83355cc514e2954fb896c75c87f3 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/pointer.h @@ -0,0 +1,117 @@ +/* + * Copyright 2008-2020 NVIDIA Corporation + * + * 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. + */ + +/*! \file thrust/system/omp/memory.h + * \brief Managing memory associated with Thrust's OpenMP system. + */ + +#pragma once + +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system { namespace omp +{ + +/*! \p omp::pointer stores a pointer to an object allocated in memory accessible + * by the \p omp system. This type provides type safety when dispatching + * algorithms on ranges resident in \p omp memory. + * + * \p omp::pointer has pointer semantics: it may be dereferenced and + * manipulated with pointer arithmetic. + * + * \p omp::pointer can be created with the function \p omp::malloc, or by + * explicitly calling its constructor with a raw pointer. + * + * The raw pointer encapsulated by a \p omp::pointer may be obtained by eiter its + * get member function or the \p raw_pointer_cast function. + * + * \note \p omp::pointer is not a "smart" pointer; it is the programmer's + * responsibility to deallocate memory pointed to by \p omp::pointer. + * + * \tparam T specifies the type of the pointee. + * + * \see omp::malloc + * \see omp::free + * \see raw_pointer_cast + */ +template +using pointer = thrust::pointer< + T, + thrust::system::omp::tag, + thrust::tagged_reference +>; + +/*! \p omp::universal_pointer stores a pointer to an object allocated in memory + * accessible by the \p omp system and host systems. + * + * \p omp::universal_pointer has pointer semantics: it may be dereferenced and + * manipulated with pointer arithmetic. + * + * \p omp::universal_pointer can be created with \p omp::universal_allocator + * or by explicitly calling its constructor with a raw pointer. + * + * The raw pointer encapsulated by a \p omp::universal_pointer may be obtained + * by eiter its get member function or the \p raw_pointer_cast + * function. + * + * \note \p omp::universal_pointer is not a "smart" pointer; it is the + * programmer's responsibility to deallocate memory pointed to by + * \p omp::universal_pointer. + * + * \tparam T specifies the type of the pointee. + * + * \see omp::universal_allocator + * \see raw_pointer_cast + */ +template +using universal_pointer = thrust::pointer< + T, + thrust::system::omp::tag, + typename std::add_lvalue_reference::type +>; + +/*! \p reference is a wrapped reference to an object stored in memory available + * to the \p omp system. \p reference is the type of the result of + * dereferencing a \p omp::pointer. + * + * \tparam T Specifies the type of the referenced object. + */ +template +using reference = thrust::tagged_reference; + +}} // namespace system::omp + +/*! \addtogroup system_backends Systems + * \ingroup system + * \{ + */ + +/*! \namespace thrust::omp + * \brief \p thrust::omp is a top-level alias for \p thrust::system::omp. */ +namespace omp +{ +using thrust::system::omp::pointer; +using thrust::system::omp::universal_pointer; +using thrust::system::omp::reference; +} // namespace omp + +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/vector.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/vector.h new file mode 100644 index 0000000000000000000000000000000000000000..179b5207dd60744becf995031dcb439e7ee40df6 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/omp/vector.h @@ -0,0 +1,82 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +/*! \file thrust/system/omp/vector.h + * \brief A dynamically-sizable array of elements which reside in memory available to + * Thrust's OpenMP system. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system { namespace omp +{ + +/*! \p omp::vector is a container that supports random access to elements, + * constant time removal of elements at the end, and linear time insertion + * and removal of elements at the beginning or in the middle. The number of + * elements in a \p omp::vector may vary dynamically; memory management is + * automatic. The elements contained in an \p omp::vector reside in memory + * accessible by the \p omp system. + * + * \tparam T The element type of the \p omp::vector. + * \tparam Allocator The allocator type of the \p omp::vector. + * Defaults to \p omp::allocator. + * + * \see https://en.cppreference.com/w/cpp/container/vector + * \see host_vector For the documentation of the complete interface which is + * shared by \p omp::vector. + * \see device_vector + * \see universal_vector + */ +template > +using vector = thrust::detail::vector_base; + +/*! \p omp::universal_vector is a container that supports random access to + * elements, constant time removal of elements at the end, and linear time + * insertion and removal of elements at the beginning or in the middle. The + * number of elements in a \p omp::universal_vector may vary dynamically; + * memory management is automatic. The elements contained in a + * \p omp::universal_vector reside in memory accessible by the \p omp system + * and host systems. + * + * \tparam T The element type of the \p omp::universal_vector. + * \tparam Allocator The allocator type of the \p omp::universal_vector. + * Defaults to \p omp::universal_allocator. + * + * \see https://en.cppreference.com/w/cpp/container/vector + * \see host_vector For the documentation of the complete interface which is + * shared by \p omp::universal_vector + * \see device_vector + * \see universal_vector + */ +template > +using universal_vector = thrust::detail::vector_base; + +}} // namespace system::omp + +namespace omp +{ +using thrust::system::omp::vector; +using thrust::system::omp::universal_vector; +} + +THRUST_NAMESPACE_END diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/adjacent_difference.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/adjacent_difference.h new file mode 100644 index 0000000000000000000000000000000000000000..ab519d11eb45ae791e5ba16b8f94d59d5cc0dbce --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/adjacent_difference.h @@ -0,0 +1,49 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ + +template + OutputIterator adjacent_difference(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + BinaryFunction binary_op) +{ + // tbb prefers generic::adjacent_difference to cpp::adjacent_difference + return thrust::system::detail::generic::adjacent_difference(exec, first, last, result, binary_op); +} // end adjacent_difference() + +} // end detail +} // end tbb +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/assign_value.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/assign_value.h new file mode 100644 index 0000000000000000000000000000000000000000..cf244a02193211b9b4e4f07a6bc9b975d50e5388 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/assign_value.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits assign_value +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/binary_search.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/binary_search.h new file mode 100644 index 0000000000000000000000000000000000000000..0847e5d1fdb3a446651897d62c959d56ad9dd1b9 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/binary_search.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits binary_search +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/copy.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/copy.h new file mode 100644 index 0000000000000000000000000000000000000000..30e95a98ce2069b52c3c3481af2c8a52c731ea7e --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/copy.h @@ -0,0 +1,56 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ + + +template +OutputIterator copy(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result); + + +template +OutputIterator copy_n(execution_policy &exec, + InputIterator first, + Size n, + OutputIterator result); + + +} // end namespace detail +} // end namespace tbb +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/copy.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/copy.inl new file mode 100644 index 0000000000000000000000000000000000000000..1016f40d4da70c1250fc952ea3ea7f254396d94a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/copy.inl @@ -0,0 +1,136 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ +namespace dispatch +{ + + +template + OutputIterator copy(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + thrust::incrementable_traversal_tag) +{ + return thrust::system::detail::sequential::copy(exec, first, last, result); +} // end copy() + + +template + OutputIterator copy(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + thrust::random_access_traversal_tag) +{ + return thrust::system::detail::generic::copy(exec, first, last, result); +} // end copy() + + +template + OutputIterator copy_n(execution_policy &exec, + InputIterator first, + Size n, + OutputIterator result, + thrust::incrementable_traversal_tag) +{ + return thrust::system::detail::sequential::copy_n(exec, first, n, result); +} // end copy_n() + + +template + OutputIterator copy_n(execution_policy &exec, + InputIterator first, + Size n, + OutputIterator result, + thrust::random_access_traversal_tag) +{ + return thrust::system::detail::generic::copy_n(exec, first, n, result); +} // end copy_n() + + +} // end dispatch + + +template +OutputIterator copy(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result) +{ + typedef typename thrust::iterator_traversal::type traversal1; + typedef typename thrust::iterator_traversal::type traversal2; + + typedef typename thrust::detail::minimum_type::type traversal; + + // dispatch on minimum traversal + return thrust::system::tbb::detail::dispatch::copy(exec,first,last,result,traversal()); +} // end copy() + + + +template +OutputIterator copy_n(execution_policy &exec, + InputIterator first, + Size n, + OutputIterator result) +{ + typedef typename thrust::iterator_traversal::type traversal1; + typedef typename thrust::iterator_traversal::type traversal2; + + typedef typename thrust::detail::minimum_type::type traversal; + + // dispatch on minimum traversal + return thrust::system::tbb::detail::dispatch::copy_n(exec,first,n,result,traversal()); +} // end copy_n() + + +} // end namespace detail +} // end namespace tbb +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/copy_if.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/copy_if.h new file mode 100644 index 0000000000000000000000000000000000000000..db860f37758344dd4d3db57b2909d761da59d411 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/copy_if.h @@ -0,0 +1,49 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ + + +template + OutputIterator copy_if(tag, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator result, + Predicate pred); + + +} // end detail +} // end tbb +} // end system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/copy_if.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/copy_if.inl new file mode 100644 index 0000000000000000000000000000000000000000..aa2379b8d038fcda20684989c5139d84036ee9bf --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/copy_if.inl @@ -0,0 +1,130 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ +namespace copy_if_detail +{ + +template +struct body +{ + + InputIterator1 first; + InputIterator2 stencil; + OutputIterator result; + thrust::detail::wrapped_function pred; + Size sum; + + body(InputIterator1 first, InputIterator2 stencil, OutputIterator result, Predicate pred) + : first(first), stencil(stencil), result(result), pred(pred), sum(0) + {} + + body(body& b, ::tbb::split) + : first(b.first), stencil(b.stencil), result(b.result), pred(b.pred), sum(0) + {} + + void operator()(const ::tbb::blocked_range& r, ::tbb::pre_scan_tag) + { + InputIterator2 iter = stencil + r.begin(); + + for (Size i = r.begin(); i != r.end(); ++i, ++iter) + { + if (pred(*iter)) + ++sum; + } + } + + void operator()(const ::tbb::blocked_range& r, ::tbb::final_scan_tag) + { + InputIterator1 iter1 = first + r.begin(); + InputIterator2 iter2 = stencil + r.begin(); + OutputIterator iter3 = result + sum; + + for (Size i = r.begin(); i != r.end(); ++i, ++iter1, ++iter2) + { + if (pred(*iter2)) + { + *iter3 = *iter1; + ++sum; + ++iter3; + } + } + } + + void reverse_join(body& b) + { + sum = b.sum + sum; + } + + void assign(body& b) + { + sum = b.sum; + } +}; // end body + +} // end copy_if_detail + +template + OutputIterator copy_if(tag, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator result, + Predicate pred) +{ + typedef typename thrust::iterator_difference::type Size; + typedef typename copy_if_detail::body Body; + + Size n = thrust::distance(first, last); + + if (n != 0) + { + Body body(first, stencil, result, pred); + ::tbb::parallel_scan(::tbb::blocked_range(0,n), body); + thrust::advance(result, body.sum); + } + + return result; +} // end copy_if() + +} // end detail +} // end tbb +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/count.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/count.h new file mode 100644 index 0000000000000000000000000000000000000000..fde1728b77261d75c561b9042ec365281d78cee9 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/count.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits count +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/equal.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/equal.h new file mode 100644 index 0000000000000000000000000000000000000000..13398fc9db5a02ba7cd7d2141f106fa59ba2a941 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/equal.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits equal +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/execution_policy.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/execution_policy.h new file mode 100644 index 0000000000000000000000000000000000000000..ac4a788e760f9ca7884336e421b0bd58f9621517 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/execution_policy.h @@ -0,0 +1,82 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +// put the canonical tag in the same ns as the backend's entry points +namespace tbb +{ +namespace detail +{ + +// this awkward sequence of definitions arise +// from the desire both for tag to derive +// from execution_policy and for execution_policy +// to convert to tag (when execution_policy is not +// an ancestor of tag) + +// forward declaration of tag +struct tag; + +// forward declaration of execution_policy +template struct execution_policy; + +// specialize execution_policy for tag +template<> + struct execution_policy + : thrust::system::cpp::detail::execution_policy +{}; + +// tag's definition comes before the +// generic definition of execution_policy +struct tag : execution_policy {}; + +// allow conversion to tag when it is not a successor +template + struct execution_policy + : thrust::system::cpp::detail::execution_policy +{ + typedef tag tag_type; + operator tag() const { return tag(); } +}; + +} // end detail + +// alias execution_policy and tag here +using thrust::system::tbb::detail::execution_policy; +using thrust::system::tbb::detail::tag; + +} // end tbb +} // end system + +// alias items at top-level +namespace tbb +{ + +using thrust::system::tbb::execution_policy; +using thrust::system::tbb::tag; + +} // end tbb +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/extrema.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/extrema.h new file mode 100644 index 0000000000000000000000000000000000000000..c6c747f426ba82ab51dc1b3c69e1b5c9a81c0791 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/extrema.h @@ -0,0 +1,66 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ + +template +ForwardIterator max_element(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate comp) +{ + // tbb prefers generic::max_element to cpp::max_element + return thrust::system::detail::generic::max_element(exec, first, last, comp); +} // end max_element() + +template +ForwardIterator min_element(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate comp) +{ + // tbb prefers generic::min_element to cpp::min_element + return thrust::system::detail::generic::min_element(exec, first, last, comp); +} // end min_element() + +template +thrust::pair minmax_element(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate comp) +{ + // tbb prefers generic::minmax_element to cpp::minmax_element + return thrust::system::detail::generic::minmax_element(exec, first, last, comp); +} // end minmax_element() + +} // end detail +} // end tbb +} // end system +THRUST_NAMESPACE_END + + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/fill.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/fill.h new file mode 100644 index 0000000000000000000000000000000000000000..6665a264873f6a0a775de0aa670ee7567d899ad9 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/fill.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits fill +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/find.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/find.h new file mode 100644 index 0000000000000000000000000000000000000000..e5dea8e779d8d949ba798c5e32308a5f9a6fd0e8 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/find.h @@ -0,0 +1,45 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ + +template +InputIterator find_if(execution_policy &exec, + InputIterator first, + InputIterator last, + Predicate pred) +{ + // tbb prefers generic::find_if to cpp::find_if + return thrust::system::detail::generic::find_if(exec, first, last, pred); +} + +} // end namespace detail +} // end namespace tbb +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/for_each.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/for_each.h new file mode 100644 index 0000000000000000000000000000000000000000..26c4b539b051d5f3a13b070dc67c8a50978b1b78 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/for_each.h @@ -0,0 +1,53 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ + +template + RandomAccessIterator for_each(execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator last, + UnaryFunction f); + +template + RandomAccessIterator for_each_n(execution_policy &exec, + RandomAccessIterator first, + Size n, + UnaryFunction f); + +} // end namespace detail +} // end namespace tbb +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/for_each.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/for_each.inl new file mode 100644 index 0000000000000000000000000000000000000000..21dfce9aebf3e7c2bd9b8eacd3cccd24b7949e77 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/for_each.inl @@ -0,0 +1,102 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ +namespace for_each_detail +{ + +template + struct body +{ + RandomAccessIterator m_first; + UnaryFunction m_f; + + body(RandomAccessIterator first, UnaryFunction f) + : m_first(first), m_f(f) + {} + + void operator()(const ::tbb::blocked_range &r) const + { + // we assume that blocked_range specifies a contiguous range of integers + thrust::for_each_n(thrust::system::detail::sequential::seq, m_first + r.begin(), r.size(), m_f); + } // end operator()() +}; // end body + + +template + body + make_body(RandomAccessIterator first, UnaryFunction f) +{ + return body(first, f); +} // end make_body() + + +} // end for_each_detail + + +template +RandomAccessIterator for_each_n(execution_policy &, + RandomAccessIterator first, + Size n, + UnaryFunction f) +{ + ::tbb::parallel_for(::tbb::blocked_range(0,n), for_each_detail::make_body(first,f)); + + // return the end of the range + return first + n; +} // end for_each_n + + +template + RandomAccessIterator for_each(execution_policy &s, + RandomAccessIterator first, + RandomAccessIterator last, + UnaryFunction f) +{ + return tbb::detail::for_each_n(s, first, thrust::distance(first,last), f); +} // end for_each() + + +} // end namespace detail +} // end namespace tbb +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/gather.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/gather.h new file mode 100644 index 0000000000000000000000000000000000000000..098e0f4fbad4001632ed02ee9e9b39aa17e54ea0 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/gather.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits gather +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/generate.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/generate.h new file mode 100644 index 0000000000000000000000000000000000000000..f907b6acc079577642c446d6f0736073defc44b8 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/generate.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits generate +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/get_value.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/get_value.h new file mode 100644 index 0000000000000000000000000000000000000000..23a11a8574f77f95bc6ca96d0cd8ff6de8c71c7e --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/get_value.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits get_value +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/inner_product.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/inner_product.h new file mode 100644 index 0000000000000000000000000000000000000000..e8cf941a1dc3df1a6a516eee54f92fa610fd35cc --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/inner_product.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits inner_product +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/iter_swap.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/iter_swap.h new file mode 100644 index 0000000000000000000000000000000000000000..a096739947c8854afe003e6bf498d89683854ff1 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/iter_swap.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits iter_swap +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/logical.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/logical.h new file mode 100644 index 0000000000000000000000000000000000000000..4199063183dbc38b79c7707bb8301e5ca8aa6ad5 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/logical.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits logical +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/malloc_and_free.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/malloc_and_free.h new file mode 100644 index 0000000000000000000000000000000000000000..01ab1e6dbe1732da1f8606b7a9121c1b404edb6f --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/malloc_and_free.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits malloc and free +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/memory.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/memory.inl new file mode 100644 index 0000000000000000000000000000000000000000..32e28300a411b09c4bbcdd38b6123b38041435e1 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/memory.inl @@ -0,0 +1,87 @@ +/* + * Copyright 2008-2018 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ + + +namespace detail +{ + +// XXX circular #inclusion problems cause the compiler to believe that cpp::malloc +// is not defined +// WAR the problem by using adl to call cpp::malloc, which requires it to depend +// on a template parameter +template + pointer malloc_workaround(Tag t, std::size_t n) +{ + return pointer(malloc(t, n)); +} // end malloc_workaround() + +// XXX circular #inclusion problems cause the compiler to believe that cpp::free +// is not defined +// WAR the problem by using adl to call cpp::free, which requires it to depend +// on a template parameter +template + void free_workaround(Tag t, pointer ptr) +{ + free(t, ptr.get()); +} // end free_workaround() + +} // end detail + +inline pointer malloc(std::size_t n) +{ + // XXX this is how we'd like to implement this function, + // if not for circular #inclusion problems: + // + // return pointer(thrust::system::cpp::malloc(n)) + // + return detail::malloc_workaround(cpp::tag(), n); +} // end malloc() + +template +pointer malloc(std::size_t n) +{ + pointer raw_ptr = thrust::system::tbb::malloc(sizeof(T) * n); + return pointer(reinterpret_cast(raw_ptr.get())); +} // end malloc() + +inline void free(pointer ptr) +{ + // XXX this is how we'd like to implement this function, + // if not for circular #inclusion problems: + // + // thrust::system::cpp::free(ptr) + // + detail::free_workaround(cpp::tag(), ptr); +} // end free() + +} // end tbb +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/merge.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/merge.h new file mode 100644 index 0000000000000000000000000000000000000000..014e2eb8bcea8aec0ae8e7d3cca02d963c618263 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/merge.h @@ -0,0 +1,69 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ + +template +OutputIterator merge(execution_policy &exec, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result, + StrictWeakOrdering comp); + +template +thrust::pair + merge_by_key(execution_policy &exec, + InputIterator1 keys_first1, + InputIterator1 keys_last1, + InputIterator2 keys_first2, + InputIterator2 keys_last2, + InputIterator3 values_first3, + InputIterator4 values_first4, + OutputIterator1 keys_result, + OutputIterator2 values_result, + StrictWeakOrdering comp); + +} // end detail +} // end tbb +} // end system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/merge.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/merge.inl new file mode 100644 index 0000000000000000000000000000000000000000..89a01aebfc80f15a762abfadd556b6c81b2d3fac --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/merge.inl @@ -0,0 +1,289 @@ +/* + * Copyright 2008-2021 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ +namespace merge_detail +{ + +template +struct range +{ + InputIterator1 first1, last1; + InputIterator2 first2, last2; + OutputIterator result; + StrictWeakOrdering comp; + size_t grain_size; + + range(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + OutputIterator result, + StrictWeakOrdering comp, + size_t grain_size = 1024) + : first1(first1), last1(last1), + first2(first2), last2(last2), + result(result), comp(comp), grain_size(grain_size) + {} + + range(range& r, ::tbb::split) + : first1(r.first1), last1(r.last1), + first2(r.first2), last2(r.last2), + result(r.result), comp(r.comp), grain_size(r.grain_size) + { + // we can assume n1 and n2 are not both 0 + size_t n1 = thrust::distance(first1, last1); + size_t n2 = thrust::distance(first2, last2); + + InputIterator1 mid1 = first1; + InputIterator2 mid2 = first2; + + if (n1 > n2) + { + mid1 += n1 / 2; + mid2 = thrust::lower_bound(thrust::seq, first2, last2, raw_reference_cast(*mid1), comp); + } + else + { + mid2 += n2 / 2; + mid1 = thrust::upper_bound(thrust::seq, first1, last1, raw_reference_cast(*mid2), comp); + } + + // set first range to [first1, mid1), [first2, mid2), result + r.last1 = mid1; + r.last2 = mid2; + + // set second range to [mid1, last1), [mid2, last2), result + (mid1 - first1) + (mid2 - first2) + first1 = mid1; + first2 = mid2; + result += thrust::distance(r.first1, mid1) + thrust::distance(r.first2, mid2); + } + + bool empty(void) const + { + return (first1 == last1) && (first2 == last2); + } + + bool is_divisible(void) const + { + return static_cast(thrust::distance(first1, last1) + thrust::distance(first2, last2)) > grain_size; + } +}; + +struct body +{ + template + void operator()(Range& r) const + { + thrust::merge(thrust::seq, + r.first1, r.last1, + r.first2, r.last2, + r.result, + r.comp); + } +}; + +} // end namespace merge_detail + +namespace merge_by_key_detail +{ + +template +struct range +{ + InputIterator1 keys_first1, keys_last1; + InputIterator2 keys_first2, keys_last2; + InputIterator3 values_first1; + InputIterator4 values_first2; + OutputIterator1 keys_result; + OutputIterator2 values_result; + StrictWeakOrdering comp; + size_t grain_size; + + range(InputIterator1 keys_first1, InputIterator1 keys_last1, + InputIterator2 keys_first2, InputIterator2 keys_last2, + InputIterator3 values_first1, + InputIterator4 values_first2, + OutputIterator1 keys_result, + OutputIterator2 values_result, + StrictWeakOrdering comp, + size_t grain_size = 1024) + : keys_first1(keys_first1), keys_last1(keys_last1), + keys_first2(keys_first2), keys_last2(keys_last2), + values_first1(values_first1), + values_first2(values_first2), + keys_result(keys_result), values_result(values_result), + comp(comp), grain_size(grain_size) + {} + + range(range& r, ::tbb::split) + : keys_first1(r.keys_first1), keys_last1(r.keys_last1), + keys_first2(r.keys_first2), keys_last2(r.keys_last2), + values_first1(r.values_first1), + values_first2(r.values_first2), + keys_result(r.keys_result), values_result(r.values_result), + comp(r.comp), grain_size(r.grain_size) + { + // we can assume n1 and n2 are not both 0 + size_t n1 = thrust::distance(keys_first1, keys_last1); + size_t n2 = thrust::distance(keys_first2, keys_last2); + + InputIterator1 mid1 = keys_first1; + InputIterator2 mid2 = keys_first2; + + if (n1 > n2) + { + mid1 += n1 / 2; + mid2 = thrust::lower_bound(thrust::seq, keys_first2, keys_last2, raw_reference_cast(*mid1), comp); + } + else + { + mid2 += n2 / 2; + mid1 = thrust::upper_bound(thrust::seq, keys_first1, keys_last1, raw_reference_cast(*mid2), comp); + } + + // set first range to [keys_first1, mid1), [keys_first2, mid2), keys_result, values_result + r.keys_last1 = mid1; + r.keys_last2 = mid2; + + // set second range to [mid1, keys_last1), [mid2, keys_last2), keys_result + (mid1 - keys_first1) + (mid2 - keys_first2), values_result + (mid1 - keys_first1) + (mid2 - keys_first2) + keys_first1 = mid1; + keys_first2 = mid2; + values_first1 += thrust::distance(r.keys_first1, mid1); + values_first2 += thrust::distance(r.keys_first2, mid2); + keys_result += thrust::distance(r.keys_first1, mid1) + thrust::distance(r.keys_first2, mid2); + values_result += thrust::distance(r.keys_first1, mid1) + thrust::distance(r.keys_first2, mid2); + } + + bool empty(void) const + { + return (keys_first1 == keys_last1) && (keys_first2 == keys_last2); + } + + bool is_divisible(void) const + { + return static_cast(thrust::distance(keys_first1, keys_last1) + thrust::distance(keys_first2, keys_last2)) > grain_size; + } +}; + +struct body +{ + template + void operator()(Range& r) const + { + thrust::merge_by_key(thrust::seq, + r.keys_first1, r.keys_last1, + r.keys_first2, r.keys_last2, + r.values_first1, + r.values_first2, + r.keys_result, + r.values_result, + r.comp); + } +}; + +} // end namespace merge_by_key_detail + + +template +OutputIterator merge(execution_policy &, + InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result, + StrictWeakOrdering comp) +{ + typedef typename merge_detail::range Range; + typedef merge_detail::body Body; + Range range(first1, last1, first2, last2, result, comp); + Body body; + + ::tbb::parallel_for(range, body); + + thrust::advance(result, thrust::distance(first1, last1) + thrust::distance(first2, last2)); + + return result; +} // end merge() + +template +thrust::pair + merge_by_key(execution_policy &, + InputIterator1 keys_first1, + InputIterator1 keys_last1, + InputIterator2 keys_first2, + InputIterator2 keys_last2, + InputIterator3 values_first3, + InputIterator4 values_first4, + OutputIterator1 keys_result, + OutputIterator2 values_result, + StrictWeakOrdering comp) +{ + typedef typename merge_by_key_detail::range Range; + typedef merge_by_key_detail::body Body; + + Range range(keys_first1, keys_last1, keys_first2, keys_last2, values_first3, values_first4, keys_result, values_result, comp); + Body body; + + ::tbb::parallel_for(range, body); + + thrust::advance(keys_result, thrust::distance(keys_first1, keys_last1) + thrust::distance(keys_first2, keys_last2)); + thrust::advance(values_result, thrust::distance(keys_first1, keys_last1) + thrust::distance(keys_first2, keys_last2)); + + return thrust::make_pair(keys_result,values_result); +} + +} // end namespace detail +} // end namespace tbb +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/mismatch.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/mismatch.h new file mode 100644 index 0000000000000000000000000000000000000000..b5c6b2c4bdd1cc242c87d7526a42e21bf4b1561c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/mismatch.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits mismatch +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/par.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/par.h new file mode 100644 index 0000000000000000000000000000000000000000..308d41e1366683443a3da03a5e8f17d0b5a5aaa9 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/par.h @@ -0,0 +1,61 @@ +/* + * Copyright 2008-2018 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ + + +struct par_t : thrust::system::tbb::detail::execution_policy, + thrust::detail::allocator_aware_execution_policy< + thrust::system::tbb::detail::execution_policy> +{ + __host__ __device__ + constexpr par_t() : thrust::system::tbb::detail::execution_policy() {} +}; + + +} // end detail + + +static const detail::par_t par; + + +} // end tbb +} // end system + + +// alias par here +namespace tbb +{ + + +using thrust::system::tbb::par; + + +} // end tbb +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/partition.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/partition.h new file mode 100644 index 0000000000000000000000000000000000000000..f9c56b92b5293598efc3f56502f091d9d73ac614 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/partition.h @@ -0,0 +1,86 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ + + +template + ForwardIterator stable_partition(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Predicate pred); + +template + ForwardIterator stable_partition(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + InputIterator stencil, + Predicate pred); + +template + thrust::pair + stable_partition_copy(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator1 out_true, + OutputIterator2 out_false, + Predicate pred); + + +template + thrust::pair + stable_partition_copy(execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator1 out_true, + OutputIterator2 out_false, + Predicate pred); + + +} // end namespace detail +} // end namespace tbb +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/partition.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/partition.inl new file mode 100644 index 0000000000000000000000000000000000000000..74ad809da4e3da2f226c8b4afd2abebdf668a4ed --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/partition.inl @@ -0,0 +1,101 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ + + +template + ForwardIterator stable_partition(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Predicate pred) +{ + // tbb prefers generic::stable_partition to cpp::stable_partition + return thrust::system::detail::generic::stable_partition(exec, first, last, pred); +} // end stable_partition() + + +template + ForwardIterator stable_partition(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + InputIterator stencil, + Predicate pred) +{ + // tbb prefers generic::stable_partition to cpp::stable_partition + return thrust::system::detail::generic::stable_partition(exec, first, last, stencil, pred); +} // end stable_partition() + +template + thrust::pair + stable_partition_copy(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator1 out_true, + OutputIterator2 out_false, + Predicate pred) +{ + // tbb prefers generic::stable_partition_copy to cpp::stable_partition_copy + return thrust::system::detail::generic::stable_partition_copy(exec, first, last, out_true, out_false, pred); +} // end stable_partition_copy() + + +template + thrust::pair + stable_partition_copy(execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator1 out_true, + OutputIterator2 out_false, + Predicate pred) +{ + // tbb prefers generic::stable_partition_copy to cpp::stable_partition_copy + return thrust::system::detail::generic::stable_partition_copy(exec, first, last, stencil, out_true, out_false, pred); +} // end stable_partition_copy() + + +} // end namespace detail +} // end namespace tbb +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/per_device_resource.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/per_device_resource.h new file mode 100644 index 0000000000000000000000000000000000000000..1b8d61f92169e0e09c3821e59218f0dcbb70cbe5 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/per_device_resource.h @@ -0,0 +1,22 @@ +/* + * Copyright 2018 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special per device resource functions + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/reduce.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/reduce.h new file mode 100644 index 0000000000000000000000000000000000000000..81e8d1f6f30c5b2e6b981a83bc784297d49bc8d1 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/reduce.h @@ -0,0 +1,53 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file reduce.h + * \brief TBB implementation of reduce. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ + + +template + OutputType reduce(execution_policy &exec, + InputIterator begin, + InputIterator end, + OutputType init, + BinaryFunction binary_op); + + +} // end namespace detail +} // end namespace tbb +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/reduce.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/reduce.inl new file mode 100644 index 0000000000000000000000000000000000000000..47fe6616d6bd529a9b5a792d2046d4b3977fb6cb --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/reduce.inl @@ -0,0 +1,130 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ +namespace reduce_detail +{ + +template +struct body +{ + RandomAccessIterator first; + OutputType sum; + bool first_call; // TBB can invoke operator() multiple times on the same body + thrust::detail::wrapped_function binary_op; + + // note: we only initalize sum with init to avoid calling OutputType's default constructor + body(RandomAccessIterator first, OutputType init, BinaryFunction binary_op) + : first(first), sum(init), first_call(true), binary_op(binary_op) + {} + + // note: we only initalize sum with b.sum to avoid calling OutputType's default constructor + body(body& b, ::tbb::split) + : first(b.first), sum(b.sum), first_call(true), binary_op(b.binary_op) + {} + + template + void operator()(const ::tbb::blocked_range &r) + { + // we assume that blocked_range specifies a contiguous range of integers + + if (r.empty()) return; // nothing to do + + RandomAccessIterator iter = first + r.begin(); + + OutputType temp = thrust::raw_reference_cast(*iter); + + ++iter; + + for (Size i = r.begin() + 1; i != r.end(); ++i, ++iter) + temp = binary_op(temp, *iter); + + + if (first_call) + { + // first time body has been invoked + first_call = false; + sum = temp; + } + else + { + // body has been previously invoked, accumulate temp into sum + sum = binary_op(sum, temp); + } + } // end operator()() + + void join(body& b) + { + sum = binary_op(sum, b.sum); + } +}; // end body + +} // end reduce_detail + + +template + OutputType reduce(execution_policy &, + InputIterator begin, + InputIterator end, + OutputType init, + BinaryFunction binary_op) +{ + typedef typename thrust::iterator_difference::type Size; + + Size n = thrust::distance(begin, end); + + if (n == 0) + { + return init; + } + else + { + typedef typename reduce_detail::body Body; + Body reduce_body(begin, init, binary_op); + ::tbb::parallel_reduce(::tbb::blocked_range(0,n), reduce_body); + return binary_op(init, reduce_body.sum); + } +} + + +} // end namespace detail +} // end namespace tbb +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/reduce_by_key.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/reduce_by_key.h new file mode 100644 index 0000000000000000000000000000000000000000..04d46e7c0fa6143cad7cd937573bac14d2984d30 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/reduce_by_key.h @@ -0,0 +1,56 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ + + +template + thrust::pair + reduce_by_key(execution_policy &exec, + InputIterator1 keys_first, + InputIterator1 keys_last, + InputIterator2 values_first, + OutputIterator1 keys_output, + OutputIterator2 values_output, + BinaryPredicate binary_pred, + BinaryFunction binary_op); + + +} // end namespace detail +} // end namespace tbb +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/reduce_by_key.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/reduce_by_key.inl new file mode 100644 index 0000000000000000000000000000000000000000..693abb2e73919c91ce135cf837dbc83c0d1c0037 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/reduce_by_key.inl @@ -0,0 +1,341 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ +namespace reduce_by_key_detail +{ + + +template + inline L divide_ri(const L x, const R y) +{ + return (x + (y - 1)) / y; +} + + +template + struct partial_sum_type + : thrust::detail::eval_if< + thrust::detail::has_result_type::value, + thrust::detail::result_type, + thrust::detail::eval_if< + thrust::detail::is_output_iterator::value, + thrust::iterator_value, + thrust::iterator_value + > + > +{}; + + +template + struct partial_sum_type + : thrust::detail::eval_if< + thrust::detail::has_result_type::value, + thrust::detail::result_type, + thrust::iterator_value + > +{}; + + +template + thrust::pair< + InputIterator1, + thrust::pair< + typename thrust::iterator_value::type, + typename partial_sum_type::type + > + > + reduce_last_segment_backward(InputIterator1 keys_first, + InputIterator1 keys_last, + InputIterator2 values_first, + BinaryPredicate binary_pred, + BinaryFunction binary_op) +{ + typename thrust::iterator_difference::type n = keys_last - keys_first; + + // reverse the ranges and consume from the end + thrust::reverse_iterator keys_first_r(keys_last); + thrust::reverse_iterator keys_last_r(keys_first); + thrust::reverse_iterator values_first_r(values_first + n); + + typename thrust::iterator_value::type result_key = *keys_first_r; + typename partial_sum_type::type result_value = *values_first_r; + + // consume the entirety of the first key's sequence + for(++keys_first_r, ++values_first_r; + (keys_first_r != keys_last_r) && binary_pred(*keys_first_r, result_key); + ++keys_first_r, ++values_first_r) + { + result_value = binary_op(result_value, *values_first_r); + } + + return thrust::make_pair(keys_first_r.base(), thrust::make_pair(result_key, result_value)); +} + + +template + thrust::tuple< + OutputIterator1, + OutputIterator2, + typename thrust::iterator_value::type, + typename partial_sum_type::type + > + reduce_by_key_with_carry(InputIterator1 keys_first, + InputIterator1 keys_last, + InputIterator2 values_first, + OutputIterator1 keys_output, + OutputIterator2 values_output, + BinaryPredicate binary_pred, + BinaryFunction binary_op) +{ + // first, consume the last sequence to produce the carry + // XXX is there an elegant way to pose this such that we don't need to default construct carry? + thrust::pair< + typename thrust::iterator_value::type, + typename partial_sum_type::type + > carry; + + thrust::tie(keys_last, carry) = reduce_last_segment_backward(keys_first, keys_last, values_first, binary_pred, binary_op); + + // finish with sequential reduce_by_key + thrust::tie(keys_output, values_output) = + thrust::reduce_by_key(thrust::seq, keys_first, keys_last, values_first, keys_output, values_output, binary_pred, binary_op); + + return thrust::make_tuple(keys_output, values_output, carry.first, carry.second); +} + + +template + bool interval_has_carry(size_t interval_idx, size_t interval_size, size_t num_intervals, Iterator tail_flags) +{ + // to discover whether the interval has a carry, look at the tail_flag corresponding to its last element + // the final interval never has a carry by definition + return (interval_idx + 1 < num_intervals) ? !tail_flags[(interval_idx + 1) * interval_size - 1] : false; +} + + +template + struct serial_reduce_by_key_body +{ + typedef typename thrust::iterator_difference::type size_type; + + Iterator1 keys_first; + Iterator2 values_first; + Iterator3 result_offset; + Iterator4 keys_result; + Iterator5 values_result; + Iterator6 carry_result; + + size_type n; + size_type interval_size; + size_type num_intervals; + + BinaryPredicate binary_pred; + BinaryFunction binary_op; + + serial_reduce_by_key_body(Iterator1 keys_first, Iterator2 values_first, Iterator3 result_offset, Iterator4 keys_result, Iterator5 values_result, Iterator6 carry_result, size_type n, size_type interval_size, size_type num_intervals, BinaryPredicate binary_pred, BinaryFunction binary_op) + : keys_first(keys_first), values_first(values_first), + result_offset(result_offset), + keys_result(keys_result), + values_result(values_result), + carry_result(carry_result), + n(n), + interval_size(interval_size), + num_intervals(num_intervals), + binary_pred(binary_pred), + binary_op(binary_op) + {} + + void operator()(const ::tbb::blocked_range &r) const + { + assert(r.size() == 1); + + const size_type interval_idx = r.begin(); + + const size_type offset_to_first = interval_size * interval_idx; + const size_type offset_to_last = (thrust::min)(n, offset_to_first + interval_size); + + Iterator1 my_keys_first = keys_first + offset_to_first; + Iterator1 my_keys_last = keys_first + offset_to_last; + Iterator2 my_values_first = values_first + offset_to_first; + Iterator3 my_result_offset = result_offset + interval_idx; + Iterator4 my_keys_result = keys_result + *my_result_offset; + Iterator5 my_values_result = values_result + *my_result_offset; + Iterator6 my_carry_result = carry_result + interval_idx; + + // consume the rest of the interval with reduce_by_key + typedef typename thrust::iterator_value::type key_type; + typedef typename partial_sum_type::type value_type; + + // XXX is there a way to pose this so that we don't require default construction of carry? + thrust::pair carry; + + thrust::tie(my_keys_result, my_values_result, carry.first, carry.second) = + reduce_by_key_with_carry(my_keys_first, + my_keys_last, + my_values_first, + my_keys_result, + my_values_result, + binary_pred, + binary_op); + + // store to carry only when we actually have a carry + // store to my_keys_result & my_values_result otherwise + + // create tail_flags so we can check for a carry + thrust::detail::tail_flags flags = thrust::detail::make_tail_flags(keys_first, keys_first + n, binary_pred); + + if(interval_has_carry(interval_idx, interval_size, num_intervals, flags.begin())) + { + // we can ignore the carry's key + // XXX because the carry result is uninitialized, we should copy construct + *my_carry_result = carry.second; + } + else + { + *my_keys_result = carry.first; + *my_values_result = carry.second; + } + } +}; + + +template + serial_reduce_by_key_body + make_serial_reduce_by_key_body(Iterator1 keys_first, Iterator2 values_first, Iterator3 result_offset, Iterator4 keys_result, Iterator5 values_result, Iterator6 carry_result, typename thrust::iterator_difference::type n, size_t interval_size, size_t num_intervals, BinaryPredicate binary_pred, BinaryFunction binary_op) +{ + return serial_reduce_by_key_body(keys_first, values_first, result_offset, keys_result, values_result, carry_result, n, interval_size, num_intervals, binary_pred, binary_op); +} + + +} // end reduce_by_key_detail + + +template + thrust::pair + reduce_by_key(thrust::tbb::execution_policy &exec, + Iterator1 keys_first, Iterator1 keys_last, + Iterator2 values_first, + Iterator3 keys_result, + Iterator4 values_result, + BinaryPredicate binary_pred, + BinaryFunction binary_op) +{ + + typedef typename thrust::iterator_difference::type difference_type; + difference_type n = keys_last - keys_first; + if(n == 0) return thrust::make_pair(keys_result, values_result); + + // XXX this value is a tuning opportunity + const difference_type parallelism_threshold = 10000; + + if(n < parallelism_threshold) + { + // don't bother parallelizing for small n + return thrust::reduce_by_key(thrust::seq, keys_first, keys_last, values_first, keys_result, values_result, binary_pred, binary_op); + } + + // count the number of processors + const unsigned int p = thrust::max(1u, std::thread::hardware_concurrency()); + + // generate O(P) intervals of sequential work + // XXX oversubscribing is a tuning opportunity + const unsigned int subscription_rate = 1; + difference_type interval_size = thrust::min(parallelism_threshold, thrust::max(n, n / (subscription_rate * p))); + difference_type num_intervals = reduce_by_key_detail::divide_ri(n, interval_size); + + // decompose the input into intervals of size N / num_intervals + // add one extra element to this vector to store the size of the entire result + thrust::detail::temporary_array interval_output_offsets(0, exec, num_intervals + 1); + + // first count the number of tail flags in each interval + thrust::detail::tail_flags tail_flags = thrust::detail::make_tail_flags(keys_first, keys_last, binary_pred); + thrust::system::tbb::detail::reduce_intervals(exec, tail_flags.begin(), tail_flags.end(), interval_size, interval_output_offsets.begin() + 1, thrust::plus()); + interval_output_offsets[0] = 0; + + // scan the counts to get each body's output offset + thrust::inclusive_scan(thrust::seq, + interval_output_offsets.begin() + 1, interval_output_offsets.end(), + interval_output_offsets.begin() + 1); + + // do a reduce_by_key serially in each thread + // the final interval never has a carry by definition, so don't reserve space for it + typedef typename reduce_by_key_detail::partial_sum_type::type carry_type; + thrust::detail::temporary_array carries(0, exec, num_intervals - 1); + + // force grainsize == 1 with simple_partioner() + ::tbb::parallel_for(::tbb::blocked_range(0, num_intervals, 1), + reduce_by_key_detail::make_serial_reduce_by_key_body(keys_first, values_first, interval_output_offsets.begin(), keys_result, values_result, carries.begin(), n, interval_size, num_intervals, binary_pred, binary_op), + ::tbb::simple_partitioner()); + + difference_type size_of_result = interval_output_offsets[num_intervals]; + + // sequentially accumulate the carries + // note that the last interval does not have a carry + // XXX find a way to express this loop via a sequential algorithm, perhaps reduce_by_key + for(typename thrust::detail::temporary_array::size_type i = 0; i < carries.size(); ++i) + { + // if our interval has a carry, then we need to sum the carry to the next interval's output offset + // if it does not have a carry, then we need to ignore carry_value[i] + if(reduce_by_key_detail::interval_has_carry(i, interval_size, num_intervals, tail_flags.begin())) + { + difference_type output_idx = interval_output_offsets[i+1]; + + values_result[output_idx] = binary_op(values_result[output_idx], carries[i]); + } + } + + return thrust::make_pair(keys_result + size_of_result, values_result + size_of_result); +} + + +} // end detail +} // end tbb +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/reduce_intervals.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/reduce_intervals.h new file mode 100644 index 0000000000000000000000000000000000000000..7164c3f97c5c87a23fa7a6f3cdc44fca481c16d2 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/reduce_intervals.h @@ -0,0 +1,124 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ +namespace reduce_intervals_detail +{ + + +template + inline L divide_ri(const L x, const R y) +{ + return (x + (y - 1)) / y; +} + + +template + struct body +{ + RandomAccessIterator1 first; + RandomAccessIterator2 result; + Size n, interval_size; + BinaryFunction binary_op; + + body(RandomAccessIterator1 first, RandomAccessIterator2 result, Size n, Size interval_size, BinaryFunction binary_op) + : first(first), result(result), n(n), interval_size(interval_size), binary_op(binary_op) + {} + + void operator()(const ::tbb::blocked_range &r) const + { + assert(r.size() == 1); + + Size interval_idx = r.begin(); + + Size offset_to_first = interval_size * interval_idx; + Size offset_to_last = (thrust::min)(n, offset_to_first + interval_size); + + RandomAccessIterator1 my_first = first + offset_to_first; + RandomAccessIterator1 my_last = first + offset_to_last; + + // carefully pass the init value for the interval with raw_reference_cast + typedef typename BinaryFunction::result_type sum_type; + result[interval_idx] = + thrust::reduce(thrust::seq, my_first + 1, my_last, sum_type(thrust::raw_reference_cast(*my_first)), binary_op); + } +}; + + +template + body + make_body(RandomAccessIterator1 first, RandomAccessIterator2 result, Size n, Size interval_size, BinaryFunction binary_op) +{ + return body(first, result, n, interval_size, binary_op); +} + + +} // end reduce_intervals_detail + + +template + void reduce_intervals(thrust::tbb::execution_policy &, + RandomAccessIterator1 first, + RandomAccessIterator1 last, + Size interval_size, + RandomAccessIterator2 result, + BinaryFunction binary_op) +{ + typename thrust::iterator_difference::type n = last - first; + + Size num_intervals = reduce_intervals_detail::divide_ri(n, interval_size); + + ::tbb::parallel_for(::tbb::blocked_range(0, num_intervals, 1), reduce_intervals_detail::make_body(first, result, Size(n), interval_size, binary_op), ::tbb::simple_partitioner()); +} + + +template + void reduce_intervals(thrust::tbb::execution_policy &exec, + RandomAccessIterator1 first, + RandomAccessIterator1 last, + Size interval_size, + RandomAccessIterator2 result) +{ + typedef typename thrust::iterator_value::type value_type; + + return thrust::system::tbb::detail::reduce_intervals(exec, first, last, interval_size, result, thrust::plus()); +} + + +} // end detail +} // end tbb +} // end system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/remove.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/remove.h new file mode 100644 index 0000000000000000000000000000000000000000..34cd917994a331da0e84058a1315ee90be862ccd --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/remove.h @@ -0,0 +1,80 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace omp +{ +namespace detail +{ + +template + ForwardIterator remove_if(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Predicate pred); + + +template + ForwardIterator remove_if(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + InputIterator stencil, + Predicate pred); + + +template + OutputIterator remove_copy_if(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + Predicate pred); + + +template + OutputIterator remove_copy_if(execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator result, + Predicate pred); + + +} // end namespace detail +} // end namespace omp +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/remove.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/remove.inl new file mode 100644 index 0000000000000000000000000000000000000000..76d77e64ba5659e0578350ff26977eeaf338ba15 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/remove.inl @@ -0,0 +1,93 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ + +template + ForwardIterator remove_if(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + Predicate pred) +{ + // tbb prefers generic::remove_if to cpp::remove_if + return thrust::system::detail::generic::remove_if(exec, first, last, pred); +} + + +template + ForwardIterator remove_if(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + InputIterator stencil, + Predicate pred) +{ + // tbb prefers generic::remove_if to cpp::remove_if + return thrust::system::detail::generic::remove_if(exec, first, last, stencil, pred); +} + + +template + OutputIterator remove_copy_if(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator result, + Predicate pred) +{ + // tbb prefers generic::remove_copy_if to cpp::remove_copy_if + return thrust::system::detail::generic::remove_copy_if(exec, first, last, result, pred); +} + +template + OutputIterator remove_copy_if(execution_policy &exec, + InputIterator1 first, + InputIterator1 last, + InputIterator2 stencil, + OutputIterator result, + Predicate pred) +{ + // tbb prefers generic::remove_copy_if to cpp::remove_copy_if + return thrust::system::detail::generic::remove_copy_if(exec, first, last, stencil, result, pred); +} + +} // end namespace detail +} // end namespace tbb +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/replace.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/replace.h new file mode 100644 index 0000000000000000000000000000000000000000..95c5a14ba3df120019c9a5b6ed638db3f2555a5b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/replace.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits this algorithm +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/reverse.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/reverse.h new file mode 100644 index 0000000000000000000000000000000000000000..1f3e0325e257c301215e62c690837433ae24c30c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/reverse.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits reverse +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/scan.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/scan.h new file mode 100644 index 0000000000000000000000000000000000000000..b31b46317cf7d7321462c6648dd993822cdc5d2e --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/scan.h @@ -0,0 +1,63 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + + +/*! \file scan.h + * \brief TBB implementations of scan functions. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ + +template + OutputIterator inclusive_scan(tag, + InputIterator first, + InputIterator last, + OutputIterator result, + BinaryFunction binary_op); + + +template + OutputIterator exclusive_scan(tag, + InputIterator first, + InputIterator last, + OutputIterator result, + T init, + BinaryFunction binary_op); + + +} // end namespace detail +} // end namespace tbb +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/scan.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/scan.inl new file mode 100644 index 0000000000000000000000000000000000000000..d6e8949839050fd4be75a5ae42f1f42710430057 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/scan.inl @@ -0,0 +1,258 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ +namespace scan_detail +{ + +template +struct inclusive_body +{ + InputIterator input; + OutputIterator output; + thrust::detail::wrapped_function binary_op; + ValueType sum; + bool first_call; + + inclusive_body(InputIterator input, OutputIterator output, BinaryFunction binary_op, ValueType dummy) + : input(input), output(output), binary_op(binary_op), sum(dummy), first_call(true) + {} + + inclusive_body(inclusive_body& b, ::tbb::split) + : input(b.input), output(b.output), binary_op(b.binary_op), sum(b.sum), first_call(true) + {} + + template + void operator()(const ::tbb::blocked_range& r, ::tbb::pre_scan_tag) + { + InputIterator iter = input + r.begin(); + + ValueType temp = *iter; + + ++iter; + + for (Size i = r.begin() + 1; i != r.end(); ++i, ++iter) + temp = binary_op(temp, *iter); + + if (first_call) + sum = temp; + else + sum = binary_op(sum, temp); + + first_call = false; + } + + template + void operator()(const ::tbb::blocked_range& r, ::tbb::final_scan_tag) + { + InputIterator iter1 = input + r.begin(); + OutputIterator iter2 = output + r.begin(); + + if (first_call) + { + *iter2 = sum = *iter1; + ++iter1; + ++iter2; + for (Size i = r.begin() + 1; i != r.end(); ++i, ++iter1, ++iter2) + *iter2 = sum = binary_op(sum, *iter1); + } + else + { + for (Size i = r.begin(); i != r.end(); ++i, ++iter1, ++iter2) + *iter2 = sum = binary_op(sum, *iter1); + } + + first_call = false; + } + + void reverse_join(inclusive_body& b) + { + // Only accumulate this functor's partial sum if this functor has been + // called at least once -- otherwise we'll over-count the initial value. + if (!first_call) + { + sum = binary_op(b.sum, sum); + } + } + + void assign(inclusive_body& b) + { + sum = b.sum; + } +}; + + +template +struct exclusive_body +{ + InputIterator input; + OutputIterator output; + thrust::detail::wrapped_function binary_op; + ValueType sum; + bool first_call; + + exclusive_body(InputIterator input, OutputIterator output, BinaryFunction binary_op, ValueType init) + : input(input), output(output), binary_op(binary_op), sum(init), first_call(true) + {} + + exclusive_body(exclusive_body& b, ::tbb::split) + : input(b.input), output(b.output), binary_op(b.binary_op), sum(b.sum), first_call(true) + {} + + template + void operator()(const ::tbb::blocked_range& r, ::tbb::pre_scan_tag) + { + InputIterator iter = input + r.begin(); + + ValueType temp = *iter; + + ++iter; + + for (Size i = r.begin() + 1; i != r.end(); ++i, ++iter) + temp = binary_op(temp, *iter); + + if (first_call && r.begin() > 0) + sum = temp; + else + sum = binary_op(sum, temp); + + first_call = false; + } + + template + void operator()(const ::tbb::blocked_range& r, ::tbb::final_scan_tag) + { + InputIterator iter1 = input + r.begin(); + OutputIterator iter2 = output + r.begin(); + + for (Size i = r.begin(); i != r.end(); ++i, ++iter1, ++iter2) + { + ValueType temp = binary_op(sum, *iter1); + *iter2 = sum; + sum = temp; + } + + first_call = false; + } + + void reverse_join(exclusive_body& b) + { + // Only accumulate this functor's partial sum if this functor has been + // called at least once -- otherwise we'll over-count the initial value. + if (!first_call) + { + sum = binary_op(b.sum, sum); + } + } + + void assign(exclusive_body& b) + { + sum = b.sum; + } +}; + +} // end scan_detail + +template + OutputIterator inclusive_scan(tag, + InputIterator first, + InputIterator last, + OutputIterator result, + BinaryFunction binary_op) +{ + using namespace thrust::detail; + + // Use the input iterator's value type per https://wg21.link/P0571 + using ValueType = typename thrust::iterator_value::type; + + using Size = typename thrust::iterator_difference::type; + Size n = thrust::distance(first, last); + + if (n != 0) + { + typedef typename scan_detail::inclusive_body Body; + Body scan_body(first, result, binary_op, *first); + ::tbb::parallel_scan(::tbb::blocked_range(0,n), scan_body); + } + + thrust::advance(result, n); + + return result; +} + +template + OutputIterator exclusive_scan(tag, + InputIterator first, + InputIterator last, + OutputIterator result, + InitialValueType init, + BinaryFunction binary_op) +{ + using namespace thrust::detail; + + // Use the initial value type per https://wg21.link/P0571 + using ValueType = InitialValueType; + + using Size = typename thrust::iterator_difference::type; + Size n = thrust::distance(first, last); + + if (n != 0) + { + typedef typename scan_detail::exclusive_body Body; + Body scan_body(first, result, binary_op, init); + ::tbb::parallel_scan(::tbb::blocked_range(0,n), scan_body); + } + + thrust::advance(result, n); + + return result; +} + +} // end namespace detail +} // end namespace tbb +} // end namespace system +THRUST_NAMESPACE_END diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/scan_by_key.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/scan_by_key.h new file mode 100644 index 0000000000000000000000000000000000000000..2b5fa36483c451bac93827b239c17fb7850e2ed1 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/scan_by_key.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits scan_by_key +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/scatter.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/scatter.h new file mode 100644 index 0000000000000000000000000000000000000000..95c5a14ba3df120019c9a5b6ed638db3f2555a5b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/scatter.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits this algorithm +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/sequence.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/sequence.h new file mode 100644 index 0000000000000000000000000000000000000000..c33b2d4333ce2ded0ffe73c23c20a80c5a35b928 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/sequence.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits sequence +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/set_operations.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/set_operations.h new file mode 100644 index 0000000000000000000000000000000000000000..421fa8a4bd955706497d0c9b30614035ccbbc46f --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/set_operations.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits set_operations +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/sort.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/sort.h new file mode 100644 index 0000000000000000000000000000000000000000..9c58bf6d49ffeed36d63a01563ff2174ad148af8 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/sort.h @@ -0,0 +1,54 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ + +template + void stable_sort(execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator last, + StrictWeakOrdering comp); + +template + void stable_sort_by_key(execution_policy &exec, + RandomAccessIterator1 keys_first, + RandomAccessIterator1 keys_last, + RandomAccessIterator2 values_first, + StrictWeakOrdering comp); + +} // end namespace detail +} // end namespace tbb +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/sort.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/sort.inl new file mode 100644 index 0000000000000000000000000000000000000000..103710fba54121345b7651966c0f410894278775 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/sort.inl @@ -0,0 +1,266 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ +namespace sort_detail +{ + + +// TODO tune this based on data type and comp +const static int threshold = 128 * 1024; + + +template +void merge_sort(execution_policy &exec, Iterator1 first1, Iterator1 last1, Iterator2 first2, StrictWeakOrdering comp, bool inplace); + + +template +struct merge_sort_closure +{ + execution_policy &exec; + Iterator1 first1, last1; + Iterator2 first2; + StrictWeakOrdering comp; + bool inplace; + + merge_sort_closure(execution_policy &exec, Iterator1 first1, Iterator1 last1, Iterator2 first2, StrictWeakOrdering comp, bool inplace) + : exec(exec), first1(first1), last1(last1), first2(first2), comp(comp), inplace(inplace) + {} + + void operator()(void) const + { + merge_sort(exec, first1, last1, first2, comp, inplace); + } +}; + + +template +void merge_sort(execution_policy &exec, Iterator1 first1, Iterator1 last1, Iterator2 first2, StrictWeakOrdering comp, bool inplace) +{ + typedef typename thrust::iterator_difference::type difference_type; + + difference_type n = thrust::distance(first1, last1); + + if (n < threshold) + { + thrust::stable_sort(thrust::seq, first1, last1, comp); + + if(!inplace) + { + thrust::copy(thrust::seq, first1, last1, first2); + } + + return; + } + + Iterator1 mid1 = first1 + (n / 2); + Iterator2 mid2 = first2 + (n / 2); + Iterator2 last2 = first2 + n; + + typedef merge_sort_closure Closure; + + Closure left (exec, first1, mid1, first2, comp, !inplace); + Closure right(exec, mid1, last1, mid2, comp, !inplace); + + ::tbb::parallel_invoke(left, right); + + if(inplace) thrust::merge(exec, first2, mid2, mid2, last2, first1, comp); + else thrust::merge(exec, first1, mid1, mid1, last1, first2, comp); +} + + +} // end namespace sort_detail + + +namespace sort_by_key_detail +{ + + +// TODO tune this based on data type and comp +const static int threshold = 128 * 1024; + + +template +void merge_sort_by_key(execution_policy &exec, + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator3 first3, + Iterator4 first4, + StrictWeakOrdering comp, + bool inplace); + + +template +struct merge_sort_by_key_closure +{ + execution_policy &exec; + Iterator1 first1, last1; + Iterator2 first2; + Iterator3 first3; + Iterator4 first4; + StrictWeakOrdering comp; + bool inplace; + + merge_sort_by_key_closure(execution_policy &exec, + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator3 first3, + Iterator4 first4, + StrictWeakOrdering comp, + bool inplace) + : exec(exec), first1(first1), last1(last1), first2(first2), first3(first3), first4(first4), comp(comp), inplace(inplace) + {} + + void operator()(void) const + { + merge_sort_by_key(exec, first1, last1, first2, first3, first4, comp, inplace); + } +}; + + +template +void merge_sort_by_key(execution_policy &exec, + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator3 first3, + Iterator4 first4, + StrictWeakOrdering comp, + bool inplace) +{ + typedef typename thrust::iterator_difference::type difference_type; + + difference_type n = thrust::distance(first1, last1); + + Iterator1 mid1 = first1 + (n / 2); + Iterator2 mid2 = first2 + (n / 2); + Iterator3 mid3 = first3 + (n / 2); + Iterator4 mid4 = first4 + (n / 2); + Iterator2 last2 = first2 + n; + Iterator3 last3 = first3 + n; + + if (n < threshold) + { + thrust::stable_sort_by_key(thrust::seq, first1, last1, first2, comp); + + if(!inplace) + { + thrust::copy(thrust::seq, first1, last1, first3); + thrust::copy(thrust::seq, first2, last2, first4); + } + + return; + } + + typedef merge_sort_by_key_closure Closure; + + Closure left (exec, first1, mid1, first2, first3, first4, comp, !inplace); + Closure right(exec, mid1, last1, mid2, mid3, mid4, comp, !inplace); + + ::tbb::parallel_invoke(left, right); + + if(inplace) + { + thrust::merge_by_key(exec, first3, mid3, mid3, last3, first4, mid4, first1, first2, comp); + } + else + { + thrust::merge_by_key(exec, first1, mid1, mid1, last1, first2, mid2, first3, first4, comp); + } +} + + +} // end namespace sort_detail + + +template +void stable_sort(execution_policy &exec, + RandomAccessIterator first, + RandomAccessIterator last, + StrictWeakOrdering comp) +{ + typedef typename thrust::iterator_value::type key_type; + + thrust::detail::temporary_array temp(exec, first, last); + + sort_detail::merge_sort(exec, first, last, temp.begin(), comp, true); +} + + +template + void stable_sort_by_key(execution_policy &exec, + RandomAccessIterator1 first1, + RandomAccessIterator1 last1, + RandomAccessIterator2 first2, + StrictWeakOrdering comp) +{ + typedef typename thrust::iterator_value::type key_type; + typedef typename thrust::iterator_value::type val_type; + + RandomAccessIterator2 last2 = first2 + thrust::distance(first1, last1); + + thrust::detail::temporary_array temp1(exec, first1, last1); + thrust::detail::temporary_array temp2(exec, first2, last2); + + sort_by_key_detail::merge_sort_by_key(exec, first1, last1, first2, temp1.begin(), temp2.begin(), comp, true); +} + + +} // end namespace detail +} // end namespace tbb +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/swap_ranges.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/swap_ranges.h new file mode 100644 index 0000000000000000000000000000000000000000..4a0b06cbe9e770e0a5b6475dbb5402c1563f383b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/swap_ranges.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// tbb inherits swap_ranges +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/tabulate.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/tabulate.h new file mode 100644 index 0000000000000000000000000000000000000000..ea135c707064b7195e4a78efc15849ba431e9068 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/tabulate.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits tabulate +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/temporary_buffer.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/temporary_buffer.h new file mode 100644 index 0000000000000000000000000000000000000000..2adfaf2810c67462e41f271e43ad0aff9cfbf75f --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/temporary_buffer.h @@ -0,0 +1,22 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system has no special temporary buffer functions + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/transform.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/transform.h new file mode 100644 index 0000000000000000000000000000000000000000..20d606dfbeec6d376a138db500ec368d94efa748 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/transform.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// omp inherits transform +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/transform_reduce.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/transform_reduce.h new file mode 100644 index 0000000000000000000000000000000000000000..a8736bd75d06e54d9158baeb2504162d75312885 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/transform_reduce.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits transform_reduce +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/transform_scan.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/transform_scan.h new file mode 100644 index 0000000000000000000000000000000000000000..75b075b6b16f063a1c5cda8893911d3f3c533f2d --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/transform_scan.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits transform_scan +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/uninitialized_copy.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/uninitialized_copy.h new file mode 100644 index 0000000000000000000000000000000000000000..bda06ac13e9ca1d14ee5e047986884f5207d3d2b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/uninitialized_copy.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits uninitialized_copy +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/uninitialized_fill.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/uninitialized_fill.h new file mode 100644 index 0000000000000000000000000000000000000000..764de876233a012e5a9de9113c5fb2dac7a22499 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/uninitialized_fill.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include + +// this system inherits uninitialized_fill +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/unique.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/unique.h new file mode 100644 index 0000000000000000000000000000000000000000..843e6406e3a79c39d57ed9d363a6c46b65205edf --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/unique.h @@ -0,0 +1,68 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ + + +template + ForwardIterator unique(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate binary_pred); + + +template + OutputIterator unique_copy(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator output, + BinaryPredicate binary_pred); + + +template + typename thrust::iterator_traits::difference_type + unique_count(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate binary_pred); + + +} // end namespace detail +} // end namespace tbb +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/unique.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/unique.inl new file mode 100644 index 0000000000000000000000000000000000000000..136af897c694fbdf002749fc819e6d9cfc847e48 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/unique.inl @@ -0,0 +1,79 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ + + +template + ForwardIterator unique(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate binary_pred) +{ + // tbb prefers generic::unique to cpp::unique + return thrust::system::detail::generic::unique(exec,first,last,binary_pred); +} // end unique() + + +template + OutputIterator unique_copy(execution_policy &exec, + InputIterator first, + InputIterator last, + OutputIterator output, + BinaryPredicate binary_pred) +{ + // tbb prefers generic::unique_copy to cpp::unique_copy + return thrust::system::detail::generic::unique_copy(exec,first,last,output,binary_pred); +} // end unique_copy() + + +template + typename thrust::iterator_traits::difference_type + unique_count(execution_policy &exec, + ForwardIterator first, + ForwardIterator last, + BinaryPredicate binary_pred) +{ + // tbb prefers generic::unique_count to cpp::unique_count + return thrust::system::detail::generic::unique_count(exec,first,last,binary_pred); +} // end unique_count() + + +} // end namespace detail +} // end namespace tbb +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/unique_by_key.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/unique_by_key.h new file mode 100644 index 0000000000000000000000000000000000000000..513bb386e23edf4ba7c701160fc9dc1aa716e1da --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/unique_by_key.h @@ -0,0 +1,66 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ + + +template + thrust::pair + unique_by_key(execution_policy &exec, + ForwardIterator1 keys_first, + ForwardIterator1 keys_last, + ForwardIterator2 values_first, + BinaryPredicate binary_pred); + + +template + thrust::pair + unique_by_key_copy(execution_policy &exec, + InputIterator1 keys_first, + InputIterator1 keys_last, + InputIterator2 values_first, + OutputIterator1 keys_output, + OutputIterator2 values_output, + BinaryPredicate binary_pred); + + +} // end namespace detail +} // end namespace tbb +} // end namespace system +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/unique_by_key.inl b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/unique_by_key.inl new file mode 100644 index 0000000000000000000000000000000000000000..dbd5922b072db069ae6cd7d2affacd3c259e93f5 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/detail/unique_by_key.inl @@ -0,0 +1,73 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ +namespace detail +{ + + +template + thrust::pair + unique_by_key(execution_policy &exec, + ForwardIterator1 keys_first, + ForwardIterator1 keys_last, + ForwardIterator2 values_first, + BinaryPredicate binary_pred) +{ + // tbb prefers generic::unique_by_key to cpp::unique_by_key + return thrust::system::detail::generic::unique_by_key(exec,keys_first,keys_last,values_first,binary_pred); +} // end unique_by_key() + + +template + thrust::pair + unique_by_key_copy(execution_policy &exec, + InputIterator1 keys_first, + InputIterator1 keys_last, + InputIterator2 values_first, + OutputIterator1 keys_output, + OutputIterator2 values_output, + BinaryPredicate binary_pred) +{ + // tbb prefers generic::unique_by_key_copy to cpp::unique_by_key_copy + return thrust::system::detail::generic::unique_by_key_copy(exec,keys_first,keys_last,values_first,keys_output,values_output,binary_pred); +} // end unique_by_key_copy() + + +} // end namespace detail +} // end namespace tbb +} // end namespace system +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/execution_policy.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/execution_policy.h new file mode 100644 index 0000000000000000000000000000000000000000..bfa6b7893b1a37435247eb935e626c7dcc804769 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/execution_policy.h @@ -0,0 +1,155 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +#pragma once + +/*! \file thrust/system/tbb/execution_policy.h + * \brief Execution policies for Thrust's TBB system. + */ + +#include + +// get the execution policies definitions first +#include + +// get the definition of par +#include + +// now get all the algorithm definitions + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +// define these entities here for the purpose of Doxygenating them +// they are actually defined elsewhere +#if 0 +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ + + +/*! \addtogroup execution_policies + * \{ + */ + + +/*! \p thrust::tbb::execution_policy is the base class for all Thrust parallel execution + * policies which are derived from Thrust's TBB backend system. + */ +template +struct execution_policy : thrust::execution_policy +{}; + + +/*! \p tbb::tag is a type representing Thrust's TBB backend system in C++'s type system. + * Iterators "tagged" with a type which is convertible to \p tbb::tag assert that they may be + * "dispatched" to algorithm implementations in the \p tbb system. + */ +struct tag : thrust::system::tbb::execution_policy { unspecified }; + + +/*! \p thrust::tbb::par is the parallel execution policy associated with Thrust's TBB + * backend system. + * + * Instead of relying on implicit algorithm dispatch through iterator system tags, users may + * directly target Thrust's TBB backend system by providing \p thrust::tbb::par as an algorithm + * parameter. + * + * Explicit dispatch can be useful in avoiding the introduction of data copies into containers such + * as \p thrust::tbb::vector. + * + * The type of \p thrust::tbb::par is implementation-defined. + * + * The following code snippet demonstrates how to use \p thrust::tbb::par to explicitly dispatch an + * invocation of \p thrust::for_each to the TBB backend system: + * + * \code + * #include + * #include + * #include + * + * struct printf_functor + * { + * __host__ __device__ + * void operator()(int x) + * { + * printf("%d\n", x); + * } + * }; + * ... + * int vec[3]; + * vec[0] = 0; vec[1] = 1; vec[2] = 2; + * + * thrust::for_each(thrust::tbb::par, vec.begin(), vec.end(), printf_functor()); + * + * // 0 1 2 is printed to standard output in some unspecified order + * \endcode + */ +static const unspecified par; + + +/*! \} + */ + + +} // end tbb +} // end system +THRUST_NAMESPACE_END +#endif + + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/memory.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/memory.h new file mode 100644 index 0000000000000000000000000000000000000000..3bd4422320ed6867e499d059c576e739169452bf --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/memory.h @@ -0,0 +1,103 @@ +/* + * Copyright 2008-2018 NVIDIA Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in ctbbliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*! \file thrust/system/tbb/memory.h + * \brief Managing memory associated with Thrust's TBB system. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system +{ +namespace tbb +{ + +/*! Allocates an area of memory available to Thrust's tbb system. + * \param n Number of bytes to allocate. + * \return A tbb::pointer pointing to the beginning of the newly + * allocated memory. A null tbb::pointer is returned if + * an error occurs. + * \note The tbb::pointer returned by this function must be + * deallocated with \p tbb::free. + * \see tbb::free + * \see std::malloc + */ +inline pointer malloc(std::size_t n); + +/*! Allocates a typed area of memory available to Thrust's tbb system. + * \param n Number of elements to allocate. + * \return A tbb::pointer pointing to the beginning of the newly + * allocated memory. A null tbb::pointer is returned if + * an error occurs. + * \note The tbb::pointer returned by this function must be + * deallocated with \p tbb::free. + * \see tbb::free + * \see std::malloc + */ +template +inline pointer malloc(std::size_t n); + +/*! Deallocates an area of memory previously allocated by tbb::malloc. + * \param ptr A tbb::pointer pointing to the beginning of an area + * of memory previously allocated with tbb::malloc. + * \see tbb::malloc + * \see std::free + */ +inline void free(pointer ptr); + +/*! \p tbb::allocator is the default allocator used by the \p tbb system's + * containers such as tbb::vector if no user-specified allocator is + * provided. \p tbb::allocator allocates (deallocates) storage with \p + * tbb::malloc (\p tbb::free). + */ +template +using allocator = thrust::mr::stateless_resource_allocator< + T, thrust::system::tbb::memory_resource +>; + +/*! \p tbb::universal_allocator allocates memory that can be used by the \p tbb + * system and host systems. + */ +template +using universal_allocator = thrust::mr::stateless_resource_allocator< + T, thrust::system::tbb::universal_memory_resource +>; + +}} // namespace system::tbb + +/*! \namespace thrust::tbb + * \brief \p thrust::tbb is a top-level alias for thrust::system::tbb. + */ +namespace tbb +{ +using thrust::system::tbb::malloc; +using thrust::system::tbb::free; +using thrust::system::tbb::allocator; +using thrust::system::tbb::universal_allocator; +} // namsespace tbb + +THRUST_NAMESPACE_END + +#include + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/memory_resource.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/memory_resource.h new file mode 100644 index 0000000000000000000000000000000000000000..a698b9242715274b81d8c30588a4a4afa0ec9ef6 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/memory_resource.h @@ -0,0 +1,69 @@ +/* + * Copyright 2018-2020 NVIDIA Corporation + * + * 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. + */ + +/*! \file tbb/memory_resource.h + * \brief Memory resources for the TBB system. + */ + +#pragma once + +#include +#include +#include + +#include + +THRUST_NAMESPACE_BEGIN +namespace system { namespace tbb +{ + +//! \cond +namespace detail +{ + typedef thrust::mr::fancy_pointer_resource< + thrust::mr::new_delete_resource, + thrust::tbb::pointer + > native_resource; + + typedef thrust::mr::fancy_pointer_resource< + thrust::mr::new_delete_resource, + thrust::tbb::universal_pointer + > universal_native_resource; +} // namespace detail +//! \endcond + +/*! \addtogroup memory_resources Memory Resources + * \ingroup memory_management + * \{ + */ + +/*! The memory resource for the TBB system. Uses \p mr::new_delete_resource and + * tags it with \p tbb::pointer. + */ +typedef detail::native_resource memory_resource; +/*! The unified memory resource for the TBB system. Uses + * \p mr::new_delete_resource and tags it with \p tbb::universal_pointer. + */ +typedef detail::universal_native_resource universal_memory_resource; +/*! An alias for \p tbb::universal_memory_resource. */ +typedef detail::native_resource universal_host_pinned_memory_resource; + +/*! \} // memory_resources + */ + +}} // namespace system::tbb + +THRUST_NAMESPACE_END diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/pointer.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/pointer.h new file mode 100644 index 0000000000000000000000000000000000000000..065e1a548f0c605388d9f85fec9a3cc20d8f4ec6 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/pointer.h @@ -0,0 +1,117 @@ +/* + * Copyright 2008-2020 NVIDIA Corporation + * + * 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. + */ + +/*! \file thrust/system/tbb/memory.h + * \brief Managing memory associated with Thrust's TBB system. + */ + +#pragma once + +#include +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system { namespace tbb +{ + +/*! \p tbb::pointer stores a pointer to an object allocated in memory accessible + * by the \p tbb system. This type provides type safety when dispatching + * algorithms on ranges resident in \p tbb memory. + * + * \p tbb::pointer has pointer semantics: it may be dereferenced and + * manipulated with pointer arithmetic. + * + * \p tbb::pointer can be created with the function \p tbb::malloc, or by + * explicitly calling its constructor with a raw pointer. + * + * The raw pointer encapsulated by a \p tbb::pointer may be obtained by eiter its + * get member function or the \p raw_pointer_cast function. + * + * \note \p tbb::pointer is not a "smart" pointer; it is the programmer's + * responsibility to deallocate memory pointed to by \p tbb::pointer. + * + * \tparam T specifies the type of the pointee. + * + * \see tbb::malloc + * \see tbb::free + * \see raw_pointer_cast + */ +template +using pointer = thrust::pointer< + T, + thrust::system::tbb::tag, + thrust::tagged_reference +>; + +/*! \p tbb::universal_pointer stores a pointer to an object allocated in memory + * accessible by the \p tbb system and host systems. + * + * \p tbb::universal_pointer has pointer semantics: it may be dereferenced and + * manipulated with pointer arithmetic. + * + * \p tbb::universal_pointer can be created with \p tbb::universal_allocator + * or by explicitly calling its constructor with a raw pointer. + * + * The raw pointer encapsulated by a \p tbb::universal_pointer may be obtained + * by eiter its get member function or the \p raw_pointer_cast + * function. + * + * \note \p tbb::universal_pointer is not a "smart" pointer; it is the + * programmer's responsibility to deallocate memory pointed to by + * \p tbb::universal_pointer. + * + * \tparam T specifies the type of the pointee. + * + * \see tbb::universal_allocator + * \see raw_pointer_cast + */ +template +using universal_pointer = thrust::pointer< + T, + thrust::system::tbb::tag, + typename std::add_lvalue_reference::type +>; + +/*! \p reference is a wrapped reference to an object stored in memory available + * to the \p tbb system. \p reference is the type of the result of + * dereferencing a \p tbb::pointer. + * + * \tparam T Specifies the type of the referenced object. + */ +template +using reference = thrust::tagged_reference; + +}} // namespace system::tbb + +/*! \addtogroup system_backends Systems + * \ingroup system + * \{ + */ + +/*! \namespace thrust::tbb + * \brief \p thrust::tbb is a top-level alias for \p thrust::system::tbb. */ +namespace tbb +{ +using thrust::system::tbb::pointer; +using thrust::system::tbb::universal_pointer; +using thrust::system::tbb::reference; +} // namespace tbb + +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/vector.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/vector.h new file mode 100644 index 0000000000000000000000000000000000000000..8cbbabbd2427358f249f3956b5326dfe1793ba8c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/system/tbb/vector.h @@ -0,0 +1,82 @@ +/* + * Copyright 2008-2013 NVIDIA Corporation + * + * 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. + */ + +/*! \file thrust/system/tbb/vector.h + * \brief A dynamically-sizable array of elements which reside in memory available to + * Thrust's TBB system. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN +namespace system { namespace tbb +{ + +/*! \p tbb::vector is a container that supports random access to elements, + * constant time removal of elements at the end, and linear time insertion + * and removal of elements at the beginning or in the middle. The number of + * elements in a \p tbb::vector may vary dynamically; memory management is + * automatic. The elements contained in a \p tbb::vector reside in memory + * accessible by the \p tbb system. + * + * \tparam T The element type of the \p tbb::vector. + * \tparam Allocator The allocator type of the \p tbb::vector. + * Defaults to \p tbb::allocator. + * + * \see https://en.cppreference.com/w/cpp/container/vector + * \see host_vector For the documentation of the complete interface which is + * shared by \p tbb::vector. + * \see device_vector + * \see universal_vector + */ +template > +using vector = thrust::detail::vector_base; + +/*! \p tbb::universal_vector is a container that supports random access to + * elements, constant time removal of elements at the end, and linear time + * insertion and removal of elements at the beginning or in the middle. The + * number of elements in a \p tbb::universal_vector may vary dynamically; + * memory management is automatic. The elements contained in a + * \p tbb::universal_vector reside in memory accessible by the \p tbb system + * and host systems. + * + * \tparam T The element type of the \p tbb::universal_vector. + * \tparam Allocator The allocator type of the \p tbb::universal_vector. + * Defaults to \p tbb::universal_allocator. + * + * \see https://en.cppreference.com/w/cpp/container/vector + * \see host_vector For the documentation of the complete interface which is + * shared by \p tbb::universal_vector + * \see device_vector + * \see universal_vector + */ +template > +using universal_vector = thrust::detail::vector_base; + +}} // namespace system::tbb + +namespace tbb +{ +using thrust::system::tbb::vector; +using thrust::system::tbb::universal_vector; +} + +THRUST_NAMESPACE_END diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/integer_sequence.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/integer_sequence.h new file mode 100644 index 0000000000000000000000000000000000000000..26ea542134a37242a7ce440ded5f01f2b8d999d1 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/integer_sequence.h @@ -0,0 +1,381 @@ +/* + * Copyright 2008-2021 NVIDIA Corporation + * + * 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. + */ + +/*! \file + * \brief C++14's + * std::index_sequence, + * associated helper aliases, and some related extensions. + */ + +#pragma once + +#include +#include + +#if THRUST_CPP_DIALECT >= 2011 + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN + +/*! \addtogroup utility + * \{ + */ + +/*! \addtogroup type_traits Type Traits + * \{ + */ + +/*! \brief A compile-time sequence of + * integral constants + * of type \c T with values Is.... + * + * \see integral constants + * \see index_sequence + * \see make_integer_sequence + * \see make_reversed_integer_sequence + * \see make_index_sequence + * \see make_reversed_index_sequence + * \see integer_sequence_push_front + * \see integer_sequence_push_back + * \see std::integer_sequence + */ +#if THRUST_CPP_DIALECT >= 2014 +template +using integer_sequence = std::integer_sequence; +#else +template +struct integer_sequence +{ + using type = integer_sequence; + using value_type = T; + using size_type = std::size_t; + + __host__ __device__ + static constexpr size_type size() noexcept + { + return sizeof...(Is); + } +}; +#endif + +/////////////////////////////////////////////////////////////////////////////// + +/*! \brief A compile-time sequence of type + * std::size_t + * with values Is.... + * + * \see integer_sequence + * \see make_integer_sequence + * \see make_reversed_integer_sequence + * \see make_index_sequence + * \see make_reversed_index_sequence + * \see integer_sequence_push_front + * \see integer_sequence_push_back + * \see std::index_sequence + */ +#if THRUST_CPP_DIALECT >= 2014 +template +using index_sequence = std::index_sequence; +#else +template +using index_sequence = integer_sequence; +#endif + +#if THRUST_CPP_DIALECT < 2014 +/*! \cond + */ + +namespace detail +{ + +/*! \brief Create a new \c integer_sequence containing the elements of \c + * Sequence0 followed by the elements of \c Sequence1. \c Sequence0::size() is + * added to each element from \c Sequence1 in the new sequence. + * + * \see integer_sequence + * \see index_sequence + * \see make_reversed_integer_sequence + * \see make_index_sequence + * \see make_reversed_index_sequence + * \see merge_and_renumber_reversed_integer_sequences_impl + */ +template + struct merge_and_renumber_integer_sequences_impl; +template + using merge_and_renumber_integer_sequences = + typename merge_and_renumber_integer_sequences_impl< + Sequence0, Sequence1 + >::type; + +template + struct make_integer_sequence_impl; + +} // namespace detail + +/*! \endcond + */ +#endif + +/*! \brief Create a new \c integer_sequence with elements + * 0, 1, 2, ..., N - 1 of type \c T. + * + * \see integer_sequence + * \see index_sequence + * \see make_reversed_integer_sequence + * \see make_index_sequence + * \see make_reversed_index_sequence + * \see std::make_integer_sequence + */ +#if THRUST_CPP_DIALECT >= 2014 +template +using make_integer_sequence = std::make_integer_sequence; +#else +template +using make_integer_sequence = + typename detail::make_integer_sequence_impl::type; + +/*! \cond + */ + +namespace detail +{ + +template +struct merge_and_renumber_integer_sequences_impl< + integer_sequence, integer_sequence +> +{ + using type = integer_sequence; +}; + +template +struct make_integer_sequence_impl +{ + using type = merge_and_renumber_integer_sequences< + make_integer_sequence + , make_integer_sequence + >; +}; + +template +struct make_integer_sequence_impl +{ + using type = integer_sequence; +}; + +template +struct make_integer_sequence_impl +{ + using type = integer_sequence; +}; + +} // namespace detail + +/*! \endcond + */ +#endif + +/////////////////////////////////////////////////////////////////////////////// + +/*! \brief Create a new \c integer_sequence with elements + * 0, 1, 2, ..., N - 1 of type + * std::size_t. + * + * \see integer_sequence + * \see index_sequence + * \see make_integer_sequence + * \see make_reversed_integer_sequence + * \see make_reversed_index_sequence + * \see std::make_index_sequence + */ +#if THRUST_CPP_DIALECT >= 2014 +template +using make_index_sequence = std::make_index_sequence; +#else +template +using make_index_sequence = + make_integer_sequence; +#endif + +/////////////////////////////////////////////////////////////////////////////// + +/*! \cond + */ + +namespace detail +{ + +/*! \brief Create a new \c integer_sequence containing the elements of \c + * Sequence0 followed by the elements of \c Sequence1. \c Sequence1::size() is + * added to each element from \c Sequence0 in the new sequence. + * + * \see make_reversed_integer_sequence + * \see integer_sequence + * \see index_sequence + * \see make_integer_sequence + * \see make_reversed_integer_sequence + * \see make_index_sequence + * \see make_reversed_index_sequence + * \see merge_and_renumber_integer_sequences_impl + */ +template + struct merge_and_renumber_reversed_integer_sequences_impl; +template + using merge_and_renumber_reversed_integer_sequences = + typename merge_and_renumber_reversed_integer_sequences_impl< + Sequence0, Sequence1 + >::type; + +template +struct make_reversed_integer_sequence_impl; + +template +struct integer_sequence_push_front_impl; + +template +struct integer_sequence_push_back_impl; + +template +struct merge_and_renumber_reversed_integer_sequences_impl< + integer_sequence, integer_sequence +> +{ + using type = integer_sequence; +}; + +} // namespace detail + +/*! \endcond + */ + +/////////////////////////////////////////////////////////////////////////////// + +/*! \brief Create a new \c integer_sequence with elements + * N - 1, N - 2, N - 3, ..., 0. + * + * \see integer_sequence + * \see index_sequence + * \see make_integer_sequence + * \see make_index_sequence + * \see make_reversed_index_sequence + */ +template +using make_reversed_integer_sequence = + typename detail::make_reversed_integer_sequence_impl::type; + +/*! \brief Create a new \c index_sequence with elements + * N - 1, N - 2, N - 3, ..., 0. + * + * \see integer_sequence + * \see index_sequence + * \see make_integer_sequence + * \see make_reversed_integer_sequence + * \see make_reversed_index_sequence + */ +template +using make_reversed_index_sequence = + make_reversed_integer_sequence; + +/*! \brief Add a new element to the front of an \c integer_sequence. + * + * \see integer_sequence + * \see index_sequence + * \see make_integer_sequence + * \see make_index_sequence + */ +template +using integer_sequence_push_front = + typename detail::integer_sequence_push_front_impl::type; + +/*! \brief Add a new element to the back of an \c integer_sequence. + * + * \see integer_sequence + * \see index_sequence + * \see make_integer_sequence + * \see make_index_sequence + */ +template +using integer_sequence_push_back = + typename detail::integer_sequence_push_back_impl::type; + +/////////////////////////////////////////////////////////////////////////////// + +/*! \cond + */ + +namespace detail +{ + +template +struct make_reversed_integer_sequence_impl +{ + using type = merge_and_renumber_reversed_integer_sequences< + make_reversed_integer_sequence + , make_reversed_integer_sequence + >; +}; + +/////////////////////////////////////////////////////////////////////////////// + +template +struct make_reversed_integer_sequence_impl +{ + using type = integer_sequence; +}; + +template +struct make_reversed_integer_sequence_impl +{ + using type = integer_sequence; +}; + +/////////////////////////////////////////////////////////////////////////////// + +template +struct integer_sequence_push_front_impl > +{ + using type = integer_sequence; +}; + +/////////////////////////////////////////////////////////////////////////////// + +template +struct integer_sequence_push_back_impl > +{ + using type = integer_sequence; +}; + +/////////////////////////////////////////////////////////////////////////////// + +} // namespace detail + +/*! \endcond + */ + +/*! \} // type traits + */ + +/*! \} // utility + */ + +THRUST_NAMESPACE_END + +#endif // THRUST_CPP_DIALECT >= 2011 + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/is_contiguous_iterator.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/is_contiguous_iterator.h new file mode 100644 index 0000000000000000000000000000000000000000..eaa088978c4565a7525a37c8356e9b547f96c319 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/is_contiguous_iterator.h @@ -0,0 +1,295 @@ +/* + * Copyright 2008-2021 NVIDIA Corporation + * + * 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. + */ + +/*! \file + * \brief An extensible type trait for determining if an iterator satisifies the + * ContiguousIterator + * requirements (aka is pointer-like). + */ + +#pragma once + +#include +#include +#include +#include + +#include +#include +#include + +#if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC && _MSC_VER < 1916 // MSVC 2017 version 15.9 + #include + #include + #include + + #if THRUST_CPP_DIALECT >= 2017 + #include + #endif +#endif + +THRUST_NAMESPACE_BEGIN + +/*! \addtogroup utility + * \{ + */ + +/*! \addtogroup type_traits Type Traits + * \{ + */ + +/*! \cond + */ + +namespace detail +{ + +template +struct is_contiguous_iterator_impl; + +} // namespace detail + +/*! \endcond + */ + +/*! \brief UnaryTypeTrait + * that returns \c true_type if \c Iterator satisfies + * ContiguousIterator, + * aka it points to elements that are contiguous in memory, and \c false_type + * otherwise. + * + * \see is_contiguous_iterator_v + * \see proclaim_contiguous_iterator + * \see THRUST_PROCLAIM_CONTIGUOUS_ITERATOR + */ +template +#if THRUST_CPP_DIALECT >= 2011 +using is_contiguous_iterator = +#else +struct is_contiguous_iterator : +#endif + detail::is_contiguous_iterator_impl +#if THRUST_CPP_DIALECT < 2011 +{} +#endif +; + +#if THRUST_CPP_DIALECT >= 2014 +/*! \brief constexpr bool that is \c true if \c Iterator satisfies + * ContiguousIterator, + * aka it points to elements that are contiguous in memory, and \c false + * otherwise. + * + * \see is_contiguous_iterator + * \see proclaim_contiguous_iterator + * \see THRUST_PROCLAIM_CONTIGUOUS_ITERATOR + */ +template +constexpr bool is_contiguous_iterator_v = is_contiguous_iterator::value; +#endif + +/*! \brief Customization point that can be customized to indicate that an + * iterator type \c Iterator satisfies + * ContiguousIterator, + * aka it points to elements that are contiguous in memory. + * + * \see is_contiguous_iterator + * \see THRUST_PROCLAIM_CONTIGUOUS_ITERATOR + */ +template +struct proclaim_contiguous_iterator : false_type {}; + +/*! \brief Declares that the iterator \c Iterator is + * ContiguousIterator + * by specializing \c proclaim_contiguous_iterator. + * + * \see is_contiguous_iterator + * \see proclaim_contiguous_iterator + */ +#define THRUST_PROCLAIM_CONTIGUOUS_ITERATOR(Iterator) \ + THRUST_NAMESPACE_BEGIN \ + template <> \ + struct proclaim_contiguous_iterator \ + : THRUST_NS_QUALIFIER::true_type {}; \ + THRUST_NAMESPACE_END \ + /**/ + +/*! \cond + */ + +namespace detail +{ + +template +struct is_libcxx_wrap_iter : false_type {}; + +#if defined(_LIBCPP_VERSION) +template +struct is_libcxx_wrap_iter< + _VSTD::__wrap_iter +> : true_type {}; +#endif + +template +struct is_libstdcxx_normal_iterator : false_type {}; + +#if defined(__GLIBCXX__) +template +struct is_libstdcxx_normal_iterator< + ::__gnu_cxx::__normal_iterator +> : true_type {}; +#endif + +#if _MSC_VER >= 1916 // MSVC 2017 version 15.9. +template +struct is_msvc_contiguous_iterator + : is_pointer<::std::_Unwrapped_t > {}; +#elif _MSC_VER >= 1700 // MSVC 2012. +template +struct is_msvc_contiguous_iterator : false_type {}; + +template +struct is_msvc_contiguous_iterator< + ::std::_Vector_const_iterator +> : true_type {}; + +template +struct is_msvc_contiguous_iterator< + ::std::_Vector_iterator +> : true_type {}; + +template +struct is_msvc_contiguous_iterator< + ::std::_String_const_iterator +> : true_type {}; + +template +struct is_msvc_contiguous_iterator< + ::std::_String_iterator +> : true_type {}; + +template +struct is_msvc_contiguous_iterator< + ::std::_Array_const_iterator +> : true_type {}; + +template +struct is_msvc_contiguous_iterator< + ::std::_Array_iterator +> : true_type {}; + +#if THRUST_CPP_DIALECT >= 2017 +template +struct is_msvc_contiguous_iterator< + ::std::_String_view_iterator +> : true_type {}; +#endif +#else +template +struct is_msvc_contiguous_iterator : false_type {}; +#endif + +template +struct is_contiguous_iterator_impl + : integral_constant< + bool + , is_pointer::value + || is_thrust_pointer::value + || is_libcxx_wrap_iter::value + || is_libstdcxx_normal_iterator::value + || is_msvc_contiguous_iterator::value + || proclaim_contiguous_iterator::value + > +{}; + +// Type traits for contiguous iterators: +template +struct contiguous_iterator_traits +{ + static_assert(thrust::is_contiguous_iterator::value, + "contiguous_iterator_traits requires a contiguous iterator."); + + using raw_pointer = typename thrust::detail::pointer_traits< + decltype(&*std::declval())>::raw_pointer; +}; + +template +using contiguous_iterator_raw_pointer_t = + typename contiguous_iterator_traits::raw_pointer; + +// Converts a contiguous iterator to a raw pointer: +template +__host__ __device__ +contiguous_iterator_raw_pointer_t +contiguous_iterator_raw_pointer_cast(Iterator it) +{ + static_assert(thrust::is_contiguous_iterator::value, + "contiguous_iterator_raw_pointer_cast called with " + "non-contiguous iterator."); + return thrust::raw_pointer_cast(&*it); +} + +// Implementation for non-contiguous iterators -- passthrough. +template ::value> +struct try_unwrap_contiguous_iterator_impl +{ + using type = Iterator; + + static __host__ __device__ type get(Iterator it) { return it; } +}; + +// Implementation for contiguous iterators -- unwraps to raw pointer. +template +struct try_unwrap_contiguous_iterator_impl +{ + using type = contiguous_iterator_raw_pointer_t; + + static __host__ __device__ type get(Iterator it) + { + return contiguous_iterator_raw_pointer_cast(it); + } +}; + +template +using try_unwrap_contiguous_iterator_return_t = + typename try_unwrap_contiguous_iterator_impl::type; + +// Casts to a raw pointer if iterator is marked as contiguous, otherwise returns +// the input iterator. +template +__host__ __device__ +try_unwrap_contiguous_iterator_return_t +try_unwrap_contiguous_iterator(Iterator it) +{ + return try_unwrap_contiguous_iterator_impl::get(it); +} + +} // namespace detail + +/*! \endcond + */ + +/////////////////////////////////////////////////////////////////////////////// + +/*! \} // type traits + */ + +/*! \} // utility + */ + +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/is_execution_policy.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/is_execution_policy.h new file mode 100644 index 0000000000000000000000000000000000000000..f83751ea2da75aaca7d73d8ca72065433d4b7e32 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/is_execution_policy.h @@ -0,0 +1,69 @@ +/* + * Copyright 2008-2021 NVIDIA Corporation + * + * 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. + */ + +/*! \file + * \brief A type trait that determines if a type is an \a ExecutionPolicy. + */ + +#pragma once + +#include + +#include +#include + +THRUST_NAMESPACE_BEGIN + +/*! \addtogroup utility + * \{ + */ + +/*! \addtogroup type_traits Type Traits + * \{ + */ + +/*! \brief UnaryTypeTrait + * that returns \c true_type if \c T is an \a ExecutionPolicy and \c false_type + * otherwise. + */ +template +#if THRUST_CPP_DIALECT >= 2011 +using is_execution_policy = +#else +struct is_execution_policy : +#endif + detail::is_base_of +#if THRUST_CPP_DIALECT < 2011 +{} +#endif +; + +#if THRUST_CPP_DIALECT >= 2014 +/*! \brief constexpr bool that is \c true if \c T is an + * \a ExecutionPolicy and \c false otherwise. + */ +template +constexpr bool is_execution_policy_v = is_execution_policy::value; +#endif + +/*! \} // type traits + */ + +/*! \} // utility + */ + +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/is_operator_less_or_greater_function_object.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/is_operator_less_or_greater_function_object.h new file mode 100644 index 0000000000000000000000000000000000000000..ef5a19f691e5b17846ee48b1506ee5224f97a62b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/is_operator_less_or_greater_function_object.h @@ -0,0 +1,208 @@ +/* + * Copyright 2008-2021 NVIDIA Corporation + * + * 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. + */ + +/*! \file + * \brief Type traits for determining if a + * BinaryPredicate + * is equivalent to either \c operator< or \c operator>. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN + +/*! \addtogroup utility + * \{ + */ + +/*! \addtogroup type_traits Type Traits + * \{ + */ + +/*! \cond + */ + +namespace detail +{ + +template +struct is_operator_less_function_object_impl; + +template +struct is_operator_greater_function_object_impl; + +} // namespace detail + +/*! \endcond + */ + +/*! \brief UnaryTypeTrait + * that returns \c true_type if \c T is a + * BinaryPredicate + * equivalent to \c operator<, and \c false_type otherwise. + * + * \see is_operator_less_function_object_v + * \see is_operator_greater_function_object + * \see is_operator_less_or_greater_function_object + * \see is_operator_plus_function_object + */ +template +#if THRUST_CPP_DIALECT >= 2011 +using is_operator_less_function_object = +#else +struct is_operator_less_function_object : +#endif + detail::is_operator_less_function_object_impl +#if THRUST_CPP_DIALECT < 2011 +{} +#endif +; + +#if THRUST_CPP_DIALECT >= 2014 +/*! \brief constexpr bool that is \c true if \c T is a + * BinaryPredicate + * equivalent to \c operator<, and \c false otherwise. + * + * \see is_operator_less_function_object + * \see is_operator_greater_function_object + * \see is_operator_less_or_greater_function_object + * \see is_operator_plus_function_object + */ +template +constexpr bool is_operator_less_function_object_v + = is_operator_less_function_object::value; +#endif + +/*! \brief UnaryTypeTrait + * that returns \c true_type if \c T is a + * BinaryPredicate + * equivalent to \c operator>, and \c false_type otherwise. + * + * \see is_operator_greater_function_object_v + * \see is_operator_less_function_object + * \see is_operator_less_or_greater_function_object + * \see is_operator_plus_function_object + */ +template +#if THRUST_CPP_DIALECT >= 2011 +using is_operator_greater_function_object = +#else +struct is_operator_greater_function_object : +#endif + detail::is_operator_greater_function_object_impl +#if THRUST_CPP_DIALECT < 2011 +{} +#endif +; + +#if THRUST_CPP_DIALECT >= 2014 +/*! \brief constexpr bool that is \c true if \c T is a + * BinaryPredicate + * equivalent to \c operator>, and \c false otherwise. + * + * \see is_operator_greater_function_object + * \see is_operator_less_function_object + * \see is_operator_less_or_greater_function_object + * \see is_operator_plus_function_object + */ +template +constexpr bool is_operator_greater_function_object_v + = is_operator_greater_function_object::value; +#endif + +/*! \brief UnaryTypeTrait + * that returns \c true_type if \c T is a + * BinaryPredicate + * equivalent to \c operator< or \c operator>, and \c false_type otherwise. + * + * \see is_operator_less_or_greater_function_object_v + * \see is_operator_less_function_object + * \see is_operator_greater_function_object + * \see is_operator_plus_function_object + */ +template +#if THRUST_CPP_DIALECT >= 2011 +using is_operator_less_or_greater_function_object = +#else +struct is_operator_less_or_greater_function_object : +#endif + integral_constant< + bool + , detail::is_operator_less_function_object_impl::value + || detail::is_operator_greater_function_object_impl::value + > +#if THRUST_CPP_DIALECT < 2011 +{} +#endif +; + +#if THRUST_CPP_DIALECT >= 2014 +/*! \brief constexpr bool that is \c true if \c T is a + * BinaryPredicate + * equivalent to \c operator< or \c operator>, and \c false otherwise. + * + * \see is_operator_less_or_greater_function_object + * \see is_operator_less_function_object + * \see is_operator_greater_function_object + * \see is_operator_plus_function_object + */ +template +constexpr bool is_operator_less_or_greater_function_object_v + = is_operator_less_or_greater_function_object::value; +#endif + +/////////////////////////////////////////////////////////////////////////////// + +/*! \cond + */ + +namespace detail +{ + +template +struct is_operator_less_function_object_impl : false_type {}; +template +struct is_operator_less_function_object_impl > : true_type {}; +template +struct is_operator_less_function_object_impl > : true_type {}; + +template +struct is_operator_greater_function_object_impl : false_type {}; +template +struct is_operator_greater_function_object_impl > : true_type {}; +template +struct is_operator_greater_function_object_impl > : true_type {}; + +} // namespace detail + +/*! \endcond + */ + +/////////////////////////////////////////////////////////////////////////////// + +/*! \} // type traits + */ + +/*! \} // utility + */ + +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/is_operator_plus_function_object.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/is_operator_plus_function_object.h new file mode 100644 index 0000000000000000000000000000000000000000..800847532cf35416ec3373427a6b4f94d769dc09 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/is_operator_plus_function_object.h @@ -0,0 +1,118 @@ +/* + * Copyright 2008-2021 NVIDIA Corporation + * + * 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. + */ + +/*! \file + * \brief Type traits for determining if a + * FunctionObject + * is equivalent to \c operator+. + */ + +#pragma once + +#include +#include +#include +#include + +THRUST_NAMESPACE_BEGIN + +/*! \addtogroup utility + * \{ + */ + +/*! \addtogroup type_traits Type Traits + * \{ + */ + +/*! \cond + */ + +namespace detail +{ + +template +struct is_operator_plus_function_object_impl; + +} // namespace detail + +/*! \endcond + */ + +/*! \brief UnaryTypeTrait + * that returns \c true_type if \c T is a + * FunctionObject + * equivalent to \c operator+, and \c false_type otherwise. + * + * \see is_operator_plus_function_object_v + * \see is_operator_less_function_object + * \see is_operator_greater_function_object + * \see is_operator_less_or_greater_function_object + */ +template +#if THRUST_CPP_DIALECT >= 2011 +using is_operator_plus_function_object = +#else +struct is_operator_plus_function_object : +#endif + detail::is_operator_plus_function_object_impl +#if THRUST_CPP_DIALECT < 2011 +{} +#endif +; + +#if THRUST_CPP_DIALECT >= 2014 +/*! \brief constexpr bool that is \c true if \c T is a + * FunctionObject + * equivalent to \c operator<, and \c false otherwise. + * + * \see is_operator_plus_function_object + * \see is_operator_less_function_object + * \see is_operator_greater_function_object + * \see is_operator_less_or_greater_function_object + */ +template +constexpr bool is_operator_plus_function_object_v + = is_operator_plus_function_object::value; +#endif + +/////////////////////////////////////////////////////////////////////////////// + +/*! \cond + */ + +namespace detail +{ + +template +struct is_operator_plus_function_object_impl : false_type {}; +template +struct is_operator_plus_function_object_impl > : true_type {}; +template +struct is_operator_plus_function_object_impl > : true_type {}; + +} // namespace detail + +/*! \endcond + */ + +/*! \} // type traits + */ + +/*! \} // utility + */ + +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/is_trivially_relocatable.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/is_trivially_relocatable.h new file mode 100644 index 0000000000000000000000000000000000000000..21d1f09d8d7f0ed0fccca214cbcd3932717e48f3 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/is_trivially_relocatable.h @@ -0,0 +1,366 @@ +/* + * Copyright 2008-2021 NVIDIA Corporation + * + * 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. + */ + +/*! \file + * \brief P1144's proposed + * \c std::is_trivially_relocatable, an extensible type trait indicating + * whether a type can be bitwise copied with a facility like + * std::memcpy. + */ + +#pragma once + +#include +#include +#include +#include + +#if THRUST_CPP_DIALECT >= 2011 + #include +#endif + +THRUST_NAMESPACE_BEGIN + +/*! \addtogroup utility + * \{ + */ + +/*! \addtogroup type_traits Type Traits + * \{ + */ + +/*! \cond + */ + +namespace detail +{ + +template +struct is_trivially_relocatable_impl; + +} // namespace detail + +/*! \endcond + */ + +/*! \brief UnaryTypeTrait + * that returns \c true_type if \c T is + * TriviallyRelocatable, + * aka can be bitwise copied with a facility like + * std::memcpy, + * and \c false_type otherwise. + * + * \see is_trivially_relocatable_v + * \see is_trivially_relocatable_to + * \see is_indirectly_trivially_relocatable_to + * \see proclaim_trivially_relocatable + * \see THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE + */ +template +#if THRUST_CPP_DIALECT >= 2011 +using is_trivially_relocatable = +#else +struct is_trivially_relocatable : +#endif + detail::is_trivially_relocatable_impl +#if THRUST_CPP_DIALECT < 2011 +{} +#endif +; + +#if THRUST_CPP_DIALECT >= 2014 +/*! \brief constexpr bool that is \c true if \c T is + * TriviallyRelocatable, + * aka can be bitwise copied with a facility like + * std::memcpy, + * and \c false otherwise. + * + * \see is_trivially_relocatable + * \see is_trivially_relocatable_to + * \see is_indirectly_trivially_relocatable_to + * \see proclaim_trivially_relocatable + * \see THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE + */ +template +constexpr bool is_trivially_relocatable_v = is_trivially_relocatable::value; +#endif + +/*! \brief BinaryTypeTrait + * that returns \c true_type if \c From is + * TriviallyRelocatable, + * to \c To, aka can be bitwise copied with a facility like + * std::memcpy, + * and \c false_type otherwise. + * + * \see is_trivially_relocatable_to_v + * \see is_trivially_relocatable + * \see is_indirectly_trivially_relocatable_to + * \see proclaim_trivially_relocatable + * \see THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE + */ +template +#if THRUST_CPP_DIALECT >= 2011 +using is_trivially_relocatable_to = +#else +struct is_trivially_relocatable_to : +#endif + integral_constant< + bool + , detail::is_same::value && is_trivially_relocatable::value + > +#if THRUST_CPP_DIALECT < 2011 +{} +#endif +; + +#if THRUST_CPP_DIALECT >= 2014 +/*! \brief constexpr bool that is \c true if \c From is + * TriviallyRelocatable, + * to \c To, aka can be bitwise copied with a facility like + * std::memcpy, + * and \c false otherwise. + * + * \see is_trivially_relocatable_to + * \see is_trivially_relocatable + * \see is_indirectly_trivially_relocatable_to + * \see proclaim_trivially_relocatable + * \see THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE + */ +template +constexpr bool is_trivially_relocatable_to_v + = is_trivially_relocatable_to::value; +#endif + +/*! \brief BinaryTypeTrait + * that returns \c true_type if the element type of \c FromIterator is + * TriviallyRelocatable, + * to the element type of \c ToIterator, aka can be bitwise copied with a + * facility like + * std::memcpy, + * and \c false_type otherwise. + * + * \see is_indirectly_trivially_relocatable_to_v + * \see is_trivially_relocatable + * \see is_trivially_relocatable_to + * \see proclaim_trivially_relocatable + * \see THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE + */ +template +#if THRUST_CPP_DIALECT >= 2011 +using is_indirectly_trivially_relocatable_to = +#else +struct is_indirectly_trivially_relocatable_to : +#endif + integral_constant< + bool + , is_contiguous_iterator::value + && is_contiguous_iterator::value + && is_trivially_relocatable_to< + typename thrust::iterator_traits::value_type, + typename thrust::iterator_traits::value_type + >::value + > +#if THRUST_CPP_DIALECT < 2011 +{} +#endif +; + +#if THRUST_CPP_DIALECT >= 2014 +/*! \brief constexpr bool that is \c true if the element type of + * \c FromIterator is + * TriviallyRelocatable, + * to the element type of \c ToIterator, aka can be bitwise copied with a + * facility like + * std::memcpy, + * and \c false otherwise. + * + * \see is_indirectly_trivially_relocatable_to + * \see is_trivially_relocatable + * \see is_trivially_relocatable_to + * \see proclaim_trivially_relocatable + * \see THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE + */ +template +constexpr bool is_indirectly_trivially_relocate_to_v + = is_indirectly_trivially_relocatable_to::value; +#endif + +/*! \brief customization point + * that can be specialized customized to indicate that a type \c T is + * TriviallyRelocatable, + * aka it can be bitwise copied with a facility like + * std::memcpy. + * + * \see is_indirectly_trivially_relocatable_to + * \see is_trivially_relocatable + * \see is_trivially_relocatable_to + * \see THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE + */ +template +struct proclaim_trivially_relocatable : false_type {}; + +/*! \brief Declares that the type \c T is + * TriviallyRelocatable, + * aka it can be bitwise copied with a facility like + * std::memcpy, + * by specializing \c proclaim_trivially_relocatable. + * + * \see is_indirectly_trivially_relocatable_to + * \see is_trivially_relocatable + * \see is_trivially_relocatable_to + * \see proclaim_trivially_relocatable + */ +#define THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(T) \ + THRUST_NAMESPACE_BEGIN \ + template <> \ + struct proclaim_trivially_relocatable : THRUST_NS_QUALIFIER::true_type \ + {}; \ + THRUST_NAMESPACE_END \ + /**/ + +/////////////////////////////////////////////////////////////////////////////// + +/*! \cond + */ + +namespace detail +{ + +// There is no way to actually detect the libstdc++ version; __GLIBCXX__ +// is always set to the date of libstdc++ being packaged, not the release +// day or version. This means that we can't detect the libstdc++ version, +// except when compiling with GCC. +// +// Therefore, for the best approximation of is_trivially_copyable, we need to +// handle three distinct cases: +// 1) GCC above 5, or another C++11 compiler not using libstdc++: use the +// standard trait directly. +// 2) A C++11 compiler using libstdc++ that provides the intrinsic: use the +// intrinsic. +// 3) Any other case (essentially: compiling without C++11): has_trivial_assign. + +#ifndef __has_feature + #define __has_feature(x) 0 +#endif + +template +struct is_trivially_copyable_impl + : integral_constant< + bool, + #if THRUST_CPP_DIALECT >= 2011 + #if defined(__GLIBCXX__) && __has_feature(is_trivially_copyable) + __is_trivially_copyable(T) + #elif THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_GCC && THRUST_GCC_VERSION >= 50000 + std::is_trivially_copyable::value + #else + has_trivial_assign::value + #endif + #else + has_trivial_assign::value + #endif + > +{ +}; + +// https://wg21.link/P1144R0#wording-inheritance +template +struct is_trivially_relocatable_impl + : integral_constant< + bool, + is_trivially_copyable_impl::value + || proclaim_trivially_relocatable::value + > +{}; + +template +struct is_trivially_relocatable_impl : is_trivially_relocatable_impl {}; + +} // namespace detail + +THRUST_NAMESPACE_END + +#if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA + +#include + +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(char1) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(char2) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(char3) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(char4) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(uchar1) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(uchar2) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(uchar3) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(uchar4) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(short1) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(short2) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(short3) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(short4) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(ushort1) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(ushort2) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(ushort3) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(ushort4) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(int1) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(int2) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(int3) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(int4) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(uint1) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(uint2) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(uint3) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(uint4) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(long1) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(long2) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(long3) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(long4) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(ulong1) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(ulong2) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(ulong3) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(ulong4) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(longlong1) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(longlong2) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(longlong3) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(longlong4) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(ulonglong1) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(ulonglong2) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(ulonglong3) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(ulonglong4) + +struct __half; +struct __half2; + +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(__half) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(__half2) + +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(float1) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(float2) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(float3) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(float4) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(double1) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(double2) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(double3) +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(double4) +#endif + +/*! \endcond + */ + +/////////////////////////////////////////////////////////////////////////////// + +/*! \} // type traits + */ + +/*! \} // utility + */ + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/logical_metafunctions.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/logical_metafunctions.h new file mode 100644 index 0000000000000000000000000000000000000000..914b477e8ef22a1ee86a0457046bd101196e5d2b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/logical_metafunctions.h @@ -0,0 +1,287 @@ +/* + * Copyright 2008-2021 NVIDIA Corporation + * + * 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. + */ + +/*! \file + * \brief C++17's + * std::conjunction, + * std::disjunction, + * and std::negation + * metafunctions and related extensions. + */ + +#pragma once + +#include +#include + +#if THRUST_CPP_DIALECT >= 2011 + +#include + +THRUST_NAMESPACE_BEGIN + +/*! \addtogroup utility + * \{ + */ + +/*! \addtogroup type_traits Type Traits + * \{ + */ + +/*! \brief std::integral_constant + * whose value is (... && Ts::value). + * + * \see conjunction_v + * \see conjunction_value + * \see std::conjunction + */ +#if THRUST_CPP_DIALECT >= 2017 +template +using conjunction = std::conjunction; +#else // Older than C++17. +template +struct conjunction; + +/*! \cond + */ + +template <> +struct conjunction<> : std::true_type {}; + +template +struct conjunction : T {}; + +template +struct conjunction : std::conditional::type {}; + +template +struct conjunction + : std::conditional, T0>::type {}; + +/*! \endcond + */ +#endif + +/*! \brief constexpr bool whose value is (... && Ts::value). + * + * \see conjunction + * \see conjunction_value + * \see std::conjunction + */ +#if THRUST_CPP_DIALECT >= 2014 +template +constexpr bool conjunction_v = conjunction::value; +#endif + +/*! \brief std::integral_constant + * whose value is (... || Ts::value). + * + * \see disjunction_v + * \see disjunction_value + * \see std::disjunction + */ +#if THRUST_CPP_DIALECT >= 2017 +template +using disjunction = std::disjunction; +#else // Older than C++17. +template +struct disjunction; + +/*! \cond + */ + +template <> +struct disjunction<> : std::false_type {}; + +template +struct disjunction : T {}; + +template +struct disjunction + : std::conditional >::type {}; + +/*! \endcond + */ +#endif + +/*! \brief constexpr bool whose value is (... || Ts::value). + * + * \see disjunction + * \see disjunction_value + * \see std::disjunction + */ +#if THRUST_CPP_DIALECT >= 2014 +template +constexpr bool disjunction_v = disjunction::value; +#endif + +/*! \brief std::integral_constant + * whose value is !Ts::value. + * + * \see negation_v + * \see negation_value + * \see std::negation + */ +#if THRUST_CPP_DIALECT >= 2017 +template +using negation = std::negation; +#else // Older than C++17. +template +struct negation; + +/*! \cond + */ + +template +struct negation : std::integral_constant {}; + +/*! \endcond + */ +#endif + +/*! \brief constexpr bool whose value is !Ts::value. + * + * \see negation + * \see negation_value + * \see std::negation + */ +#if THRUST_CPP_DIALECT >= 2014 +template +constexpr bool negation_v = negation::value; +#endif + +/////////////////////////////////////////////////////////////////////////////// + +/*! \brief std::integral_constant + * whose value is (... && Bs). + * + * \see conjunction_value_v + * \see conjunction + * \see std::conjunction + */ +template +struct conjunction_value; + +#if THRUST_CPP_DIALECT >= 2014 +/*! \brief constexpr bool whose value is (... && Bs). + * + * \see conjunction_value + * \see conjunction + * \see std::conjunction + */ +template +constexpr bool conjunction_value_v = conjunction_value::value; +#endif + +/*! \cond + */ + +template <> +struct conjunction_value<> : std::true_type {}; + +template +struct conjunction_value : std::integral_constant {}; + +template +struct conjunction_value + : std::integral_constant::value> {}; + +/*! \endcond + */ + +/////////////////////////////////////////////////////////////////////////////// + +/*! \brief std::integral_constant + * whose value is (... || Bs). + * + * \see disjunction_value_v + * \see disjunction + * \see std::disjunction + */ +template +struct disjunction_value; + +#if THRUST_CPP_DIALECT >= 2014 +/*! \brief constexpr bool whose value is (... || Bs). + * + * \see disjunction_value + * \see disjunction + * \see std::disjunction + */ +template +constexpr bool disjunction_value_v = disjunction_value::value; +#endif + +/*! \cond + */ + +template <> +struct disjunction_value<> : std::false_type {}; + +template +struct disjunction_value : std::integral_constant {}; + +template +struct disjunction_value + : std::integral_constant::value> {}; + +/*! \endcond + */ + +/////////////////////////////////////////////////////////////////////////////// + +/*! \brief std::integral_constant + * whose value is !Bs. + * + * \see negation_value_v + * \see negation + * \see std::negation + */ +template +struct negation_value; + +#if THRUST_CPP_DIALECT >= 2014 +/*! \brief constexpr bool whose value is !Ts::value. + * + * \see negation_value + * \see negation + * \see std::negation + */ +template +constexpr bool negation_value_v = negation_value::value; +#endif + +/*! \cond + */ + +template +struct negation_value : std::integral_constant {}; + +/*! \endcond + */ + +/////////////////////////////////////////////////////////////////////////////// + +/*! \} // type traits + */ + +/*! \} // utility + */ + +THRUST_NAMESPACE_END + +#endif // THRUST_CPP_DIALECT >= 2011 + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/remove_cvref.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/remove_cvref.h new file mode 100644 index 0000000000000000000000000000000000000000..1da2e0de35c3d881330746c5dc3c09020b84f0df --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/remove_cvref.h @@ -0,0 +1,97 @@ +/* + * Copyright 2018-2021 NVIDIA Corporation + * + * 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. + */ + +/*! \file + * \brief C++20's + * std::remove_cvref. + */ + +#pragma once + +#include + +#if THRUST_CPP_DIALECT >= 2017 +#if __has_include() +# include +#endif +#endif + +#include + +THRUST_NAMESPACE_BEGIN + +/*! \addtogroup utility + * \{ + */ + +/*! \addtogroup type_traits Type Traits + * \{ + */ + +/*! \brief UnaryTypeTrait + * that removes + * const-volatile qualifiers + * and + * references + * from \c T. + * Equivalent to \c remove_cv_t>. + * + * \see std::remove_cvref + * \see std::remove_cv + * \see std::remove_const + * \see std::remove_volatile + * \see std::remove_reference + */ +#if defined(__cpp_lib_remove_cvref) && (__cpp_lib_remove_cvref >= 201711L) +using std::remove_cvref; +#else // Older than C++20. +template +struct remove_cvref +{ + using type = typename std::remove_cv< + typename std::remove_reference::type + >::type; +}; +#endif + +/*! \brief Type alias that removes + * const-volatile qualifiers + * and + * references + * from \c T. + * Equivalent to \c remove_cv_t>. + * + * \see std::remove_cvref + * \see std::remove_cv + * \see std::remove_const + * \see std::remove_volatile + * \see std::remove_reference + */ +#if defined(__cpp_lib_remove_cvref) && (__cpp_lib_remove_cvref >= 201711L) +using std::remove_cvref_t; +#else // Older than C++20. +template +using remove_cvref_t = typename remove_cvref::type; +#endif + +/*! \} // type traits + */ + +/*! \} // utility + */ + +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/void_t.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/void_t.h new file mode 100644 index 0000000000000000000000000000000000000000..ed12d861dcb0f267fca9110dba0d9c5d93e78be4 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/third_party/gpus/cuda/include/thrust/type_traits/void_t.h @@ -0,0 +1,77 @@ +/* + * Copyright 2018-2021 NVIDIA Corporation + * + * 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. + */ + +/*! \file + * \brief C++17's `void_t`. + */ + +#pragma once + +#include + +#if THRUST_CPP_DIALECT >= 2017 +# include +#endif + +THRUST_NAMESPACE_BEGIN + +/*! \addtogroup utility + * \{ + */ + +/*! \addtogroup type_traits Type Traits + * \{ + */ + +#if THRUST_CPP_DIALECT >= 2011 + +template struct voider { using type = void; }; + +#if THRUST_CPP_DIALECT >= 2017 +using std::void_t; +#else +template using void_t = typename voider::type; +#endif + +#else // Older than C++11. + +template < + typename = void +, typename = void +, typename = void +, typename = void +, typename = void +, typename = void +, typename = void +, typename = void +, typename = void +, typename = void +> +struct voider +{ + typedef void type; +}; + +#endif + +/*! \} // type traits + */ + +/*! \} // utility + */ + +THRUST_NAMESPACE_END + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/c/tsl_status.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/c/tsl_status.h new file mode 100644 index 0000000000000000000000000000000000000000..6e332747c3b3fd007a9c08b8a9b357bc0f756112 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/c/tsl_status.h @@ -0,0 +1,92 @@ +/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_C_TSL_STATUS_H_ +#define TENSORFLOW_TSL_C_TSL_STATUS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct TSL_Status TSL_Status; + +// -------------------------------------------------------------------------- +// TSL_Code holds an error code. The enum values here are identical to +// corresponding values in error_codes.proto. +typedef enum TSL_Code { + TSL_OK = 0, + TSL_CANCELLED = 1, + TSL_UNKNOWN = 2, + TSL_INVALID_ARGUMENT = 3, + TSL_DEADLINE_EXCEEDED = 4, + TSL_NOT_FOUND = 5, + TSL_ALREADY_EXISTS = 6, + TSL_PERMISSION_DENIED = 7, + TSL_UNAUTHENTICATED = 16, + TSL_RESOURCE_EXHAUSTED = 8, + TSL_FAILED_PRECONDITION = 9, + TSL_ABORTED = 10, + TSL_OUT_OF_RANGE = 11, + TSL_UNIMPLEMENTED = 12, + TSL_INTERNAL = 13, + TSL_UNAVAILABLE = 14, + TSL_DATA_LOSS = 15, +} TSL_Code; + +// -------------------------------------------------------------------------- + +// Return a new status object. +extern TSL_Status* TSL_NewStatus(void); + +// Delete a previously created status object. +extern void TSL_DeleteStatus(TSL_Status*); + +// Record in *s. Any previous information is lost. +// A common use is to clear a status: TSL_SetStatus(s, TSL_OK, ""); +extern void TSL_SetStatus(TSL_Status* s, TSL_Code code, const char* msg); + +// Record as a payload in *s. The previous payload having the +// same key (if any) is overwritten. Payload will not be added if the Status +// is OK. +extern void TSL_SetPayload(TSL_Status* s, const char* key, const char* value); + +// Iterates over the stored payloads and calls the `visitor(key, value)` +// callable for each one. `key` and `value` is only usable during the callback. +// `capture` will be passed to the callback without modification. +typedef void (*TSL_PayloadVisitor)(const char* key, const char* value, + void* capture); +extern void TSL_ForEachPayload(const TSL_Status* s, TSL_PayloadVisitor visitor, + void* capture); + +// Convert from an I/O error code (e.g., errno) to a TSL_Status value. +// Any previous information is lost. Prefer to use this instead of TSL_SetStatus +// when the error comes from I/O operations. +extern void TSL_SetStatusFromIOError(TSL_Status* s, int error_code, + const char* context); + +// Return the code record in *s. +extern TSL_Code TSL_GetCode(const TSL_Status* s); + +// Return a pointer to the (null-terminated) error message in *s. The +// return value points to memory that is only usable until the next +// mutation to *s. Always returns an empty string if TSL_GetCode(s) is +// TSL_OK. +extern const char* TSL_Message(const TSL_Status* s); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif + +#endif // TENSORFLOW_TSL_C_TSL_STATUS_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/c/tsl_status_helper.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/c/tsl_status_helper.h new file mode 100644 index 0000000000000000000000000000000000000000..80cc80ffab321af2d9827a94ba03ade30367f403 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/c/tsl_status_helper.h @@ -0,0 +1,32 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_C_TSL_STATUS_HELPER_H_ +#define TENSORFLOW_TSL_C_TSL_STATUS_HELPER_H_ + +#include + +#include "tsl/c/tsl_status.h" +#include "tsl/platform/status.h" + +namespace tsl { + +TSL_Code TSLCodeFromStatusCode(absl::StatusCode code); + +absl::StatusCode StatusCodeFromTSLCode(TSL_Code code); + +} // namespace tsl + +#endif // TENSORFLOW_TSL_C_TSL_STATUS_HELPER_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/c/tsl_status_internal.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/c/tsl_status_internal.h new file mode 100644 index 0000000000000000000000000000000000000000..8da822511cbaf53f475580a68450a355acbced58 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/c/tsl_status_internal.h @@ -0,0 +1,28 @@ +/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_C_TSL_STATUS_INTERNAL_H_ +#define TENSORFLOW_TSL_C_TSL_STATUS_INTERNAL_H_ + +#include "tsl/platform/status.h" + +// Internal structures used by the status C API. These are likely to change +// and should not be depended on. + +struct TSL_Status { + tsl::Status status; +}; + +#endif // TENSORFLOW_TSL_C_TSL_STATUS_INTERNAL_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/call_options.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/call_options.h new file mode 100644 index 0000000000000000000000000000000000000000..6021ba8f1d24eb82ccf5f6958b9ca01d8fd4934f --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/call_options.h @@ -0,0 +1,82 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_CALL_OPTIONS_H_ +#define TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_CALL_OPTIONS_H_ + +#include + +#include "tsl/platform/macros.h" +#include "tsl/platform/mutex.h" +#include "tsl/platform/thread_annotations.h" +#include "tsl/platform/types.h" + +namespace tsl { + +// Options passed to interface calls. This class provides portable +// functionality across different RPC systems on top of +// platform-specific mechanisms (for client and server contexts, +// cancellation, etc.). +// +// TODO(zhifengc): Maybe change all RPC methods to take CallOptions. +class CallOptions { + public: + CallOptions(); + + // Cancellation. + // + // The caller may call StartCancel() anytime as long as this + // CallOptions object is alive. The callee may or may not receive + // the cancellation notification depending on the rpc layer + // implementation. + void StartCancel(); + + // The callee (the rpc layer implementation) must set a cancellation + // notifier before its blocking operation and clear the notifier + // before the call returns. + // + // "cancel_func" may be called zero, once or more time. Therefore, it + // should _not_ be responsible for memory management of any objects. + // + // "cancel_func" must be very light-weight. It should not block on + // IO or locking. Typically, it just calls the rpc implementation + // layer's specific cancellation mechanism and does nothing else. + // + // NOTE: "cancel_func" itself is pass-by-value. Therefore, we do not + // worry about its ownership here. + typedef std::function CancelFunction; + void SetCancelCallback(CancelFunction cancel_func); + void ClearCancelCallback(); + + // Get and set operation timeout. Timeout value is in milliseconds. + // + // Default: 0. indicating there is no timeout for this call. + int64_t GetTimeout(); + void SetTimeout(int64_t ms); + + private: + mutex mu_; + CancelFunction cancel_func_ TF_GUARDED_BY(mu_); + + // RPC operation timeout in milliseconds. + int64_t timeout_in_ms_ TF_GUARDED_BY(mu_) = 0; + + CallOptions(const CallOptions&) = delete; + void operator=(const CallOptions&) = delete; +}; + +} // namespace tsl + +#endif // TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_CALL_OPTIONS_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/coordination/coordination_client.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/coordination/coordination_client.h new file mode 100644 index 0000000000000000000000000000000000000000..1de6a45fe70e191fa1251b35c91e8f1e879f6135 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/coordination/coordination_client.h @@ -0,0 +1,146 @@ +/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_COORDINATION_COORDINATION_CLIENT_H_ +#define TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_COORDINATION_COORDINATION_CLIENT_H_ + +#include +#include + +#include "tsl/distributed_runtime/call_options.h" +#include "tsl/platform/status.h" +#include "tsl/protobuf/coordination_service.pb.h" + +namespace tsl { +using tensorflow::BarrierRequest; +using tensorflow::BarrierResponse; +using tensorflow::CancelBarrierRequest; +using tensorflow::CancelBarrierResponse; +using tensorflow::DeleteKeyValueRequest; +using tensorflow::DeleteKeyValueResponse; +using tensorflow::GetKeyValueDirRequest; +using tensorflow::GetKeyValueDirResponse; +using tensorflow::GetKeyValueRequest; +using tensorflow::GetKeyValueResponse; +using tensorflow::GetTaskStateRequest; +using tensorflow::GetTaskStateResponse; +using tensorflow::HeartbeatRequest; +using tensorflow::HeartbeatResponse; +using tensorflow::InsertKeyValueRequest; +using tensorflow::InsertKeyValueResponse; +using tensorflow::RegisterTaskRequest; +using tensorflow::RegisterTaskResponse; +using tensorflow::ReportErrorToServiceRequest; +using tensorflow::ReportErrorToServiceResponse; +using tensorflow::ReportErrorToTaskRequest; +using tensorflow::ReportErrorToTaskResponse; +using tensorflow::ResetTaskRequest; +using tensorflow::ResetTaskResponse; +using tensorflow::ShutdownTaskRequest; +using tensorflow::ShutdownTaskResponse; +using tensorflow::TryGetKeyValueRequest; +using tensorflow::TryGetKeyValueResponse; +using tensorflow::WaitForAllTasksRequest; +using tensorflow::WaitForAllTasksResponse; + +// Base class of client interface for communicating with coordination service. +// Can be implemented by a variety of transports such as gRPC. +class CoordinationClient { + public: + virtual ~CoordinationClient() = default; + + virtual void RegisterTaskAsync(CallOptions* call_opts, + const RegisterTaskRequest* request, + RegisterTaskResponse* response, + StatusCallback done) = 0; + + virtual void HeartbeatAsync(CallOptions* call_opts, + const HeartbeatRequest* request, + HeartbeatResponse* response, + StatusCallback done) = 0; + + virtual void WaitForAllTasksAsync(const WaitForAllTasksRequest* request, + WaitForAllTasksResponse* response, + StatusCallback done) = 0; + + virtual void ShutdownTaskAsync(CallOptions* call_opts, + const ShutdownTaskRequest* request, + ShutdownTaskResponse* response, + StatusCallback done) = 0; + + virtual void ResetTaskAsync(const ResetTaskRequest* request, + ResetTaskResponse* response, + StatusCallback done) = 0; + + virtual void ReportErrorToTaskAsync(CallOptions* call_opts, + const ReportErrorToTaskRequest* request, + ReportErrorToTaskResponse* response, + StatusCallback done) = 0; + + virtual void ReportErrorToServiceAsync( + const ReportErrorToServiceRequest* request, + ReportErrorToServiceResponse* response, StatusCallback done) = 0; + + virtual void GetTaskStateAsync(const GetTaskStateRequest* request, + GetTaskStateResponse* response, + StatusCallback done) = 0; + + virtual void InsertKeyValueAsync(const InsertKeyValueRequest* request, + InsertKeyValueResponse* response, + StatusCallback done) = 0; + + virtual void GetKeyValueAsync(CallOptions* call_opts, + const GetKeyValueRequest* request, + GetKeyValueResponse* response, + StatusCallback done) = 0; + + virtual void TryGetKeyValueAsync(const TryGetKeyValueRequest* request, + TryGetKeyValueResponse* response, + StatusCallback done) = 0; + + virtual void GetKeyValueDirAsync(const GetKeyValueDirRequest* request, + GetKeyValueDirResponse* response, + StatusCallback done) = 0; + + virtual void DeleteKeyValueAsync(const DeleteKeyValueRequest* request, + DeleteKeyValueResponse* response, + StatusCallback done) = 0; + + virtual void BarrierAsync(const BarrierRequest* request, + BarrierResponse* response, StatusCallback done) = 0; + + virtual void CancelBarrierAsync(const CancelBarrierRequest* request, + CancelBarrierResponse* response, + StatusCallback done) = 0; +}; + +// Simple wrapper class that can be used to retrieve CoordinationClients. +class CoordinationClientCache { + public: + virtual ~CoordinationClientCache() = default; + + // If the `target` names a remote task, returns a pointer of the + // CoordinationClient object wrapping that channel to the remote task. + virtual CoordinationClient* GetClient(const std::string& target) = 0; + + // If the `target` names a remote task, returns an owned pointer of the + // CoordinationClient object wrapping that channel to the remote task. + virtual std::unique_ptr GetOwnedClient( + const std::string& target) = 0; +}; + +} // namespace tsl + +#endif // TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_COORDINATION_COORDINATION_CLIENT_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/coordination/coordination_service.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/coordination/coordination_service.h new file mode 100644 index 0000000000000000000000000000000000000000..d95d4f7f54d0df976b27b4f41fdc9c7ab807b064 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/coordination/coordination_service.h @@ -0,0 +1,253 @@ +/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_COORDINATION_COORDINATION_SERVICE_H_ +#define TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_COORDINATION_COORDINATION_SERVICE_H_ + +#include +#include +#include +#include +#include +#include + +#include "absl/strings/string_view.h" +#include "absl/time/time.h" +#include "tsl/distributed_runtime/coordination/coordination_client.h" +#include "tsl/platform/status.h" +#include "tsl/platform/statusor.h" +#include "tsl/protobuf/coordination_config.pb.h" + +namespace tsl { +class Env; + +// Static registration for coordination service implementations. +#define REGISTER_COORDINATION_SERVICE(service_type_name, factory_fn) \ + REGISTER_COORDINATION_SERVICE_UNIQ_HELPER(__COUNTER__, service_type_name, \ + factory_fn) +#define REGISTER_COORDINATION_SERVICE_UNIQ_HELPER(counter, service_type_name, \ + factory_fn) \ + static bool static_coordination_service_##counter TF_ATTRIBUTE_UNUSED = \ + []() { \ + ::tsl::CoordinationServiceInterface::RegisterCoordinationService( \ + service_type_name, std::move(factory_fn)); \ + return true; \ + }() + +// Coordination service is used for controlling and coordinating distributed +// execution in a cluster of multiple tasks. +// +// When enabled, the service keeps track of cluster configurations and the state +// of cluster members. TF runtime and libraries can use it to orchastrate +// cluster initialization, check the healthiness of tasks, and propagate error +// messages to the cluster. +// +// Normally, the service should first Start(), then perform the supported +// coordination operations, and finally Stop(). When service runs into error or +// SetError() is called, all subsequent operations will be in error state. +// +// CoordinationServiceInterface defines the service interface for distributed +// coordination. One instance of the service should be deployed in a cluster, +// handling various requests and stores configuration key-value data for the +// tasks. Each task interacts with the service through CoordinationServiceAgent. +class CoordinationServiceInterface { + public: + using CoordinationServiceFactory = + std::function( + Env* env, const tensorflow::CoordinationServiceConfig& config, + std::unique_ptr cache)>; + + using StatusOrValueCallback = + std::function&)>; + + virtual ~CoordinationServiceInterface() = default; + + static void RegisterCoordinationService( + const std::string& service_type_name, + CoordinationServiceFactory factory_fn) { + auto factories = GetCoordinationServiceFactories(); + factories->emplace(service_type_name, factory_fn); + } + + static std::unique_ptr + EnableCoordinationService(Env* env, + const tensorflow::CoordinationServiceConfig& config, + std::unique_ptr cache) { + const auto* factories = GetCoordinationServiceFactories(); + auto factories_iter = factories->find(config.service_type()); + if (factories_iter == factories->end()) { + LOG(ERROR) << "No coordination service factory found for service type " + << config.service_type(); + return nullptr; + } + auto service = factories_iter->second(env, config, std::move(cache)); + if (service != nullptr) { + *GetCoordinationServiceInstancePtr() = service.get(); + } + return service; + } + + static CoordinationServiceInterface* GetCoordinationServiceInstance() { + return *GetCoordinationServiceInstancePtr(); + } + + // This function is invoked after each task's local devices are appended in a + // deterministic order during WaitForAllTasks(). This is useful to convert the + // result into another message, or set global device ids. + virtual void SetDeviceAggregationFunction( + std::function< + tensorflow::DeviceInfo(const tensorflow::DeviceInfo& devices)> + post_aggregate_device_fn) = 0; + + // Register a task to the service. + // Possible service errors: + // - InvalidArgument: Unexpected task request. + // - Aborted: (1) task is in error state, or (2) task is in connected state + // with a different incarnation, indicating that it restarted. + virtual Status RegisterTask(const tensorflow::CoordinatedTask& task, + uint64_t incarnation) = 0; + + // Wait for all tasks to be up and running, and register local device + // info. The callback is invoked when all tasks are up and registered, or some + // error occurs. + // Each task's local devices will be appended in a deterministic order, and + // post-processed by the callback in SetDeviceAggregationFunction() (if set). + virtual void WaitForAllTasks(const tensorflow::CoordinatedTask& task, + const tensorflow::DeviceInfo& devices, + StatusCallback done) = 0; + + // Disconnects task from the service. If `shutdown_barrier_timeout_in_ms` is + // specified in the config, blocks until all tasks reach the barrier before + // disconnecting together. + // Possible service errors: + // - InvalidArgument: Unexpected task request. + // - FailedPrecondition: task has already disconnected. + virtual void ShutdownTaskAsync(const tensorflow::CoordinatedTask& task, + StatusCallback done) = 0; + + // Disconnects task from the service and cleans up its internal error state. + // Possible service errors: + // - InvalidArgument: Unexpected task request. + // - FailedPrecondition: task has already disconnected. + virtual Status ResetTask(const tensorflow::CoordinatedTask& task) = 0; + + // Update the heartbeat timestamp of a task. This should only be invoked on + // the leader of the cluster. + virtual Status RecordHeartbeat(const tensorflow::CoordinatedTask& task, + uint64_t incarnation) = 0; + + // Set a task in error state permanently. + virtual Status ReportTaskError(const tensorflow::CoordinatedTask& task, + Status error) = 0; + + // Get the state and the error status of the tasks. + virtual std::vector GetTaskState( + const std::vector& task) = 0; + + // Insert a configuration key-value in the coordination service. + // For now, a key-value can only be inserted once and cannot be updated. + // The key-values are not persisted and will be lost if the leader fails. + virtual Status InsertKeyValue(const std::string& key, + const std::string& value) = 0; + + // Get a configuration key-value from the coordination service. The `done` + // callback is invoked when the key-value becomes available. + virtual void GetKeyValueAsync(const std::string& key, + StatusOrValueCallback done) = 0; + + // Get a configuration key-value from the coordination service. If the key + // does not exist, return NotFound error. + virtual StatusOr TryGetKeyValue(const std::string& key) = 0; + + // Gets all values under a directory (key). + // A value is considered to be in the directory if its key is prefixed with + // the directory. This is not a blocking call. Agent does not need to be + // connected to utilize the distributed key-value store. + virtual std::vector GetKeyValueDir( + absl::string_view directory_key) = 0; + + // Delete configuration key-value. If key is a directory, recursively clean + // up all key-values under the directory. + virtual Status DeleteKeyValue(const std::string& key) = 0; + + // Blocks until all (or a subset of) tasks are at the barrier or the barrier + // fails. + // + // `barrier_id` should be unique across barriers. Once the barrier has passed + // or failed, subsequent calls will not block, and immediately respond with + // the previous response. + // + // The first WaitAtBarrier() call received by the service for a particular + // barrier id is special in that it determines the barrier deadline based on + // timeout duration. + // However, if subsequent calls by different agents specify a different set of + // `participating_tasks` for the same `barrier_id`, the barrier will fail + // instantly. + // + // If no tasks are specified (default), the barrier will block for all the + // connected tasks. + // + // Possible service errors: + // - DeadlineExceeded: Timed out waiting for specified tasks at the barrier. + // Deadline is determined by the server timestamp when it receives the + // first WaitAtBarrier() + timeout duration. + // - Cancelled: One of the tasks called CancelBarrier(). + // - Aborted: Service is shutting down. + // - Internal: Any participating task is in ERROR state. + // - InvalidArgument: (1) Conflicting tasks specified by different agents + // for the same barrier, (2) one of the participating tasks is not in + // the cluster, or (3) task making the request is not included in the + // list of participating tasks. + // - FailedPrecondition: Agent is in UNINITIALIZED or ERROR state. + virtual void BarrierAsync( + const std::string& barrier_id, absl::Duration timeout, + const tensorflow::CoordinatedTask& task, + const std::vector& participating_tasks, + StatusCallback done) = 0; + + // Aborts the barrier if it is ongoing. + // Current and future WaitAtBarrier() calls with the same id will return a + // CANCELLED error status. + // Possible service errors: + // - FailedPrecondition: Barrier has already been passed. + virtual Status CancelBarrier(const std::string& barrier_id, + const tensorflow::CoordinatedTask& task) = 0; + + private: + friend class CoordinationServiceRpcHandler; + friend class CoordinationServiceTest_ListClusterDevices_TfDevice_Test; + friend class CoordinationServiceTest_ListClusterDevices_XlaDevice_Test; + friend class + CoordinationServiceTest_ListClusterDevices_DevicesAreNotAddedTwice_Test; + + virtual const tensorflow::DeviceInfo& ListClusterDevices() = 0; + virtual uint64_t GetServiceIncarnation() = 0; + + static std::unordered_map* + GetCoordinationServiceFactories() { + static auto* coordination_service_factories = + new std::unordered_map(); + return coordination_service_factories; + } + + static CoordinationServiceInterface** GetCoordinationServiceInstancePtr() { + static CoordinationServiceInterface* instance = nullptr; + return &instance; + } +}; + +} // namespace tsl + +#endif // TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_COORDINATION_COORDINATION_SERVICE_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/coordination/coordination_service_agent.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/coordination/coordination_service_agent.h new file mode 100644 index 0000000000000000000000000000000000000000..a567272f9d72ef7a23e34a07a1bf2397d8a99799 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/coordination/coordination_service_agent.h @@ -0,0 +1,287 @@ +/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_COORDINATION_COORDINATION_SERVICE_AGENT_H_ +#define TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_COORDINATION_COORDINATION_SERVICE_AGENT_H_ + +#include +#include +#include +#include +#include +#include + +#include "absl/time/time.h" +#include "tsl/distributed_runtime/call_options.h" +#include "tsl/distributed_runtime/coordination/coordination_client.h" +#include "tsl/platform/status.h" +#include "tsl/platform/statusor.h" +#include "tsl/protobuf/coordination_service.pb.h" + +namespace tensorflow { +class CoordinationServiceConfig; +}; // namespace tensorflow + +namespace tsl { +class Env; + +// CoordinationServiceAgent defines the interface for tasks to communicate with +// the coordination service instance (which implements +// CoordinationServiceInterface). One instance of the agent should be deployed +// on each task for it to send various requests and stores / retrieves config +// key-value data to the service. +// +// See CoordinationServiceInterface for more details on coordination service. +// +// All coordination service errors will have an additional +// CoordinationServiceError payload to distinguish themselves from RPC failures. +// The payload can optionally specify the error origin, and if the error is +// reported by the user via `agent->ReportError()`. +// +// Possible service errors: +// - errors::Internal: Coordination service is not enabled. +// If it was previously accessible, coordination service +// has been shut down. +// - errors::Aborted: Incarnation mismatch during heartbeat (either remote +// task or coordination service has restarted). +// - errors::Unavailable: Heartbeat timeout from remote task (failed, +// crashed or got preempted). +// - errors::InvalidArgument: Unexpected heartbeat from remote task (not +// registered or wrong config). +// TODO(hanyangtay): Migrate to string_view for string parameters. +class CoordinationServiceAgent { + public: + using StatusOrValueCallback = + std::function&)>; + // Collection of key-value pairs in the same directory. + using StatusOrValueDirCallback = std::function>&)>; + using ChangedKeyValuesCallback = + std::function&)>; + + virtual ~CoordinationServiceAgent() = default; + + // Initialize coordination service agent. + virtual Status Initialize( + tsl::Env* env, const std::string& job_name, int task_id, + const tensorflow::CoordinationServiceConfig& configs, + std::unique_ptr leader_client, + StatusCallback error_fn) = 0; + virtual Status Initialize( + tsl::Env* env, const tensorflow::CoordinatedTask& task, + const tensorflow::CoordinationServiceConfig& configs, + std::unique_ptr leader_client, + StatusCallback error_fn) = 0; + + // Return true if the coordination service agent has been initialized. + virtual bool IsInitialized() = 0; + + // Return true if the coordination service agent has successfully connected + // with the Coordination Service + virtual bool IsConnected() = 0; + + // Return true if the coordination service agent has an error state. + virtual bool IsError() = 0; + + // Connect to coordination service with the following steps: + // - connect to service address specified in the config of `server_def` + // - register itself as a task to the service + // - start a thread to periodically send heartbeat message with the service + // Possible service errors: + // - FailedPrecondition: Agent is not in DISCONNECTED state. + // - InvalidArgument: Unexpected task registration + // - Aborted: Duplicate task registration (agent will retry connecting until + // the configured timeout) + virtual Status Connect() = 0; + + // Wait for all tasks to be up and registered. The call blocks until all tasks + // in the cluster are up, or some error occurs. + // Possible service errors: + // - FailedPrecondition: Agent is not in CONNECTED state. + // - InvalidArgument: Unexpected task request + virtual Status WaitForAllTasks( + const tensorflow::DeviceInfo& local_devices) = 0; + + // Get the device attributes of tasks from remote tasks in the cluster. + virtual const tensorflow::DeviceInfo& GetClusterDeviceInfo() = 0; + + // State transition in coordination service agent: + // + // Init Connect SetError + // UNINITIALIZED ---> DISCONNECTED ------> CONNECTED -------> ERROR + // ^ | + // |__________________________________| + // Reset + + // Get task associated with this agent. + virtual StatusOr GetOwnTask() = 0; + + // Get status of a remote task. + virtual StatusOr> + GetTaskState(const std::vector& task) = 0; + + // Report error to coordination service. This will invoke the error callback. + // Note that the error payload will set `is_reported_error` to true, to + // distinguish user-specified errors from internal service or RPC failures. + // Possible service errors: + // - FailedPrecondition: Uninitialized/disconnected/already in error state. + // - InvalidArgument: Unexpected task request + virtual Status ReportError(const Status& error) = 0; + + // Shuts down by disconnecting from the service. Should only be called if + // agent is connected and no further agent calls (except the destructor) are + // expected. If `shutdown_barrier_timeout_in_ms` is specified in the config, + // blocks until all tasks reach the barrier before shutting down together. If + // the barrier times out, this agent will still disconnect, while an error is + // reported to other agents that did not reach the barrier on time. + // Possible service errors: + // - InvalidArgument: Unexpected task request. + // - FailedPrecondition: Task was in error state (note: agent is still + // shut down forcefully). + virtual Status Shutdown() = 0; + + // Disconnect from the service, and clean up the internal error status. + // Possible service errors: + // - InvalidArgument: Unexpected task request. + // - FailedPrecondition: task is not in error state/has already + // disconnected. + virtual Status Reset() = 0; + + // Key-value store API. + // The agent does not need to be connected to utilize the key-value store. + // There are no concurrency guarantees. To avoid a race / impose an ordering + // on potentially concurrent ops (e.g. set, delete), use WaitAtBarrier(). + + // Get config key-value from the service. + // If the key-value is not inserted yet, this is a blocking call that waits + // until the corresponding key is inserted. + // - errors::DeadlineExceeded: timed out waiting for key. + virtual StatusOr GetKeyValue(const std::string& key) = 0; + virtual StatusOr GetKeyValue(const char* key, + int64_t key_size) = 0; + virtual StatusOr GetKeyValue(const std::string& key, + absl::Duration timeout) = 0; + // Note: Cancel the underlying RPC call with `call_opts->StartCancel()` and + // `call_opts->ClearCancelCallback()`. + virtual std::shared_ptr GetKeyValueAsync( + const std::string& key, StatusOrValueCallback done) = 0; + + // Get config key-value from the service. + // - errors::NotFound: the requested key does not exist. + virtual StatusOr TryGetKeyValue(const std::string& key) = 0; + + // Get all values under a directory (key). + // A value is considered to be in the directory if its key is prefixed with + // the directory. + // This is not a blocking call. If no keys are found, an empty vector is + // returned immediately. + virtual StatusOr> GetKeyValueDir( + const std::string& key) = 0; + virtual void GetKeyValueDirAsync(const std::string& key, + StatusOrValueDirCallback done) = 0; + + // Insert config key-value to the service. + // - errors::AlreadyExists: key is already set. + virtual Status InsertKeyValue(const std::string& key, + const std::string& value) = 0; + virtual Status InsertKeyValue(const char* key, int64_t key_size, + const char* value, int64_t value_size) = 0; + + // Delete config keys in the coordination service. + virtual Status DeleteKeyValue(const std::string& key) = 0; + virtual Status DeleteKeyValue(const char* key, int64_t key_size) = 0; + + // Update the value of a config key. + virtual Status UpdateKeyValue(const std::string& key, + const std::string& value) = 0; + + // Register a callback that will be invoked when the key or keys under the key + // directory are changed (inserted, deleted, or updated). + virtual Status StartWatchKey(const std::string& key, + ChangedKeyValuesCallback on_change) = 0; + virtual Status StopWatchKey(const std::string& key) = 0; + + // Blocks until all (or a subset of) tasks are at the barrier or the barrier + // fails. + // + // `barrier_id` should be unique across barriers. + // + // The first WaitAtBarrier() call received by the service for a particular + // barrier_id is special in that it determines the barrier deadline based on + // timeout duration. + // However, if subsequent calls by different agents specify a different set of + // `tasks` for the same `barrier_id`, the barrier will fail instantly. + // For example, + // agent_1->WaitAtBarrier(“barrier”, 10min, <<”worker”, 1>, <”worker”, 2>>); + // agent_2->WaitAtBarrier(“barrier”, 10min, <<”worker”, 2>, <”worker”, 3>>); + // Barrier fails after agent_2’s call because it specifies a different set of + // participating tasks. + // + // If no tasks are specified (default), the barrier will block for all the + // connected tasks. + // + // Possible service errors: + // - DeadlineExceeded: Timed out waiting for specified tasks at the barrier. + // Deadline is determined by the server timestamp when it receives the + // first WaitAtBarrier() + timeout duration. + // - Cancelled: One of the tasks called CancelBarrier(). + // - Aborted: Service is shutting down. + // - Internal: Any participating task is in ERROR state. + // - InvalidArgument: (1) Conflicting tasks specified by different agents + // for the same barrier, (2) one of the participating tasks is not in + // the cluster, or (3) task making the request is not included in the + // list of participating tasks. + // - FailedPrecondition: Agent is in UNINITIALIZED or ERROR state. Or the + // same barrier_id was already used previously. + virtual Status WaitAtBarrier( + const std::string& barrier_id, absl::Duration timeout, + const std::vector& tasks) = 0; + + virtual void WaitAtBarrierAsync( + const std::string& barrier_id, absl::Duration timeout, + const std::vector& tasks, + StatusCallback done) = 0; + + // Aborts the barrier if it is ongoing. + // Current and future WaitAtBarrier() calls with the same id will return a + // CANCELLED error status. + // Possible service errors: + // - FailedPrecondition: Barrier has already been passed. + virtual Status CancelBarrier(const std::string& barrier_id) = 0; + virtual void CancelBarrierAsync(const std::string& barrier_id, + StatusCallback done) = 0; + + // Get unowned Env* that the agent was initialized with. + virtual StatusOr GetEnv() = 0; + + protected: + // Set the service agent to error status and invoke the error callback. + // Note: different from ReportError, this does not report the error status to + // remote coordination service. + virtual void SetError(const Status& error) = 0; + + // Activate the key-value callback watch. + virtual Status ActivateWatch(const std::string& key, + const std::map&) = 0; + + private: + friend class CoordinationServiceRpcHandler; +}; + +std::unique_ptr CreateCoordinationServiceAgent(); + +} // namespace tsl + +#endif // TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_COORDINATION_COORDINATION_SERVICE_AGENT_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/coordination/coordination_service_error_util.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/coordination/coordination_service_error_util.h new file mode 100644 index 0000000000000000000000000000000000000000..79156778f40d9e332f26c1e36a44744e88ae3134 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/coordination/coordination_service_error_util.h @@ -0,0 +1,60 @@ +/* Copyright 2022 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ +#ifndef TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_COORDINATION_COORDINATION_SERVICE_ERROR_UTIL_H_ +#define TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_COORDINATION_COORDINATION_SERVICE_ERROR_UTIL_H_ + +#include "absl/strings/string_view.h" +#include "tsl/platform/errors.h" +#include "tsl/platform/status.h" +#include "tsl/protobuf/coordination_service.pb.h" + +namespace tsl { + +constexpr absl::string_view CoordinationErrorPayloadKey() { + return "type.googleapis.com/tensorflow.CoordinationServiceError"; +} + +// Mark error as a coordination service error (as opposed to RPC +// errors). +inline Status MakeCoordinationError(Status s) { + s.SetPayload(CoordinationErrorPayloadKey(), absl::Cord("")); + return s; +} + +// Mark error as a coordination service error (as opposed to RPC +// errors), and indicate error origin. +// Errors reported via the agent API by the user should set `is_reported_error` +// to true. +inline Status MakeCoordinationError(Status s, + const tensorflow::CoordinatedTask& origin, + bool is_reported_error = false) { + tensorflow::CoordinationServiceError error; + *error.mutable_source_task() = origin; + error.set_is_reported_error(is_reported_error); + s.SetPayload(CoordinationErrorPayloadKey(), + absl::Cord(error.SerializeAsString())); + return s; +} + +// Mark error as a coordination service error with payload. +inline Status MakeCoordinationError( + Status s, const tensorflow::CoordinationServiceError& payload) { + s.SetPayload(CoordinationErrorPayloadKey(), + absl::Cord(payload.SerializeAsString())); + return s; +} +} // namespace tsl + +#endif // TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_COORDINATION_COORDINATION_SERVICE_ERROR_UTIL_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/coordination/coordination_service_rpc_handler.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/coordination/coordination_service_rpc_handler.h new file mode 100644 index 0000000000000000000000000000000000000000..cb92ea68bb173d2634b6e1cab7749f7b440d25ce --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/coordination/coordination_service_rpc_handler.h @@ -0,0 +1,102 @@ +/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_COORDINATION_COORDINATION_SERVICE_RPC_HANDLER_H_ +#define TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_COORDINATION_COORDINATION_SERVICE_RPC_HANDLER_H_ + +#include "tsl/distributed_runtime/coordination/coordination_service.h" +#include "tsl/distributed_runtime/coordination/coordination_service_agent.h" +#include "tsl/platform/mutex.h" +#include "tsl/platform/status.h" +#include "tsl/platform/thread_annotations.h" +#include "tsl/protobuf/coordination_service.pb.h" + +namespace tsl { +class CoordinationServiceRpcHandler { + public: + explicit CoordinationServiceRpcHandler() {} + + void SetAgentInstance(CoordinationServiceAgent* agent); + + void SetServiceInstance(CoordinationServiceInterface* service); + + void RegisterTaskAsync(const tensorflow::RegisterTaskRequest* request, + tensorflow::RegisterTaskResponse* response, + StatusCallback done); + + void HeartbeatAsync(const tensorflow::HeartbeatRequest* request, + tensorflow::HeartbeatResponse* response, + StatusCallback done); + + void WaitForAllTasksAsync(const tensorflow::WaitForAllTasksRequest* request, + tensorflow::WaitForAllTasksResponse* response, + StatusCallback done); + + void ShutdownTaskAsync(const tensorflow::ShutdownTaskRequest* request, + tensorflow::ShutdownTaskResponse* response, + StatusCallback done); + + void ResetTaskAsync(const tensorflow::ResetTaskRequest* request, + tensorflow::ResetTaskResponse* response, + StatusCallback done); + + void ReportErrorToTaskAsync( + const tensorflow::ReportErrorToTaskRequest* request, + tensorflow::ReportErrorToTaskResponse* response, StatusCallback done); + + void ReportErrorToServiceAsync( + const tensorflow::ReportErrorToServiceRequest* request, + tensorflow::ReportErrorToServiceResponse* response, StatusCallback done); + + void GetTaskStateAsync(const tensorflow::GetTaskStateRequest* request, + tensorflow::GetTaskStateResponse* response, + StatusCallback done); + + void InsertKeyValueAsync(const tensorflow::InsertKeyValueRequest* request, + tensorflow::InsertKeyValueResponse* response, + StatusCallback done); + + void GetKeyValueAsync(const tensorflow::GetKeyValueRequest* request, + tensorflow::GetKeyValueResponse* response, + StatusCallback done); + + void TryGetKeyValueAsync(const tensorflow::TryGetKeyValueRequest* request, + tensorflow::TryGetKeyValueResponse* response, + StatusCallback done); + + void GetKeyValueDirAsync(const tensorflow::GetKeyValueDirRequest* request, + tensorflow::GetKeyValueDirResponse* response, + StatusCallback done); + + void DeleteKeyValueAsync(const tensorflow::DeleteKeyValueRequest* request, + tensorflow::DeleteKeyValueResponse* response, + StatusCallback done); + + void BarrierAsync(const tensorflow::BarrierRequest* request, + tensorflow::BarrierResponse* response, StatusCallback done); + + void CancelBarrierAsync(const tensorflow::CancelBarrierRequest* request, + tensorflow::CancelBarrierResponse* response, + StatusCallback done); + + private: + mutex mu_; + CoordinationServiceAgent* agent_ TF_GUARDED_BY(mu_) = nullptr; + CoordinationServiceInterface* service_ TF_GUARDED_BY(mu_) = nullptr; +}; + +} // namespace tsl + +#endif // TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_COORDINATION_COORDINATION_SERVICE_RPC_HANDLER_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/preemption/preemption_notifier.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/preemption/preemption_notifier.h new file mode 100644 index 0000000000000000000000000000000000000000..53941ceea6493e412ccf148338dca0aa46787c3c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/preemption/preemption_notifier.h @@ -0,0 +1,147 @@ +/* Copyright 2022 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ +#ifndef TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_PREEMPTION_PREEMPTION_NOTIFIER_H_ +#define TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_PREEMPTION_PREEMPTION_NOTIFIER_H_ + +#include +#include +#include +#include +#include +#include + +#include "absl/strings/str_join.h" +#include "absl/time/time.h" +#include "tsl/platform/env.h" +#include "tsl/platform/mutex.h" +#include "tsl/platform/statusor.h" + +namespace tsl { + +// Static registration for preemption notifiers. +#define REGISTER_PREEMPTION_NOTIFIER(notifier_type_name, factory_fn) \ + REGISTER_PREEMPTION_NOTIFIER_UNIQ_HELPER(__COUNTER__, notifier_type_name, \ + factory_fn) +#define REGISTER_PREEMPTION_NOTIFIER_UNIQ_HELPER(counter, notifier_type_name, \ + factory_fn) \ + static bool static_preemption_notifier_##counter TF_ATTRIBUTE_UNUSED = \ + []() { \ + ::tsl::PreemptionNotifier::RegisterPreemptionNotifier( \ + notifier_type_name, factory_fn); \ + return true; \ + }() + +// Base class for listening and propagating task preemption notices. +// +// This class provides common mechanism to block on waiting for preemption +// signals, or register callbacks that will be triggered upon preemption. +// +// Example: +// +// // Monitors the SIGTERM preemption signal +// notifier = PreemptionNotifier::CreatePreemptionNotifier("sigterm", env); +// +// // Register callback that will be invoked once preempted +// notifier->WillBePreemptedAtAsync( +// [](StatusOr status_or_time) { +// if (status_or_time.ok()) { +// LOG(INFO) << "Preempted at time: " << status_or_time.value(); +// } else { +// LOG(ERROR) << "Received error: " << status_or_time.status(); +// } +// }); +// +// // Block current thread until preemption +// absl::Time preempt_time = notifier->WillBePreemptedAt().value(); +// +// Users can extend this class to support custom preemption signals, by subclass +// `PreemptionNotifier` with a custom constructor, register its creator (factory +// function) with `REGISTER_PREEMPTION_NOTIFIER`. The custom constructor should +// set up the communication with the cluster scheduler, and invoke the +// `NotifyRegisteredListeners` method once a preemption signal is received. +// See `SigtermNotifier` as an example. + +class PreemptionNotifier { + public: + typedef std::function)> PreemptTimeCallback; + using PreemptionNotifierFactory = + std::function(Env* env)>; + + explicit PreemptionNotifier(Env* env) : env_(env) {} + virtual ~PreemptionNotifier() = default; + + static void RegisterPreemptionNotifier(const std::string& notifier_type_name, + PreemptionNotifierFactory factory_fn) { + GetPreemptionNotifierFactories()->emplace(notifier_type_name, + std::move(factory_fn)); + } + + static std::unique_ptr CreatePreemptionNotifier( + const std::string& notifier_type, Env* env) { + const auto* factories = GetPreemptionNotifierFactories(); + auto it = factories->find(notifier_type); + if (it == factories->end()) { + std::vector registered_types; + registered_types.reserve(factories->size()); + for (auto& kv : *factories) { + registered_types.push_back(kv.first); + } + LOG(ERROR) << "No preemption notifier factory found for notifier type " + << notifier_type + << ". All registered preemption notifier types are: " + << absl::StrJoin(registered_types, ", ") + << ". Make sure the library is loaded to the program."; + return nullptr; + } + return it->second(env); + } + + // This is a blocking call that returns a death time when preemption / + // termination will occur once the listener receives the preemption + // notification. If no death time is specified, absl::Now() is returned. + // Returns error::Cancelled if UnregisterListeners() is called. + StatusOr WillBePreemptedAt(); + + // Registers a callback that takes the death time as input once the listener + // receives the preemption notification. + // If no death time is specified, absl::Now() is specified as input. + // Note: callback should be kept as simple and fast as possible (e.g. simply + // retrieve result). It should not wait for work done by another callback, and + // invoke ahy PreemptionNotifier method (e.g. Reset(), destructor). + void WillBePreemptedAtAsync(PreemptTimeCallback callback); + + protected: + Env* GetEnv() { return env_; } + // Invokes all pending callbacks upon receipt of preemption notice with death + // time or errors (e.g. cancellation during shutdown). + void NotifyRegisteredListeners(StatusOr death_time); + + private: + static std::unordered_map* + GetPreemptionNotifierFactories() { + static auto* preemption_notifier_factories = + new std::unordered_map(); + return preemption_notifier_factories; + } + + Env* env_; // Not owned. + mutex mu_; + absl::Time death_time_ TF_GUARDED_BY(mu_) = absl::InfinitePast(); + std::vector callbacks_ TF_GUARDED_BY(mu_); +}; + +} // namespace tsl + +#endif // TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_PREEMPTION_PREEMPTION_NOTIFIER_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/async_service_interface.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/async_service_interface.h new file mode 100644 index 0000000000000000000000000000000000000000..479ca0ec8a4c6ae1cebc85cd10a43f2fc9641572 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/async_service_interface.h @@ -0,0 +1,41 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_ASYNC_SERVICE_INTERFACE_H_ +#define TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_ASYNC_SERVICE_INTERFACE_H_ + +namespace tsl { + +// Represents an abstract asynchronous service that handles incoming +// RPCs with a polling loop. +class AsyncServiceInterface { + public: + virtual ~AsyncServiceInterface() {} + + // A blocking method that should be called to handle incoming RPCs. + // This method will block until the service shuts down. + virtual void HandleRPCsLoop() = 0; + + // Starts shutting down this service. + // + // NOTE(mrry): To shut down this service completely, the caller must + // also shut down any servers that might share ownership of this + // service's resources (e.g. completion queues). + virtual void Shutdown() = 0; +}; + +} // namespace tsl + +#endif // TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_ASYNC_SERVICE_INTERFACE_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/coordination/grpc_coordination_client.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/coordination/grpc_coordination_client.h new file mode 100644 index 0000000000000000000000000000000000000000..969722bac3376f4835909a4c1168a8ab65a60aff --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/coordination/grpc_coordination_client.h @@ -0,0 +1,34 @@ +/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_COORDINATION_GRPC_COORDINATION_CLIENT_H_ +#define TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_COORDINATION_GRPC_COORDINATION_CLIENT_H_ + +#include + +#include "tsl/distributed_runtime/coordination/coordination_client.h" +#include "tsl/distributed_runtime/rpc/grpc_channel.h" + +namespace tsl { + +CoordinationClientCache* NewGrpcCoordinationClientCache( + std::shared_ptr channel); + +CoordinationClient* NewGrpcCoordinationClient( + std::shared_ptr<::grpc::Channel> channel); + +} // namespace tsl + +#endif // TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_COORDINATION_GRPC_COORDINATION_CLIENT_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/coordination/grpc_coordination_service_impl.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/coordination/grpc_coordination_service_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..daa7e65225f6607c72a394c63c32522840e71d9c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/coordination/grpc_coordination_service_impl.h @@ -0,0 +1,117 @@ +/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_COORDINATION_GRPC_COORDINATION_SERVICE_IMPL_H_ +#define TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_COORDINATION_GRPC_COORDINATION_SERVICE_IMPL_H_ + +#include + +#include "grpcpp/alarm.h" +#include "grpcpp/completion_queue.h" +#include "grpcpp/server_builder.h" +#include "tsl/distributed_runtime/coordination/coordination_service_agent.h" +#include "tsl/distributed_runtime/coordination/coordination_service_rpc_handler.h" +#include "tsl/distributed_runtime/rpc/async_service_interface.h" +#include "tsl/distributed_runtime/rpc/grpc_call.h" +#include "tsl/distributed_runtime/rpc/grpc_util.h" +#include "tsl/platform/mutex.h" +#include "tsl/platform/thread_annotations.h" +#include "tsl/platform/threadpool.h" +#include "tsl/protobuf/coordination_service.grpc.pb.h" +#include "tsl/protobuf/coordination_service.pb.h" + +namespace tsl { + +class GrpcCoordinationServiceImpl : public AsyncServiceInterface { + public: + template + using CoordCall = Call; + + GrpcCoordinationServiceImpl(thread::ThreadPool* compute_pool, + ::grpc::ServerBuilder* server_builder); + ~GrpcCoordinationServiceImpl() override {} + + void HandleRPCsLoop() override; + void Shutdown() override; + void SetCoordinationServiceAgentInstance(CoordinationServiceAgent* agent) { + rpc_handler_.SetAgentInstance(agent); + } + void SetCoordinationServiceInstance(CoordinationServiceInterface* service) { + rpc_handler_.SetServiceInstance(service); + } + CoordinationServiceRpcHandler* GetRpcHandler() { return &rpc_handler_; } + + private: +#define HANDLER(method) \ + void method##Handler(CoordCall* call) { \ + tf_shared_lock l(shutdown_mu_); \ + if (shutdown_) { \ + call->SendResponse(ToGrpcStatus( \ + errors::Internal("Coordination service has been shut down."))); \ + return; \ + } \ + compute_pool_.Schedule([this, call]() { \ + rpc_handler_.method##Async(&call->request, &call->response, \ + [call](const Status& s) { \ + call->ClearCancelCallback(); \ + call->SendResponse(ToGrpcStatus(s)); \ + }); \ + }); \ + Call:: \ + EnqueueRequest(&service_, cq_.get(), \ + &tensorflow::grpc::CoordinationService::AsyncService:: \ + Request##method, \ + &GrpcCoordinationServiceImpl::method##Handler, \ + /*supports_cancel=*/false); \ + } + HANDLER(RegisterTask); + HANDLER(WaitForAllTasks); + HANDLER(ShutdownTask); + HANDLER(ResetTask); + HANDLER(Heartbeat); + HANDLER(ReportErrorToTask); + HANDLER(ReportErrorToService); + HANDLER(GetTaskState); + HANDLER(InsertKeyValue); + HANDLER(GetKeyValue); + HANDLER(TryGetKeyValue); + HANDLER(GetKeyValueDir); + HANDLER(DeleteKeyValue); + HANDLER(Barrier); + HANDLER(CancelBarrier); +#undef HANDLER + + thread::ThreadPool& compute_pool_; + CoordinationServiceRpcHandler rpc_handler_; + + mutex shutdown_mu_; + bool shutdown_ TF_GUARDED_BY(shutdown_mu_); + std::unique_ptr<::grpc::Alarm> shutdown_alarm_; + + std::unique_ptr<::grpc::ServerCompletionQueue> cq_; + tensorflow::grpc::CoordinationService::AsyncService service_; + + GrpcCoordinationServiceImpl(const GrpcCoordinationServiceImpl&) = delete; + void operator=(const GrpcCoordinationServiceImpl&) = delete; +}; + +} // namespace tsl + +#endif // TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_COORDINATION_GRPC_COORDINATION_SERVICE_IMPL_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/grpc_call.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/grpc_call.h new file mode 100644 index 0000000000000000000000000000000000000000..73d285e3ef8b8c71ecc7db07c28cb1c353586b82 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/grpc_call.h @@ -0,0 +1,521 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_GRPC_CALL_H_ +#define TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_GRPC_CALL_H_ + +#include "grpcpp/completion_queue.h" +#include "grpcpp/impl/service_type.h" +#include "grpcpp/server_builder.h" +#include "grpcpp/server_context.h" +#include "grpcpp/support/async_stream.h" +#include "grpcpp/support/async_unary_call.h" +#include "tsl/platform/mutex.h" +#include "tsl/platform/refcount.h" + +namespace tsl { + +// CALL STRUCTURES +// =============== +// +// Each pending (incoming) request corresponds to a call object that +// encapsulates the state of the call. Templates and +// pointers-to-member functions are used to avoid boilerplate and +// redundant closure creation. The class hierarchy is as follows: +// +// * `UntypedCall`: The base class represents a call that +// could be associated with any of the methods on a service of type +// `Service`. Also defines a `Tag` nested class that can be used as +// the tag in a `grpc::CompletionQueue`. Each class that +// instantiates `Service` should have a completion queue polling +// loop that knows about `UntypedCall::Tag` objects, and +// invokes their `OnCompleted()` method to continue processing. +// +// * `Call`: This class extends +// `UntypedCall` and is additionally parameterized by the +// gRPC-generated asynchronous service class, and the request and +// response message types. It defines the state associated with a +// call (whose type depends on the message types), and stores a +// pointer to a `Service::HandleFoo()` handler method. Each +// `Service::HandleFoo()` method knows about the corresponding +// `Call` type, in order to access its state, and invoke its +// `SendResponse()` method. +// +// The lifecycle of a call object is as follows. +// +// 1. A `Service` creates a `Call` for a particular method and +// enqueues it in its completion queue (via an +// `UntypedCall::Tag`). +// +// 2. When the tag is returned from `cq_->Next()`, the +// `UntypedCall::RequestReceived()` method is invoked and takes +// ownership of the call object. This indirectly invokes the +// appropriate handler method on `Service`. +// +// 3. After the response has been written (perhaps in another thread), +// the `Call::SendResponse()` method is invoked. It transfers +// ownership of the call object back to the completion queue (via +// an `UntypedCall::Tag`). +// +// 4. When the response has been sent, the tag is returned from +// `cq_->Next()`, and the call object is deleted. +// + +template +class GrpcCallTag { + public: + virtual ~GrpcCallTag() {} + + // Calls the callback associated with this tag. + virtual void OnCompleted(Service* service, bool ok) = 0; +}; + +// Represents a pending request with unknown message types. +template +class UntypedCall : public core::RefCounted { + public: + virtual ~UntypedCall() {} + + // The implementation of this method should use `service` to handle + // an incoming request, and (perhaps asynchronously) send the + // response. + // + // One reference on `this` is transferred to the callee, and the + // callee is responsible for releasing it (typically via + // `Call::SendResponse()`). + // + // `ok` is true if the request was received in a "regular event", + // otherwise false. + virtual void RequestReceived(Service* service, bool ok) = 0; + + // This method will be called either (i) when the server is notified + // that the request has been canceled, or (ii) when the request completes + // normally. The implementation should distinguish these cases by querying + // the `grpc::ServerContext` associated with the request. + virtual void RequestCancelled(Service* service, bool ok) = 0; + + // Associates a tag in a `::grpc::CompletionQueue` with a callback + // for an incoming RPC. An active Tag owns a reference on the corresponding + // Call object. + class Tag : public GrpcCallTag { + public: + // One enum value per supported callback. + enum Callback { kRequestReceived, kResponseSent, kCancelled }; + + Tag(UntypedCall* call, Callback cb) : call_(call), callback_(cb) {} + + // Calls the callback associated with this tag. + // + // The callback takes ownership of `this->call_`. + void OnCompleted(Service* service, bool ok) override { + switch (callback_) { + case kRequestReceived: + call_->RequestReceived(service, ok); + break; + case kResponseSent: + // No special handling needed apart from the Unref below. + break; + case kCancelled: + call_->RequestCancelled(service, ok); + break; + } + call_->Unref(); // Ref acquired when tag handed to grpc. + } + + private: + UntypedCall* const call_; // `this` owns one reference. + Callback callback_; + }; +}; + +// Represents a pending call with known request and response message +// types, and a known request-handling method. +template +class Call : public UntypedCall { + public: + // Represents the generic signature of a generated + // `GrpcService::RequestFoo()` method, where `Foo` is the name of an + // RPC method. + using EnqueueFunction = void (GrpcService::*)( + ::grpc::ServerContext*, RequestMessage*, + ::grpc::ServerAsyncResponseWriter*, + ::grpc::CompletionQueue*, ::grpc::ServerCompletionQueue*, void*); + + // Represents the generic signature of a `Service::HandleFoo()` + // method, where `Foo` is the name of an RPC method. + using HandleRequestFunction = void (Service::*)( + Call*); + + Call(HandleRequestFunction handle_request_function) + : handle_request_function_(handle_request_function), responder_(&ctx_) {} + + virtual ~Call() {} + + void RequestReceived(Service* service, bool ok) override { + if (ok) { + this->Ref(); + (service->*handle_request_function_)(this); + } + } + + void SendResponse(::grpc::Status status) { + this->Ref(); // Ref for grpc; released in Tag callback. + responder_.Finish(response, status, &response_sent_tag_); + this->Unref(); + } + + void RequestCancelled(Service* service, bool ok) override { + if (ctx_.IsCancelled()) { + mutex_lock l(mu_); + if (cancel_callback_) { + cancel_callback_(); + } + } + } + + // Registers `callback` as the function that should be called if and when this + // call is canceled by the client. + void SetCancelCallback(std::function callback) { + mutex_lock l(mu_); + cancel_callback_ = std::move(callback); + } + + // Clears any cancellation callback that has been registered for this call. + void ClearCancelCallback() { + mutex_lock l(mu_); + cancel_callback_ = nullptr; + } + + // Enqueues a new request for the given service on the given + // completion queue, using the given `enqueue_function`. + // + // The request will be handled with the given + // `handle_request_function`. + static void EnqueueRequest(GrpcService* grpc_service, + ::grpc::ServerCompletionQueue* cq, + EnqueueFunction enqueue_function, + HandleRequestFunction handle_request_function, + bool supports_cancel) { + auto call = new Call( + handle_request_function); + if (supports_cancel) { + call->RegisterCancellationHandler(); + } + + // Initial ref for call handed to grpc; released in Tag callback. + (grpc_service->*enqueue_function)(&call->ctx_, &call->request, + &call->responder_, cq, cq, + &call->request_received_tag_); + } + + // Enqueues a new request for the given service on the given + // completion queue, using the given `method_id`. + // + // The request will be handled with the given + // `handle_request_function`. + static void EnqueueRequestForMethod( + GrpcService* grpc_service, ::grpc::ServerCompletionQueue* cq, + int method_id, HandleRequestFunction handle_request_function, + bool supports_cancel) { + auto call = new Call( + handle_request_function); + if (supports_cancel) { + call->RegisterCancellationHandler(); + } + + // Initial ref for call handed to grpc; released in Tag callback. + grpc_service->RequestAsyncUnary(method_id, &call->ctx_, &call->request, + &call->responder_, cq, cq, + &call->request_received_tag_); + } + + RequestMessage request; + ResponseMessage response; + + const std::multimap<::grpc::string_ref, ::grpc::string_ref>& client_metadata() + const { + return ctx_.client_metadata(); + } + + private: + // Creates a completion queue tag for handling cancellation by the client. + // NOTE: This method must be called before this call is enqueued on a + // completion queue. + void RegisterCancellationHandler() { + this->Ref(); // Ref for grpc; released in Tag callback. + ctx_.AsyncNotifyWhenDone(&cancelled_tag_); + } + + HandleRequestFunction handle_request_function_; + ::grpc::ServerContext ctx_; + ::grpc::ServerAsyncResponseWriter responder_; + + // Used as void* completion markers from grpc to indicate different + // events of interest for a Call. + typedef typename UntypedCall::Tag Tag; + Tag request_received_tag_{this, Tag::kRequestReceived}; + Tag response_sent_tag_{this, Tag::kResponseSent}; + Tag cancelled_tag_{this, Tag::kCancelled}; + + mutex mu_; + std::function cancel_callback_ TF_GUARDED_BY(mu_); +}; + +// Lifetime of a server-side bidirectional streaming call: +// - The call is created in the static EnqueueRequest method. It transfers +// ownership to the kCallOpen tag pushed onto the completion queue. +// - If kCallOpen completes successfully, a read is requested and the +// kRequestReceived tag takes ownership of the call. If kCallOpen fails, +// e.g. server is shutdown, no further requests are pushed and the call is +// destroyed (at the end of Tag::OnCompleted). +// - When the first request is received, we Ref() the call and invoke the +// handler method thereby transferring ownership to the handler method. +// The handler is responsible for calling SendResponse() or Finish() on this +// call. +// - If the handler calls Finish(), e.g. the request was invalid, Finish() +// transfers ownership from the handler to the kServerFinished tag that +// it pushes on the completion queue. The ownership is transferred because +// the ref count is not incremented before putting the tag on the queue. +// - If the handler calls SendResponse(), SendResponse() transfers ownership +// to the kResponseSent tag. +// - When kResponseSent completes, we request a new read, which owns the call +// now. +// - When the next request is received, it is handled the same way as the first +// request. +// +// Because we request a read only after the write is sent, we can safely reuse +// the same request and response messages for the whole call. +template +class ServerUntypedBidirectionalStreamingCall : public core::RefCounted { + public: + virtual void RequestReceived(Service* service) = 0; + + // Enqueues a request on the completion queue to read the next request. + virtual void CallOpen() = 0; + + virtual void RequestRead() = 0; + + // Associates a tag in a `::grpc::CompletionQueue` with a callback. + // An active Tag owns a reference on the corresponding Call object. + class Tag : public GrpcCallTag { + public: + // One enum value per supported callback. + enum class TagType { + kCallOpen, + kRequestReceived, + kResponseSent, + kServerFinished, + }; + + Tag(ServerUntypedBidirectionalStreamingCall* call, TagType cb) + : call_(call), callback_(cb) {} + + // Calls the callback associated with this tag and Unrefs this->call_. + void OnCompleted(Service* service, bool ok) override { + switch (callback_) { + case TagType::kCallOpen: + // Non-ok value indicates that the server has been shutdown before we + // received a message for this call type. We do nothing to let this + // call object be destroyed and avoid enqueuing request for another + // call. + if (ok) { + call_->CallOpen(); + } + break; + case TagType::kRequestReceived: + // Non-ok value from completion queue here means that we will not + // receive any more messages from the client, e.g. the client called + // WritesDone. There is nothing we need to do in this case. The call + // will be Unref'ed and deleted. If the client wants to open a new + // call, we have already enqueued a request for a new call in CallOpen + // above. + if (ok) { + call_->RequestReceived(service); + } + break; + case TagType::kResponseSent: + if (ok) { + // The obvious place to request a read would be at the end of + // RequestReceived(). Unfortunately, this can result in multiple + // outstanding write requests in the completion queue. This is + // currently not supported by gRPC, which requires at most one + // outstanding write request in the completion queue. + // Requesting a read here, in ResponseSent, works because at + // this point, the completion queue has no write requests + // (kResponseSent happens when a write completes). + // This might be synchronizing the processing more than strictly + // necessary, but is probably fine because, AFAICT from gRPC docs, + // the write request completes as soon as it can be written to + // outgoing buffer. + call_->RequestRead(); + } + // ok == false means that the response is not going on the wire + // because the call is already dead (i.e., canceled, deadline + // expired, other side dropped the channel, etc). Since the call is + // dead, there is nothing for us to do, we just let the call be + // deleted. + break; + case TagType::kServerFinished: + // Whether our finish request is successful or not (whether it went + // on the wire towards the client), there is nothing for us to do. + // In the current implementation, there can be no read or write + // requests in the completion queue (see the comment in kResponseSent) + // above. Even if there were pending requests, they would complete + // with a non-ok status, we would not do anything, and let the call be + // deleted. + break; + } + call_->Unref(); // Ref acquired when tag was handed to grpc. + } + + private: + ServerUntypedBidirectionalStreamingCall* const + call_; // `this` owns one reference. + TagType callback_; + }; +}; + +// Represents a pending call with known request and response message +// types, and a known request-handling method. +// Common usage pattern is to have a single thread waiting on events from +// completion queue and calling Tag::OnCompleted(), which invokes methods +// on this. +// This implementation assumes that the server will generate a single response +// message for each request message. More precisely, this class expects that +// each time it invokes handle_request_function_, the service implementation +// will either call SendResponse or Finish exactly once. +// Not thread-safe. +template +class ServerBidirectionalStreamingCall + : public ServerUntypedBidirectionalStreamingCall { + public: + // Represents the generic signature of a generated + // `GrpcService::RequestFoo()` method, where `Foo` is the name of an + // RPC method. + using EnqueueFunction = void (GrpcService::*)( + ::grpc::ServerContext*, + ::grpc::ServerAsyncReaderWriter*, + ::grpc::CompletionQueue*, ::grpc::ServerCompletionQueue*, void*); + + // Represents the generic signature of a `Service::HandleFoo()` + // method, where `Foo` is the name of an RPC method. + using HandleRequestFunction = void (Service::*)( + ServerBidirectionalStreamingCall*); + + ServerBidirectionalStreamingCall( + HandleRequestFunction handle_request_function, GrpcService* grpc_service, + ::grpc::ServerCompletionQueue* cq, EnqueueFunction enqueue_function) + : handle_request_function_(handle_request_function), + stream_(&ctx_), + grpc_service_(grpc_service), + cq_(cq), + enqueue_function_(enqueue_function) { + VLOG(3) << "Creating ServerBidirectionalStreamingCall " << this; + } + + ~ServerBidirectionalStreamingCall() override { + VLOG(3) << "Destroying ServerBidirectionalStreamingCall " << this; + } + + void CallOpen() override { + // Let gRPC know that we can accept another call. + ServerBidirectionalStreamingCall< + Service, GrpcService, RequestMessage, + ResponseMessage>::EnqueueRequest(grpc_service_, cq_, enqueue_function_, + handle_request_function_); + RequestRead(); + } + + void RequestRead() override { + this->Ref(); + request_.Clear(); + stream_.Read(&request_, &request_received_tag_); + } + + void RequestReceived(Service* service) override { + this->Ref(); + // Request handling should result in a call to SendResponse or Finish. + (service->*handle_request_function_)(this); + } + + void SendResponse() { + // Transferring ownership of this to the response_sent_tag_. + stream_.Write(response_, &response_sent_tag_); + // stream_.Write does not save references to response_. We are free to muck + // around with it as soon as Write returns. + // We clear the response_ to prepare it for the next response. + response_.Clear(); + } + + void Finish(::grpc::Status status) { + // Transferring ownership of this to the server_finished_tag_. + stream_.Finish(status, &server_finished_tag_); + } + + // Enqueues a new request for the given service on the given + // completion queue, using the given `enqueue_function`. + // + // The request will be handled by the given `handle_request_function`. + static void EnqueueRequest(GrpcService* grpc_service, + ::grpc::ServerCompletionQueue* cq, + EnqueueFunction enqueue_function, + HandleRequestFunction handle_request_function) { + auto call = + new ServerBidirectionalStreamingCall( + handle_request_function, grpc_service, cq, enqueue_function); + + // Initial ref for call handed to grpc; released in Tag callback. + (grpc_service->*enqueue_function)(&call->ctx_, &call->stream_, cq, cq, + &call->call_open_tag_); + } + + const RequestMessage& request() const { return request_; } + ResponseMessage* mutable_response() { return &response_; } + + private: + // Request and response messages are reused for each request/response exchange + // between the client and the server. + RequestMessage request_; + ResponseMessage response_; + ::grpc::ServerContext ctx_; + + HandleRequestFunction handle_request_function_; + ::grpc::ServerAsyncReaderWriter stream_; + + // Used as void* completion markers from grpc to indicate different + // events of interest for a ServerBidirectionalStreamingCall. + typedef typename ServerUntypedBidirectionalStreamingCall::Tag Tag; + // At most one tag of each kind may be given to gRPC at any one time. + // Beyond semantic sanity, this is needed to ensure proper ref counting + // of this call object. + Tag call_open_tag_{this, Tag::TagType::kCallOpen}; + Tag request_received_tag_{this, Tag::TagType::kRequestReceived}; + Tag response_sent_tag_{this, Tag::TagType::kResponseSent}; + Tag server_finished_tag_{this, Tag::TagType::kServerFinished}; + + // These fields are used only to spawn another instance of this to accept + // more streaming calls. + GrpcService* grpc_service_; + ::grpc::ServerCompletionQueue* cq_; + EnqueueFunction enqueue_function_; +}; + +} // namespace tsl + +#endif // TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_GRPC_CALL_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/grpc_channel.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/grpc_channel.h new file mode 100644 index 0000000000000000000000000000000000000000..b019377f9986dd312b5742749a9d687b0fb83c1c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/grpc_channel.h @@ -0,0 +1,100 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_GRPC_CHANNEL_H_ +#define TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_GRPC_CHANNEL_H_ + +#include +#include +#include +#include +#include + +#include "grpcpp/grpcpp.h" +#include "tsl/distributed_runtime/rpc/grpc_util.h" +#include "tsl/protobuf/rpc_options.pb.h" + +namespace tsl { +using tensorflow::RPCOptions; + +// Consolidated parameter structure to ease use of generic interfaces. +// +// Each job_id requires: +// - a list of host:port (or sparse list of index:host:port) +// - the number of tasks per replica +class GrpcChannelSpec { + public: + struct HostPortsJob { + HostPortsJob(const string& job_id, const std::map& host_ports) + : job_id(job_id), host_ports(host_ports) {} + const string job_id; + const std::map host_ports; + }; + + Status AddHostPortsJob(const string& job_id, + const std::map& host_ports); + + const std::vector& host_ports_jobs() const { + return host_ports_jobs_; + } + + private: + std::vector host_ports_jobs_; + std::set job_ids_; +}; + +class GrpcChannelCache { + public: + virtual ~GrpcChannelCache() {} + + // Populates *workers with names of all workers which this object + // was created to handle. Worker names are in the format + // /job:/task: + // e.g. /job:mnist/task:2 + virtual void ListWorkers(std::vector* workers) = 0; + virtual void ListWorkersInJob(const string& job_name, + std::vector* workers) = 0; + + // If found, returns a gRPC channel that is connected to the remote + // worker named by 'target'. 'target' is of the following + // format: /job:/task: + // E.g., /job:mnist/task:2 + virtual SharedGrpcChannelPtr FindWorkerChannel(const string& target) = 0; + + // Translates a string in the form `/job:X/task:Z` into a host_port. + virtual string TranslateTask(const string& task) = 0; +}; + +typedef std::function ChannelCreationFunction; + +GrpcChannelCache* NewGrpcChannelCache( + const GrpcChannelSpec& channel_spec, ChannelCreationFunction channel_func, + const RPCOptions& rpc_options = RPCOptions()); + +// Below here are internal-only functions. + +::grpc::ChannelArguments GetChannelArguments(const RPCOptions* rpc_options); + +ChannelCreationFunction ConvertToChannelCreationFunction( + const std::function& new_channel_func_ptr); + +Status NewHostPortGrpcChannel(const string& target, + const RPCOptions* rpc_options, + SharedGrpcChannelPtr* channel_pointer); + +} // namespace tsl + +#endif // TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_GRPC_CHANNEL_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/grpc_channel_common.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/grpc_channel_common.h new file mode 100644 index 0000000000000000000000000000000000000000..7e1ef32151f1480c888e3ca22d46bfe4ad0b6608 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/grpc_channel_common.h @@ -0,0 +1,103 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_GRPC_CHANNEL_COMMON_H_ +#define TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_GRPC_CHANNEL_COMMON_H_ + +#include +#include + +#include "absl/container/flat_hash_map.h" +#include "tsl/distributed_runtime/rpc/grpc_util.h" +#include "tsl/platform/logging.h" +#include "tsl/platform/mutex.h" + +namespace tsl { + +// GenericCachingChannelCache that caches results to FindWorkerChannel() calls. +// To use instantiate with the type of channel cache needed. +// GenericCachingChannelCache allows using multiple channels to communiate with +// same target to provide throughput gains. When multiple channels exist for +// the same target they are chosen in a simple round robin fashion on each call +// to FindWorkerChannel. +template +class GenericCachingChannelCache : public ChannelCacheT { + public: + explicit GenericCachingChannelCache(int num_channels_per_target) + : num_channels_per_target_( + num_channels_per_target > 0 ? num_channels_per_target : 1) {} + + ~GenericCachingChannelCache() override {} + + SharedGrpcChannelPtr FindWorkerChannel(const string& target) override { + { + mutex_lock l(mu_); + auto iter = channels_.find(target); + if (iter != channels_.end()) { + return GetNextChannelPtrAndUpdateState(iter->second); + } + } + ChannelState new_chan_state; + for (int indx = 0; indx < num_channels_per_target_; indx++) { + auto ch = FindChannelOnce(target); + if (!ch) return nullptr; + new_chan_state.channels.push_back(ch); + } + new_chan_state.last_used = num_channels_per_target_ - 1; + + { + mutex_lock l(mu_); + typename absl::flat_hash_map::iterator iter; + bool was_inserted; + std::tie(iter, was_inserted) = channels_.insert({target, new_chan_state}); + VLOG(2) << "Channel cache for target: " << target + << " Size: " << new_chan_state.channels.size() + << " insertion: " << was_inserted; + return GetNextChannelPtrAndUpdateState(iter->second); + } + } + + protected: + // Find the ClientChannel for "target". Only called when no channel was + // found in the channels_ cache for "target". A non nullptr result will be + // cached in channels_. + virtual SharedGrpcChannelPtr FindChannelOnce(const string& target) = 0; + + private: + struct ChannelState { + std::vector channels; + int last_used; + }; + + // Should be called with mu_ held. + SharedGrpcChannelPtr GetNextChannelPtrAndUpdateState( + ChannelState& chan_state) { + // Following statement is marked as Crash OK as this is an invariant of + // code flow in this class. + CHECK_EQ(chan_state.channels.size(), num_channels_per_target_); // Crash OK + chan_state.last_used = + (chan_state.last_used + 1) % num_channels_per_target_; + return chan_state.channels[chan_state.last_used]; + } + + const int num_channels_per_target_; + // TODO(zhifengc): Eviction when the map becomes too big. + mutex mu_; + absl::flat_hash_map channels_ TF_GUARDED_BY(mu_); +}; + +} // namespace tsl + +#endif // TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_GRPC_CHANNEL_COMMON_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/grpc_client_cq_tag.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/grpc_client_cq_tag.h new file mode 100644 index 0000000000000000000000000000000000000000..183ca52e8d2d0a4c772e0fe4fbbdefb3236011be --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/grpc_client_cq_tag.h @@ -0,0 +1,41 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_GRPC_CLIENT_CQ_TAG_H_ +#define TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_GRPC_CLIENT_CQ_TAG_H_ + +#include "tsl/platform/macros.h" + +namespace tsl { + +// Represents a pending asynchronous client call as a tag that can be +// stored in a `grpc::CompletionQueue`. +class GrpcClientCQTag { + public: + GrpcClientCQTag() = default; + virtual ~GrpcClientCQTag() = default; + + // OnCompleted is invoked when the RPC has finished. + // Implementations of OnCompleted can delete *this. + virtual void OnCompleted(bool ok) = 0; + + private: + GrpcClientCQTag(const GrpcClientCQTag&) = delete; + void operator=(const GrpcClientCQTag&) = delete; +}; + +} // namespace tsl + +#endif // TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_GRPC_CLIENT_CQ_TAG_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/grpc_state.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/grpc_state.h new file mode 100644 index 0000000000000000000000000000000000000000..37b41edc0a01038ff280ee40b2f6c7df7157a62c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/grpc_state.h @@ -0,0 +1,254 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_GRPC_STATE_H_ +#define TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_GRPC_STATE_H_ + +#include +#include +#include + +#include "grpcpp/generic/generic_stub.h" +#include "grpcpp/grpcpp.h" +#include "absl/status/status.h" +#include "tsl/distributed_runtime/call_options.h" +#include "tsl/distributed_runtime/rpc/grpc_client_cq_tag.h" +#include "tsl/distributed_runtime/rpc/grpc_util.h" +#include "tsl/platform/errors.h" +#include "tsl/platform/status.h" +#include "tsl/platform/strcat.h" +#include "tsl/platform/threadpool.h" +#include "tsl/util/env_var.h" + +namespace tsl { + +// Object allocated per active RPC. +// Manage the state of a single asynchronous RPC request. If `max_retries` +// is greater than 0, the request will be retried for any transient failures. +// Note: `parse_proto_fn` is used solely to allow TensorFlow's worker service +// to pass in an optimized function that avoids an unnecessary copy of tensors. +// That is not implemented as an overload of tsl::GrpcMaybeParseProto because it +// has dependencies on many TensorFlow-specific absractions. +template +class RPCState : public GrpcClientCQTag { + public: + RPCState( + ::grpc::GenericStub* stub, ::grpc::CompletionQueue* cq, + const ::grpc::string& method, const protobuf::Message& request, + Response* response, StatusCallback done, CallOptions* call_opts, + thread::ThreadPool* threadpool, int32_t max_retries = 0, + bool fail_fast = true, const string* target = nullptr, + std::function parse_proto_fn = + [](::grpc::ByteBuffer* src, Response* dst) { + return tsl::GrpcMaybeParseProto(src, dst); + }) + : RPCState( + stub, cq, method, request, response, std::move(done), call_opts, + threadpool, + // 1) If GRPC_FAIL_FAST is set to 'true' or 'false', + // fail_fast=$GRPC_FAIL_FAST. See b/141948186. + // 2) Otherwise if GRPC_FAIL_FAST is set to 'use_caller', use the + // fail_fast from the caller. See b/140260119. + // + // Current default: use caller's fail_fast argument. + // + // NOTE: Callers mostly set fail_fast=true to prevent job hanging + // on worker task failures, except a few cases such as GetStatus + // in cluster initialization and collective param resolution. + [fail_fast, &done]() -> bool { + string fail_fast_env; + TF_CHECK_OK(ReadStringFromEnvVar("GRPC_FAIL_FAST", "use_caller", + &fail_fast_env)); + string fail_fast_env_lower = absl::AsciiStrToLower(fail_fast_env); + if (fail_fast_env_lower == "true") { + return true; + } else if (fail_fast_env_lower == "use_caller") { + return fail_fast; + } else if (fail_fast_env_lower == "false") { + return false; + } else { + string error_message = strings::StrCat( + "Invalid GRPC_FAIL_FAST config: ", fail_fast_env); + LOG(WARNING) << error_message; + done(errors::InvalidArgument(error_message)); + return false; + } + }(), + (call_opts != nullptr ? call_opts->GetTimeout() : 0), max_retries, + target, parse_proto_fn) {} + + template + RPCState( + ::grpc::GenericStub* stub, ::grpc::CompletionQueue* cq, + const ::grpc::string& method, const Request& request, Response* response, + StatusCallback done, CallOptions* call_opts, + thread::ThreadPool* threadpool, bool fail_fast, int64_t timeout_in_ms, + int32_t max_retries, const string* target, + std::function parse_proto_fn = + [](::grpc::ByteBuffer* src, Response* dst) { + return tsl::GrpcMaybeParseProto(src, dst); + }) + : call_opts_(call_opts), + threadpool_(threadpool), + done_(std::move(done)), + timeout_in_ms_(timeout_in_ms), + max_retries_(max_retries), + cq_(cq), + stub_(stub), + method_(method), + fail_fast_(fail_fast), + target_(target), + parse_proto_fn_(std::move(parse_proto_fn)) { + response_ = response; + ::grpc::Status s = GrpcMaybeUnparseProto(request, &request_buf_); + if (!s.ok()) { + LOG(ERROR) << "GrpcMaybeUnparseProto returned with non-ok status: " + << s.error_message(); + // Skip retry logic if we fail to parse our request. + done_(FromGrpcStatus(s)); + delete this; + return; + } + StartCall(); + } + + void StartCall() { + context_.reset(new ::grpc::ClientContext()); + context_->set_wait_for_ready(!fail_fast_); + if (timeout_in_ms_ > 0) { + context_->set_deadline( + gpr_time_from_millis(timeout_in_ms_, GPR_TIMESPAN)); + } + if (call_opts_) { + call_opts_->SetCancelCallback([this]() { context_->TryCancel(); }); + } + + VLOG(2) << "Starting call: " << method_; + + call_ = stub_->PrepareUnaryCall(context_.get(), method_, request_buf_, cq_); + call_->StartCall(); + call_->Finish(&response_buf_, &status_, this); + } + + void OnCompleted(bool ok) override { + if (call_opts_) { + call_opts_->ClearCancelCallback(); + } + + VLOG(2) << "Completed call: " << method_; + + Status s = FromGrpcStatus(status_); + if (s.ok() && !ok) { + // Since this function is only being used for processing the response + // to Finish for client-side unary calls, ok should never be false + s.Update( + errors::Internal("GRPC status is okay but CompletionQueueStatus is " + "not. This should never happen.")); + } + + if (s.ok()) { + if (threadpool_) { + // Run parse and callback in another thread, returning this + // one to service more RPCs. + threadpool_->Schedule([this]() { ParseAndCallDone(); }); + } else { + ParseAndCallDone(); + } + return; + } + + VLOG(1) << method_ << " returned with non-ok status: " << s + << " Retries: " << num_retries_ << " Max: " << max_retries_ << "\n" + << context_->debug_error_string(); + // Retry if we have any attempts left + if (++num_retries_ <= max_retries_ && + (absl::IsUnavailable(s) || absl::IsUnknown(s))) { + response_buf_.Clear(); + VLOG(1) << "Retrying call for " << method_ << "Retry: " << num_retries_ + << " of " << max_retries_; + + ComputeRetryBackoffMs(/*min_backoff_ms=*/1, /*max_backoff_ms=*/10000); + int64_t backoff_us = retry_backoff_ms_ * 1000; + Env::Default()->SchedClosureAfter(/*micros=*/backoff_us, + [this]() { StartCall(); }); + } else { + // Attach additional GRPC error information if any to the final status + string error_msg = std::string(s.message()); + strings::StrAppend(&error_msg, "\nAdditional GRPC error information"); + if (target_) { + strings::StrAppend(&error_msg, " from remote target ", *target_); + } + strings::StrAppend(&error_msg, " while calling ", method_); + strings::StrAppend(&error_msg, ":\n:", context_->debug_error_string()); + s = errors::CreateWithUpdatedMessage(s, error_msg); + // Always treat gRPC cancellation as a derived error. This ensures that + // other error types are preferred during status aggregation. (gRPC + // cancellation messages do not contain the original status message). + if (s.code() == absl::StatusCode::kCancelled) { + s = StatusGroup::MakeDerived(s); + } + + done_(s); + delete this; + } + } + + void ParseAndCallDone() { + Status s; + if (!parse_proto_fn_(&response_buf_, response_)) { + s.Update(errors::Internal("could not parse rpc response")); + } + done_(s); + delete this; + } + + private: + void ComputeRetryBackoffMs(int min_backoff_ms, int max_backoff_ms) { + constexpr float kBackoffBase = 1.3; + if (retry_backoff_ms_ < 0) { + retry_backoff_ms_ = min_backoff_ms; + } else { + retry_backoff_ms_ *= kBackoffBase; + if (retry_backoff_ms_ > max_backoff_ms) { + retry_backoff_ms_ = max_backoff_ms; + } + } + } + + CallOptions* call_opts_; + std::unique_ptr<::grpc::ClientContext> context_; + thread::ThreadPool* threadpool_; + std::unique_ptr<::grpc::GenericClientAsyncResponseReader> call_; + Response* response_; + ::grpc::ByteBuffer request_buf_; + ::grpc::ByteBuffer response_buf_; + ::grpc::Status status_; + StatusCallback done_; + int64_t timeout_in_ms_; + + size_t num_retries_ = 0; + size_t max_retries_; + double retry_backoff_ms_ = -1; + + ::grpc::CompletionQueue* cq_; + ::grpc::GenericStub* stub_; + ::grpc::string method_; + bool fail_fast_; + const string* target_; + std::function parse_proto_fn_ = nullptr; +}; +} // namespace tsl + +#endif // TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_GRPC_STATE_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/grpc_util.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/grpc_util.h new file mode 100644 index 0000000000000000000000000000000000000000..2268124318559013bdd29df19fdfd2c89c9f9566 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/distributed_runtime/rpc/grpc_util.h @@ -0,0 +1,139 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_GRPC_UTIL_H_ +#define TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_GRPC_UTIL_H_ + +#include +#include + +#include "grpcpp/grpcpp.h" +#include "grpcpp/support/byte_buffer.h" +#include "absl/status/status.h" +#include "absl/strings/cord.h" +#include "tsl/platform/protobuf.h" +#include "tsl/platform/status.h" +#include "tsl/platform/stringpiece.h" +#include "tsl/platform/stringprintf.h" +#include "tsl/protobuf/distributed_runtime_payloads.pb.h" + +namespace tsl { + +// Proto: tensorflow::distributed_runtime::GrpcPayloadsLost +// Location: tsl/protobuf/distributed_runtime_payloads.proto +// Usage: Flags the Status to have lost payloads during GRPC conversion. +constexpr char kGrpcPayloadsLost[] = + "type.googleapis.com/tensorflow.distributed_runtime.GrpcPayloadsLost"; + +// Given the total number of RPC retries attempted, return a randomized +// amount of time to delay before retrying the request. +// +// The average computed backoff increases with the number of RPCs attempted. +// See implementation for details on the calculations. +int64_t ComputeBackoffMicroseconds(int current_retry_attempt, + int64_t min_delay = 1000, + int64_t max_delay = 10000000); + +constexpr char kStreamRemovedMessage[] = "Stream removed"; + +// Identify if the given grpc::Status corresponds to an HTTP stream removed +// error (see chttp2_transport.cc). +// +// When auto-reconnecting to a remote worker after it restarts, gRPC can return +// an UNKNOWN error code with a "Stream removed" error message. This should not +// be treated as an unrecoverable error. +// +// N.B. This is dependent on the error message from grpc remaining consistent. +inline bool IsStreamRemovedError(const ::grpc::Status& s) { + return !s.ok() && s.error_code() == ::grpc::StatusCode::UNKNOWN && + s.error_message() == kStreamRemovedMessage; +} + +inline std::string SerializePayloads(const Status& s) { + tensorflow::distributed_runtime::GrpcPayloadContainer container; + s.ForEachPayload([&container](StringPiece key, const absl::Cord& value) { + (*container.mutable_payloads())[std::string(key)] = std::string(value); + }); + return container.SerializeAsString(); +} + +inline void InsertSerializedPayloads(Status& s, std::string payloads) { + tensorflow::distributed_runtime::GrpcPayloadContainer container; + if (container.ParseFromString(payloads)) { + for (const auto& key_val : container.payloads()) { + s.SetPayload(key_val.first, absl::Cord(key_val.second)); + } + } else { + s.SetPayload(kGrpcPayloadsLost, + absl::Cord(tensorflow::distributed_runtime::GrpcPayloadsLost() + .SerializeAsString())); + } +} + +inline Status FromGrpcStatus(const ::grpc::Status& s) { + if (s.ok()) { + return OkStatus(); + } else { + Status converted; + // Convert "UNKNOWN" stream removed errors into unavailable, to allow + // for retry upstream. + if (IsStreamRemovedError(s)) { + converted = Status(absl::StatusCode::kUnavailable, s.error_message()); + } + converted = Status(static_cast(s.error_code()), + s.error_message()); + InsertSerializedPayloads(converted, s.error_details()); + return converted; + } +} + +inline ::grpc::Status ToGrpcStatus(const Status& s) { + if (s.ok()) { + return ::grpc::Status::OK; + } else { + if (s.message().size() > 3072 /* 3k bytes */) { + // TODO(b/62947679): Remove truncation once the gRPC issue is resolved. + string scratch = strings::Printf("%.3072s ... [truncated]", + tsl::NullTerminatedMessage(s)); + LOG(ERROR) << "Truncated error message: " << s; + return ::grpc::Status(static_cast<::grpc::StatusCode>(s.code()), scratch, + SerializePayloads(s)); + } + return ::grpc::Status(static_cast<::grpc::StatusCode>(s.code()), + std::string(s.message()), SerializePayloads(s)); + } +} + +typedef std::shared_ptr<::grpc::Channel> SharedGrpcChannelPtr; + +// Serialize src and store in *dst. +::grpc::Status GrpcMaybeUnparseProto(const protobuf::Message& src, + ::grpc::ByteBuffer* dst); + +// Parse contents of src and initialize *dst with them. +bool GrpcMaybeParseProto(::grpc::ByteBuffer* src, protobuf::Message* dst); + +// Copy string src to grpc buffer *dst. +::grpc::Status GrpcMaybeUnparseProto(const string& src, + ::grpc::ByteBuffer* dst); + +// Copy grpc buffer src to string *dst. +bool GrpcMaybeParseProto(::grpc::ByteBuffer* src, string* dst); + +// Copy grpc buffer src to tstring *dst. +bool GrpcMaybeParseProto(::grpc::ByteBuffer* src, tstring* dst); +} // namespace tsl + +#endif // TENSORFLOW_TSL_DISTRIBUTED_RUNTIME_RPC_GRPC_UTIL_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/allocator.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/allocator.h new file mode 100644 index 0000000000000000000000000000000000000000..84aef0b1f99c1fdbf9f35ba8f11caebf3d783fb6 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/allocator.h @@ -0,0 +1,430 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_ALLOCATOR_H_ +#define TENSORFLOW_TSL_FRAMEWORK_ALLOCATOR_H_ + +#include + +#include +#include +#include + +#include "absl/strings/string_view.h" +#include "absl/types/optional.h" +#include "tsl/framework/numeric_types.h" +#include "tsl/framework/type_traits.h" +#include "tsl/platform/logging.h" +#include "tsl/platform/macros.h" +#include "tsl/platform/numa.h" +#include "tsl/platform/types.h" + +namespace tsl { + +// Attributes for a single allocation call. Different calls to the same +// allocator could potentially have different allocation attributes. +struct AllocationAttributes { + AllocationAttributes() = default; + + AllocationAttributes(bool retry_on_failure, bool allocation_will_be_logged, + std::function* freed_by_func) + : retry_on_failure(retry_on_failure), + allocation_will_be_logged(allocation_will_be_logged), + freed_by_func(freed_by_func) {} + + // If the first attempt to allocate the memory fails, the allocation should + // wait and retry (with a timeout). + // + // This is usually set to true, but we may set it to false in cases where a + // failure has only performance impact (e.g. optional scratch space + // allocation). + bool retry_on_failure = true; + // If a Tensor is allocated without the following set to true, then + // it is logged as an unknown allocation. During execution Tensors + // should be allocated through the OpKernelContext which records + // which Op is performing the allocation, and sets this flag to + // true. + bool allocation_will_be_logged = false; + // EXPERIMENTAL: If provided, then evaluates to a timing count such that only + // a memory chunk whose freed_at_count is at this value or earlier may be + // returned. + std::function* freed_by_func = nullptr; // Not owned. + + AllocationAttributes(const AllocationAttributes&) = delete; + void operator=(const AllocationAttributes&) = delete; +}; + +// Runtime statistics collected by an allocator. Exactly the same as +// stream_executor::AllocatorStats, but independently defined to preserve the +// mutual independence of StreamExecutor and TensorFlow. +struct AllocatorStats { + int64_t num_allocs; // Number of allocations. + int64_t bytes_in_use; // Number of bytes in use. + int64_t peak_bytes_in_use; // The peak bytes in use. + int64_t largest_alloc_size; // The largest single allocation seen. + + // The upper limit of bytes of user allocatable device memory, if such a limit + // is known. + std::optional bytes_limit; + + // Stats for reserved memory usage. + int64_t bytes_reserved; // Number of bytes reserved. + int64_t peak_bytes_reserved; // The peak number of bytes reserved. + // The upper limit on the number bytes of reservable memory, + // if such a limit is known. + std::optional bytes_reservable_limit; + + int64_t largest_free_block_bytes; // Largest free block's size in heap. + + // Number of bytes of memory held by the allocator. This may be higher than + // bytes_in_use if the allocator holds a pool of memory (e.g. BFCAllocator). + std::optional pool_bytes; + std::optional peak_pool_bytes; + + AllocatorStats() + : num_allocs(0), + bytes_in_use(0), + peak_bytes_in_use(0), + largest_alloc_size(0), + bytes_reserved(0), + peak_bytes_reserved(0), + largest_free_block_bytes(0) {} + + std::string DebugString() const; +}; + +// The type of the allocated memory. +enum class AllocatorMemoryType { + kUnknown = 0, // Memory type unknown. + kDevice = 1, // Memory on device. + kHostPageable = 2, // Memory on host and it is pagable. + kHostPinned = 3, // Memory on host and it is pinned. +}; + +// Allocator is an abstract interface for allocating and deallocating +// device memory. +class Allocator { + public: + // Align to 64 byte boundary. + static constexpr size_t kAllocatorAlignment = 64; + + virtual ~Allocator(); + + // Return a string identifying this allocator + virtual std::string Name() = 0; + + // Return an uninitialized block of memory that is "num_bytes" bytes + // in size. The returned pointer is guaranteed to be aligned to a + // multiple of "alignment" bytes. + // REQUIRES: "alignment" is a power of 2. + virtual void* AllocateRaw(size_t alignment, size_t num_bytes) = 0; + + // Return an uninitialized block of memory that is "num_bytes" bytes + // in size with specified allocation attributes. The returned pointer is + // guaranteed to be aligned to a multiple of "alignment" bytes. + // REQUIRES: "alignment" is a power of 2. + virtual void* AllocateRaw(size_t alignment, size_t num_bytes, + const AllocationAttributes& allocation_attr) { + // The default behavior is to use the implementation without any allocation + // attributes. + return AllocateRaw(alignment, num_bytes); + } + + // Deallocate a block of memory pointer to by "ptr" + // REQUIRES: "ptr" was previously returned by a call to AllocateRaw + virtual void DeallocateRaw(void* ptr) = 0; + + // Returns true if this allocator tracks the sizes of allocations. + // RequestedSize and AllocatedSize must be overridden if + // TracksAllocationSizes is overridden to return true. + virtual bool TracksAllocationSizes() const { return false; } + + // Returns true if this allocator allocates an opaque handle rather than the + // requested number of bytes. + // + // This method returns false for most allocators, but may be used by + // special-case allocators that track tensor usage. If this method returns + // true, AllocateRaw() should be invoked for all values of `num_bytes`, + // including 0. + // + // NOTE: It is the caller's responsibility to track whether an allocated + // object is a buffer or an opaque handle. In particular, when this method + // returns `true`, users of this allocator must not run any constructors or + // destructors for complex objects, since there is no backing store for the + // tensor in which to place their outputs. + virtual bool AllocatesOpaqueHandle() const { return false; } + + // Returns the user-requested size of the data allocated at + // 'ptr'. Note that the actual buffer allocated might be larger + // than requested, but this function returns the size requested by + // the user. + // + // REQUIRES: TracksAllocationSizes() is true. + // + // REQUIRES: 'ptr!=nullptr' and points to a buffer previously + // allocated by this allocator. + virtual size_t RequestedSize(const void* ptr) const { + CHECK(false) << "allocator doesn't track sizes"; + return size_t(0); + } + + // Returns the allocated size of the buffer at 'ptr' if known, + // otherwise returns RequestedSize(ptr). AllocatedSize(ptr) is + // guaranteed to be >= RequestedSize(ptr). + // + // REQUIRES: TracksAllocationSizes() is true. + // + // REQUIRES: 'ptr!=nullptr' and points to a buffer previously + // allocated by this allocator. + virtual size_t AllocatedSize(const void* ptr) const { + return RequestedSize(ptr); + } + + // Returns either 0 or an identifier assigned to the buffer at 'ptr' + // when the buffer was returned by AllocateRaw. If non-zero, the + // identifier differs from every other ID assigned by this + // allocator. + // + // REQUIRES: TracksAllocationSizes() is true. + // + // REQUIRES: 'ptr!=nullptr' and points to a buffer previously + // allocated by this allocator. + virtual int64_t AllocationId(const void* ptr) const { return 0; } + + // Returns the allocated size of the buffer at 'ptr' if known, + // otherwise returns 0. This method can be called when + // TracksAllocationSizes() is false, but can be extremely slow. + // + // REQUIRES: 'ptr!=nullptr' and points to a buffer previously + // allocated by this allocator. + virtual size_t AllocatedSizeSlow(const void* ptr) const { + if (TracksAllocationSizes()) { + return AllocatedSize(ptr); + } + return 0; + } + + // Fills in 'stats' with statistics collected by this allocator. + virtual absl::optional GetStats() { return absl::nullopt; } + + // If implemented, clears the internal stats except for the `in_use` fields + // and sets the `peak_bytes_in_use` to be equal to the `bytes_in_use`. Returns + // true if implemented. + // + // REQUIRES: GetStats is overridden. + virtual bool ClearStats() TF_MUST_USE_RESULT { return false; } + + virtual void SetSafeFrontier(uint64 count) {} + + // For allocator that are stream aware, allow to specify the compute + // stream this allocator is used for. This can also trigger memory + // preallocation. + virtual void SetStreamAndPreallocateMemory(void* stream) {} + + // Returns the type of the memory allocated by this allocator. + virtual AllocatorMemoryType GetMemoryType() const { + return AllocatorMemoryType::kUnknown; + } +}; + +// An implementation of Allocator that delegates all calls to another Allocator. +// +// Useful to clients who want to override part of the functionality of another +// allocator. +class AllocatorWrapper : public Allocator { + public: + explicit AllocatorWrapper(Allocator* wrapped) : wrapped_(wrapped) {} + + ~AllocatorWrapper() override {} + + // Returns the wrapped allocator to which all calls are delegated. + Allocator* wrapped() const { return wrapped_; } + + std::string Name() override { return wrapped_->Name(); } + + void* AllocateRaw(size_t alignment, size_t num_bytes) override { + return wrapped_->AllocateRaw(alignment, num_bytes); + } + + void* AllocateRaw(size_t alignment, size_t num_bytes, + const AllocationAttributes& allocation_attr) override { + return wrapped_->AllocateRaw(alignment, num_bytes, allocation_attr); + } + + void DeallocateRaw(void* ptr) override { wrapped_->DeallocateRaw(ptr); } + + bool TracksAllocationSizes() const override { + return wrapped_->TracksAllocationSizes(); + } + + bool AllocatesOpaqueHandle() const override { + return wrapped_->AllocatesOpaqueHandle(); + } + + size_t RequestedSize(const void* ptr) const override { + return wrapped_->RequestedSize(ptr); + } + + size_t AllocatedSize(const void* ptr) const override { + return wrapped_->AllocatedSize(ptr); + } + + int64_t AllocationId(const void* ptr) const override { + return wrapped_->AllocationId(ptr); + } + + size_t AllocatedSizeSlow(const void* ptr) const override { + return wrapped_->AllocatedSizeSlow(ptr); + } + + AllocatorMemoryType GetMemoryType() const override { + return wrapped_->GetMemoryType(); + } + + private: + Allocator* const wrapped_; +}; + +// A tensorflow Op may need access to different kinds of memory that +// are not simply a function of the device to which the Op has been +// assigned. For example, an Op executing on a GPU may still need +// to allocate CPU RAM for some purpose. Internal to the tensorflow +// runtime we may choose to allocate CPU ram from special regions +// that have been prepared for higher performance in some use +// contexts, e.g. doing DMA with particular devices. For these +// reasons, the Device interface does not expose just one memory +// Allocator, but instead provides an accessor that takes a +// specification of the desired memory attributes in order to select +// an Allocator. +// +// Example use: +// // Allocator for ordinary device memory: +// Allocator* a = allocator(AllocatorAttributes()); +// ... +// // Allocator for CPU RAM, regardless of where Op is executing: +// AllocatorAttributes attr; +// attr.set_on_host(true); +// Allocator* a = allocator(attr); +struct AllocatorAttributes { + void set_on_host(bool v) { value |= (static_cast(v)); } + bool on_host() const { return value & 0x1; } + void set_nic_compatible(bool v) { value |= (static_cast(v) << 1); } + bool nic_compatible() const { return value & (0x1 << 1); } + void set_gpu_compatible(bool v) { value |= (static_cast(v) << 2); } + bool gpu_compatible() const { return value & (0x1 << 2); } + void set_use_pjrt_allocator(bool v) { value |= (static_cast(v) << 3); } + bool use_pjrt_allocator() const { return value & (0x1 << 3); } + void Merge(AllocatorAttributes other) { + value |= other.value; + if (scope_id != other.scope_id) { + CHECK(scope_id == 0 || other.scope_id == 0) + << "At least one scope_id should be zero to merge " + "AllocatorAttributes but found this.scope_id=" + << scope_id << " and other.scope_id=" << other.scope_id; + scope_id = scope_id == 0 ? other.scope_id : scope_id; + } + } + // Returns true if the fields set in *this is a subset of or equal to + // those set in other. + bool IsEqualOrLessRestrictiveThan(const AllocatorAttributes& other) const { + return (value | other.value) == other.value; + } + + // NOTE: The upper 8 bits of the value are reserved for + // device-specific uses. Implementors of a device can interpret these + // upper 8 bits in device-specific ways, and ops implemented for those + // devices are responsible for setting those 8 bits appropriately. + uint32 value = 0; + // EXPERIMENTAL: If this is greater than zero, then allocation is delegated to + // a named special-purpose allocator on the same device. + int32 scope_id = 0; + + // Returns a human readable representation of this. + std::string DebugString() const; +}; + +// Returns a trivial implementation of Allocator, which is a process singleton. +// Access through this function is only intended for use by restricted parts +// of the infrastructure. +Allocator* cpu_allocator_base(); + +// If available, calls ProcessState::GetCPUAllocator(numa_node). +// If not, falls back to cpu_allocator_base(). +// Intended for use in contexts where ProcessState is not visible at +// compile time. Where ProcessState is visible, it's preferable to +// call it directly. +Allocator* cpu_allocator(int numa_node = port::kNUMANoAffinity); + +// Enables AllocatorStats in the default CPU allocator implementation. By +// default, it's disabled. +void EnableCPUAllocatorStats(); +// Disables AllocatorStats in the default CPU allocator implementation. By +// default, it's disabled. +void DisableCPUAllocatorStats(); +bool CPUAllocatorStatsEnabled(); + +// Enables full statistics collection in the default CPU allocator +// implementation. By default, it's disabled. +void EnableCPUAllocatorFullStats(); +bool CPUAllocatorFullStatsEnabled(); + +// An object that does the underlying suballoc/free of memory for a higher-level +// allocator. The expectation is that the higher-level allocator is doing some +// kind of cache or pool management so that it will call SubAllocator::Alloc and +// Free relatively infrequently, compared to the number of times its own +// AllocateRaw and Free methods are called. +class SubAllocator { + public: + // Visitor gets called with a pointer to a memory area and its + // size in bytes. The index value will be numa_node for a CPU + // allocator and GPU id for a GPU allocator. + typedef std::function Visitor; + + SubAllocator(const std::vector& alloc_visitors, + const std::vector& free_visitors); + + virtual ~SubAllocator() {} + // Allocates at least num_bytes. Returns actual number of bytes allocated in + // bytes_received. The caller can safely use the full bytes_received sized + // buffer following the returend pointer. + virtual void* Alloc(size_t alignment, size_t num_bytes, + size_t* bytes_received) = 0; + virtual void Free(void* ptr, size_t num_bytes) = 0; + + // Returns true if the BFC allocator can safely coalesce adjacent regions + // returned by this allocator. + virtual bool SupportsCoalescing() const = 0; + + // Returns the type of the memory allocated by this SubAllocator. + virtual AllocatorMemoryType GetMemoryType() const { + return AllocatorMemoryType::kUnknown; + } + + protected: + // Implementation of Alloc() method must call this on newly allocated + // value. + void VisitAlloc(void* ptr, int index, size_t num_bytes); + + // Implementation of Free() method must call this on value to be + // freed immediately before deallocation. + void VisitFree(void* ptr, int index, size_t num_bytes); + + const std::vector alloc_visitors_; + const std::vector free_visitors_; +}; + +} // namespace tsl + +#endif // TENSORFLOW_TSL_FRAMEWORK_ALLOCATOR_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/allocator_registry.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/allocator_registry.h new file mode 100644 index 0000000000000000000000000000000000000000..b827ce42dc7ab42f2f863c0bc3696c0c5cfa2f48 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/allocator_registry.h @@ -0,0 +1,154 @@ +/* Copyright 2017 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +// Classes to maintain a static registry of memory allocator factories. +#ifndef TENSORFLOW_TSL_FRAMEWORK_ALLOCATOR_REGISTRY_H_ +#define TENSORFLOW_TSL_FRAMEWORK_ALLOCATOR_REGISTRY_H_ + +#include +#include +#include + +#include "absl/base/thread_annotations.h" +#include "tsl/framework/allocator.h" +#include "tsl/platform/macros.h" +#include "tsl/platform/mutex.h" +#include "tsl/platform/numa.h" + +namespace tensorflow { + +class ProcessState; + +} + +namespace tsl { + +class AllocatorFactory { + public: + virtual ~AllocatorFactory() {} + + // Returns true if the factory will create a functionally different + // SubAllocator for different (legal) values of numa_node. + virtual bool NumaEnabled() { return false; } + + // Create an Allocator. + virtual Allocator* CreateAllocator() = 0; + + // Create a SubAllocator. If NumaEnabled() is true, then returned SubAllocator + // will allocate memory local to numa_node. If numa_node == kNUMANoAffinity + // then allocated memory is not specific to any NUMA node. + virtual SubAllocator* CreateSubAllocator(int numa_node) = 0; +}; + +// ProcessState is defined in a package that cannot be a dependency of +// framework. This definition allows us to access the one method we need. +class ProcessStateInterface { + public: + virtual ~ProcessStateInterface() {} + virtual Allocator* GetCPUAllocator(int numa_node) = 0; +}; + +// A singleton registry of AllocatorFactories. +// +// Allocators should be obtained through ProcessState or cpu_allocator() +// (deprecated), not directly through this interface. The purpose of this +// registry is to allow link-time discovery of multiple AllocatorFactories among +// which ProcessState will obtain the best fit at startup. +class AllocatorFactoryRegistry { + public: + AllocatorFactoryRegistry() {} + ~AllocatorFactoryRegistry() {} + + void Register(const char* source_file, int source_line, const string& name, + int priority, AllocatorFactory* factory); + + // Returns 'best fit' Allocator. Find the factory with the highest priority + // and return an allocator constructed by it. If multiple factories have + // been registered with the same priority, picks one by unspecified criteria. + Allocator* GetAllocator(); + + // Returns 'best fit' SubAllocator. First look for the highest priority + // factory that is NUMA-enabled. If none is registered, fall back to the + // highest priority non-NUMA-enabled factory. If NUMA-enabled, return a + // SubAllocator specific to numa_node, otherwise return a NUMA-insensitive + // SubAllocator. + SubAllocator* GetSubAllocator(int numa_node); + + // Returns the singleton value. + static AllocatorFactoryRegistry* singleton(); + + ProcessStateInterface* process_state() const { + mutex_lock ml(mu_); + return process_state_; + } + + protected: + friend class tensorflow::ProcessState; + + void SetProcessState(ProcessStateInterface* interface) { + mutex_lock ml(mu_); + process_state_ = interface; + } + + private: + mutable mutex mu_; + ProcessStateInterface* process_state_ ABSL_GUARDED_BY(mu_) = nullptr; + bool first_alloc_made_ = false; + struct FactoryEntry { + const char* source_file; + int source_line; + string name; + int priority; + std::unique_ptr factory; + std::unique_ptr allocator; + // Index 0 corresponds to kNUMANoAffinity, other indices are (numa_node + + // 1). + std::vector> sub_allocators; + }; + std::vector factories_ ABSL_GUARDED_BY(mu_); + + // Returns any FactoryEntry registered under 'name' and 'priority', + // or 'nullptr' if none found. + const FactoryEntry* FindEntry(const string& name, int priority) const + ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_); + + AllocatorFactoryRegistry(const AllocatorFactoryRegistry&) = delete; + void operator=(const AllocatorFactoryRegistry&) = delete; +}; + +class AllocatorFactoryRegistration { + public: + AllocatorFactoryRegistration(const char* file, int line, const string& name, + int priority, AllocatorFactory* factory) { + AllocatorFactoryRegistry::singleton()->Register(file, line, name, priority, + factory); + } +}; + +#define REGISTER_MEM_ALLOCATOR(name, priority, factory) \ + REGISTER_MEM_ALLOCATOR_UNIQ_HELPER(__COUNTER__, __FILE__, __LINE__, name, \ + priority, factory) + +#define REGISTER_MEM_ALLOCATOR_UNIQ_HELPER(ctr, file, line, name, priority, \ + factory) \ + REGISTER_MEM_ALLOCATOR_UNIQ(ctr, file, line, name, priority, factory) + +#define REGISTER_MEM_ALLOCATOR_UNIQ(ctr, file, line, name, priority, factory) \ + static AllocatorFactoryRegistration allocator_factory_reg_##ctr( \ + file, line, name, priority, new factory) + +} // namespace tsl + +#endif // TENSORFLOW_TSL_FRAMEWORK_ALLOCATOR_REGISTRY_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/allocator_retry.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/allocator_retry.h new file mode 100644 index 0000000000000000000000000000000000000000..6ca14c12d040826ec784bedc5ee26e6c786b47e8 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/allocator_retry.h @@ -0,0 +1,60 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_ALLOCATOR_RETRY_H_ +#define TENSORFLOW_TSL_FRAMEWORK_ALLOCATOR_RETRY_H_ + +#include "tsl/platform/env.h" +#include "tsl/platform/mutex.h" +#include "tsl/platform/types.h" + +namespace tsl { + +// A retrying wrapper for a memory allocator. +class AllocatorRetry { + public: + AllocatorRetry(); + + // Call 'alloc_func' to obtain memory. On first call, + // 'verbose_failure' will be false. If return value is nullptr, + // then wait up to 'max_millis_to_wait' milliseconds, retrying each + // time a call to DeallocateRaw() is detected, until either a good + // pointer is returned or the deadline is exhausted. If the + // deadline is exhausted, try one more time with 'verbose_failure' + // set to true. The value returned is either the first good pointer + // obtained from 'alloc_func' or nullptr. + void* AllocateRaw(std::function + alloc_func, + int max_millis_to_wait, size_t alignment, size_t bytes); + + // Called to notify clients that some memory was returned. + void NotifyDealloc(); + + private: + Env* env_; + mutex mu_; + condition_variable memory_returned_; +}; + +// Implementation details below +inline void AllocatorRetry::NotifyDealloc() { + mutex_lock l(mu_); + memory_returned_.notify_all(); +} + +} // namespace tsl + +#endif // TENSORFLOW_TSL_FRAMEWORK_ALLOCATOR_RETRY_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/bfc_allocator.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/bfc_allocator.h new file mode 100644 index 0000000000000000000000000000000000000000..47619856abe8dd92f059278395233ae6aaae53d1 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/bfc_allocator.h @@ -0,0 +1,629 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_BFC_ALLOCATOR_H_ +#define TENSORFLOW_TSL_FRAMEWORK_BFC_ALLOCATOR_H_ + +#include +#include +#include +#include +#include +#include + +#include "absl/container/flat_hash_set.h" +#include "tsl/framework/allocator.h" +#include "tsl/framework/allocator_retry.h" +#include "tsl/framework/shared_counter.h" +#include "tsl/platform/macros.h" +#include "tsl/platform/mutex.h" +#include "tsl/platform/numbers.h" +#include "tsl/platform/strcat.h" +#include "tsl/platform/thread_annotations.h" +#include "tsl/platform/types.h" + +namespace tensorflow { +class MemoryDump; +} +namespace tsl { +using tensorflow::MemoryDump; + +// A memory allocator that implements a 'best-fit with coalescing' +// algorithm. This is essentially a very simple version of Doug Lea's +// malloc (dlmalloc). +// +// The goal of this allocator is to support defragmentation via +// coalescing. One assumption we make is that the process using this +// allocator owns pretty much all of the memory, and that nearly +// all requests to allocate memory go through this interface. +class BFCAllocator : public Allocator { + public: + struct Options { + bool allow_growth = true; + + // If true, the allocator may sleep for a period of time when it can't + // fulfill an allocation request, in the hopes that another thread will free + // up memory in the meantime. + // + // If false, the allocator will never sleep, even if + // AllocationAttributes::attr_retry_on_failure is true. + bool allow_retry_on_failure = true; + + // Whether the allocator will deallocate free regions to avoid OOM due to + // memory fragmentation. + bool garbage_collection = false; + + // Controls when a chunk should be split, if its size exceeds the requested + // allocation size. + double fragmentation_fraction = 0; + }; + BFCAllocator(std::unique_ptr sub_allocator, size_t total_memory, + const string& name, const Options& opts); + + ~BFCAllocator() override; + + string Name() override { return name_; } + + void* AllocateRaw(size_t alignment, size_t num_bytes) override { + return AllocateRaw(alignment, num_bytes, AllocationAttributes()); + } + + void* AllocateRaw(size_t alignment, size_t num_bytes, + const AllocationAttributes& allocation_attr) override; + + void DeallocateRaw(void* ptr) override; + + bool TracksAllocationSizes() const override; + + size_t RequestedSize(const void* ptr) const override; + + size_t AllocatedSize(const void* ptr) const override; + + int64_t AllocationId(const void* ptr) const override; + + absl::optional GetStats() override; + + bool ClearStats() override; + + void SetTimingCounter(SharedCounter* sc) { timing_counter_ = sc; } + + void SetSafeFrontier(uint64 count) override; + + AllocatorMemoryType GetMemoryType() const override; + + bool ShouldRecordOpName() const { return true; } + + MemoryDump RecordMemoryMap(); + + private: + struct Bin; + + void* AllocateRawInternal(size_t alignment, size_t num_bytes, + bool dump_log_on_failure, + uint64 freed_before_count); + + void* AllocateRawInternalWithRetry( + size_t alignment, size_t num_bytes, + const AllocationAttributes& allocation_attr); + + void DeallocateRawInternal(void* ptr); + + // Chunks whose freed_at_count is later than the safe frontier value are kept + // on a special list and not subject to merging immediately upon being freed. + // + // This function sweeps that list looking for Chunks whose timestamp is now + // safe. When found their freed_at_count is set to 0 and we attempt to merge + // them with their neighbors. + // + // If required_bytes > 0 then this function is being called in the context of + // a need for this many bytes that could not be satisfied without merging + // unsafe chunks, so we go ahead and merge the unsafe chunks too, just up to + // the point that a free chunk of required_bytes is produced. Note that + // unsafe merged chunks adopt the most conservative timestamp from their + // constituents so they're only useful for allocations not requiring a + // particular timestamp. + bool MergeTimestampedChunks(size_t required_bytes) + TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + + // Return the largest free chunk bytes from the largest bin in constant time. + // The free chunks are sorted by size (and then address) in a bin. + int64_t LargestFreeChunk() TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + + // Add TraceMe (in memory allocation and deallocation) for memory stats + // profiling. The chunk_ptr is passed to get information such as address, + // chunk size and requested_size. + void AddTraceMe(absl::string_view traceme_name, const void* ptr) + TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + + // Overloaded AddTraceMe function with chunk information. + void AddTraceMe(absl::string_view traceme_name, const void* chunk_ptr, + int64_t req_bytes, int64_t alloc_bytes) + TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + + // A ChunkHandle is an index into the chunks_ vector in BFCAllocator + // kInvalidChunkHandle means an invalid chunk + typedef size_t ChunkHandle; + static constexpr ChunkHandle kInvalidChunkHandle = SIZE_MAX; + + typedef int BinNum; + static constexpr int kInvalidBinNum = -1; + // The following means that the largest bin'd chunk size is 256 << 21 = 512MB. + static constexpr int kNumBins = 21; + + // A Chunk points to a piece of memory that's either entirely free or entirely + // in use by one user memory allocation. + // + // An AllocationRegion's memory is split up into one or more disjoint Chunks, + // which together cover the whole region without gaps. Chunks participate in + // a doubly-linked list, and the prev/next pointers point to the physically + // adjacent chunks. + // + // Since a chunk cannot be partially in use, we may need to split a free chunk + // in order to service a user allocation. We always merge adjacent free + // chunks. + // + // Chunks contain information about whether they are in use or whether they + // are free, and contain a pointer to the bin they are in. + struct Chunk { + size_t size = 0; // Full size of buffer. + + // We sometimes give chunks that are larger than needed to reduce + // fragmentation. requested_size keeps track of what the client + // actually wanted so we can understand whether our splitting + // strategy is efficient. + size_t requested_size = 0; + + // allocation_id is set to -1 when the chunk is not in use. It is assigned a + // value greater than zero before the chunk is returned from + // AllocateRaw, and this value is unique among values assigned by + // the parent allocator. + int64_t allocation_id = -1; + void* ptr = nullptr; // pointer to granted subbuffer. + + // If not kInvalidChunkHandle, the memory referred to by 'prev' is directly + // preceding the memory used by this chunk. E.g., It should start + // at 'ptr - prev->size' + ChunkHandle prev = kInvalidChunkHandle; + + // If not kInvalidChunkHandle, the memory referred to by 'next' is directly + // following the memory used by this chunk. E.g., It should be at + // 'ptr + size' + ChunkHandle next = kInvalidChunkHandle; + + // What bin are we in? + BinNum bin_num = kInvalidBinNum; + + // Optional count when this chunk was most recently made free. + uint64 freed_at_count = 0; + + bool in_use() const { return allocation_id != -1; } + +#ifdef TENSORFLOW_MEM_DEBUG + // optional debugging info + const char* op_name = nullptr; + uint64 step_id = 0; + int64 action_count = 0; +#endif + + string DebugString(BFCAllocator* a, + bool recurse) TF_NO_THREAD_SAFETY_ANALYSIS { + string dbg; + strings::StrAppend( + &dbg, " Size: ", strings::HumanReadableNumBytes(size), + " | Requested Size: ", strings::HumanReadableNumBytes(requested_size), + " | in_use: ", in_use(), " | bin_num: ", bin_num); + if (recurse && prev != BFCAllocator::kInvalidChunkHandle) { + Chunk* p = a->ChunkFromHandle(prev); + strings::StrAppend(&dbg, ", prev: ", p->DebugString(a, false)); + } + if (recurse && next != BFCAllocator::kInvalidChunkHandle) { + Chunk* n = a->ChunkFromHandle(next); + strings::StrAppend(&dbg, ", next: ", n->DebugString(a, false)); + } +#ifdef TENSORFLOW_MEM_DEBUG + strings::StrAppend(&dbg, ", for: ", op_name ? op_name : "UNKNOWN", + ", stepid: ", step_id, + ", last_action: ", action_count); +#endif + return dbg; + } + }; + + // A Bin is a collection of similar-sized free chunks. + // Allocated chunks are never in a Bin. + struct Bin { + // All chunks in this bin have >= bin_size memory. + size_t bin_size = 0; + + class ChunkComparator { + public: + explicit ChunkComparator(BFCAllocator* allocator) + : allocator_(allocator) {} + // Sort first by size and then use pointer address as a tie breaker. + bool operator()(const ChunkHandle ha, + const ChunkHandle hb) const TF_NO_THREAD_SAFETY_ANALYSIS { + const Chunk* a = allocator_->ChunkFromHandle(ha); + const Chunk* b = allocator_->ChunkFromHandle(hb); + if (a->size != b->size) { + return a->size < b->size; + } + return a->ptr < b->ptr; + } + + private: + BFCAllocator* allocator_; // The parent allocator + }; + + typedef std::set FreeChunkSet; + // List of free chunks within the bin, sorted by chunk size. + // Chunk * not owned. + FreeChunkSet free_chunks; + Bin(BFCAllocator* allocator, size_t bs) + : bin_size(bs), free_chunks(ChunkComparator(allocator)) {} + }; + + static constexpr size_t kMinAllocationBits = 8; + static constexpr size_t kMinAllocationSize = 1 << kMinAllocationBits; + + // BFCAllocator allocates memory into a collection of disjoint + // AllocationRegions. Each AllocationRegion corresponds to one call to + // SubAllocator::Alloc(). (Actually, if a subsequent call to + // SubAllocator::Alloc() returns another region immediately adjacent to the + // last, it will be used to extend the first AllocationRegion, not create a + // separate one.) + // + // An AllocationRegion contains one or more Chunks, covering all of its + // memory. Its primary job is to map pointers to ChunkHandles. + // + // This class is thread-compatible. + class AllocationRegion { + public: + AllocationRegion(void* ptr, size_t memory_size) + : ptr_(ptr), + memory_size_(memory_size), + end_ptr_( + static_cast(static_cast(ptr_) + memory_size_)) { + DCHECK_EQ(0, memory_size % kMinAllocationSize); + const size_t n_handles = + (memory_size + kMinAllocationSize - 1) / kMinAllocationSize; + handles_.resize(n_handles, kInvalidChunkHandle); + } + + AllocationRegion() = default; + AllocationRegion(AllocationRegion&& other) { Swap(&other); } + AllocationRegion& operator=(AllocationRegion&& other) { + Swap(&other); + return *this; + } + + void* ptr() const { return ptr_; } + void* end_ptr() const { return end_ptr_; } + size_t memory_size() const { return memory_size_; } + void extend(size_t size) { + memory_size_ += size; + DCHECK_EQ(0, memory_size_ % kMinAllocationSize); + + end_ptr_ = static_cast(static_cast(end_ptr_) + size); + const size_t n_handles = + (memory_size_ + kMinAllocationSize - 1) / kMinAllocationSize; + handles_.resize(n_handles, kInvalidChunkHandle); + } + ChunkHandle get_handle(const void* p) const { + return handles_[IndexFor(p)]; + } + void set_handle(const void* p, ChunkHandle h) { handles_[IndexFor(p)] = h; } + void erase(const void* p) { set_handle(p, kInvalidChunkHandle); } + + private: + void Swap(AllocationRegion* other) { + std::swap(ptr_, other->ptr_); + std::swap(memory_size_, other->memory_size_); + std::swap(end_ptr_, other->end_ptr_); + std::swap(handles_, other->handles_); + } + + size_t IndexFor(const void* p) const { + std::uintptr_t p_int = reinterpret_cast(p); + std::uintptr_t base_int = reinterpret_cast(ptr_); + DCHECK_GE(p_int, base_int); + DCHECK_LT(p_int, base_int + memory_size_); + return static_cast(((p_int - base_int) >> kMinAllocationBits)); + } + + // Metadata about the allocation region. + void* ptr_ = nullptr; + size_t memory_size_ = 0; + void* end_ptr_ = nullptr; + + // Array of size "memory_size / kMinAllocationSize". It is + // indexed by (p-base) / kMinAllocationSize, contains ChunkHandle + // for the memory allocation represented by "p" + std::vector handles_; + + AllocationRegion(const AllocationRegion&) = delete; + void operator=(const AllocationRegion&) = delete; + }; + + // RegionManager aggregates one or more "AllocationRegions" and provides + // a layer of indirection from pointers to the underlying ChunkHandle, + // allowing allocation across multiple discontiguous memory regions. + // + // This class is thread-compatible. + class RegionManager { + public: + RegionManager() {} + ~RegionManager() {} + + void AddAllocationRegion(void* ptr, size_t memory_size) { + // Insert sorted by end_ptr. + auto entry = + std::upper_bound(regions_.begin(), regions_.end(), ptr, &Comparator); + regions_.insert(entry, AllocationRegion(ptr, memory_size)); + } + + // Adds an alloation region for the given ptr and size, potentially + // extending a region if ptr matches the end_ptr of an existing region. + // If a region is extended, returns a pointer to the extended region so that + // the BFC allocator can reason about chunkification. + AllocationRegion* AddOrExtendAllocationRegion(void* ptr, + size_t memory_size) { + // Insert sorted by end_ptr. + auto entry = + std::upper_bound(regions_.begin(), regions_.end(), ptr, &Comparator); + // Check if can be coalesced with preceding region. + if (entry != regions_.begin()) { + auto preceding_region = entry - 1; + if (preceding_region->end_ptr() == ptr) { + if (VLOG_IS_ON(1)) { + LOG(INFO) << "Extending region " << preceding_region->ptr() + << " of " + << strings::HumanReadableNumBytes( + preceding_region->memory_size()) + << " by " << strings::HumanReadableNumBytes(memory_size) + << " bytes"; + } + preceding_region->extend(memory_size); + return &*preceding_region; + } + } + VLOG(1) << "Inserting new region " << ptr << " of " + << strings::HumanReadableNumBytes(memory_size); + regions_.insert(entry, AllocationRegion(ptr, memory_size)); + return nullptr; + } + + std::vector::iterator RemoveAllocationRegion( + std::vector::iterator it) { + return regions_.erase(it); + } + + ChunkHandle get_handle(const void* p) const { + return RegionFor(p)->get_handle(p); + } + + void set_handle(const void* p, ChunkHandle h) { + return MutableRegionFor(p)->set_handle(p, h); + } + void erase(const void* p) { return MutableRegionFor(p)->erase(p); } + + const std::vector& regions() const { return regions_; } + + private: + static bool Comparator(const void* ptr, const AllocationRegion& other) { + return ptr < other.end_ptr(); + } + + AllocationRegion* MutableRegionFor(const void* p) { + return const_cast(RegionFor(p)); + } + + const AllocationRegion* RegionFor(const void* p) const { + auto entry = + std::upper_bound(regions_.begin(), regions_.end(), p, &Comparator); + + if (entry != regions_.end()) { + return &(*entry); + } + + LOG(FATAL) << "Could not find Region for " << p; + return nullptr; + } + + private: + std::vector regions_; + }; + + // Returns 'bytes' rounded up to the next highest kMinAllocationSize. + static size_t RoundedBytes(size_t bytes); + + // Try to add a new memory region that can satisfy an allocation of + // 'rounded_bytes' bytes. Returns true on success and false on + // failure. + bool Extend(size_t alignment, size_t rounded_bytes) + TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + + // Deallocate free regions to give back the memory to suballocator, so that + // we can re-allocate a larger region. The main use scenario of this function + // is when OOM happens but we have free regions and the sum of sizes of free + // regions and unallocated bytes is larger than the requested size, implying + // (external) memory fragmentation. Returns true if any free regions are + // found and freed; false otherwise. + bool DeallocateFreeRegions(size_t rounded_bytes); + + // Helper function to deallocate regions. + void DeallocateRegions(const absl::flat_hash_set& region_ptrs) + TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + + // Returns a pointer to an underlying allocated chunk of size + // 'rounded_bytes'. + void* FindChunkPtr(BinNum bin_num, size_t rounded_bytes, size_t num_bytes, + uint64 freed_before) TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + + // Splits the chunk specified by 'h' into two chunks, one at least + // of size 'num_bytes'. + void SplitChunk(ChunkHandle h, size_t num_bytes) + TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + + // Merges the two chunk handles. Requires that the chunks are + // contiguous in their allocation. + void Merge(ChunkHandle h, ChunkHandle h2) TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + + // Adds the chunk 'h' to the proper free bin. + void InsertFreeChunkIntoBin(ChunkHandle h) TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + + // Removes the free chunk pointed to by 'c' from the set free_chunks. + void RemoveFreeChunkIterFromBin(Bin::FreeChunkSet* free_chunks, + const Bin::FreeChunkSet::iterator& c) + TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + + // Removes a free chunk from the bin. + void RemoveFreeChunkFromBin(ChunkHandle h) TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + void MaybeRemoveFreeChunkFromBin(ChunkHandle h) + TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + + // Removes the chunk metadata represented by 'h'. + void DeleteChunk(ChunkHandle h) TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + + string RenderOccupancy() TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + void DumpMemoryLog(size_t num_bytes) TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + tensorflow::MemoryDump RecordMemoryMapInternal() + TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + void MaybeWriteMemoryMap() TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + + ChunkHandle AllocateChunk() TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + void DeallocateChunk(ChunkHandle h) TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + + Chunk* ChunkFromHandle(ChunkHandle h) TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + const Chunk* ChunkFromHandle(ChunkHandle h) const + TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + + void MarkFree(ChunkHandle h) TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + + ChunkHandle TryToCoalesce(ChunkHandle h, bool ignore_freed_at) + TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + + // Fragmentation is calculated as the reverse ratio of the largest free chunk + // size over total free memory, and returns a value within [0, 1]. + double GetFragmentation() TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + + // Information about a Bin that is useful for debugging. + struct BinDebugInfo { + size_t total_bytes_in_use = 0; + size_t total_bytes_in_bin = 0; + size_t total_requested_bytes_in_use = 0; + size_t total_chunks_in_use = 0; + size_t total_chunks_in_bin = 0; + }; + + // Computes and returns a BinDebugInfo for each Bin. + std::array get_bin_debug_info() + TF_EXCLUSIVE_LOCKS_REQUIRED(lock_); + + AllocatorRetry retry_helper_; + + // Structures immutable after construction + size_t memory_limit_ = 0; + + inline int Log2FloorNonZeroSlow(uint64 n) { + int r = 0; + while (n > 0) { + r++; + n >>= 1; + } + return r - 1; + } + + // Returns floor(log2(n)). + inline int Log2FloorNonZero(uint64 n) { +#if defined(__GNUC__) + return 63 ^ __builtin_clzll(n); +#elif defined(PLATFORM_WINDOWS) && (_WIN64) + unsigned long index; + _BitScanReverse64(&index, n); + return index; +#else + return Log2FloorNonZeroSlow(n); +#endif + } + + // Map from bin size to Bin + Bin* BinFromIndex(BinNum index) { + return reinterpret_cast(&(bins_space_[index * sizeof(Bin)])); + } + size_t BinNumToSize(BinNum index) { + return static_cast(256) << index; + } + BinNum BinNumForSize(size_t bytes) { + uint64 v = std::max(bytes, 256) >> kMinAllocationBits; + int b = std::min(kNumBins - 1, Log2FloorNonZero(v)); + return b; + } + Bin* BinForSize(size_t bytes) { return BinFromIndex(BinNumForSize(bytes)); } + + char bins_space_[sizeof(Bin) * kNumBins]; + + const Options opts_; + + // The size of the current region allocation. + size_t curr_region_allocation_bytes_; + + // An indicator that expansion of a region has hit the limits + // of the available memory. + bool started_backpedal_ = false; + + // Whether the allocator will coalesce adjacent sub allocator provided + // AllocationRegions. This may be disabled if discrete sub allocator + // regions can't be treated as contiguous (e.g. if the allocation refers to + // device visible memory which is not adjacent to the other region in the + // device's address space). + const bool coalesce_regions_; + + std::unique_ptr sub_allocator_; + string name_; + SharedCounter* timing_counter_ = nullptr; + std::deque timestamped_chunks_; + + std::atomic safe_frontier_ = {0}; + + // Structures mutable after construction + mutable mutex lock_; + RegionManager region_manager_ TF_GUARDED_BY(lock_); + + std::vector chunks_ TF_GUARDED_BY(lock_); + + // Pointer to head of linked list of free Chunks + ChunkHandle free_chunks_list_ TF_GUARDED_BY(lock_); + + // Counter containing the next unique identifier to assign to a + // newly-created chunk. + int64_t next_allocation_id_ TF_GUARDED_BY(lock_); + + // Stats. + AllocatorStats stats_ TF_GUARDED_BY(lock_); +#ifdef TENSORFLOW_MEM_DEBUG + int64 action_counter_ TF_GUARDED_BY(lock_) = 0; +#define MEM_DEBUG_SIZE_HISTORY_SIZE 4096 + int64 size_history_[MEM_DEBUG_SIZE_HISTORY_SIZE]; +#endif + + friend class GPUBFCAllocatorPrivateMethodsTest; + friend class GPUBFCAllocatorPrivateMethodsTest_SubAllocatorSpecific; + BFCAllocator(const BFCAllocator&) = delete; + void operator=(const BFCAllocator&) = delete; +}; + +} // namespace tsl + +#endif // TENSORFLOW_TSL_FRAMEWORK_BFC_ALLOCATOR_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/cancellation.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/cancellation.h new file mode 100644 index 0000000000000000000000000000000000000000..90792a742a528add3331ab22f72fca11f2652540 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/cancellation.h @@ -0,0 +1,217 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_CANCELLATION_H_ +#define TENSORFLOW_TSL_FRAMEWORK_CANCELLATION_H_ + +#include +#include + +#include "tsl/lib/gtl/flatmap.h" +#include "tsl/platform/hash.h" +#include "tsl/platform/mutex.h" +#include "tsl/platform/notification.h" +#include "tsl/platform/status.h" +#include "tsl/platform/stringpiece.h" +#include "tsl/platform/thread_annotations.h" +#include "tsl/platform/types.h" + +namespace tsl { + +// A token that can be used to register and deregister a +// CancelCallback with a CancellationManager. +// +// CancellationToken values must be created by a call to +// CancellationManager::get_cancellation_token. +typedef int64_t CancellationToken; + +// A callback that is invoked when a step is canceled. +// +// NOTE(mrry): See caveats about CancelCallback implementations in the +// comment for CancellationManager::RegisterCallback. +typedef std::function CancelCallback; + +// This class should never simultaneously be used as the cancellation manager +// for two separate sets of executions (i.e two separate steps, or two separate +// function executions). +class CancellationManager { + public: + // A value that won't be returned by get_cancellation_token(). + static const CancellationToken kInvalidToken; + + CancellationManager(); + + // Constructs a new CancellationManager that is a "child" of `*parent`. + // + // If `*parent` is cancelled, `*this` will be cancelled. `*parent` must + // outlive the created CancellationManager. + explicit CancellationManager(CancellationManager* parent); + + ~CancellationManager(); + + // Run all callbacks associated with this manager. + void StartCancel(); + + // Run all callbacks associated with this manager with a status. + // Currently the status is for logging purpose only. See also + // CancellationManager::RegisterCallbackWithErrorLogging. + void StartCancelWithStatus(const Status& status); + + // Returns true iff StartCancel() has been called. + bool IsCancelled() { return is_cancelled_.load(std::memory_order_acquire); } + + // Returns a token that must be used in calls to RegisterCallback + // and DeregisterCallback. + CancellationToken get_cancellation_token() { + return next_cancellation_token_.fetch_add(1); + } + + // Attempts to register the given callback to be invoked when this + // manager is cancelled. Returns true if the callback was + // registered; returns false if this manager was already cancelled, + // and the callback was not registered. + // + // If this method returns false, it is the caller's responsibility + // to perform any cancellation cleanup. + // + // This method is tricky to use correctly. The following usage pattern + // is recommended: + // + // class ObjectWithCancellableOperation { + // mutex mu_; + // void CancellableOperation(CancellationManager* cm, + // std::function callback) { + // bool already_cancelled; + // CancellationToken token = cm->get_cancellation_token(); + // { + // mutex_lock(mu_); + // already_cancelled = !cm->RegisterCallback( + // [this, token]() { Cancel(token); }); + // if (!already_cancelled) { + // // Issue asynchronous operation. Associate the pending operation + // // with `token` in some object state, or provide another way for + // // the Cancel method to look up the operation for cancellation. + // // Ensure that `cm->DeregisterCallback(token)` is called without + // // holding `mu_`, before `callback` is invoked. + // // ... + // } + // } + // if (already_cancelled) { + // callback(errors::Cancelled("Operation was cancelled")); + // } + // } + // + // void Cancel(CancellationToken token) { + // mutex_lock(mu_); + // // Take action to cancel the operation with the given cancellation + // // token. + // } + // + // NOTE(mrry): The caller should take care that (i) the calling code + // is robust to `callback` being invoked asynchronously (e.g. from + // another thread), (ii) `callback` is deregistered by a call to + // this->DeregisterCallback(token) when the operation completes + // successfully, and (iii) `callback` does not invoke any method + // on this cancellation manager. Furthermore, it is important that + // the eventual caller of the complementary DeregisterCallback does not + // hold any mutexes that are required by `callback`. + bool RegisterCallback(CancellationToken token, CancelCallback callback); + + // Similar to RegisterCallback, but if the cancellation manager starts a + // cancellation with an error status, it will log the error status before + // invoking the callback. `callback_name` is a human-readable name of the + // callback, which will be displayed on the log. + bool RegisterCallbackWithErrorLogging(CancellationToken token, + CancelCallback callback, + tsl::StringPiece callback_name); + + // Deregister the callback that, when registered, was associated + // with the given cancellation token. Returns true iff the callback + // was deregistered and will not be invoked; otherwise returns false + // after the callback has been invoked, blocking if necessary. + // + // NOTE(mrry): This method may block if cancellation is in progress. + // The caller of this method must not hold any mutexes that are required + // to invoke any cancellation callback that has been registered with this + // cancellation manager. + bool DeregisterCallback(CancellationToken token); + + // Deregister the callback that, when registered, was associated + // with the given cancellation token. Returns true iff the callback + // was deregistered and will not be invoked; otherwise returns false + // immediately, with no guarantee that the callback has completed. + // + // This method is guaranteed to return true if StartCancel has not been + // called. + bool TryDeregisterCallback(CancellationToken token); + + // Returns true iff cancellation is in progress. + bool IsCancelling(); + + private: + struct CallbackConfiguration { + CancelCallback callback; + std::string name; + bool log_error = false; + }; + + struct State { + Notification cancelled_notification; + gtl::FlatMap callbacks; + + // If this CancellationManager has any children, this member points to the + // head of a doubly-linked list of its children. + CancellationManager* first_child = nullptr; // Not owned. + }; + + bool RegisterCallbackConfig(CancellationToken token, + CallbackConfiguration config); + + bool RegisterChild(CancellationManager* child); + void DeregisterChild(CancellationManager* child); + + bool is_cancelling_; + std::atomic_bool is_cancelled_; + std::atomic next_cancellation_token_; + + CancellationManager* const parent_ = nullptr; // Not owned. + + // If this CancellationManager is associated with a parent, this member will + // be set to `true` after this is removed from the parent's list of children. + bool is_removed_from_parent_ TF_GUARDED_BY(parent_->mu_) = false; + + // If this CancellationManager is associated with a parent, these members form + // a doubly-linked list of that parent's children. + // + // These fields are valid only when `this->is_removed_from_parent_` is false. + CancellationManager* prev_sibling_ TF_GUARDED_BY(parent_->mu_) = + nullptr; // Not owned. + CancellationManager* next_sibling_ TF_GUARDED_BY(parent_->mu_) = + nullptr; // Not owned. + + mutex mu_; + std::unique_ptr state_ TF_GUARDED_BY(mu_); +}; + +// Registers the given cancellation callback, returning a function that can be +// used to deregister the callback. If `cancellation_manager` is NULL, no +// registration occurs and `deregister_fn` will be a no-op. +Status RegisterCancellationCallback(CancellationManager* cancellation_manager, + std::function callback, + std::function* deregister_fn); + +} // namespace tsl + +#endif // TENSORFLOW_TSL_FRAMEWORK_CANCELLATION_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/contraction/eigen_contraction_kernel.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/contraction/eigen_contraction_kernel.h new file mode 100644 index 0000000000000000000000000000000000000000..efb55e93de7559f9e4c340da322e693d93f3b891 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/contraction/eigen_contraction_kernel.h @@ -0,0 +1,905 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_CONTRACTION_EIGEN_CONTRACTION_KERNEL_H_ +#define TENSORFLOW_TSL_FRAMEWORK_CONTRACTION_EIGEN_CONTRACTION_KERNEL_H_ + +// Depending on a build configuration this header provides custom kernel for +// Eigen tensor contractions (small matrix multiplication kernel used to +// multiple together blocks of the original tensors). +// +// 1) --define tensorflow_mkldnn_contraction_kernel=1 +// Use Mkldnn single threaded sgemm. The mkldnn kernels are generated at +// runtime and use avx/avx2/fma/avx512 based on cpu status registers +// (https://en.wikipedia.org/wiki/CPUID). +// +// If you use `tensor.contract(other_tensor)` in your code, you must include +// this header to get the benefit of custom contraction kernel: +// +// #if defined(TENSORFLOW_USE_CUSTOM_CONTRACTION_KERNEL) +// #include +// "third_party/tensorflow/tsl/framework/contraction/eigen_contraction_kernel.h" +// #endif + +#include "unsupported/Eigen/CXX11/Tensor" // from @eigen_archive +#include "tsl/framework/fixedpoint/FixedPoint.h" + +#if defined(TENSORFLOW_USE_MKLDNN_CONTRACTION_KERNEL) +#include "dnnl.h" +#endif + +#include "tsl/platform/dynamic_annotations.h" + +namespace Eigen { +namespace internal { + +#if defined(TENSORFLOW_USE_CUSTOM_CONTRACTION_KERNEL) +// Returns `true` iff we can use custom contraction kernels. This is a runtime +// check, that uses environment variables. +EIGEN_DEVICE_FUNC EIGEN_DONT_INLINE bool UseCustomContractionKernels(); + +// Pack a 2D block of a Tensor expression into contiguous block of memory with +// col-major storage order. We do not have access to the underlying Tensor +// expression, we only have a DataMapper (TensorContractionInputMapper for +// tensor contractions, or blas_data_mapper for plain tensors), that provides a +// two-dimensional view into the Tensor expression. +// +// Default Eigen gemm_pack_rhs and gemm_pack_lhs pack blocks of tensor +// expressions into the packed format described in "Anatomy of High-Performance +// Matrix Multiplication" paper (1). Eigen::internal::gebp_kernel relies on this +// packing format for efficient micro-panel multiplication. +// +// This simple packing can be used with any '?gemm' function from BLAS +// libraries, that work with col-major matrices. +// +// (1) http://www.cs.utexas.edu/~flame/pubs/GotoTOMS_revision.pdf +// +// IMPORTANT: `gemm_pack_colmajor_block` always packs the block in column major +// order, DataMapperStorageOrder specifies the storage order of the underlying +// Tensor expression. +template +struct gemm_pack_colmajor_block; + +// gemm_pack_colmajor_block for ColMajor storage order. +template +struct gemm_pack_colmajor_block { + typedef typename internal::packet_traits::type Packet; + typedef typename DataMapper::LinearMapper LinearMapper; + + enum { PacketSize = internal::packet_traits::size }; + + EIGEN_DONT_INLINE + void operator()(Scalar* block, const DataMapper& data_mapper, IndexType rows, + IndexType cols) { + const IndexType unrolled_rows = rows - 4 * PacketSize; + const IndexType vectorized_rows = rows - PacketSize; + + for (IndexType col = 0; col < cols; ++col) { + LinearMapper lm = data_mapper.getLinearMapper(0, col); + + IndexType row = 0; + // Give compiler a strong possibility to unroll the loop. + for (; row <= unrolled_rows; row += 4 * PacketSize) { + for (IndexType j = 0; j < 4; ++j) { + const Packet p = lm.template loadPacket(row + j * PacketSize); + internal::pstoreu(block + j * PacketSize, p); + } + block += 4 * PacketSize; + } + // Process remaining rows with packets. + for (; row <= vectorized_rows; row += PacketSize) { + const Packet p = lm.template loadPacket(row); + internal::pstoreu(block, p); + block += PacketSize; + } + // Finalize with coefficients. + for (; row < rows; ++row) { + *block = lm(row); + ++block; + } + } + } +}; + +#endif // TENSORFLOW_USE_CUSTOM_CONTRACTION_KERNEL + +// Enabled by build option: "--define tensorflow_mkldnn_contraction_kernel=1" +#if defined(TENSORFLOW_USE_MKLDNN_CONTRACTION_KERNEL) + +template +struct dnnl_gemm_kernel; + +// dnnl_gemm_kernel for floats defined as a thin layer on top of mkldnn_sgemm. +template +struct dnnl_gemm_kernel { + static_assert(!ConjugateLhs, "DNNL kernel doesn't support ConjugateLhs"); + static_assert(!ConjugateRhs, "DNNL kernel doesn't support ConjugateRhs"); + + static constexpr int kComputeStrideFromBlockDimensions = -1; + + using LhsScalar = float; + using RhsScalar = float; + using ResScalar = float; + + EIGEN_DONT_INLINE + void operator()(const OutputMapper& output, const LhsScalar* blockA, + const RhsScalar* blockB, const IndexType rows, + const IndexType depth, const IndexType cols, float alpha, + float beta, int ldA = kComputeStrideFromBlockDimensions, + int ldB = kComputeStrideFromBlockDimensions, + char transposeA = 'N', char transposeB = 'N') { + static const int max_index = (std::numeric_limits::max)(); + + eigen_assert(max_index >= rows); + eigen_assert(max_index >= cols); + eigen_assert(max_index >= depth); + eigen_assert(max_index >= output.stride()); + + const int m = static_cast(rows); + const int n = static_cast(cols); + const int k = static_cast(depth); + + ldA = ldA == kComputeStrideFromBlockDimensions ? m : ldA; + ldB = ldB == kComputeStrideFromBlockDimensions ? k : ldB; + const int ldC = static_cast(output.stride()); + + // DNNL takes row-major matrices. Our packed column-major matrices can be + // viewed as a transposed row-major matrix, i.e., + // C_colmajor = C_rowmajor^T = (A_rowmajor * B_rowmajor)^T + // = B_rowmajor^T * A_rowmajor^T + // = B_colmajor * A_colmajor + // So we can just swap the input matrices A and B for DNNL. + // TODO(penporn): Switch to row-major packing instead. + dnnl_status_t st = + dnnl_sgemm(transposeB, transposeA, n, m, k, alpha, blockB, ldB, blockA, + ldA, beta, const_cast(output.data()), ldC); + eigen_assert(st == 0); + +#if DYNAMIC_ANNOTATIONS_ENABLED == 1 || defined(MEMORY_SANITIZER) + for (IndexType col = 0; col < cols; ++col) { + ResScalar* row_base = &output(0, col); + EIGEN_UNUSED_VARIABLE(row_base); // Suppress unused variable error. + TF_ANNOTATE_MEMORY_IS_INITIALIZED(row_base, sizeof(ResScalar) * rows); + } +#endif + + // eigen_assert is a no-op in optimized mode so we add these to avoid + // compiler's unused-variable errors. + EIGEN_UNUSED_VARIABLE(max_index); + EIGEN_UNUSED_VARIABLE(st); + } +}; + +template +struct mkldnn_gemm_s8u8s32_kernel { + static_assert(!ConjugateLhs, "DNNL kernel doesn't support ConjugateLhs"); + static_assert(!ConjugateRhs, "DNNL kernel doesn't support ConjugateRhs"); + + static constexpr int kComputeStrideFromBlockDimensions = -1; + + using LhsScalar = Eigen::QInt8; + using RhsScalar = Eigen::QUInt8; + using ResScalar = Eigen::QInt32; + + EIGEN_DONT_INLINE + void operator()(const OutputMapper& output, const LhsScalar* blockA, + const RhsScalar* blockB, const IndexType rows, + const IndexType depth, const IndexType cols, float alpha, + float beta, int ldA = kComputeStrideFromBlockDimensions, + int ldB = kComputeStrideFromBlockDimensions, + char transposeA = 'N', char transposeB = 'N') { + static const int max_index = (std::numeric_limits::max)(); + + eigen_assert(max_index >= rows); + eigen_assert(max_index >= cols); + eigen_assert(max_index >= depth); + eigen_assert(max_index >= output.stride()); + + const int m = static_cast(rows); + const int n = static_cast(cols); + const int k = static_cast(depth); + + ldA = ldA == kComputeStrideFromBlockDimensions ? m : ldA; + ldB = ldB == kComputeStrideFromBlockDimensions ? k : ldB; + const int ldC = static_cast(output.stride()); + + // Currently we support only symmetric quantization with zero point at 0. + const int8_t ao = 0; + const int8_t bo = 0; + + // Don't add any offset to the result C. + const char offsetc = 'F'; + const int32_t co = 0; + + const auto* A = reinterpret_cast(blockA); + const auto* B = reinterpret_cast(blockB); + auto* C = reinterpret_cast(const_cast(output.data())); + + // DNNL takes row-major matrices. Our packed column-major matrices can be + // viewed as a transposed row-major matrix, i.e., C_colmajor = C_rowmajor^T. + // C_colmajor = C_rowmajor^T = (A_rowmajor * B_rowmajor)^T + // = B_rowmajor^T * A_rowmajor^T + // = B_colmajor * A_colmajor + // So we can just swap the input matrices A and B for DNNL. + // TODO(penporn): Switch to row-major packing instead. + dnnl_status_t st = dnnl_gemm_u8s8s32(transposeB, transposeA, offsetc, // + n, m, k, // + alpha, // + B, ldB, bo, // + A, ldA, ao, // + beta, // + C, ldC, &co); + eigen_assert(st == 0); + +#if DYNAMIC_ANNOTATIONS_ENABLED == 1 || defined(MEMORY_SANITIZER) + for (IndexType col = 0; col < cols; ++col) { + ResScalar* row_base = &output(0, col); + EIGEN_UNUSED_VARIABLE(row_base); // Suppress unused variable error. + TF_ANNOTATE_MEMORY_IS_INITIALIZED(row_base, sizeof(ResScalar) * rows); + } +#endif + + // eigen_assert is a no-op in optimized mode so we add these to avoid + // compiler's unused-variable errors. + EIGEN_UNUSED_VARIABLE(max_index); + EIGEN_UNUSED_VARIABLE(st); + } +}; + +// For mkldnn_sgemm having the right dimensions (especially for small matrices) +// is more important than fitting all the working set in L1/L2 caches. +// TODO(ezhulenev): Do better heuristics. +template +class TensorContractionBlocking { + // For now mkldnn has only mkldnn_sgemm (gemm for floats). + using Scalar = float; + + // Adjust the block sizes to work well with mkldnn kernels. + + // Multiply default choice of block size along M and N dimensions. + // TODO(ezhulenev): Explore if this can work in general (kScaleM=2.0 worked + // well in some of models). + static constexpr float kScaleM = 1.5; + static constexpr float kScaleN = 1.0; + + // Mkldnn Avx/Avx2/Avx512 unroll factors are: 8/16/48. + static constexpr StorageIndex kUnrollM = 48; + + // Mkldnn Avx/Avx2/Avx512 unroll factors are: 6/6/8. + static constexpr StorageIndex kUnrollN = 24; + + public: + TensorContractionBlocking(StorageIndex k, StorageIndex m, StorageIndex n, + StorageIndex num_threads = 1) + : kc_(k), mc_(m), nc_(n) { + // 1. Compute block sizes using default Eigen heuristics. + if (sharding_type == ShardByCol) { + computeProductBlockingSizes(kc_, mc_, nc_, + num_threads); + } else { + computeProductBlockingSizes(kc_, nc_, mc_, + num_threads); + } + + // If dimensions do not pass basic sanity checks return immediately. + if (kc_ <= 0 || mc_ <= 0 || nc_ <= 0) return; + + // If we are using default Eigen gebp kernel there is no need to adjust the + // block sizes for DNNL. + if (!UseCustomContractionKernels()) return; + + // 2. And refine them to work well with mkldnn sgemm. + mc_ = (std::min)( + m, Eigen::divup(static_cast(mc_ * kScaleM), kUnrollM) * + kUnrollM); + nc_ = (std::min)( + n, Eigen::divup(static_cast(nc_ * kScaleN), kUnrollN) * + kUnrollN); + + // We split Kth dimensions in roughly equal slices. + StorageIndex target_k_slices = + (std::max)(StorageIndex(1), Eigen::divup(k, kc_)); + StorageIndex packet_size = internal::packet_traits::size; + if (packet_size < 8) packet_size = 8; + StorageIndex target_bk = + Eigen::divup(k / target_k_slices, packet_size) * packet_size; + kc_ = (std::min)(k, target_bk); + } + + EIGEN_ALWAYS_INLINE StorageIndex kc() const { return kc_; } + EIGEN_ALWAYS_INLINE StorageIndex mc() const { return mc_; } + EIGEN_ALWAYS_INLINE StorageIndex nc() const { return nc_; } + + private: + StorageIndex kc_; + StorageIndex mc_; + StorageIndex nc_; +}; + +template +class TensorContractionBlocking { + // TODO(ezhulenev): Define proper gebp_traits in Eigen for quantized types? + + // Default Eigen block heuristics for `QInt8xQUInt8 -> QInt32` are wrong. + // Mostly because gebp_traits are not correctly defined. But we know that we + // are going to use s8u8s32_gemm from DNNL, so we use float heuristics, and + // adjust them to work well with DNNL. + using LhsScalar = Eigen::QInt8; + using RhsScalar = Eigen::QUInt8; + using ResScalar = Eigen::QInt32; + + // Multiply default choice of block size along M, N and K dimensions. + static constexpr float kScaleM = 1.5; + static constexpr float kScaleN = 1.5; + static constexpr float kScaleK = 1.5; + + public: + TensorContractionBlocking(StorageIndex k, StorageIndex m, StorageIndex n, + StorageIndex num_threads = 1) + : kc_(k), mc_(m), nc_(n) { + // Each dimension is a multiple of 32 (fits into _m256i). + mc_ = (std::min)(m, static_cast(192)); + nc_ = (std::min)(n, static_cast(288)); + kc_ = (std::min)(k, static_cast(320)); + } + + EIGEN_ALWAYS_INLINE StorageIndex kc() const { return kc_; } + EIGEN_ALWAYS_INLINE StorageIndex mc() const { return mc_; } + EIGEN_ALWAYS_INLINE StorageIndex nc() const { return nc_; } + + private: + StorageIndex kc_; + StorageIndex mc_; + StorageIndex nc_; +}; + +// If the Lhs or Rhs Tensor expressions are already evaluated and have access to +// raw data, we can skip packing step and setup pointers and a stride to the +// underlying memory buffer and pass them directly to Gemm. +template +struct ColMajorBlock { + bool is_direct_access; + + // Valid iff `is_direct_access == false` + Scalar* packed_data; + + // Valid iff `is_direct_access == true` + Scalar* raw_data; + StorageIndex stride; + char transpose; +}; + +template +struct DirectColMajorAccess { + enum { value = false }; + + template + static bool block(const typename DataMapper::SubMapper& data_mapper, + const StorageIndex rows, const StorageIndex cols, + const StorageIndex num_kernels, + ColMajorBlock* block) { + eigen_assert(false && "Not implemented"); + return false; + } +}; + +// If we have an access to raw memory of the contraction input, we can safely +// skip packing if: +// (1) Packing is a no-op. +// (2) Packed block will be used just once. +// +// If a packed block is used many times, it's more efficient to pack it into +// contiguous block of memory to reduce pressure on TLB. +// +// TODO(ezhulenev): Add support for more tensor expressions that matters. +#define REGISTER_DIRECT_COL_MAJOR_ACCESS(TENSOR_EXPR) \ + template \ + struct DirectColMajorAccess, \ + nocontract_t, contract_t, packet_size, /*inner_dim_contiguous=*/true, \ + /*inner_dim_reordered=*/false, Alignment>> { \ + enum { value = true }; \ + \ + using DataMapper = TensorContractionInputMapper< \ + Scalar, StorageIndex, Side, TensorEvaluator, \ + nocontract_t, contract_t, packet_size, /*inner_dim_contiguous=*/true, \ + /*inner_dim_reordered=*/false, Alignment>; \ + \ + static bool block(const typename DataMapper::SubMapper& data_mapper, \ + const StorageIndex rows, const StorageIndex cols, \ + const StorageIndex num_kernels, \ + ColMajorBlock* block) { \ + static_assert(DataMapper::DirectOffsets == true, \ + "DataMapper must support direct offsets"); \ + \ + const StorageIndex vert_offset = data_mapper.vert_offset(); \ + const StorageIndex horiz_offset = data_mapper.horiz_offset(); \ + const StorageIndex stride = \ + Side == Lhs ? data_mapper.base_mapper().stride() \ + : data_mapper.base_mapper().nocontract_strides()[0]; \ + const Scalar* data = data_mapper.base_mapper().tensor().data(); \ + data = Side == Lhs ? data : data + vert_offset + horiz_offset * stride; \ + \ + const bool is_no_op_packing = stride == rows; \ + const StorageIndex addressable_mem = (stride * cols * sizeof(Scalar)); \ + const bool use_direct_access = \ + is_no_op_packing || num_kernels == 1 /* used once */ || \ + ((num_kernels == 2) && \ + (addressable_mem < (256 << 10) /* 256 kb */)); \ + \ + if (use_direct_access) { \ + block->is_direct_access = true; \ + block->raw_data = const_cast(data); \ + block->stride = stride; \ + block->transpose = 'N'; \ + return true; \ + } \ + return false; \ + } \ + } + +#define SIMPLE_TENSOR const Tensor + +#define TENSOR_MAP_ROWMAJOR \ + const TensorMap, \ + Eigen::Aligned> + +#define TENSOR_MAP_COLMAJOR \ + const TensorMap, \ + Eigen::Aligned> + +#define TENSOR_MAP_CONST_ROWMAJOR \ + const TensorMap, \ + Eigen::Aligned> + +#define TENSOR_MAP_CONST_COLMAJOR \ + const TensorMap, \ + Eigen::Aligned> + +// This is reshaped convolution filter from `eigen_spatial_convolutions.h`. +#define TENSOR_RESHAPE \ + const TensorReshapingOp< \ + const Eigen::DSizes, \ + const TensorMap, \ + Eigen::Aligned>> + +REGISTER_DIRECT_COL_MAJOR_ACCESS(SIMPLE_TENSOR); +REGISTER_DIRECT_COL_MAJOR_ACCESS(TENSOR_MAP_ROWMAJOR); +REGISTER_DIRECT_COL_MAJOR_ACCESS(TENSOR_MAP_COLMAJOR); +REGISTER_DIRECT_COL_MAJOR_ACCESS(TENSOR_MAP_CONST_ROWMAJOR); +REGISTER_DIRECT_COL_MAJOR_ACCESS(TENSOR_MAP_CONST_COLMAJOR); +REGISTER_DIRECT_COL_MAJOR_ACCESS(TENSOR_RESHAPE); + +#undef SIMPLE_TENSOR +#undef TENSOR_MAP_ROWMAJOR +#undef TENSOR_MAP_COLMAJOR +#undef TENSOR_MAP_CONST_ROWMAJOR +#undef TENSOR_MAP_CONST_COLMAJOR +#undef TENSOR_RESHAPE +#undef REGISTER_DIRECT_COL_MAJOR_ACCESS + +template +struct GemmKernelProvider { + enum { Defined = 0 }; + using GemmKernel = void; +}; + +template +struct GemmKernelProvider { + enum { Defined = 1 }; + using GemmKernel = dnnl_gemm_kernel; +}; + +template +struct GemmKernelProvider { + enum { Defined = 1 }; + using GemmKernel = mkldnn_gemm_s8u8s32_kernel; +}; + +// NOTE: 'std::enable_if' doesn't work for template specializations. See +// "default template argument in a class template partial specialization". + +// Tensor contraction kernel that can fallback on Eigen gebp_kernel at runtime. +#define REGISTER_TENSOR_CONTRACTION_KERNEL_WITH_FALLBACK( \ + RES_SCALAR, LHS_SCALAR, RHS_SCALAR) \ + \ + template \ + struct TensorContractionKernel { \ + TensorContractionKernel(StorageIndex m, StorageIndex k, StorageIndex n, \ + StorageIndex bm, StorageIndex bk, StorageIndex bn) \ + : m(m), k(k), n(n), bm(bm), bk(bk), bn(bn) {} \ + \ + enum { HasBeta = true }; \ + \ + using ResScalar = RES_SCALAR; \ + using LhsScalar = LHS_SCALAR; \ + using RhsScalar = RHS_SCALAR; \ + \ + using Traits = typename internal::gebp_traits; \ + \ + using LhsBlock = ColMajorBlock; \ + using RhsBlock = ColMajorBlock; \ + \ + using DirectLhsAccess = DirectColMajorAccess; \ + using DirectRhsAccess = DirectColMajorAccess; \ + \ + /* Packed Lhs/Rhs block memory allocator.*/ \ + typedef TensorContractionBlockMemAllocator \ + BlockMemAllocator; \ + typedef typename BlockMemAllocator::BlockMemHandle BlockMemHandle; \ + \ + using LhsPacker = \ + gemm_pack_colmajor_block; \ + using RhsPacker = \ + gemm_pack_colmajor_block; \ + \ + using GemmKernelProviderType = \ + GemmKernelProvider; \ + static_assert( \ + GemmKernelProviderType::Defined, \ + "Custom GEMM kernel is not registered for given scalar types"); \ + using GemmKernel = typename GemmKernelProviderType::GemmKernel; \ + \ + /* Fallback on default Eigen pack and GEBP kernel if custom contraction */ \ + /* kernels disabled at runtime. */ \ + using EigenLhsPacker = \ + gemm_pack_lhs; \ + using EigenRhsPacker = \ + gemm_pack_rhs; \ + using GebpKernel = \ + gebp_kernel; \ + \ + template \ + EIGEN_DEVICE_FUNC BlockMemHandle allocate(Device& d, LhsBlock* lhs_block, \ + RhsBlock* rhs_block) { \ + return BlockMemAllocator::allocate( \ + d, bm, bk, bn, &lhs_block->packed_data, &rhs_block->packed_data); \ + } \ + \ + template \ + EIGEN_DEVICE_FUNC BlockMemHandle \ + allocateSlices(Device& d, const int num_lhs, const int num_rhs, \ + const int num_slices, std::vector* lhs_blocks, \ + std::vector* rhs_blocks) { \ + eigen_assert(num_slices > 0); \ + std::vector> lhs_mem(num_slices); \ + std::vector> rhs_mem(num_slices); \ + \ + BlockMemHandle block_mem = BlockMemAllocator::allocateSlices( \ + d, bm, bk, bn, num_lhs, num_rhs, num_slices, lhs_mem.data(), \ + rhs_mem.data()); \ + \ + for (Index x = 0; x < num_slices; x++) { \ + if (num_lhs > 0) lhs_blocks[x].resize(num_lhs); \ + for (Index m = 0; m < num_lhs; m++) { \ + lhs_blocks[x][m].packed_data = lhs_mem[x][m]; \ + } \ + if (num_rhs > 0) rhs_blocks[x].resize(num_rhs); \ + for (Index n = 0; n < num_rhs; n++) { \ + rhs_blocks[x][n].packed_data = rhs_mem[x][n]; \ + } \ + } \ + \ + return block_mem; \ + } \ + \ + template \ + EIGEN_DEVICE_FUNC static void deallocate(Device& d, \ + BlockMemHandle handle) { \ + BlockMemAllocator::deallocate(d, handle); \ + } \ + \ + EIGEN_DEVICE_FUNC EIGEN_DONT_INLINE void packLhs( \ + LhsBlock* lhsBlock, const typename LhsMapper::SubMapper& data_mapper, \ + const StorageIndex depth, const StorageIndex rows) { \ + if (UseCustomContractionKernels()) { \ + const bool is_direct_access = \ + DirectLhsAccess::value && \ + DirectLhsAccess::block(data_mapper, rows, depth, \ + bn > 0 ? divup(n, bn) : 0, lhsBlock); \ + \ + if (!is_direct_access) { \ + lhsBlock->is_direct_access = false; \ + LhsPacker()(lhsBlock->packed_data, data_mapper, rows, depth); \ + } \ + } else { \ + lhsBlock->is_direct_access = false; \ + EigenLhsPacker()(lhsBlock->packed_data, data_mapper, depth, rows, \ + /*stride*/ 0, /*offset*/ 0); \ + } \ + } \ + \ + EIGEN_DEVICE_FUNC EIGEN_DONT_INLINE void packRhs( \ + RhsBlock* rhsBlock, const typename RhsMapper::SubMapper& data_mapper, \ + const StorageIndex depth, const StorageIndex cols) { \ + if (UseCustomContractionKernels()) { \ + const bool is_direct_access = \ + DirectRhsAccess::value && \ + DirectRhsAccess::block(data_mapper, depth, cols, \ + bm > 0 ? divup(m, bm) : 0, rhsBlock); \ + \ + if (!is_direct_access) { \ + rhsBlock->is_direct_access = false; \ + RhsPacker()(rhsBlock->packed_data, data_mapper, depth, cols); \ + } \ + } else { \ + rhsBlock->is_direct_access = false; \ + EigenRhsPacker()(rhsBlock->packed_data, data_mapper, depth, cols); \ + } \ + } \ + \ + EIGEN_DEVICE_FUNC EIGEN_DONT_INLINE void invoke( \ + const OutputMapper& output_mapper, const LhsBlock& lhsBlock, \ + const RhsBlock& rhsBlock, const StorageIndex rows, \ + const StorageIndex depth, const StorageIndex cols, const float alpha, \ + const float beta) { \ + if (UseCustomContractionKernels()) { \ + if ((DirectLhsAccess::value && lhsBlock.is_direct_access) && \ + (DirectRhsAccess::value && rhsBlock.is_direct_access)) { \ + GemmKernel()(output_mapper, lhsBlock.raw_data, rhsBlock.raw_data, \ + rows, depth, cols, alpha, beta, \ + /*ldA=*/lhsBlock.stride, /*ldB=*/rhsBlock.stride, \ + /*transposeA=*/lhsBlock.transpose, \ + /*transposeB=*/rhsBlock.transpose); \ + \ + } else if (DirectLhsAccess::value && lhsBlock.is_direct_access) { \ + GemmKernel()(output_mapper, lhsBlock.raw_data, rhsBlock.packed_data, \ + rows, depth, cols, alpha, beta, \ + /*ldA=*/lhsBlock.stride, \ + /*ldB=*/GemmKernel::kComputeStrideFromBlockDimensions, \ + /*transposeA=*/lhsBlock.transpose, /*transposeB=*/'N'); \ + \ + } else if (DirectRhsAccess::value && rhsBlock.is_direct_access) { \ + GemmKernel()(output_mapper, lhsBlock.packed_data, rhsBlock.raw_data, \ + rows, depth, cols, alpha, beta, \ + /*ldA=*/GemmKernel::kComputeStrideFromBlockDimensions, \ + /*ldB=*/rhsBlock.stride, /*transposeA=*/'N', \ + /*transposeB=*/rhsBlock.transpose); \ + \ + } else { \ + GemmKernel()(output_mapper, lhsBlock.packed_data, \ + rhsBlock.packed_data, rows, depth, cols, alpha, beta); \ + } \ + } else { \ + /* Gebp kernel does not support beta, so we have to clear memory in */ \ + /* the output mapper manually. */ \ + /* WARNING(ezhulenev): This is optimized into a memset in a loop, */ \ + /* could be much slower for small matrices. Currently this code */ \ + /* path used only for testing, and performance does not matter. */ \ + if (beta == 0.0) { \ + for (StorageIndex col = 0; col < cols; ++col) { \ + ResScalar* output_base = &output_mapper(0, col); \ + typedef Array OutputRow; \ + typedef Map> OutputRowMap; \ + OutputRowMap(output_base, rows).setZero(); \ + } \ + } \ + \ + GebpKernel()( \ + output_mapper, lhsBlock.packed_data, rhsBlock.packed_data, rows, \ + depth, cols, alpha, \ + /*strideA*/ GemmKernel::kComputeStrideFromBlockDimensions, \ + /*strideB*/ GemmKernel::kComputeStrideFromBlockDimensions, \ + /*offsetA*/ 0, /*offsetB*/ 0); \ + } \ + } \ + \ + private: \ + /* These are dimensions of the original Tensors, and selected block */ \ + /* sizes. The actual block sizes passed to all function above might be */ \ + /* smaller because of the partial blocks at the end. */ \ + const StorageIndex m; \ + const StorageIndex k; \ + const StorageIndex n; \ + const StorageIndex bm; \ + const StorageIndex bk; \ + const StorageIndex bn; \ + } + +// Tensor contraction kernel that do not fallback on Eigen. Currently not all +// data types are supported by Eigen data packing and default gebp_kernel. +#define REGISTER_TENSOR_CONTRACTION_KERNEL_NO_FALLBACK(RES_SCALAR, LHS_SCALAR, \ + RHS_SCALAR) \ + \ + template \ + struct TensorContractionKernel { \ + TensorContractionKernel(StorageIndex m, StorageIndex k, StorageIndex n, \ + StorageIndex bm, StorageIndex bk, StorageIndex bn) \ + : m(m), k(k), n(n), bm(bm), bk(bk), bn(bn) {} \ + \ + enum { HasBeta = true }; \ + \ + using ResScalar = RES_SCALAR; \ + using LhsScalar = LHS_SCALAR; \ + using RhsScalar = RHS_SCALAR; \ + \ + using Traits = typename internal::gebp_traits; \ + \ + using LhsBlock = ColMajorBlock; \ + using RhsBlock = ColMajorBlock; \ + \ + using DirectLhsAccess = DirectColMajorAccess; \ + using DirectRhsAccess = DirectColMajorAccess; \ + \ + /* Packed Lhs/Rhs block memory allocator.*/ \ + typedef TensorContractionBlockMemAllocator \ + BlockMemAllocator; \ + typedef typename BlockMemAllocator::BlockMemHandle BlockMemHandle; \ + \ + using LhsPacker = \ + gemm_pack_colmajor_block; \ + using RhsPacker = \ + gemm_pack_colmajor_block; \ + \ + using GemmKernelProviderType = \ + GemmKernelProvider; \ + static_assert( \ + GemmKernelProviderType::Defined, \ + "Custom GEMM kernel is not registered for given scalar types"); \ + using GemmKernel = typename GemmKernelProviderType::GemmKernel; \ + \ + template \ + EIGEN_DEVICE_FUNC BlockMemHandle allocate(Device& d, LhsBlock* lhs_block, \ + RhsBlock* rhs_block) { \ + return BlockMemAllocator::allocate( \ + d, bm, bk, bn, &lhs_block->packed_data, &rhs_block->packed_data); \ + } \ + \ + template \ + EIGEN_DEVICE_FUNC BlockMemHandle \ + allocateSlices(Device& d, const int num_lhs, const int num_rhs, \ + const int num_slices, std::vector* lhs_blocks, \ + std::vector* rhs_blocks) { \ + eigen_assert(num_slices > 0); \ + std::vector> lhs_mem(num_slices); \ + std::vector> rhs_mem(num_slices); \ + \ + BlockMemHandle block_mem = BlockMemAllocator::allocateSlices( \ + d, bm, bk, bn, num_lhs, num_rhs, num_slices, lhs_mem.data(), \ + rhs_mem.data()); \ + \ + for (Index x = 0; x < num_slices; x++) { \ + if (num_lhs > 0) lhs_blocks[x].resize(num_lhs); \ + for (Index m = 0; m < num_lhs; m++) { \ + lhs_blocks[x][m].packed_data = lhs_mem[x][m]; \ + } \ + if (num_rhs > 0) rhs_blocks[x].resize(num_rhs); \ + for (Index n = 0; n < num_rhs; n++) { \ + rhs_blocks[x][n].packed_data = rhs_mem[x][n]; \ + } \ + } \ + \ + return block_mem; \ + } \ + \ + template \ + EIGEN_DEVICE_FUNC static void deallocate(Device& d, \ + BlockMemHandle handle) { \ + BlockMemAllocator::deallocate(d, handle); \ + } \ + \ + EIGEN_DEVICE_FUNC EIGEN_DONT_INLINE void packLhs( \ + LhsBlock* lhsBlock, const typename LhsMapper::SubMapper& data_mapper, \ + const StorageIndex depth, const StorageIndex rows) { \ + const bool is_direct_access = \ + DirectLhsAccess::value && \ + DirectLhsAccess::block(data_mapper, rows, depth, \ + bn > 0 ? divup(n, bn) : 0, lhsBlock); \ + \ + if (!is_direct_access) { \ + lhsBlock->is_direct_access = false; \ + LhsPacker()(lhsBlock->packed_data, data_mapper, rows, depth); \ + } \ + } \ + \ + EIGEN_DEVICE_FUNC EIGEN_DONT_INLINE void packRhs( \ + RhsBlock* rhsBlock, const typename RhsMapper::SubMapper& data_mapper, \ + const StorageIndex depth, const StorageIndex cols) { \ + const bool is_direct_access = \ + DirectRhsAccess::value && \ + DirectRhsAccess::block(data_mapper, depth, cols, \ + bm > 0 ? divup(m, bm) : 0, rhsBlock); \ + \ + if (!is_direct_access) { \ + rhsBlock->is_direct_access = false; \ + RhsPacker()(rhsBlock->packed_data, data_mapper, depth, cols); \ + } \ + } \ + \ + EIGEN_DEVICE_FUNC EIGEN_DONT_INLINE void invoke( \ + const OutputMapper& output_mapper, const LhsBlock& lhsBlock, \ + const RhsBlock& rhsBlock, const StorageIndex rows, \ + const StorageIndex depth, const StorageIndex cols, const float alpha, \ + const float beta) { \ + if ((DirectLhsAccess::value && lhsBlock.is_direct_access) && \ + (DirectRhsAccess::value && rhsBlock.is_direct_access)) { \ + GemmKernel()(output_mapper, lhsBlock.raw_data, rhsBlock.raw_data, \ + rows, depth, cols, alpha, beta, /*ldA=*/lhsBlock.stride, \ + /*ldB=*/rhsBlock.stride, \ + /*transposeA=*/lhsBlock.transpose, \ + /*transposeB=*/rhsBlock.transpose); \ + \ + } else if (DirectLhsAccess::value && lhsBlock.is_direct_access) { \ + GemmKernel()(output_mapper, lhsBlock.raw_data, rhsBlock.packed_data, \ + rows, depth, cols, alpha, beta, /*ldA=*/lhsBlock.stride, \ + /*ldB=*/GemmKernel::kComputeStrideFromBlockDimensions, \ + /*transposeA=*/lhsBlock.transpose, /*transposeB=*/'N'); \ + \ + } else if (DirectRhsAccess::value && rhsBlock.is_direct_access) { \ + GemmKernel()(output_mapper, lhsBlock.packed_data, rhsBlock.raw_data, \ + rows, depth, cols, alpha, beta, \ + /*ldA=*/GemmKernel::kComputeStrideFromBlockDimensions, \ + /*ldB=*/rhsBlock.stride, /*transposeA=*/'N', \ + /*transposeB=*/rhsBlock.transpose); \ + \ + } else { \ + GemmKernel()(output_mapper, lhsBlock.packed_data, \ + rhsBlock.packed_data, rows, depth, cols, alpha, beta); \ + } \ + } \ + \ + private: \ + /* These are dimensions of the original Tensors, and selected block */ \ + /* sizes. The actual block sizes passed to all function above might be */ \ + /* smaller because of the partial blocks at the end. */ \ + const StorageIndex m; \ + const StorageIndex k; \ + const StorageIndex n; \ + const StorageIndex bm; \ + const StorageIndex bk; \ + const StorageIndex bn; \ + } + +REGISTER_TENSOR_CONTRACTION_KERNEL_WITH_FALLBACK(float, float, float); +REGISTER_TENSOR_CONTRACTION_KERNEL_NO_FALLBACK(Eigen::QInt32, Eigen::QInt8, + Eigen::QUInt8); + +#undef REGISTER_TENSOR_CONTRACTION_KERNEL + +#endif // defined(TENSORFLOW_USE_MKLDNN_CONTRACTION_KERNEL) + +} // namespace internal +} // namespace Eigen + +#endif // TENSORFLOW_TSL_FRAMEWORK_CONTRACTION_EIGEN_CONTRACTION_KERNEL_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/convolution/eigen_convolution_helpers.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/convolution/eigen_convolution_helpers.h new file mode 100644 index 0000000000000000000000000000000000000000..5b94994d4084bb1610537c1019ce41d59bd02718 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/convolution/eigen_convolution_helpers.h @@ -0,0 +1,87 @@ +/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_CONVOLUTION_EIGEN_CONVOLUTION_HELPERS_H_ +#define TENSORFLOW_TSL_FRAMEWORK_CONVOLUTION_EIGEN_CONVOLUTION_HELPERS_H_ + +#include "unsupported/Eigen/CXX11/Tensor" // from @eigen_archive + +namespace Eigen { +namespace internal { + +// TensorEvaluatorHasPartialPacket +// provides `value` that is true if TensorEvaluatorType has `PacketType +// partialPacket(IndexType, unpacket_traits::mask_t) +// const` and if the PacketType supports masked load. +// +// Partial packets are used to: +// +// 1) Split the packet over two columns in eigen based spatial convolution and +// use partial loads for each individual part before combining them to get the +// required packet. This class is used to pick the correct implementation of +// loadPacketStandard function. +// +// 2) Split the packet over two rows (within the same column) in eigen based +// cuboid convolution and use partial loads for each individual part before +// combining them to get the required packet. This class is used to pick the +// correct implementation of loadPacketStandard function. This usage is similar +// to the usage in eigen based spatial convolution described above. +// +// 3) Finalize packing of columns in gemm_pack_colmajor after processing +// vectorized part with full packets (see eigen_spatial_convolutions.h). +template +class TensorEvaluatorHasPartialPacket { + public: + template + static auto functionExistsSfinae( + typename std::enable_if< + unpacket_traits::masked_load_available && + std::is_same() + .template partialPacket( + std::declval(), + std::declval::mask_t>()))>::value>:: + type*) -> std::true_type; + + template + static auto functionExistsSfinae(...) -> std::false_type; + + typedef decltype(functionExistsSfinae(nullptr)) status; + + static constexpr bool value = status::value; +}; + +// Compute a mask for loading/storing coefficients in/from a packet in a +// [from, to) range. If the mask bit is 1, element will be loaded/stored. +template +EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE + typename std::enable_if::masked_load_available, + typename unpacket_traits::mask_t>::type + mask(int from, int to) { + const Index packet_size = internal::unpacket_traits::size; + eigen_assert(0 <= from && to <= (packet_size + 1) && from < to); + + using Mask = typename internal::unpacket_traits::mask_t; + const Mask mask_max = std::numeric_limits::max(); + + return (mask_max >> (packet_size - to)) ^ (mask_max >> (packet_size - from)); +} + +} // namespace internal +} // namespace Eigen + +#endif // TENSORFLOW_TSL_FRAMEWORK_CONVOLUTION_EIGEN_CONVOLUTION_HELPERS_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/convolution/eigen_spatial_convolutions-inl.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/convolution/eigen_spatial_convolutions-inl.h new file mode 100644 index 0000000000000000000000000000000000000000..fe689c9f40c95b18a822fc5ea62a05bf46c0a007 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/convolution/eigen_spatial_convolutions-inl.h @@ -0,0 +1,1772 @@ +/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_CONVOLUTION_EIGEN_SPATIAL_CONVOLUTIONS_INL_H_ +#define TENSORFLOW_TSL_FRAMEWORK_CONVOLUTION_EIGEN_SPATIAL_CONVOLUTIONS_INL_H_ + +#include "tsl/framework/convolution/eigen_convolution_helpers.h" + +// Note this header is used in both TF and TFLite. +namespace Eigen { + +namespace internal { + +#if !EIGEN_ALTIVEC_USE_CUSTOM_PACK +// WARNING: Most of the code here implicitly assumes that the matrix is in +// ColMajor layout. This is guaranteed by the tensor contraction (see +// TensorContraction.h). +// +// Inside Eigen a tensor contraction is represented by a matrix multiplication. +// We don't want to actually extract image patches and reshape the result into +// a matrix (this involves allocating huge extra memory), so the patch +// extraction and reshape operations are implicit. +// +// TensorContractionInputMapper takes a matrix index and returns the coefficient +// (or the packet) of the "virtual tensor", that would be at that index if we +// were to actually reshape the result of patch extraction. +// +// TensorContractionSubMapper provides a similar view into the "virtual matrix" +// at the given vertical and horizontal offsets. +// +// "Virtual matrix" dimensions: +// *0: kernelChannels * kernelRows * kernelCols; +// 1: out_height * out_width; * OTHERS (e.g batches, etc...) +// +// *) extracted patches are continuous in memory (innermost dimension assuming +// col major layout) +// +// With this dimensions: +// row - offset within a single patch (in code: patchId) +// col - index of the extracted patch (in code: patchIndex) +// patchIndex ∈ [0..num_patches * OTHERS] (batch and other dimensions) +// +// TODO(ezhulenev): Consolidate this part of the code with the image patch +// extraction code since they are both very similar. + +template +class TensorContractionInputMapper< + Scalar_, Index, Side, + TensorEvaluator< + const TensorReshapingOp >, + Device>, + nocontract_t, contract_t, packet_size, inner_dim_contiguous, + inner_dim_reordered, Alignment> { + public: + typedef Scalar_ Scalar; + + typedef TensorContractionInputMapper< + Scalar, Index, Side, + TensorEvaluator< + const TensorReshapingOp< + NewDimension, const TensorImagePatchOp >, + Device>, + nocontract_t, contract_t, packet_size, inner_dim_contiguous, + inner_dim_reordered, Alignment> + Self; + + typedef TensorContractionSubMapper< + Scalar, Index, Side, + TensorEvaluator< + const TensorReshapingOp< + NewDimension, const TensorImagePatchOp >, + Device>, + nocontract_t, contract_t, packet_size, inner_dim_contiguous, + inner_dim_reordered, Alignment> + SubMapper; + + typedef SubMapper VectorMapper; + typedef SubMapper LinearMapper; + typedef typename packet_traits::type Packet; + + typedef TensorEvaluator TensorEvaluatorT; + + EIGEN_DEVICE_FUNC + TensorContractionInputMapper( + const TensorEvaluator< + const TensorReshapingOp< + NewDimension, const TensorImagePatchOp >, + Device>& tensor, + const nocontract_t&, const nocontract_t&, const contract_t&, + const contract_t&) + : m_impl(tensor.impl().impl()) { + Index patch_rows; + Index patch_depth; + if (internal::traits::Layout == ColMajor) { + patch_depth = tensor.impl().dimensions()[0]; + patch_rows = tensor.impl().dimensions()[1]; + m_patch_cols = tensor.impl().dimensions()[2]; + m_num_patches = tensor.impl().dimensions()[3]; + } else { + const size_t NumDims = tensor.impl().dimensions().size(); + patch_depth = tensor.impl().dimensions()[NumDims - 1]; + patch_rows = tensor.impl().dimensions()[NumDims - 2]; + m_patch_cols = tensor.impl().dimensions()[NumDims - 3]; + m_num_patches = tensor.impl().dimensions()[NumDims - 4]; + } + + // Strides for navigating through the single patch. + m_patch_row_stride = patch_depth; + m_patch_col_stride = patch_rows * m_patch_row_stride; + + m_patch_row_inflate_strides = tensor.impl().rowInflateStride(); + m_patch_col_inflate_strides = tensor.impl().colInflateStride(); + + m_colStride = patch_rows; + + m_outputRows = tensor.impl().outputRows(); + m_outputCols = tensor.impl().outputCols(); + m_row_strides = tensor.impl().userRowStride(); + m_col_strides = tensor.impl().userColStride(); + + m_in_row_strides = tensor.impl().userInRowStride(); + m_in_col_strides = tensor.impl().userInColStride(); + + if (internal::traits::Layout == ColMajor) { + m_inputRows = tensor.impl().impl().dimensions()[1]; + m_inputCols = tensor.impl().impl().dimensions()[2]; + } else { + const int NumDims = tensor.impl().impl().dimensions().size(); + m_inputRows = tensor.impl().impl().dimensions()[NumDims - 2]; + m_inputCols = tensor.impl().impl().dimensions()[NumDims - 3]; + } + + m_rowInputStride = patch_depth; + m_colInputStride = patch_depth * m_inputRows; + m_patchInputStride = patch_depth * m_inputRows * m_inputCols; + + m_rowPaddingTop = tensor.impl().rowPaddingTop(); + m_colPaddingLeft = tensor.impl().colPaddingLeft(); + + m_fastPatchRowStride = + internal::TensorIntDivisor(m_patch_row_stride); + m_fastPatchColStride = + internal::TensorIntDivisor(m_patch_col_stride); + m_fastInputRowStride = + internal::TensorIntDivisor(m_patch_row_inflate_strides); + m_fastInputColStride = + internal::TensorIntDivisor(m_patch_col_inflate_strides); + m_fastNumPatches = internal::TensorIntDivisor(m_num_patches); + m_fastColStride = internal::TensorIntDivisor(m_colStride); + m_fastOutputRows = internal::TensorIntDivisor(m_outputRows); + m_fastDimZero = internal::TensorIntDivisor(patch_depth); + } + + EIGEN_DEVICE_FUNC + TensorContractionInputMapper(const TensorContractionInputMapper& base_mapper) + : m_impl(base_mapper.m_impl) { + m_patch_cols = base_mapper.m_patch_cols; + m_num_patches = base_mapper.m_num_patches; + + m_patch_row_stride = base_mapper.m_patch_row_stride; + m_patch_col_stride = base_mapper.m_patch_col_stride; + + m_patch_row_inflate_strides = base_mapper.m_patch_row_inflate_strides; + m_patch_col_inflate_strides = base_mapper.m_patch_col_inflate_strides; + + m_colStride = base_mapper.m_colStride; + + m_rowInputStride = base_mapper.m_rowInputStride; + m_colInputStride = base_mapper.m_colInputStride; + m_patchInputStride = base_mapper.m_patchInputStride; + + m_inputRows = base_mapper.m_inputRows; + m_inputCols = base_mapper.m_inputCols; + + m_outputRows = base_mapper.m_outputRows; + m_outputCols = base_mapper.m_outputCols; + m_row_strides = base_mapper.m_row_strides; + m_col_strides = base_mapper.m_col_strides; + + m_in_row_strides = base_mapper.m_in_row_strides; + m_in_col_strides = base_mapper.m_in_col_strides; + + m_rowPaddingTop = base_mapper.m_rowPaddingTop; + m_colPaddingLeft = base_mapper.m_colPaddingLeft; + + m_fastPatchRowStride = base_mapper.m_fastPatchRowStride; + m_fastPatchColStride = base_mapper.m_fastPatchColStride; + m_fastInputRowStride = base_mapper.m_fastInputRowStride; + m_fastInputColStride = base_mapper.m_fastInputColStride; + m_fastNumPatches = base_mapper.m_fastNumPatches; + m_fastColStride = base_mapper.m_fastColStride; + m_fastOutputRows = base_mapper.m_fastOutputRows; + m_fastDimZero = base_mapper.m_fastDimZero; + } + + // If true, turns off some optimizations for loading packets since the image + // patches are "non-standard" such as there are non-trivial strides or + // inflations in the input. + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE bool nonStandardPatches() const { + return m_in_row_strides != 1 || m_in_col_strides != 1 || + m_patch_row_inflate_strides != 1 || m_patch_col_inflate_strides != 1; + } + + EIGEN_DEVICE_FUNC + EIGEN_STRONG_INLINE SubMapper getSubMapper(Index i, Index j) const { + return SubMapper(*this, i, j); + } + + EIGEN_DEVICE_FUNC + EIGEN_STRONG_INLINE LinearMapper getLinearMapper(Index i, Index j) const { + return LinearMapper(*this, i, j); + } + + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Scalar operator()(Index row) const { + Index rowIndex, colIndex, otherIndex; + computeBaseIndices(0, rowIndex, colIndex, otherIndex); + return loadCoeff(row, rowIndex, colIndex, otherIndex); + } + + // Load the coefficient at the patchIndex location instead of the usual + // m_rowIndex, + // m_colIndex, m_otherIndex. This is currently only used by the gpu code. + // EIGEN_DEVICE_FUNC + EIGEN_DEVICE_FUNC + EIGEN_STRONG_INLINE Scalar operator()(Index row, Index patchIndex) const { + Index rowIndex, colIndex, otherIndex; + computeBaseIndices(patchIndex, rowIndex, colIndex, otherIndex); + return loadCoeff(row, rowIndex, colIndex, otherIndex); + } + + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Packet loadPacket(Index row) const { + Index rowIndex, colIndex, otherIndex; + computeBaseIndices(0, rowIndex, colIndex, otherIndex); + return loadPacket(row, rowIndex, colIndex, otherIndex); + } + + // Load the packet at the patchIndex location instead of the usual m_rowIndex, + // m_colIndex, m_otherIndex. This is currently only used by the gpu code. + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Packet loadPacket(Index row, Index patchIndex) const { + Index rowIndex, colIndex, otherIndex; + computeBaseIndices(patchIndex, rowIndex, colIndex, otherIndex); + return loadPacket(row, rowIndex, colIndex, otherIndex); + } + + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE const TensorEvaluator& impl() const { + return m_impl; + } + + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Index patchDepth() const { return m_rowInputStride; } + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Index patchRows() const { return m_colStride; } + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Index patchCols() const { return m_patch_cols; } + + private: + friend class TensorContractionSubMapper< + Scalar, Index, Side, + TensorEvaluator< + const TensorReshapingOp< + NewDimension, const TensorImagePatchOp >, + Device>, + nocontract_t, contract_t, packet_size, inner_dim_contiguous, + inner_dim_reordered, Alignment>; + + // Load coefficient from a patch specified by the "within patch offset" + // (patchId) and the precomputed indices of the first element of the patch. + EIGEN_DEVICE_FUNC + EIGEN_STRONG_INLINE Scalar loadCoeff(Index patchId, Index rowIndex, + Index colIndex, Index otherIndex) const { + // Find the offset of the element wrt the location of the first element. + const Index patchOffset = patchId / m_fastDimZero; + + const Index colOffset = patchOffset / m_fastColStride; + const Index inputCol = colIndex + colOffset * m_in_col_strides; + const Index origInputCol = + (m_patch_col_inflate_strides == 1) + ? inputCol + : ((inputCol >= 0) ? (inputCol / m_fastInputColStride) : 0); + + const Index rowOffset = patchOffset - colOffset * m_colStride; + const Index inputRow = rowIndex + rowOffset * m_in_row_strides; + const Index origInputRow = + (m_patch_row_inflate_strides == 1) + ? inputRow + : ((inputRow >= 0) ? (inputRow / m_fastInputRowStride) : 0); + if (origInputCol < 0 || origInputRow < 0 || origInputCol >= m_inputCols || + origInputRow >= m_inputRows || + (inputCol != origInputCol * m_patch_col_inflate_strides) || + (inputRow != origInputRow * m_patch_row_inflate_strides)) { + return Scalar(0); + } + const Index depth = patchId - patchOffset * patchDepth(); + const Index inputIndex = depth + origInputRow * m_rowInputStride + + origInputCol * m_colInputStride + otherIndex; + return m_impl.coeff(inputIndex); + } + + // This is the same as loadCoeff(...), but optimized for all `inflate_strides` + // and `in_strides` equal to 1 (template specialization without templates). + EIGEN_DEVICE_FUNC + EIGEN_STRONG_INLINE Scalar loadCoeffStandard(Index patchId, Index rowIndex, + Index colIndex, + Index otherIndex) const { + eigen_assert(!nonStandardPatches()); + + // Find the offset of the element wrt the location of the first element. + const Index patchOffset = patchId / m_fastDimZero; + const Index colOffset = patchOffset / m_fastColStride; + const Index rowOffset = patchOffset - colOffset * m_colStride; + const Index inputCol = colIndex + colOffset; + const Index inputRow = rowIndex + rowOffset; + if (inputCol < 0 || inputCol >= m_inputCols || inputRow < 0 || + inputRow >= m_inputRows) { + return Scalar(0); + } + const Index depth = patchId - patchOffset * patchDepth(); + const Index inputIndex = depth + inputRow * m_rowInputStride + + inputCol * m_colInputStride + otherIndex; + return m_impl.coeff(inputIndex); + } + + // Load packet from a patch specified by the "within patch offset" + // (patchId) and the precomputed indices of the first element of the patch. + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Packet loadPacket(Index patchId, Index rowIndex, + Index colIndex, + Index otherIndex) const { + const Index packetSize = internal::unpacket_traits::size; + EIGEN_STATIC_ASSERT(packetSize > 1, YOU_MADE_A_PROGRAMMING_MISTAKE) + eigen_assert(patchId < patchDepth() * patchRows() * m_patch_cols); + + if (nonStandardPatches()) { + return packetWithPossibleZero(patchId, rowIndex, colIndex, otherIndex); + } + typedef decltype(m_impl) TensorEvaluatorT; + return loadPacketStandard(patchId, rowIndex, + colIndex, otherIndex); + } + + // Helper function to load a 'partial' packet - this is the single column + // part of a packet that is split across two columns. In the 'partial' packet, + // the elements corresponding to the column (specified through colOffset) are + // loaded and the rest of the elements are zero-filled into the 'partial' + // packet. This function is called from loadPacketStandardFromTwoColumns(). + // This code path is exercised only when the packet type supports masked load + // and when the partial packet load is available in the TensorEvaluator. + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Packet loadPartialPacketStandard( + Index rowIndex, Index colIndex, Index otherIndex, Index patchId, + const Index span[], const Index patchOffsets[], Index colOffset) const { + const Index inputCol = colIndex + colOffset; + const Index rowOffsets[2] = {patchOffsets[0] - colOffset * m_colStride, + patchOffsets[1] - colOffset * m_colStride}; + const Index inputRows[2] = {rowIndex + rowOffsets[0], + rowIndex + rowOffsets[1]}; + + if (inputRows[0] >= m_inputRows || inputRows[1] < 0 || + inputCol >= m_inputCols || inputCol < 0) { + // Partial packet is all zeros + return internal::pset1(Scalar(0)); + } else if (inputRows[0] >= 0 && inputRows[1] < m_inputRows) { + // From inputIndex-span[0], we need to load elements starting from index + // span[0] all the way upto (and including) span[1]. + const Index depth = patchId - patchOffsets[0] * patchDepth(); + const Index inputIndex = depth + inputRows[0] * m_rowInputStride + + inputCol * m_colInputStride + otherIndex; + return m_impl.template partialPacket( + inputIndex - span[0], mask(span[0], span[1] + 1)); + } else { + // Using slow path for this partial packet. + // We need to load elements starting from index span[0] all the way upto + // (and including) span[1]. We split this load into 3 parts: + // 0 : span[0]-1 - Zeros will be loaded for these indices + // span[0] : span[1] - Elements will be loaded here for these indices + // span[1]+1 : packetSize-1 - Zeross will be loaded for these indices + const Index packetSize = internal::unpacket_traits::size; + EIGEN_ALIGN_MAX + std::remove_const_t values[packetSize]; + for (int i = 0; i < span[0]; ++i) values[i] = Scalar(0); + for (int i = span[0]; i < span[1] + 1; ++i) + values[i] = + loadCoeff(patchId - span[0] + i, rowIndex, colIndex, otherIndex); + for (int i = span[1] + 1; i < packetSize; ++i) values[i] = Scalar(0); + return internal::pload(values); + } + } + + // Helper function to load a packet that is split across two columns. + // If required, this function is called from loadPacketStandard() when the + // packet type supports masked load and when the partial packet load is + // available in the TensorEvaluator. + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Packet loadPacketStandardFromTwoColumns( + Index patchId, Index rowIndex, Index colIndex, Index otherIndex, + const Index patchOffsets[], const Index colOffsets[]) const { + eigen_assert(colOffsets[1] == colOffsets[0] + 1); + const Index packetSize = internal::unpacket_traits::size; + + // Packet to load will be split into 2 parts where each part spans a single + // column. First determine where to split. + const Index patchIdSplit = + ((colOffsets[1] * m_colStride) * m_rowInputStride) - 1; + const Index patchOffsetSplit = patchIdSplit / m_fastDimZero; + + // patchIds[i]: patchId corresponding to partial packet i + // spans[i]: Start and end indices corresponding to the elements + // to be loaded for partial packet i + // patchOffsets2Cols[i]: patchOffsets corresponding to partial packet i + const Index patchIds[2] = {patchId, patchIdSplit + 1}; + const Index spans[2][2] = {{0, patchIdSplit - patchId}, + {patchIdSplit - patchId + 1, packetSize - 1}}; + const Index patchOffsets2Cols[2][2] = { + {patchOffsets[0], patchOffsetSplit}, + {patchOffsetSplit + 1, patchOffsets[1]}}; + + // Load partial packets and do bit-wise OR to generate required packet + return internal::por( + loadPartialPacketStandard(rowIndex, colIndex, otherIndex, patchIds[0], + spans[0], patchOffsets2Cols[0], + colOffsets[0]), + loadPartialPacketStandard(rowIndex, colIndex, otherIndex, patchIds[1], + spans[1], patchOffsets2Cols[1], + colOffsets[1])); + } + + // Helper function to load a packet that is present in a single columns. + // If required, this function is called from loadPacketStandard(). + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Packet loadPacketStandardFromSingleColumn( + Index patchId, Index rowIndex, Index colIndex, Index otherIndex, + const Index patchOffsets[], const Index colOffsets[], + const Index inputCols[]) const { + eigen_assert(colOffsets[0] == colOffsets[1]); + const Index rowOffsets[2] = {patchOffsets[0] - colOffsets[0] * m_colStride, + patchOffsets[1] - colOffsets[1] * m_colStride}; + eigen_assert(rowOffsets[0] <= rowOffsets[1]); + const Index inputRows[2] = {rowIndex + rowOffsets[0], + rowIndex + rowOffsets[1]}; + + if (inputRows[0] >= m_inputRows || inputRows[1] < 0) { + // all zeros + return internal::pset1(Scalar(0)); // all zeros + } + + if (inputRows[0] >= 0 && inputRows[1] < m_inputRows) { + // no padding + const Index depth = patchId - patchOffsets[0] * patchDepth(); + const Index inputIndex = depth + inputRows[0] * m_rowInputStride + + inputCols[0] * m_colInputStride + otherIndex; + return m_impl.template packet(inputIndex); + } + return packetWithPossibleZero(patchId, rowIndex, colIndex, otherIndex); + } + + // Load standard packet from a patch specified by the "within patch offset" + // (patchId) and the precomputed indices of the first element of the patch. + // This function will be called if partial packet loading is not available + // for the TensorEvaluator or if the packet type does not support masked + // load. + template + EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE typename std::enable_if< + !TensorEvaluatorHasPartialPacket::value, + PacketT>::type + loadPacketStandard(Index patchId, Index rowIndex, Index colIndex, + Index otherIndex) const { + const Index packetSize = internal::unpacket_traits::size; + EIGEN_STATIC_ASSERT(packetSize > 1, YOU_MADE_A_PROGRAMMING_MISTAKE) + eigen_assert(patchId < patchDepth() * patchRows() * m_patch_cols); + + eigen_assert(!nonStandardPatches()); + + if ((patchDepth() % packetSize) == 0) { + return loadPacketFast(patchId, rowIndex, colIndex, otherIndex); + } + + // Offsets and input calculation here are identical to + // loadCoeffStandard(...), but repeated twice. + const Index patchOffsets[2] = {patchId / m_fastDimZero, + (patchId + packetSize - 1) / m_fastDimZero}; + const Index colOffsets[2] = {patchOffsets[0] / m_fastColStride, + patchOffsets[1] / m_fastColStride}; + const Index inputCols[2] = {colIndex + colOffsets[0], + colIndex + colOffsets[1]}; + + if (inputCols[0] >= m_inputCols || inputCols[1] < 0) { + // all zeros + return internal::pset1(Scalar(0)); + } + if (inputCols[0] == inputCols[1]) { + return loadPacketStandardFromSingleColumn(patchId, rowIndex, colIndex, + otherIndex, patchOffsets, + colOffsets, inputCols); + } + return packetWithPossibleZero(patchId, rowIndex, colIndex, otherIndex); + } + + // Load standard packet from a patch specified by the "within patch offset" + // (patchId) and the precomputed indices of the first element of the patch. + // This function will be called if partial packet loading is available for + // the TensorEvaluator and if the packet type supports masked load. + // The only difference between this and the other case is that if the packet + // to load is split across two columns, then in this case instead of going to + // the slow (element-by-element) load, we load two packets - each containing + // elements from one of the columns (rest of the elements of the packets are + // zeroes), and then combine these two packets to generate the required + // packet. The idea is to enable fast load (if possible) of these 'partial' + // packets. + template + EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE typename std::enable_if< + TensorEvaluatorHasPartialPacket::value, + PacketT>::type + loadPacketStandard(Index patchId, Index rowIndex, Index colIndex, + Index otherIndex) const { + const Index packetSize = internal::unpacket_traits::size; + EIGEN_STATIC_ASSERT(packetSize > 1, YOU_MADE_A_PROGRAMMING_MISTAKE) + eigen_assert(patchId < patchDepth() * patchRows() * m_patch_cols); + + eigen_assert(!nonStandardPatches()); + + if ((patchDepth() % packetSize) == 0) { + return loadPacketFast(patchId, rowIndex, colIndex, otherIndex); + } + + // Offsets and input calculation here are identical to + // loadCoeffStandard(...), but repeated twice. + const Index patchOffsets[2] = {patchId / m_fastDimZero, + (patchId + packetSize - 1) / m_fastDimZero}; + const Index colOffsets[2] = {patchOffsets[0] / m_fastColStride, + patchOffsets[1] / m_fastColStride}; + const Index inputCols[2] = {colIndex + colOffsets[0], + colIndex + colOffsets[1]}; + + if (inputCols[0] >= m_inputCols || inputCols[1] < 0) { + // all zeros + return internal::pset1(Scalar(0)); + } + if (inputCols[0] == inputCols[1]) { + return loadPacketStandardFromSingleColumn(patchId, rowIndex, colIndex, + otherIndex, patchOffsets, + colOffsets, inputCols); + } + if (inputCols[1] == inputCols[0] + 1) { + return loadPacketStandardFromTwoColumns( + patchId, rowIndex, colIndex, otherIndex, patchOffsets, colOffsets); + } + return packetWithPossibleZero(patchId, rowIndex, colIndex, otherIndex); + } + + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Packet loadPacketFast(Index patchId, Index rowIndex, + Index colIndex, + Index otherIndex) const { + const Index packetSize = internal::unpacket_traits::size; + EIGEN_STATIC_ASSERT(packetSize > 1, YOU_MADE_A_PROGRAMMING_MISTAKE) + eigen_assert(patchId < patchDepth() * patchRows() * m_patch_cols); + + eigen_assert(!nonStandardPatches()); + eigen_assert((patchDepth() % packetSize) == 0); + // Find the offset of the element wrt the location of the first element. + const Index patchOffset = patchId / m_fastDimZero; + eigen_assert((patchId + packetSize - 1) / m_fastDimZero == patchOffset); + + const Index colOffset = patchOffset / m_fastColStride; + const Index rowOffset = patchOffset - colOffset * m_colStride; + const Index inputCol = colIndex + colOffset; + const Index inputRow = rowIndex + rowOffset; + if (inputCol < 0 || inputRow < 0 || inputCol >= m_inputCols || + inputRow >= m_inputRows) { + // all zeros + return internal::pset1(Scalar(0)); + } + // no padding + const Index depth = patchId - patchOffset * patchDepth(); + const Index inputIndex = depth + inputRow * m_rowInputStride + + inputCol * m_colInputStride + otherIndex; + return m_impl.template packet(inputIndex); + } + + EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet packetWithPossibleZero( + Index patchId, Index rowIndex, Index colIndex, Index otherIndex) const { + const int packetSize = internal::unpacket_traits::size; + EIGEN_ALIGN_MAX + std::remove_const_t values[packetSize]; + for (int i = 0; i < packetSize; ++i) { + values[i] = loadCoeff(patchId + i, rowIndex, colIndex, otherIndex); + } + Packet rslt = internal::pload(values); + return rslt; + } + + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void computeBaseIndices( + Index patchIndex, Index& rowIndex, Index& colIndex, + Index& otherIndex) const { + const size_t NumInputDims = array_size< + typename TensorEvaluator::Dimensions>::value; + otherIndex = (NumInputDims == 3) ? 0 : patchIndex / m_fastNumPatches; + const Index patch2DIndex = (NumInputDims == 3) + ? patchIndex + : (patchIndex - otherIndex * m_num_patches); + otherIndex *= m_patchInputStride; + colIndex = patch2DIndex / m_fastOutputRows; + rowIndex = patch2DIndex - colIndex * m_outputRows; + colIndex = colIndex * m_col_strides - m_colPaddingLeft; + rowIndex = rowIndex * m_row_strides - m_rowPaddingTop; + } + + Index m_patch_cols; // number of columns in the patch + Index m_num_patches; // number of patches to extract. + + // Strides for navigating through the single patch. + Index m_patch_row_stride; + Index m_patch_col_stride; + internal::TensorIntDivisor m_fastPatchRowStride; + internal::TensorIntDivisor m_fastPatchColStride; + + Index m_patch_row_inflate_strides; // the strides for row inflation in the + // image patch + Index m_patch_col_inflate_strides; // the strides for col inflation in the + // image patch + // Fast representation of inflation strides. + internal::TensorIntDivisor m_fastInputRowStride; + internal::TensorIntDivisor m_fastInputColStride; + + Index m_otherStride; + Index m_colStride; + internal::TensorIntDivisor m_fastNumPatches; + internal::TensorIntDivisor m_fastColStride; + + Index m_rowInputStride; // row stride in the input tensor + Index m_colInputStride; // col stride in the input tensor + Index m_patchInputStride; // patch stride in the input tensor + + Index m_inputRows; // Number of rows in the input tensor + Index m_inputCols; // Number of cols in the input tensor + + Index m_outputRows; // Number of convolution output rows + Index m_outputCols; // Number of convolution output column + + Index m_row_strides; // User specified row stride + Index m_col_strides; // User specified col stride + + Index m_in_row_strides; // User specified input row stride + Index m_in_col_strides; // User specified input col stride + + Index m_rowPaddingTop; // Row padding + Index m_colPaddingLeft; // Column padding + + internal::TensorIntDivisor m_fastOutputRows; + internal::TensorIntDivisor m_fastDimZero; + + const TensorEvaluator m_impl; +}; + +template +class TensorContractionSubMapper< + Scalar, Index, Side, + TensorEvaluator< + const TensorReshapingOp >, + Device>, + nocontract_t, contract_t, packet_size, inner_dim_contiguous, + inner_dim_reordered, Alignment> { + public: + typedef typename packet_traits::type Packet; + typedef typename packet_traits::half HalfPacket; + + typedef TensorContractionInputMapper< + Scalar, Index, Side, + TensorEvaluator< + const TensorReshapingOp< + NewDimension, const TensorImagePatchOp >, + Device>, + nocontract_t, contract_t, packet_size, inner_dim_contiguous, + inner_dim_reordered, Alignment> + ParentMapper; + + typedef TensorContractionSubMapper< + Scalar, Index, Side, + TensorEvaluator< + const TensorReshapingOp< + NewDimension, const TensorImagePatchOp >, + Device>, + nocontract_t, contract_t, packet_size, inner_dim_contiguous, + inner_dim_reordered, Alignment> + Self; + + typedef Self LinearMapper; + + typedef typename ParentMapper::TensorEvaluatorT TensorEvaluatorT; + + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorContractionSubMapper( + const ParentMapper& base_mapper, Index vert_offset, Index horiz_offset) + : m_depth_offset(vert_offset), + m_col_offset(horiz_offset), + m_base_mapper(base_mapper) { + m_base_mapper.computeBaseIndices(m_col_offset, m_rowIndex, m_colIndex, + m_otherIndex); + } + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorContractionSubMapper( + const Self& base_mapper, Index vert_offset, Index horiz_offset) + : m_depth_offset(vert_offset + base_mapper.m_depth_offset), + m_col_offset(horiz_offset + base_mapper.m_col_offset), + m_base_mapper(base_mapper.m_base_mapper) { + m_base_mapper.computeBaseIndices(m_col_offset, m_rowIndex, m_colIndex, + m_otherIndex); + } + EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Scalar operator()(Index i) const { + return m_base_mapper.loadCoeff(i + m_depth_offset, m_rowIndex, m_colIndex, + m_otherIndex); + } + EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Scalar operator()(Index i, + Index j) const { + return m_base_mapper(i + m_depth_offset, j + m_col_offset); + } + + EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet loadPacket(Index i) const { + return m_base_mapper.loadPacket(i + m_depth_offset, m_rowIndex, m_colIndex, + m_otherIndex); + } + EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet loadPacket(Index i, + Index j) const { + return m_base_mapper.template loadPacket(i + m_depth_offset, + j + m_col_offset); + } + EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Scalar + loadCoeffStandard(Index i) const { + return m_base_mapper.loadCoeffStandard(i + m_depth_offset, m_rowIndex, + m_colIndex, m_otherIndex); + } + + EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet loadPacketFast(Index i) const { + return m_base_mapper.loadPacketFast(i + m_depth_offset, m_rowIndex, + m_colIndex, m_otherIndex); + } + EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet + loadPacketStandard(Index i) const { + typedef decltype(m_base_mapper.m_impl) TensorEvaluatorT; + return m_base_mapper.template loadPacketStandard( + i + m_depth_offset, m_rowIndex, m_colIndex, m_otherIndex); + } + template + EIGEN_DEVICE_FUNC bool aligned(Index) const { + return false; + } + + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE bool nonStandardPatches() const { + return m_base_mapper.nonStandardPatches(); + } + + // Max(Col|Row|Depth): compute the upper limit for the column, row and depth + // index respectively that fits into the peeled_k elements starting at + // m_depth_offset. + + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Index maxCol(const Index peeled_k) const { + const Index max_col = + (m_depth_offset + (peeled_k == 0 ? 0 : peeled_k - 1)) / + fastPatchColStride(); + return std::min(1 + max_col, patchCols()); + } + + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Index maxRow(const Index peeled_k, + const Index col) const { + const Index max_row = (m_depth_offset + (peeled_k == 0 ? 0 : peeled_k - 1) - + col * patchColStride()) / + fastPatchRowStride(); + return std::min(1 + max_row, patchRows()); + } + + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Index maxDepth(const Index peeled_k, const Index col, + Index row) const { + const Index max_depth = m_depth_offset + peeled_k - // + col * patchColStride() - // + row * patchRowStride(); + return std::min(max_depth, patchDepth()); + } + + // MaxDepth uses only the remaining number of elements in the peeled_k. + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Index maxDepth(const Index num_elements, + const Index start_depth) const { + return std::min(start_depth + num_elements, patchDepth()); + } + + // Every register matters in this code, so sometimes to prevent register + // spilling, instead of the variable that you would expect to see, we use + // another one, that is guaranteed to have the same value. E.g. patch depth is + // always the same as input depth, and it's also the same as input row stride. + // Bunch of other parameters have similar relations. + + typedef internal::TensorIntDivisor IndexDivisor; + + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Index patchDepth() const { + return m_base_mapper.m_rowInputStride; + } + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Index patchRows() const { + return m_base_mapper.m_colStride; + } + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Index patchCols() const { + return m_base_mapper.m_patch_cols; + } + + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Index patchRowStride() const { + eigen_assert(patchDepth() == m_base_mapper.m_patch_row_stride && + "Patch depth must be equal to patch row stride."); + return patchDepth(); + } + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Index patchColStride() const { + return m_base_mapper.m_patch_col_stride; + } + + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE IndexDivisor fastPatchRowStride() const { + eigen_assert(patchDepth() == m_base_mapper.m_patch_row_stride && + "Patch depth must be equal to patch row stride."); + return m_base_mapper.m_fastDimZero; // patch_depth + } + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE IndexDivisor fastPatchColStride() const { + return m_base_mapper.m_fastPatchColStride; + } + + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Packet packetNoPadding(const Index depth, + const Index baseIndex) const { + const Index inputIndex = depth + baseIndex; + return m_base_mapper.m_impl.template packet(inputIndex); + } + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Scalar coeffNoPadding(const Index depth, + const Index baseIndex) const { + const Index inputIndex = depth + baseIndex; + return m_base_mapper.m_impl.coeff(inputIndex); + } + template + EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE typename std::enable_if< + TensorEvaluatorHasPartialPacket::value, + PacketT>::type + partialPacketNoPadding(const Index depth, const Index baseIndex, + Index num_coeffs) const { + const Index inputIndex = depth + baseIndex; + return m_base_mapper.m_impl.template partialPacket( + inputIndex, mask(0, num_coeffs)); + } + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE bool hasPadding() const { + // TODO(ezhulenev): It does seems that for inflated filter it's still + // possible to guarantee "no padding or skipping" for non-standard packing. + if (nonStandardPatches()) return true; + + // Non zero padding before. + if (m_base_mapper.m_rowPaddingTop > 0) return true; + if (m_base_mapper.m_colPaddingLeft > 0) return true; + + // Non zero padding after in rows. + const Index last_row = + (m_base_mapper.m_outputRows - 1) * m_base_mapper.m_row_strides; + if (last_row + (patchRows() - 1) >= m_base_mapper.m_inputRows) return true; + + // Non zero padding after in cols. + const Index last_col = + (m_base_mapper.m_outputCols - 1) * m_base_mapper.m_col_strides; + if (last_col + (patchCols() - 1) >= m_base_mapper.m_inputCols) return true; + + return false; + } + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE bool padRow(const Index row) const { + const Index r = m_rowIndex + row; + return r < 0 || r >= m_base_mapper.m_inputRows; + } + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE bool padAnyRow(const Index first_row, + const Index last_row) const { + return m_rowIndex + first_row < 0 || + m_rowIndex + last_row >= m_base_mapper.m_inputRows; + } + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE bool padOrSkipRow(const Index row, + Index* orig_row) const { + eigen_assert(nonStandardPatches()); + + const Index input_row = m_rowIndex + row * m_base_mapper.m_in_row_strides; + *orig_row = (m_base_mapper.m_patch_row_inflate_strides == 1) + ? input_row + : ((input_row >= 0) + ? (input_row / m_base_mapper.m_fastInputRowStride) + : 0); + + return (*orig_row < 0 || *orig_row >= m_base_mapper.m_inputRows) || + (input_row != *orig_row * m_base_mapper.m_patch_row_inflate_strides); + } + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE bool padCol(const Index col) const { + const Index c = m_colIndex + col; + return c < 0 || c >= m_base_mapper.m_inputCols; + } + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE bool padOrSkipCol(const Index col, + Index* orig_col) const { + eigen_assert(nonStandardPatches()); + + const Index input_col = m_colIndex + col * m_base_mapper.m_in_col_strides; + *orig_col = (m_base_mapper.m_patch_col_inflate_strides == 1) + ? input_col + : ((input_col >= 0) + ? (input_col / m_base_mapper.m_fastInputColStride) + : 0); + + return (*orig_col < 0 || *orig_col >= m_base_mapper.m_inputCols) || + (input_col != *orig_col * m_base_mapper.m_patch_col_inflate_strides); + } + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Index baseIndex(const Index row, const Index col) const { + const Index r = m_rowIndex + row; + const Index c = m_colIndex + col; + return r * m_base_mapper.m_rowInputStride + + c * m_base_mapper.m_colInputStride + m_otherIndex; + } + // Compute a base index when original input row and column were precomputed + // using padOrSkipRow and padOrSkipCol. Used only for non standard patches. + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Index origBaseIndex(const Index orig_row, + const Index orig_col) const { + return orig_row * m_base_mapper.m_rowInputStride + + orig_col * m_base_mapper.m_colInputStride + m_otherIndex; + } + + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Index rowStride() const { + return m_base_mapper.m_row_strides; + } + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Index colStride() const { + return m_base_mapper.m_col_strides; + } + + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Index rowOffset() const { + const Index patchOffset = m_depth_offset / m_base_mapper.m_fastDimZero; + const Index colOffset = patchOffset / m_base_mapper.m_fastColStride; + return patchOffset - colOffset * m_base_mapper.m_colStride; + } + + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Index colOffset() const { + const Index patchOffset = m_depth_offset / m_base_mapper.m_fastDimZero; + const Index colOffset = patchOffset / m_base_mapper.m_fastColStride; + return colOffset; + } + + EIGEN_DEVICE_FUNC + EIGEN_ALWAYS_INLINE Index depthOffset() const { + return m_depth_offset % patchDepth(); + } + + EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE LinearMapper + getLinearMapper(Index i, Index j) const { + return LinearMapper(m_base_mapper, i + m_depth_offset, j + m_col_offset); + } + + private: + Index m_depth_offset; // First row in the input matrix + Index m_col_offset; // First col in the input matrix + + // Knowing that: col_offset == patchIndex * OTHERS, we keep precomputed base + // indices for the first element in a patch specified by col_offset + // (see computeBaseIndices(...) for details). + Index m_rowIndex; + Index m_colIndex; + Index m_otherIndex; + + const ParentMapper m_base_mapper; // Keeping a copy instead of a reference + // performs better in benchmarks. +}; + +// Arrange a block of the right input matrix (in our case it's always a "virtual +// matrix" constructed from extracted image patches) in contiguous memory. +// +// Given column major input (A0 beside A1 in memory): +// A0 B0 C0 D0 E0 F0 G0 H0 ... Z0 +// A1 B1 C1 D1 E1 F1 G1 H1 ... Z1 +// A2 B2 C2 D2 E2 F2 G2 H2 ... Z2 +// A3 B3 C3 D3 E3 F3 G3 H3 ... Z3 +// A4 B4 C4 D4 E4 F4 G4 H4 ... Z4 +// A5 B5 C5 D5 E5 F5 G5 H5 ... Z5 +// A6 B6 C6 D6 E6 F6 G6 H6 ... Z6 +// A7 B7 C7 D7 E7 F7 G7 H7 ... Z7 +// A8 ... +// ... +// +// *) A, B, C, ... - patches extracted from the original input. +// *) A0, A1, A2 ... - values from the same patch at different offsets. +// +// The traversal (packed rhs memory) order (B0 besides A0 in memory): +// A0 B0 C0 D0 A1 B1 C1 D1 ... +// E0 F0 G0 H0 E1 F1 G1 H1 ... +// ... +// Z0 Z1 Z2 Z3 Z4 Z5 Z6 Z7 ... <- doesn't belong to any block (nr = 4) +// +// This traversal order must be the same as in default gemm_pack_rhs defined in +// GeneralBlockPanelKernel.h. +// +// *) nr - number of registers along the 'n' dimension. +// See GeneralBlockPanelKernel.h and "Anatomy of High-Performance Matrix +// Multiplication" paper. +template +struct gemm_pack_rhs< + Scalar, Index, + TensorContractionSubMapper< + Scalar, Index, Rhs, + TensorEvaluator< + const TensorReshapingOp< + NewDimension, const TensorImagePatchOp >, + Device>, + nocontract_t, contract_t, packet_size, inner_dim_contiguous, + inner_dim_reordered, Alignment>, + nr, ColMajor, false, false> { + typedef TensorContractionSubMapper< + Scalar, Index, Rhs, + TensorEvaluator< + const TensorReshapingOp< + NewDimension, const TensorImagePatchOp >, + Device>, + nocontract_t, contract_t, packet_size, inner_dim_contiguous, + inner_dim_reordered, Alignment> + SubMapper; + typedef SubMapper DataMapper; + typedef typename packet_traits::type Packet; + + EIGEN_STATIC_ASSERT((nr == 4), YOU_MADE_A_PROGRAMMING_MISTAKE) + + EIGEN_DEVICE_FUNC + EIGEN_DONT_INLINE void operator()(Scalar* block, const DataMapper& rhs, + Index depth, Index cols, Index stride = 0, + Index offset = 0) const { + eigen_assert(stride == 0); + eigen_assert(offset == 0); + + const Index packet_cols4 = (cols / 4) * 4; + const Index peeled_k = (depth / packet_size) * packet_size; + const bool non_standard_patches = rhs.nonStandardPatches(); + + for (Index j2 = 0; j2 < packet_cols4; j2 += 4) { + const SubMapper dm0 = rhs.getLinearMapper(0, j2 + 0); + const SubMapper dm1 = rhs.getLinearMapper(0, j2 + 1); + const SubMapper dm2 = rhs.getLinearMapper(0, j2 + 2); + const SubMapper dm3 = rhs.getLinearMapper(0, j2 + 3); + + Index k = 0; + if ((packet_size % 4) == 0 && !non_standard_patches) { + // FAST PATH: + // Iterate over patch columns and rows, if we know that a single + // packet do not span across multiple rows or columns. + if ((rhs.patchDepth() % packet_size) == 0) { + const Index start_col = rhs.colOffset(); + const Index max_col = rhs.maxCol(peeled_k); + + for (Index c = start_col; c < max_col; ++c) { + eigen_assert(k <= peeled_k); + + const Index start_row = (c == start_col) ? rhs.rowOffset() : 0; + const Index max_row = rhs.maxRow(peeled_k, c); + + const bool pad_col0 = dm0.padCol(c); + const bool pad_col1 = dm1.padCol(c); + const bool pad_col2 = dm2.padCol(c); + const bool pad_col3 = dm3.padCol(c); + + // Check if we can squeeze reads along the `row` and `depth` + // dimensions (two innermost dimensions). + if (!pad_col0 && !pad_col1 && !pad_col2 && !pad_col3 && // + !dm0.padRow(start_row) && !dm0.padRow(max_row - 1) && // + !dm1.padRow(start_row) && !dm1.padRow(max_row - 1) && // + !dm2.padRow(start_row) && !dm2.padRow(max_row - 1) && // + !dm3.padRow(start_row) && !dm3.padRow(max_row - 1)) { + // Compute how many elements we can squeeze read. + const Index start_depth = + (c == start_col) ? rhs.depthOffset() : 0; + + // Upper bound for the number of elements in the depth dimension + // that we can squeeze read. + const Index squeeze_length = + (max_row - start_row) * rhs.patchDepth() - start_depth; + + // Do not overshoot beyond the block size. + const Index max_depth = + start_depth + std::min(peeled_k - k, squeeze_length); + eigen_assert((max_depth - start_depth) % packet_size == 0); + + const Index idx0 = dm0.baseIndex(start_row, c); + const Index idx1 = dm1.baseIndex(start_row, c); + const Index idx2 = dm2.baseIndex(start_row, c); + const Index idx3 = dm3.baseIndex(start_row, c); + + for (Index d = start_depth; d < max_depth; d += packet_size) { + eigen_assert(k < peeled_k); + PacketBlock kernel; + kernel.packet[0] = rhs.packetNoPadding(d, idx0); + kernel.packet[1] = rhs.packetNoPadding(d, idx1); + kernel.packet[2] = rhs.packetNoPadding(d, idx2); + kernel.packet[3] = rhs.packetNoPadding(d, idx3); + ptranspose(kernel); + pstoreu(block + 0 * packet_size, kernel.packet[0]); + pstoreu(block + 1 * packet_size, kernel.packet[1]); + pstoreu(block + 2 * packet_size, kernel.packet[2]); + pstoreu(block + 3 * packet_size, kernel.packet[3]); + block += 4 * packet_size; + k += packet_size; + } + + // Go to the next column. + continue; + } + + // If we can't squeeze reads, process rows one by one. + for (Index r = start_row; r < max_row; ++r) { + eigen_assert(k <= peeled_k); + + const bool pad0 = pad_col0 || dm0.padRow(r); + const bool pad1 = pad_col1 || dm1.padRow(r); + const bool pad2 = pad_col2 || dm2.padRow(r); + const bool pad3 = pad_col3 || dm3.padRow(r); + + const Index idx0 = dm0.baseIndex(r, c); + const Index idx1 = dm1.baseIndex(r, c); + const Index idx2 = dm2.baseIndex(r, c); + const Index idx3 = dm3.baseIndex(r, c); + + const Index start_depth = ((c == start_col) && (r == start_row)) + ? rhs.depthOffset() + : 0; + const Index max_depth = rhs.maxDepth(peeled_k - k, start_depth); + eigen_assert((max_depth - start_depth) % packet_size == 0); + + for (Index d = start_depth; d < max_depth; d += packet_size) { + eigen_assert(k < peeled_k); + PacketBlock kernel; + kernel.packet[0] = pad0 ? pset1(Scalar(0)) + : rhs.packetNoPadding(d, idx0); + kernel.packet[1] = pad1 ? pset1(Scalar(0)) + : rhs.packetNoPadding(d, idx1); + kernel.packet[2] = pad2 ? pset1(Scalar(0)) + : rhs.packetNoPadding(d, idx2); + kernel.packet[3] = pad3 ? pset1(Scalar(0)) + : rhs.packetNoPadding(d, idx3); + ptranspose(kernel); + pstoreu(block + 0 * packet_size, kernel.packet[0]); + pstoreu(block + 1 * packet_size, kernel.packet[1]); + pstoreu(block + 2 * packet_size, kernel.packet[2]); + pstoreu(block + 3 * packet_size, kernel.packet[3]); + block += 4 * packet_size; + k += packet_size; + } + } + } + + // The loop above should fill peeled_k elements. + eigen_assert(peeled_k == k); + + } else { + for (; k < peeled_k; k += packet_size) { + PacketBlock kernel; + kernel.packet[0] = dm0.loadPacketStandard(k); + kernel.packet[1] = dm1.loadPacketStandard(k); + kernel.packet[2] = dm2.loadPacketStandard(k); + kernel.packet[3] = dm3.loadPacketStandard(k); + ptranspose(kernel); + pstoreu(block + 0 * packet_size, kernel.packet[0]); + pstoreu(block + 1 * packet_size, kernel.packet[1]); + pstoreu(block + 2 * packet_size, kernel.packet[2]); + pstoreu(block + 3 * packet_size, kernel.packet[3]); + block += 4 * packet_size; + } + } + } + + // Copy the remaining coefficients of the column block after the peeled_k. + if (!rhs.nonStandardPatches()) { + for (; k < depth; k++) { + block[0] = dm0.loadCoeffStandard(k); + block[1] = dm1.loadCoeffStandard(k); + block[2] = dm2.loadCoeffStandard(k); + block[3] = dm3.loadCoeffStandard(k); + block += 4; + } + } else { + for (; k < depth; k++) { + block[0] = dm0(k); + block[1] = dm1(k); + block[2] = dm2(k); + block[3] = dm3(k); + block += 4; + } + } + } + + // copy the remaining columns one at a time (nr==1) + for (Index j2 = packet_cols4; j2 < cols; ++j2) { + const SubMapper dm0 = rhs.getLinearMapper(0, j2); + for (Index k = 0; k < depth; k++) { + *block = dm0(k); + block += 1; + } + } + } +}; + +// Template specialization for packet_size = 2. We must special-case packet +// blocks with nr > packet_size, e.g. PacketBlock. +template +struct gemm_pack_rhs< + Scalar, Index, + TensorContractionSubMapper< + Scalar, Index, Rhs, + TensorEvaluator< + const TensorReshapingOp< + NewDimension, const TensorImagePatchOp >, + Device>, + nocontract_t, contract_t, 2, inner_dim_contiguous, inner_dim_reordered, + Alignment>, + nr, ColMajor, false, false> { + typedef TensorContractionSubMapper< + Scalar, Index, Rhs, + TensorEvaluator< + const TensorReshapingOp< + NewDimension, const TensorImagePatchOp >, + Device>, + nocontract_t, contract_t, 2, inner_dim_contiguous, inner_dim_reordered, + Alignment> + SubMapper; + typedef SubMapper DataMapper; + typedef typename packet_traits::type Packet; + + EIGEN_STATIC_ASSERT((nr == 4), YOU_MADE_A_PROGRAMMING_MISTAKE) + + EIGEN_DEVICE_FUNC + EIGEN_DONT_INLINE void operator()(Scalar* block, const DataMapper& rhs, + Index depth, Index cols, Index stride = 0, + Index offset = 0) const { + eigen_assert(stride == 0); + eigen_assert(offset == 0); + + const int packet_size = 2; + const Index packet_cols4 = (cols / 4) * 4; + const Index peeled_k = (depth / packet_size) * packet_size; + const bool non_standard_patches = rhs.nonStandardPatches(); + + for (Index j2 = 0; j2 < packet_cols4; j2 += 4) { + const SubMapper dm0 = rhs.getLinearMapper(0, j2 + 0); + const SubMapper dm1 = rhs.getLinearMapper(0, j2 + 1); + const SubMapper dm2 = rhs.getLinearMapper(0, j2 + 2); + const SubMapper dm3 = rhs.getLinearMapper(0, j2 + 3); + + Index k = 0; + if (!non_standard_patches) { + // FAST PATH: + // Iterate over patch columns and rows if we know that a single + // packet do not span across multiple rows or columns. + if ((rhs.patchDepth() % packet_size) == 0) { + const Index start_col = rhs.colOffset(); + const Index max_col = rhs.maxCol(peeled_k); + + for (Index c = start_col; c < max_col; ++c) { + eigen_assert(k <= peeled_k); + + const Index start_row = (c == start_col) ? rhs.rowOffset() : 0; + const Index max_row = rhs.maxRow(peeled_k, c); + + const bool pad_col0 = dm0.padCol(c); + const bool pad_col1 = dm1.padCol(c); + const bool pad_col2 = dm2.padCol(c); + const bool pad_col3 = dm3.padCol(c); + + // We can squeeze reads along the `row` and `depth` dimensions if + // the row stride is `1`, which means that `row` and `depth` + // dimensions are contiguous (two innermost dimensions). + if (rhs.rowStride() == 1 && // + !pad_col0 && !pad_col1 && !pad_col2 && !pad_col3 && // + !dm0.padRow(start_row) && !dm0.padRow(max_row - 1) && // + !dm1.padRow(start_row) && !dm1.padRow(max_row - 1) && // + !dm2.padRow(start_row) && !dm2.padRow(max_row - 1) && // + !dm3.padRow(start_row) && !dm3.padRow(max_row - 1)) { + // Compute how many elements we can squeeze read. + const Index start_depth = + (c == start_col) ? rhs.depthOffset() : 0; + + // Upper bound for the number of elements in the depth dimension + // that we can squeeze read. + const Index squeeze_length = + (max_row - start_row) * rhs.patchDepth() - start_depth; + + // Do not overshoot beyond the block size. + const Index max_depth = + start_depth + std::min(peeled_k - k, squeeze_length); + eigen_assert((max_depth - start_depth) % packet_size == 0); + + const Index idx0 = dm0.baseIndex(start_row, c); + const Index idx1 = dm1.baseIndex(start_row, c); + const Index idx2 = dm2.baseIndex(start_row, c); + const Index idx3 = dm3.baseIndex(start_row, c); + + for (Index d = start_depth; d < max_depth; d += packet_size) { + PacketBlock kernel0; + PacketBlock kernel1; + kernel0.packet[0] = rhs.packetNoPadding(d, idx0); + kernel0.packet[1] = rhs.packetNoPadding(d, idx1); + kernel1.packet[0] = rhs.packetNoPadding(d, idx2); + kernel1.packet[1] = rhs.packetNoPadding(d, idx3); + ptranspose(kernel0); + ptranspose(kernel1); + pstoreu(block + 0 * packet_size, kernel0.packet[0]); + pstoreu(block + 1 * packet_size, kernel1.packet[0]); + pstoreu(block + 2 * packet_size, kernel0.packet[1]); + pstoreu(block + 3 * packet_size, kernel1.packet[1]); + block += 4 * packet_size; + k += packet_size; + } + + // Go to the next column. + continue; + } + + // If we can't squeeze reads, process rows one by one. + for (Index r = start_row; r < max_row; ++r) { + eigen_assert(k <= peeled_k); + + const bool pad0 = pad_col0 || dm0.padRow(r); + const bool pad1 = pad_col1 || dm1.padRow(r); + const bool pad2 = pad_col2 || dm2.padRow(r); + const bool pad3 = pad_col3 || dm3.padRow(r); + + const Index idx0 = dm0.baseIndex(r, c); + const Index idx1 = dm1.baseIndex(r, c); + const Index idx2 = dm2.baseIndex(r, c); + const Index idx3 = dm3.baseIndex(r, c); + + const Index start_depth = ((c == start_col) && (r == start_row)) + ? rhs.depthOffset() + : 0; + const Index max_depth = rhs.maxDepth(peeled_k - k, start_depth); + eigen_assert((max_depth - start_depth) % packet_size == 0); + + for (Index d = start_depth; d < max_depth; d += packet_size) { + eigen_assert(k < peeled_k); + PacketBlock kernel0; + PacketBlock kernel1; + kernel0.packet[0] = pad0 ? pset1(Scalar(0)) + : rhs.packetNoPadding(d, idx0); + kernel0.packet[1] = pad1 ? pset1(Scalar(0)) + : rhs.packetNoPadding(d, idx1); + kernel1.packet[0] = pad2 ? pset1(Scalar(0)) + : rhs.packetNoPadding(d, idx2); + kernel1.packet[1] = pad3 ? pset1(Scalar(0)) + : rhs.packetNoPadding(d, idx3); + ptranspose(kernel0); + ptranspose(kernel1); + pstoreu(block + 0 * packet_size, kernel0.packet[0]); + pstoreu(block + 1 * packet_size, kernel1.packet[0]); + pstoreu(block + 2 * packet_size, kernel0.packet[1]); + pstoreu(block + 3 * packet_size, kernel1.packet[1]); + block += 4 * packet_size; + k += packet_size; + } + } + } + + // The loop above should fill peeled_k elements. + eigen_assert(peeled_k == k); + + } else { + // Packet can span multiple rows or columns, so we have to go + // though the slower "standard" path. + for (; k < peeled_k; k += packet_size) { + PacketBlock kernel0; + PacketBlock kernel1; + kernel0.packet[0] = dm0.loadPacketStandard(k); + kernel0.packet[1] = dm1.loadPacketStandard(k); + kernel1.packet[0] = dm2.loadPacketStandard(k); + kernel1.packet[1] = dm3.loadPacketStandard(k); + ptranspose(kernel0); + ptranspose(kernel1); + pstoreu(block + 0 * packet_size, kernel0.packet[0]); + pstoreu(block + 1 * packet_size, kernel1.packet[0]); + pstoreu(block + 2 * packet_size, kernel0.packet[1]); + pstoreu(block + 3 * packet_size, kernel1.packet[1]); + block += 4 * packet_size; + } + } + } + + // Copy the remaining coefficients of the column block after the peeled_k. + if (!non_standard_patches) { + for (; k < depth; k++) { + block[0] = dm0.loadCoeffStandard(k); + block[1] = dm1.loadCoeffStandard(k); + block[2] = dm2.loadCoeffStandard(k); + block[3] = dm3.loadCoeffStandard(k); + block += 4; + } + } else { + for (; k < depth; k++) { + block[0] = dm0(k); + block[1] = dm1(k); + block[2] = dm2(k); + block[3] = dm3(k); + block += 4; + } + } + } + + // Copy the remaining columns one at a time (nr==1). + for (Index j2 = packet_cols4; j2 < cols; ++j2) { + const SubMapper dm0 = rhs.getLinearMapper(0, j2); + for (Index k = 0; k < depth; k++) { + *block = dm0(k); + block += 1; + } + } + } +}; + +// Special case for non-vectorized types such as float16. +template +struct gemm_pack_rhs< + Scalar, Index, + TensorContractionSubMapper< + Scalar, Index, Rhs, + TensorEvaluator< + const TensorReshapingOp< + NewDimension, const TensorImagePatchOp >, + Device>, + nocontract_t, contract_t, 1, inner_dim_contiguous, inner_dim_reordered, + Alignment>, + nr, ColMajor, false, false> { + typedef TensorContractionSubMapper< + Scalar, Index, Rhs, + TensorEvaluator< + const TensorReshapingOp< + NewDimension, const TensorImagePatchOp >, + Device>, + nocontract_t, contract_t, 1, inner_dim_contiguous, inner_dim_reordered, + Alignment> + SubMapper; + typedef SubMapper DataMapper; + + EIGEN_STATIC_ASSERT((nr == 4), YOU_MADE_A_PROGRAMMING_MISTAKE) + + EIGEN_DEVICE_FUNC + EIGEN_DONT_INLINE void operator()(Scalar* block, const DataMapper& rhs, + Index depth, Index cols, Index stride = 0, + Index offset = 0) const { + eigen_assert(stride == 0); + eigen_assert(offset == 0); + + const Index packet_cols4 = (cols / 4) * 4; + + for (Index j2 = 0; j2 < packet_cols4; j2 += 4) { + const SubMapper dm0 = rhs.getLinearMapper(0, j2 + 0); + const SubMapper dm1 = rhs.getLinearMapper(0, j2 + 1); + const SubMapper dm2 = rhs.getLinearMapper(0, j2 + 2); + const SubMapper dm3 = rhs.getLinearMapper(0, j2 + 3); + + if (!rhs.nonStandardPatches()) { + for (Index k = 0; k < depth; k++) { + block[0] = dm0.loadCoeffStandard(k); + block[1] = dm1.loadCoeffStandard(k); + block[2] = dm2.loadCoeffStandard(k); + block[3] = dm3.loadCoeffStandard(k); + block += 4; + } + } else { + for (Index k = 0; k < depth; k++) { + block[0] = dm0(k); + block[1] = dm1(k); + block[2] = dm2(k); + block[3] = dm3(k); + block += 4; + } + } + } + + // Copy the remaining columns one at a time (nr==1). + for (Index j2 = packet_cols4; j2 < cols; ++j2) { + const SubMapper dm0 = rhs.getLinearMapper(0, j2); + for (Index k = 0; k < depth; k++) { + *block = dm0(k); + block += 1; + } + } + } +}; +#endif +} // end namespace internal + +/** SpatialConvolution + * \ingroup CXX11_NeuralNetworks_Module + * + * \brief Applies a 2D convolution over a multichannel input image. + * + * The input parameter is expected to be a tensor with a rank of 3 or more + * (channels, height, width, and optionally others) + * The kernel parameter is expected to be a 4D tensor (filters, channels, + * kernel_height, kernel_width) + * The input and the kernel must both be in col-major layout. The result will + * also be in col-major layout. + * + * If col_in_stride, row_in_stride > 1, then applies convolution with holes + * (aka atrous convolution), sampling every col_in_stride, row_in_stride input + * pixels. + * + * If padding_top, padding_bottom, padding_left, or padding_right is specified, + * then those paddings will be used to pad the input, and padding_type must be + * PADDING_VALID. + * + * The result can be assigned to a tensor of rank equal to the rank of the + * input. The dimensions of the result will be filters, height, width (and + * others if applicable). + * + * It is possible to swap the order of the width and height dimensions provided + * that the same order is used in the input, the kernel, and the output. + * + * It is also possible to add an output kernel to the contraction, output + * kernel is called by Eigen when it "finalizes" the block of an output tensor. + * + */ +template +EIGEN_ALWAYS_INLINE static const std::conditional_t< + internal::traits::Layout == ColMajor, + TensorReshapingOp< + const DSizes::Index, + internal::traits::NumDimensions>, + const TensorContractionOp< + const array::Index>, 1>, + const TensorReshapingOp< + const DSizes::Index, 2>, + const Kernel>, + const TensorReshapingOp< + const DSizes::Index, 2>, + const TensorImagePatchOp >, + const OutputKernel> >, + TensorReshapingOp< + const DSizes::Index, + internal::traits::NumDimensions>, + const TensorContractionOp< + const array::Index>, 1>, + const TensorReshapingOp< + const DSizes::Index, 2>, + const TensorImagePatchOp >, + const TensorReshapingOp< + const DSizes::Index, 2>, + const Kernel>, + const OutputKernel> > > +SpatialConvolution(const Input& input, const Kernel& kernel, + const Index row_stride = 1, const Index col_stride = 1, + const PaddingType padding_type = PADDING_SAME, + const Index row_in_stride = 1, const Index col_in_stride = 1, + const OutputKernel& output_kernel = OutputKernel(), + Index padding_top = 0, Index padding_bottom = 0, + Index padding_left = 0, Index padding_right = 0) { + typedef typename internal::traits::Index TensorIndex; + typedef typename internal::traits::Scalar InputScalar; + TensorRef::NumDimensions, + internal::traits::Layout, TensorIndex> > + in(input); + TensorRef::Scalar, + internal::traits::NumDimensions, + internal::traits::Layout, TensorIndex> > + kern(kernel); + + EIGEN_STATIC_ASSERT( + internal::traits::Layout == internal::traits::Layout, + YOU_MADE_A_PROGRAMMING_MISTAKE) + const bool isColMajor = (internal::traits::Layout == ColMajor); + + const int NumDims = internal::traits::NumDimensions; + + // Number of filters to apply. This is the same as the output depth of the + // result + const TensorIndex kernelFilters = + isColMajor ? kern.dimensions()[0] : kern.dimensions()[3]; + // Number of channels. This is the same as the input depth. + const TensorIndex kernelChannels = + isColMajor ? kern.dimensions()[1] : kern.dimensions()[2]; + const TensorIndex kernelRows = + isColMajor ? kern.dimensions()[2] : kern.dimensions()[1]; + const TensorIndex kernelCols = + isColMajor ? kern.dimensions()[3] : kern.dimensions()[0]; + + const Index kernelRowsEff = + kernelRows + (kernelRows - 1) * (row_in_stride - 1); + const Index kernelColsEff = + kernelCols + (kernelCols - 1) * (col_in_stride - 1); + + array, 1> contract_dims; + contract_dims[0] = IndexPair(1, 0); + + const TensorIndex InputRows = + isColMajor ? in.dimension(1) : in.dimension(NumDims - 2); + const TensorIndex InputCols = + isColMajor ? in.dimension(2) : in.dimension(NumDims - 3); + const bool padding_explicit = + (padding_top || padding_bottom || padding_left || padding_right); + + TensorIndex out_height; + TensorIndex out_width; + switch (padding_type) { + case PADDING_VALID: { + const TensorIndex InputRowsEff = InputRows + padding_top + padding_bottom; + const TensorIndex InputColsEff = InputCols + padding_left + padding_right; + out_height = divup(InputRowsEff - kernelRowsEff + 1, row_stride); + out_width = divup(InputColsEff - kernelColsEff + 1, col_stride); + break; + } + case PADDING_SAME: { + eigen_assert(!padding_explicit); + out_height = divup(InputRows, row_stride); + out_width = divup(InputCols, col_stride); + break; + } + default: { + // Initialize unused variables to avoid a compiler warning + out_height = 0; + out_width = 0; + eigen_assert(false && "unexpected padding"); + } + } + + // Molds the output of the patch extraction code into a 2d tensor: + // - the first dimension (dims[0]): the patch values to be multiplied with the + // kernels + // - the second dimension (dims[1]): everything else + DSizes pre_contract_dims; + if (isColMajor) { + pre_contract_dims[0] = kernelChannels * kernelRows * kernelCols; + pre_contract_dims[1] = out_height * out_width; + for (int i = 3; i < NumDims; ++i) { + pre_contract_dims[1] *= in.dimension(i); + } + } else { + pre_contract_dims[1] = kernelChannels * kernelRows * kernelCols; + pre_contract_dims[0] = out_height * out_width; + for (int i = 0; i < NumDims - 3; ++i) { + pre_contract_dims[0] *= in.dimension(i); + } + } + + // Molds the output of the contraction into the shape expected by the used + // (assuming this is ColMajor): + // - 1st dim: kernel filters + // - 2nd dim: output height + // - 3rd dim: output width + // - 4th dim and beyond: everything else including batch size + DSizes post_contract_dims; + if (isColMajor) { + post_contract_dims[0] = kernelFilters; + post_contract_dims[1] = out_height; + post_contract_dims[2] = out_width; + for (int i = 3; i < NumDims; ++i) { + post_contract_dims[i] = in.dimension(i); + } + } else { + post_contract_dims[NumDims - 1] = kernelFilters; + post_contract_dims[NumDims - 2] = out_height; + post_contract_dims[NumDims - 3] = out_width; + for (int i = 0; i < NumDims - 3; ++i) { + post_contract_dims[i] = in.dimension(i); + } + } + + DSizes kernel_dims; + if (isColMajor) { + kernel_dims[0] = kernelFilters; + kernel_dims[1] = kernelChannels * kernelRows * kernelCols; + } else { + kernel_dims[0] = kernelChannels * kernelRows * kernelCols; + kernel_dims[1] = kernelFilters; + } + if (padding_explicit) { + return choose( + Cond::Layout == ColMajor>(), + kernel.reshape(kernel_dims) + .contract(input + .extract_image_patches( + kernelRows, kernelCols, row_stride, col_stride, + row_in_stride, col_in_stride, + /*row_inflate_stride=*/1, + /*col_inflate_stride=*/1, padding_top, + padding_bottom, padding_left, padding_right, + /*padding_value=*/static_cast(0)) + .reshape(pre_contract_dims), + contract_dims, output_kernel) + .reshape(post_contract_dims), + input + .extract_image_patches( + kernelRows, kernelCols, row_stride, col_stride, row_in_stride, + col_in_stride, + /*row_inflate_stride=*/1, + /*col_inflate_stride=*/1, padding_top, padding_bottom, + padding_left, padding_right, + /*padding_value=*/static_cast(0)) + .reshape(pre_contract_dims) + .contract(kernel.reshape(kernel_dims), contract_dims, output_kernel) + .reshape(post_contract_dims)); + } else { + return choose( + Cond::Layout == ColMajor>(), + kernel.reshape(kernel_dims) + .contract(input + .extract_image_patches( + kernelRows, kernelCols, row_stride, col_stride, + row_in_stride, col_in_stride, padding_type) + .reshape(pre_contract_dims), + contract_dims, output_kernel) + .reshape(post_contract_dims), + input + .extract_image_patches(kernelRows, kernelCols, row_stride, + col_stride, row_in_stride, col_in_stride, + padding_type) + .reshape(pre_contract_dims) + .contract(kernel.reshape(kernel_dims), contract_dims, output_kernel) + .reshape(post_contract_dims)); + } +} + +} // end namespace Eigen + +#endif // TENSORFLOW_TSL_FRAMEWORK_CONVOLUTION_EIGEN_SPATIAL_CONVOLUTIONS_INL_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/convolution/eigen_spatial_convolutions.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/convolution/eigen_spatial_convolutions.h new file mode 100644 index 0000000000000000000000000000000000000000..5ac4382d45131ab5347473855d884264cf2f78de --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/convolution/eigen_spatial_convolutions.h @@ -0,0 +1,445 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_CONVOLUTION_EIGEN_SPATIAL_CONVOLUTIONS_H_ +#define TENSORFLOW_TSL_FRAMEWORK_CONVOLUTION_EIGEN_SPATIAL_CONVOLUTIONS_H_ + +#include "unsupported/Eigen/CXX11/Tensor" // from @eigen_archive + +// Note the following header is used in both TF and TFLite. Particularly, it's +// used for float TFLite Conv2D. +#include "tsl/framework/convolution/eigen_spatial_convolutions-inl.h" + +#if defined(TENSORFLOW_USE_CUSTOM_CONTRACTION_KERNEL) +#include "tsl/framework/contraction/eigen_contraction_kernel.h" + +namespace Eigen { +namespace internal { + +// After we vectorized all loads from the underlying tensor using Packet ops, we +// have to finalize coefficients that do not fit into a packet. +template +struct FinalizeDataMapperCoeffs { + EIGEN_ALWAYS_INLINE static Index finalize(Scalar* block, + const DataMapper& rhs, + Index base_idx, Index depth, + Index max_depth, bool pad = false) { + const Index num_coeffs = max_depth - depth; + eigen_assert(num_coeffs <= packet_size); + + for (; depth < max_depth; ++depth) { + *block = pad ? Scalar(0) : rhs.coeffNoPadding(depth, base_idx); + ++block; + } + + return num_coeffs; + } +}; + +template +struct FinalizeDataMapperCoeffs { + EIGEN_ALWAYS_INLINE static Index finalize(Scalar* block, + const DataMapper& rhs, + Index base_idx, Index depth, + Index max_depth, bool pad = false) { + Index num_coeffs = max_depth - depth; + eigen_assert(num_coeffs <= packet_size); + if (num_coeffs == 0) return 0; + + using Packet = typename packet_traits::type; + Packet p = pad ? pset1(Scalar(0)) + : rhs.partialPacketNoPadding(depth, base_idx, num_coeffs); + internal::pstoreu(block, p, mask(0, num_coeffs)); + + return num_coeffs; + } +}; + +// Pack a block of the right input matrix (in our case it's always a +// "virtual matrix" constructed from extracted image patches) in contiguous +// block in column-major storage order. Knowing the properties of the +// original patch op we can do it more efficient than the default +// gemm_pack_colmajor_block. +template +struct gemm_pack_colmajor_block< + Scalar, StorageIndex, + TensorContractionSubMapper< + Scalar, StorageIndex, Rhs, + TensorEvaluator< + const TensorReshapingOp< + NewDimension, const TensorImagePatchOp >, + Device>, + nocontract_t, contract_t, packet_size, inner_dim_contiguous, + inner_dim_reordered, Alignment>, + ColMajor> { + typedef TensorContractionSubMapper< + Scalar, StorageIndex, Rhs, + TensorEvaluator< + const TensorReshapingOp< + NewDimension, const TensorImagePatchOp >, + Device>, + nocontract_t, contract_t, packet_size, inner_dim_contiguous, + inner_dim_reordered, Alignment> + SubMapper; + + typedef SubMapper DataMapper; + typedef typename packet_traits::type Packet; + + using CoeffFinalizer = FinalizeDataMapperCoeffs< + Scalar, DataMapper, packet_size, + TensorEvaluatorHasPartialPacket::value && + unpacket_traits::masked_store_available>; + + EIGEN_DONT_INLINE + void operator()(Scalar* block, const DataMapper& rhs, StorageIndex rows, + StorageIndex cols) { + const bool standard_patches = !rhs.nonStandardPatches(); + + if (standard_patches && (rhs.patchDepth() % packet_size == 0)) { + // Single packet always belong to single patch (row, col). + if (rhs.hasPadding()) { + packStandardPatches(block, rhs, rows, cols); + } else { + packStandardPatches(block, rhs, rows, cols); + } + + } else if (standard_patches) { + // Single packet can span across multiple patch rows or columns. + if (rhs.hasPadding()) { + packStandardPatches(block, rhs, rows, cols); + } else { + packStandardPatches(block, rhs, rows, cols); + } + + } else if (rhs.patchDepth() % packet_size == 0) { + // Single packet always belong to single patch (row, col). + packNonStandardPatches(block, rhs, rows, cols); + + } else { + // Single packet can span across multiple patch rows or columns. + packNonStandardPatches(block, rhs, rows, cols); + } + } + + private: + // (A) Standard image patches: + // + // (1) patch_row_inflate_strides == 1 AND + // (2) patch_col_inflate_strides == 1 + // + // Standard patches guarantee that two inner most dimensions (depth and rows) + // are contiguous in memory and we can try to squeeze reads from them. + // + // (B) Non standard image patches: in_row/in_col and patch_row/patch_col + // strides can be not equal to 1, and for each [row, col] inside a patch we + // have to do additional computations to find corresponding row and col in the + // input tensor. Also we can no longer squeeze reads from inner dimensions. + // + // Additional parameters: + // - patch_depth_is_multiple_of_packet_size=true: We are guaranteed to have + // depth dimension size to be a multiple of packet size, so we can skip all + // non vectorized loads and checks, because it's guaranteed that block size + // will be a multiple of a packet size (see TensorContractionBlocking). + // + // - has_padding: Input tensor has non-zero padding. In this case for each + // patch col and row we need to check that it doesn't correspond to the + // padded region of original input. + template + EIGEN_ALWAYS_INLINE void packStandardPatches(Scalar* __restrict block, + const DataMapper& rhs, + StorageIndex rows, + StorageIndex cols) { + eigen_assert(!rhs.nonStandardPatches()); + + // Give vectorized_rows the name used in all other gemm_pack_rhs above. + const StorageIndex peeled_k = (rows / packet_size) * packet_size; + + const StorageIndex start_col = rhs.colOffset(); + const StorageIndex max_col = rhs.maxCol(peeled_k); + const StorageIndex rhs_depth_offset = rhs.depthOffset(); + + for (StorageIndex col = 0; col < cols; ++col) { + SubMapper lm = rhs.getLinearMapper(0, col); + + StorageIndex k = 0; + for (Index c = start_col; c < max_col; ++c) { + eigen_assert(k <= peeled_k); + + const StorageIndex start_row = (c == start_col) ? rhs.rowOffset() : 0; + const StorageIndex max_row = rhs.maxRow(peeled_k, c); + const bool pad_col = has_padding && lm.padCol(c); + + eigen_assert(has_padding || !lm.padCol(c)); + eigen_assert(has_padding || !lm.padAnyRow(start_row, max_row - 1)); + + // We can squeeze reads for all rows in [start_row, max_row) range. + if (!has_padding || + (!pad_col && !lm.padAnyRow(start_row, max_row - 1))) { + const StorageIndex start_depth = + (c == start_col) ? rhs_depth_offset : 0; + + const StorageIndex max_depth = + std::min(start_depth + (peeled_k - k), + (max_row - start_row) * rhs.patchDepth()); + + const StorageIndex base_idx = lm.baseIndex(start_row, c); + + if (patch_depth_is_multiple_of_packet_size) { + // If patch depth is a multiple of packet size, it's guaranteed that + // we can process all values in depth dimension with packets. + eigen_assert((max_depth - start_depth) % packet_size == 0); + StorageIndex d = start_depth; + + const StorageIndex unrolled_depth = max_depth - 4 * packet_size; + for (; d <= unrolled_depth; d += 4 * packet_size) { + eigen_assert(k < peeled_k); + + Packet p0 = rhs.packetNoPadding(d + 0 * packet_size, base_idx); + Packet p1 = rhs.packetNoPadding(d + 1 * packet_size, base_idx); + Packet p2 = rhs.packetNoPadding(d + 2 * packet_size, base_idx); + Packet p3 = rhs.packetNoPadding(d + 3 * packet_size, base_idx); + + internal::pstoreu(block + 0 * packet_size, p0); + internal::pstoreu(block + 1 * packet_size, p1); + internal::pstoreu(block + 2 * packet_size, p2); + internal::pstoreu(block + 3 * packet_size, p3); + + block += 4 * packet_size; + k += 4 * packet_size; + } + + for (; d < max_depth; d += packet_size) { + eigen_assert(k < peeled_k); + internal::pstoreu(block, rhs.packetNoPadding(d, base_idx)); + block += packet_size; + k += packet_size; + } + + } else { + StorageIndex d = start_depth; + + const StorageIndex unrolled_depth = max_depth - 4 * packet_size; + for (; d <= unrolled_depth; d += 4 * packet_size) { + eigen_assert(k < peeled_k); + + Packet p0 = rhs.packetNoPadding(d + 0 * packet_size, base_idx); + Packet p1 = rhs.packetNoPadding(d + 1 * packet_size, base_idx); + Packet p2 = rhs.packetNoPadding(d + 2 * packet_size, base_idx); + Packet p3 = rhs.packetNoPadding(d + 3 * packet_size, base_idx); + + internal::pstoreu(block + 0 * packet_size, p0); + internal::pstoreu(block + 1 * packet_size, p1); + internal::pstoreu(block + 2 * packet_size, p2); + internal::pstoreu(block + 3 * packet_size, p3); + + block += 4 * packet_size; + k += 4 * packet_size; + } + + const StorageIndex vectorized_depth = max_depth - packet_size; + for (; d <= vectorized_depth; d += packet_size) { + eigen_assert(k < peeled_k); + internal::pstoreu(block, rhs.packetNoPadding(d, base_idx)); + block += packet_size; + k += packet_size; + } + + eigen_assert(k <= peeled_k); + const Index num_coeffs = + CoeffFinalizer::finalize(block, rhs, base_idx, d, max_depth); + + k += num_coeffs; + block += num_coeffs; + eigen_assert(k <= peeled_k); + } + + // Go to the next column. + continue; + } + + // If we are not allowed to squeeze reads along the `row` and `depth` + // dimensions, we must process rows one by one. + for (StorageIndex r = start_row; r < max_row; ++r) { + eigen_assert(k <= peeled_k); + + const StorageIndex start_depth = + ((c == start_col) && (r == start_row)) ? rhs_depth_offset : 0; + const StorageIndex max_depth = + rhs.maxDepth(peeled_k - k, start_depth); + + const bool pad = has_padding && (pad_col || lm.padRow(r)); + eigen_assert(has_padding || !lm.padRow(r)); + + const StorageIndex base_idx = lm.baseIndex(r, c); + + if (patch_depth_is_multiple_of_packet_size) { + // If patch depth is a multiple of packet size, it's guaranteed that + // we can process all values in depth dimension with packets. + eigen_assert((max_depth - start_depth) % packet_size == 0); + StorageIndex d = start_depth; + + for (; d < max_depth; d += packet_size) { + eigen_assert(k < peeled_k); + const Packet p = (has_padding && pad) + ? pset1(Scalar(0)) + : rhs.packetNoPadding(d, base_idx); + internal::pstoreu(block, p); + block += packet_size; + k += packet_size; + } + + } else { + StorageIndex d = start_depth; + + const StorageIndex vectorized_depth = max_depth - packet_size; + for (; d <= vectorized_depth; d += packet_size) { + eigen_assert(k < peeled_k); + const Packet p = (has_padding && pad) + ? pset1(Scalar(0)) + : rhs.packetNoPadding(d, base_idx); + internal::pstoreu(block, p); + block += packet_size; + k += packet_size; + } + + eigen_assert(k <= peeled_k); + const Index num_coeffs = CoeffFinalizer::finalize( + block, rhs, base_idx, d, max_depth, has_padding && pad); + + k += num_coeffs; + block += num_coeffs; + eigen_assert(k <= peeled_k); + } + } + } + + // The loop above should fill peeled_k elements. + eigen_assert(peeled_k == k); + + // Fill remaining elements using loadCoeffStandard. + for (; k < rows; ++k) { + *block = lm.loadCoeffStandard(k); + ++block; + } + } + } + + template + EIGEN_ALWAYS_INLINE void packNonStandardPatches(Scalar* __restrict block, + const DataMapper& rhs, + StorageIndex rows, + StorageIndex cols) { + eigen_assert(rhs.nonStandardPatches()); + + // Give vectorized_rows the name used in all other gemm_pack_rhs above. + const StorageIndex peeled_k = (rows / packet_size) * packet_size; + + const StorageIndex start_col = rhs.colOffset(); + const StorageIndex max_col = rhs.maxCol(peeled_k); + const StorageIndex rhs_depth_offset = rhs.depthOffset(); + + // Original input column and row after applying all non-standard strides and + // dilations. Computed by padOrSkip{Row,Col}. + Index orig_c = 0; + Index orig_r = 0; + + for (StorageIndex col = 0; col < cols; ++col) { + SubMapper lm = rhs.getLinearMapper(0, col); + + StorageIndex k = 0; + for (Index c = start_col; c < max_col; ++c) { + eigen_assert(k <= peeled_k); + + const StorageIndex start_row = (c == start_col) ? rhs.rowOffset() : 0; + const StorageIndex max_row = rhs.maxRow(peeled_k, c); + const bool pad_or_skip_col = lm.padOrSkipCol(c, &orig_c); + + for (StorageIndex r = start_row; r < max_row; ++r) { + eigen_assert(k <= peeled_k); + + const StorageIndex start_depth = + ((c == start_col) && (r == start_row)) ? rhs_depth_offset : 0; + const StorageIndex max_depth = + rhs.maxDepth(peeled_k - k, start_depth); + + const bool pad_or_skip = + pad_or_skip_col || lm.padOrSkipRow(r, &orig_r); + const StorageIndex base_idx = lm.origBaseIndex(orig_r, orig_c); + + if (patch_depth_is_multiple_of_packet_size) { + // If patch depth is a multiple of packet size, it's guaranteed that + // we can process all values in depth dimension with packets. + eigen_assert((max_depth - start_depth) % packet_size == 0); + StorageIndex d = start_depth; + + for (; d < max_depth; d += packet_size) { + eigen_assert(k < peeled_k); + const Packet p = pad_or_skip ? pset1(Scalar(0)) + : rhs.packetNoPadding(d, base_idx); + internal::pstoreu(block, p); + block += packet_size; + k += packet_size; + } + + } else { + const StorageIndex vectorized_depth = max_depth - packet_size; + StorageIndex d = start_depth; + for (; d <= vectorized_depth; d += packet_size) { + eigen_assert(k < peeled_k); + const Packet p = pad_or_skip ? pset1(Scalar(0)) + : rhs.packetNoPadding(d, base_idx); + internal::pstoreu(block, p); + block += packet_size; + k += packet_size; + } + + eigen_assert(k <= peeled_k); + const Index num_coeffs = CoeffFinalizer::finalize( + block, rhs, base_idx, d, max_depth, pad_or_skip); + + k += num_coeffs; + block += num_coeffs; + eigen_assert(k <= peeled_k); + } + } + } + + // The loop above should fill peeled_k elements. + eigen_assert(peeled_k == k); + + // Fill remaining elements using loadCoeff. + for (; k < rows; ++k) { + *block = lm(k); + ++block; + } + } + } +}; +} // namespace internal +} // namespace Eigen +#endif // defined(TENSORFLOW_USE_CUSTOM_CONTRACTION_KERNEL) +#endif // TENSORFLOW_TSL_FRAMEWORK_CONVOLUTION_EIGEN_SPATIAL_CONVOLUTIONS_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/device_id.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/device_id.h new file mode 100644 index 0000000000000000000000000000000000000000..533c63d1081c2f1b9d5e6e37743a796f932d7b7b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/device_id.h @@ -0,0 +1,89 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_DEVICE_ID_H_ +#define TENSORFLOW_TSL_FRAMEWORK_DEVICE_ID_H_ + +#include "tsl/lib/gtl/int_type.h" + +namespace tsl { + +// There are three types of device ids: +// - *physical* device id: this is the integer index of a device in the +// physical machine, it can be filtered (for e.g. using environment variable +// CUDA_VISIBLE_DEVICES when using CUDA). Note that this id is not visible to +// Tensorflow, but result after filtering is visible to TF and is called +// platform device id as below. +// For CUDA, see +// http://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#env-vars +// for more details. +// - *platform* device id (also called *visible* device id in +// third_party/tensorflow/core/protobuf/config.proto): this is the id that is +// visible to Tensorflow after filtering (for e.g. by CUDA_VISIBLE_DEVICES). +// For CUDA, this id is generated by the CUDA GPU driver. It starts from 0 +// and is used for CUDA API calls like cuDeviceGet(). +// - TF device id (also called *virtual* device id in +// third_party/tensorflow/core/protobuf/config.proto): this is the id that +// Tensorflow generates and exposes to its users. It is the id in the +// field of the device name "/device:GPU:", and is also the identifier of +// a BaseGPUDevice. Note that the configuration allows us to create multiple +// BaseGPUDevice per GPU hardware in order to use multi CUDA streams on the +// hardware, so the mapping between TF GPU id and platform GPU id is not a 1:1 +// mapping, see the example below. +// +// For example, assuming that in the machine we have GPU device with index 0, 1, +// 2 and 3 (physical GPU id). Setting "CUDA_VISIBLE_DEVICES=1,2,3" will create +// the following mapping between platform GPU id and physical GPU id: +// +// platform GPU id -> physical GPU id +// 0 -> 1 +// 1 -> 2 +// 2 -> 3 +// +// Note that physical GPU id 0 is invisible to TF so there is no mapping entry +// for it. +// +// Assuming we configure the Session to create one BaseGPUDevice per GPU +// hardware, then setting GPUOptions::visible_device_list to "2,0" will create +// the following mapping between TF device id and platform device id: +// +// TF GPU id -> platform GPU ID +// 0 (i.e. /device:GPU:0) -> 2 +// 1 (i.e. /device:GPU:1) -> 0 +// +// Note that platform device id 1 is filtered out by +// GPUOptions::visible_device_list, so it won't be used by the TF process. +// +// On the other hand, if we configure it to create 2 BaseGPUDevice per GPU +// hardware, then setting GPUOptions::visible_device_list to "2,0" will create +// the following mapping between TF device id and platform device id: +// +// TF GPU id -> platform GPU ID +// 0 (i.e. /device:GPU:0) -> 2 +// 1 (i.e. /device:GPU:1) -> 2 +// 2 (i.e. /device:GPU:2) -> 0 +// 3 (i.e. /device:GPU:3) -> 0 +// +// We create strong-typed integer classes for both TF device id and platform +// device id to minimize programming errors and improve code readability. Except +// for the StreamExecutor interface (as we don't change its API), whenever we +// need a TF device id (or platform device id) we should use TfDeviceId (or +// PlatformDeviceId) instead of a raw integer. +TSL_LIB_GTL_DEFINE_INT_TYPE(TfDeviceId, int32); +TSL_LIB_GTL_DEFINE_INT_TYPE(PlatformDeviceId, int32); + +} // namespace tsl + +#endif // TENSORFLOW_TSL_FRAMEWORK_DEVICE_ID_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/device_id_manager.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/device_id_manager.h new file mode 100644 index 0000000000000000000000000000000000000000..ca101758ee3ebb5c3b97ef52715888af13a9a16a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/device_id_manager.h @@ -0,0 +1,53 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_DEVICE_ID_MANAGER_H_ +#define TENSORFLOW_TSL_FRAMEWORK_DEVICE_ID_MANAGER_H_ + +#include + +#include "tsl/framework/device_id.h" +#include "tsl/framework/device_type.h" +#include "tsl/platform/status.h" +#include "tsl/platform/statusor.h" + +namespace tsl { + +// Class that maintains a map from TfDeviceId to PlatformDeviceId, and manages +// the translation between them. +class DeviceIdManager { + public: + // Adds a mapping from tf_device_id to platform_device_id. + static Status InsertTfPlatformDeviceIdPair( + const DeviceType& type, TfDeviceId tf_device_id, + PlatformDeviceId platform_device_id); + + // Gets the platform_device_id associated with tf_device_id. Returns OK if + // found. + static Status TfToPlatformDeviceId(const DeviceType& type, + TfDeviceId tf_device_id, + PlatformDeviceId* platform_device_id); + + // Gets all tf_device_ids that are on the platform with `platform_device_id`. + static StatusOr> GetTfDevicesOnPlatform( + const DeviceType& type, PlatformDeviceId platform_device_id); + + // Clears the map. Used in unit tests only. + static void TestOnlyReset(); +}; + +} // namespace tsl + +#endif // TENSORFLOW_TSL_FRAMEWORK_DEVICE_ID_MANAGER_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/device_id_utils.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/device_id_utils.h new file mode 100644 index 0000000000000000000000000000000000000000..c2479aded5fe0aaa88c3609e37878effe1cd8648 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/device_id_utils.h @@ -0,0 +1,72 @@ +/* Copyright 2023 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_DEVICE_ID_UTILS_H_ +#define TENSORFLOW_TSL_FRAMEWORK_DEVICE_ID_UTILS_H_ + +#include +#include + +#include "absl/container/flat_hash_map.h" +#include "tsl/framework/device_id.h" +#include "tsl/framework/device_type.h" +#include "tsl/platform/status.h" +#include "tsl/platform/statusor.h" +#include "tsl/util/device_name_utils.h" + +namespace tsl { + +// Utility methods for translation between TensorFlow device ids and platform +// device ids. + +// Verify that the platform_device_id associated with a TfDeviceId is +// legitimate. +void CheckValidTfDeviceId(const DeviceType& type, int visible_device_count, + TfDeviceId tf_device_id); + +// Parse `visible_device_list` into a list of platform Device ids. +Status ParseVisibleDeviceList( + const std::string& visible_device_list, int visible_device_count, + std::vector* visible_device_order); + +// Returns how many TF devices should be created, and generates the mapping +// between TfDeviceId and PlatformDeviceId. The number of TF devices is the +// minimum among the device count in `session_option_device_counts`, +// `visible_device_count` and the number of visible devices in +// `visible_device_list`. If `visible_device_list` is empty, the mapping +// between TfDeviceId and PlatformDeviceId is an identity mapping. +// Please refer to tensorflow/tsl/framework/device_id.h and +// tensorflow/core/protobuf/config.proto about the relationship between +// TfDeviceId and PlatformDeviceId, and how `visible_device_list` is used. +StatusOr GetNumberTfDevicesAndConfigurePlatformDeviceId( + const absl::flat_hash_map& + session_option_device_counts, + absl::string_view device_type, absl::string_view visible_device_list, + int visible_device_count); + +StatusOr GetPlatformDeviceIdFromDeviceParsedName( + const DeviceNameUtils::ParsedName& device_name, + const DeviceType& device_type); + +// TODO(b/293324740): support virtual devices. +// Returns the corresponding PlatformDeviceId if it is found. Otherwise returns +// the id in device_name. +StatusOr GetDeviceIdFromDeviceParsedName( + const DeviceNameUtils::ParsedName& device_name, + const DeviceType& device_type); + +} // namespace tsl + +#endif // TENSORFLOW_TSL_FRAMEWORK_DEVICE_ID_UTILS_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/device_type.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/device_type.h new file mode 100644 index 0000000000000000000000000000000000000000..148cb1686348b0ca86fd9c0b7289905df0f87590 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/device_type.h @@ -0,0 +1,50 @@ +/* Copyright 2022 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_DEVICE_TYPE_H_ +#define TENSORFLOW_TSL_FRAMEWORK_DEVICE_TYPE_H_ + +#include +#include + +#include "absl/strings/string_view.h" + +namespace tsl { + +// A DeviceType is just a string, but we wrap it up in a class to give +// some type checking as we're passing these around +class DeviceType { + public: + DeviceType(const char* type) // NOLINT + : type_(type) {} + + explicit DeviceType(absl::string_view type) + : type_(type.data(), type.size()) {} + + const char* type() const { return type_.c_str(); } + const std::string& type_string() const { return type_; } + + bool operator<(const DeviceType& other) const; + bool operator==(const DeviceType& other) const; + bool operator!=(const DeviceType& other) const { return !(*this == other); } + + private: + std::string type_; +}; +std::ostream& operator<<(std::ostream& os, const DeviceType& d); + +} // namespace tsl + +#endif // TENSORFLOW_TSL_FRAMEWORK_DEVICE_TYPE_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/FixedPoint.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/FixedPoint.h new file mode 100644 index 0000000000000000000000000000000000000000..5301914ad37cefdfebeb05b3320157b6955e657b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/FixedPoint.h @@ -0,0 +1,53 @@ +/* Copyright 2022 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_FIXEDPOINT_H_ +#define TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_FIXEDPOINT_H_ + +#include "unsupported/Eigen/CXX11/Tensor" // from @eigen_archive +#include "tsl/framework/fixedpoint_types.h" + +// Use optimized implementations whenever available +#if defined(EIGEN_VECTORIZE_AVX512DQ) || defined(EIGEN_VECTORIZE_AVX512BW) +#include "tsl/framework/fixedpoint/PacketMathAVX512.h" +#include "tsl/framework/fixedpoint/TypeCastingAVX512.h" + +#elif defined EIGEN_VECTORIZE_AVX2 +#define EIGEN_USE_OPTIMIZED_INT8_UINT8_MAT_MAT_PRODUCT +#define EIGEN_USE_OPTIMIZED_INT16_INT16_MAT_MAT_PRODUCT +#include "tsl/framework/fixedpoint/PacketMathAVX2.h" +// Disable clang-format to prevent 'MatMatProductAVX2.h' header from being +// included before 'PacketMathAVX2' header on which it depends. +// clang-format off +#include "tsl/framework/fixedpoint/MatMatProductAVX2.h" +// clang-format on +#include "tsl/framework/fixedpoint/TypeCastingAVX2.h" + +#elif defined EIGEN_VECTORIZE_AVX +#include "tsl/framework/fixedpoint/PacketMathAVX.h" + +#elif defined EIGEN_VECTORIZE_NEON +#define EIGEN_USE_OPTIMIZED_INT8_INT8_MAT_MAT_PRODUCT +#define EIGEN_USE_OPTIMIZED_INT8_UINT8_MAT_MAT_PRODUCT +#define EIGEN_USE_OPTIMIZED_UINT8_INT8_MAT_MAT_PRODUCT +#define EIGEN_USE_OPTIMIZED_INT16_INT16_MAT_MAT_PRODUCT +#include "tsl/framework/fixedpoint/MatMatProductNEON.h" +#endif + +// Use the default implementation when no optimized code is available +#include "tsl/framework/fixedpoint/MatMatProduct.h" +#include "tsl/framework/fixedpoint/MatVecProduct.h" + +#endif // TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_FIXEDPOINT_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/MatMatProduct.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/MatMatProduct.h new file mode 100644 index 0000000000000000000000000000000000000000..c7823d86d5c0a983fea268d64fe3df7ac3e144f9 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/MatMatProduct.h @@ -0,0 +1,363 @@ +/* Copyright 2022 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_MATMATPRODUCT_H_ +#define TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_MATMATPRODUCT_H_ + +namespace Eigen { +namespace internal { + +// Accumulate the product of 2 QInt8 inputs on 32 bits to prevent +// overflows +template <> +struct scalar_product_traits { + enum { Defined = 1 }; + typedef QInt32 ReturnType; +}; + +// Accumulate the product of 2 QInt16 inputs on 32 bits to prevent +// overflows +template <> +struct scalar_product_traits { + enum { Defined = 1 }; + typedef QInt32 ReturnType; +}; + +// Accumulate the product of QInt8 inputs with QUint8 inputs on 32 bits +// to prevent overflows +template <> +struct scalar_product_traits { + enum { Defined = 1 }; + typedef QInt32 ReturnType; +}; + +// Accumulate the product of QUInt8 inputs with Qint8 inputs on 32 bits +// to prevent overflows +template <> +struct scalar_product_traits { + enum { Defined = 1 }; + typedef QInt32 ReturnType; +}; + +// Description of the product implementation. It's pretty simple now since +// nothing is vectorized yet. +// This definition tackle the case where both lhs and rhs are encoded using +// signed 8bit integers +#ifndef EIGEN_USE_OPTIMIZED_INT8_INT8_MAT_MAT_PRODUCT + +template +class gebp_traits { + public: + typedef QInt8 LhsScalar; + typedef QInt8 RhsScalar; + typedef QInt32 ResScalar; + + typedef typename packet_traits::type LhsPacket; + typedef LhsPacket LhsPacket4Packing; + + enum { + // register block size along the M and N directions + // One for the current implementation + nr = 1, + mr = 1, + // Progress made at each iteration of the product loop + // also 1 for the current implementation + LhsProgress = 1, + RhsProgress = 1 + }; +}; + +// The signed 8bit Mat-Mat product itself. +template +struct gebp_kernel { + EIGEN_DONT_INLINE + void operator()(const DataMapper& res, const QInt8* blockA, + const QInt8* blockB, Index rows, Index depth, Index cols, + QInt32 alpha, Index strideA = -1, Index strideB = -1, + Index offsetA = 0, Index offsetB = 0); +}; + +template +EIGEN_DONT_INLINE void +gebp_kernel::operator()(const DataMapper& res, + const QInt8* blockA, const QInt8* blockB, + Index rows, Index depth, Index cols, + QInt32 alpha, Index strideA, + Index strideB, Index offsetA, + Index offsetB) { + EIGEN_STATIC_ASSERT(!ConjugateLhs, YOU_MADE_A_PROGRAMMING_MISTAKE); + EIGEN_STATIC_ASSERT(!ConjugateRhs, YOU_MADE_A_PROGRAMMING_MISTAKE); + + eigen_assert(alpha.value == 1); + eigen_assert(strideA == -1); + eigen_assert(strideB == -1); + eigen_assert(offsetA == 0); + eigen_assert(offsetB == 0); + + eigen_assert(rows > 0); + eigen_assert(cols > 0); + eigen_assert(depth > 0); + eigen_assert(blockA); + eigen_assert(blockB); + + for (Index j = 0; j < cols; ++j) { + Index startB = j * depth; + + for (Index i = 0; i < rows; ++i) { + Index startA = i * depth; + + for (Index k = 0; k < depth; ++k) { + res(i, j) += blockA[startA + k] * blockB[startB + k]; + } + } + } +} +#endif + +// This definition tackle the case where the lhs is encoded using signed 8bit +// integers and the rhs using unsigned 8bit integers. +#ifndef EIGEN_USE_OPTIMIZED_INT8_UINT8_MAT_MAT_PRODUCT +template +class gebp_traits { + public: + typedef QInt8 LhsScalar; + typedef QUInt8 RhsScalar; + typedef QInt32 ResScalar; + + typedef typename packet_traits::type LhsPacket; + typedef LhsPacket LhsPacket4Packing; + + enum { + // register block size along the M and N directions + // One for the current implementation + nr = 1, + mr = 1, + // Progress made at each iteration of the product loop + // also 1 for the current implementation + LhsProgress = 1, + RhsProgress = 1 + }; +}; + +// Mat-Mat product of a signed 8bit lhs with an unsigned 8bit rhs +template +struct gebp_kernel { + EIGEN_DONT_INLINE + void operator()(const DataMapper& res, const QInt8* blockA, + const QUInt8* blockB, Index rows, Index depth, Index cols, + QInt32 alpha, Index strideA = -1, Index strideB = -1, + Index offsetA = 0, Index offsetB = 0); +}; + +template +EIGEN_DONT_INLINE void +gebp_kernel::operator()(const DataMapper& res, + const QInt8* blockA, const QUInt8* blockB, + Index rows, Index depth, Index cols, + QInt32 alpha, Index strideA, + Index strideB, Index offsetA, + Index offsetB) { + EIGEN_STATIC_ASSERT(!ConjugateLhs, YOU_MADE_A_PROGRAMMING_MISTAKE); + EIGEN_STATIC_ASSERT(!ConjugateRhs, YOU_MADE_A_PROGRAMMING_MISTAKE); + + eigen_assert(alpha.value == 1); + eigen_assert(strideA == -1); + eigen_assert(strideB == -1); + eigen_assert(offsetA == 0); + eigen_assert(offsetB == 0); + + eigen_assert(rows > 0); + eigen_assert(cols > 0); + eigen_assert(depth > 0); + eigen_assert(blockA); + eigen_assert(blockB); + + for (Index j = 0; j < cols; ++j) { + Index startB = j * depth; + + for (Index i = 0; i < rows; ++i) { + Index startA = i * depth; + + for (Index k = 0; k < depth; ++k) { + res(i, j) += blockA[startA + k] * blockB[startB + k]; + } + } + } +} +#endif + +// This definition tackle the case where the lhs is encoded using unsigned 8bit +// integers and the rhs using signed 8bit integers. +#ifndef EIGEN_USE_OPTIMIZED_UINT8_INT8_MAT_MAT_PRODUCT +template +class gebp_traits { + public: + typedef QUInt8 LhsScalar; + typedef QInt8 RhsScalar; + typedef QInt32 ResScalar; + + typedef typename packet_traits::type LhsPacket; + typedef LhsPacket LhsPacket4Packing; + + enum { + // register block size along the M and N directions + // One for the current implementation + nr = 1, + mr = 1, + // Progress made at each iteration of the product loop + // also 1 for the current implementation + LhsProgress = 1, + RhsProgress = 1 + }; +}; + +// Mat-Mat product of an unsigned 8bit lhs with a signed 8bit rhs +template +struct gebp_kernel { + EIGEN_DONT_INLINE + void operator()(const DataMapper& res, const QUInt8* blockA, + const QInt8* blockB, Index rows, Index depth, Index cols, + QInt32 alpha, Index strideA = -1, Index strideB = -1, + Index offsetA = 0, Index offsetB = 0); +}; + +template +EIGEN_DONT_INLINE void +gebp_kernel::operator()(const DataMapper& res, + const QUInt8* blockA, const QInt8* blockB, + Index rows, Index depth, Index cols, + QInt32 alpha, Index strideA, + Index strideB, Index offsetA, + Index offsetB) { + EIGEN_STATIC_ASSERT(!ConjugateLhs, YOU_MADE_A_PROGRAMMING_MISTAKE); + EIGEN_STATIC_ASSERT(!ConjugateRhs, YOU_MADE_A_PROGRAMMING_MISTAKE); + + eigen_assert(alpha.value == 1); + eigen_assert(strideA == -1); + eigen_assert(strideB == -1); + eigen_assert(offsetA == 0); + eigen_assert(offsetB == 0); + + eigen_assert(rows > 0); + eigen_assert(cols > 0); + eigen_assert(depth > 0); + eigen_assert(blockA); + eigen_assert(blockB); + + for (Index j = 0; j < cols; ++j) { + Index startB = j * depth; + + for (Index i = 0; i < rows; ++i) { + Index startA = i * depth; + + for (Index k = 0; k < depth; ++k) { + res(i, j) += blockA[startA + k] * blockB[startB + k]; + } + } + } +} +#endif + +#ifndef EIGEN_USE_OPTIMIZED_INT16_INT16_MAT_MAT_PRODUCT + +template +class gebp_traits { + public: + typedef QInt16 LhsScalar; + typedef QInt16 RhsScalar; + typedef QInt32 ResScalar; + + typedef typename packet_traits::type LhsPacket; + typedef LhsPacket LhsPacket4Packing; + + enum { + // register block size along the M and N directions + // One for the current implementation + nr = 1, + mr = 1, + // Progress made at each iteration of the product loop + // also 1 for the current implementation + LhsProgress = 1, + RhsProgress = 1 + }; +}; + +// The signed 16bit Mat-Mat product itself. +template +struct gebp_kernel { + EIGEN_DONT_INLINE + void operator()(const DataMapper& res, const QInt16* blockA, + const QInt16* blockB, Index rows, Index depth, Index cols, + QInt32 alpha, Index strideA = -1, Index strideB = -1, + Index offsetA = 0, Index offsetB = 0); +}; + +template +EIGEN_DONT_INLINE void +gebp_kernel::operator()(const DataMapper& res, + const QInt16* blockA, + const QInt16* blockB, Index rows, + Index depth, Index cols, QInt32 alpha, + Index strideA, Index strideB, + Index offsetA, Index offsetB) { + EIGEN_STATIC_ASSERT(!ConjugateLhs, YOU_MADE_A_PROGRAMMING_MISTAKE); + EIGEN_STATIC_ASSERT(!ConjugateRhs, YOU_MADE_A_PROGRAMMING_MISTAKE); + + eigen_assert(alpha.value == 1); + eigen_assert(strideA == -1); + eigen_assert(strideB == -1); + eigen_assert(offsetA == 0); + eigen_assert(offsetB == 0); + + eigen_assert(rows > 0); + eigen_assert(cols > 0); + eigen_assert(depth > 0); + eigen_assert(blockA); + eigen_assert(blockB); + + for (Index j = 0; j < cols; ++j) { + Index startB = j * depth; + + for (Index i = 0; i < rows; ++i) { + Index startA = i * depth; + + for (Index k = 0; k < depth; ++k) { + res(i, j) += blockA[startA + k] * blockB[startB + k]; + } + } + } +} +#endif + +} // namespace internal +} // namespace Eigen + +#endif // TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_MATMATPRODUCT_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/MatMatProductAVX2.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/MatMatProductAVX2.h new file mode 100644 index 0000000000000000000000000000000000000000..742666766977598fd90e53a036c42450109c1053 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/MatMatProductAVX2.h @@ -0,0 +1,2314 @@ +/* Copyright 2022 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_MATMATPRODUCTAVX2_H_ +#define TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_MATMATPRODUCTAVX2_H_ + +namespace Eigen { +namespace internal { + +// AVX2 optimized implementation of Mat-Mat product. +// LHS is encoded using signed 16-bit integers. +// RHS is encoded using signed 16-bit integers. +#ifdef EIGEN_USE_OPTIMIZED_INT16_INT16_MAT_MAT_PRODUCT + +// Define quantized traits +template +class gebp_traits { + public: + typedef QInt16 LhsScalar; + typedef QInt16 RhsScalar; + typedef QInt32 ResScalar; + + typedef typename packet_traits::type LhsPacket; + typedef LhsPacket LhsPacket4Packing; + + enum { + // Define register blocking scheme. + nr = 16, + mr = 16, + kr = 4, + // Ignore progress tracking per loop iteration. + LhsProgress = -1, + RhsProgress = -1 + }; +}; + +// Specialized blocking for quantized implementations. +// Used by TensorContractionThreadPool, inputs must have dimensions that are +// multiples of 32. +template +class TensorContractionBlocking { + public: + TensorContractionBlocking(Index k, Index m, Index n, Index num_threads = 1) + : kc_(((k + 15) / 16) * 16), + mc_(((m + 15) / 16) * 16), + nc_(((n + 15) / 16) * 16) { + eigen_assert(mc_ % 16 == 0); + eigen_assert(kc_ % 16 == 0); + if (!k || !m || !n) { + return; + } + + if (ShardingType == ShardByCol) { + eigen_assert(nc_ % 16 == 0); + nc_ = (((nc_ / num_threads) + 15) / 16) * 16; + } else { + eigen_assert(nc_ % 16 == 0); + mc_ = (((mc_ / num_threads) + 15) / 16) * 16; + } + } + + EIGEN_ALWAYS_INLINE Index kc() const { return kc_; } + EIGEN_ALWAYS_INLINE Index mc() const { return mc_; } + EIGEN_ALWAYS_INLINE Index nc() const { return nc_; } + + private: + Index kc_; + Index mc_; + Index nc_; +}; + +// Specialized blocking for quantized implementations. +// Used by TensorContraction and GeneralMatrixMatrix, inputs are padded to +// multiples of 32. +template +class gemm_blocking_space + : public level3_blocking { + DenseIndex m_sizeA; + DenseIndex m_sizeB; + + public: + gemm_blocking_space(DenseIndex rows, DenseIndex cols, DenseIndex depth, + DenseIndex /*num_threads*/, bool /*l3_blocking*/) { + this->m_mc = ((rows + 15) / 16) * 16; + this->m_nc = ((cols + 15) / 16) * 16; + this->m_kc = ((depth + 15) / 16) * 16; + m_sizeA = this->m_mc * this->m_kc; + m_sizeB = this->m_kc * this->m_nc; + } + void allocateA() { + if (this->m_blockA == 0) this->m_blockA = aligned_new(m_sizeA); + } + void allocateB() { + if (this->m_blockB == 0) this->m_blockB = aligned_new(m_sizeB); + } + void allocateAll() { + allocateA(); + allocateB(); + } + ~gemm_blocking_space() { + aligned_delete(this->m_blockA, m_sizeA); + aligned_delete(this->m_blockB, m_sizeB); + } +}; + +// Below are the fully optimized versions that are correct only for sizes that +// are multiple of 16. It is about a 10% performance benefit to keep these +// implementations separate. + +// Arrange a block of the left input matrix in contiguous memory. +// +// Given column major input (A0 beside A1 in memory): +// A0 B0 C0 D0 E0 F0 G0 H0 ... +// A1 B1 C1 D1 E1 F1 G1 H1 ... +// A2 B2 C2 D2 E2 F2 G2 H2 ... +// A3 B3 C3 D3 E3 F3 G3 H3 ... +// A4 B4 C4 D4 E4 F4 G4 H4 ... +// A5 B5 C5 D5 E5 F5 G5 H5 ... +// A6 B6 C6 D6 E6 F6 G6 H6 ... +// A7 B7 C7 D7 E7 F7 G7 H7 ... +// A8 ... +// ... +// +// Packing with m = 8 yields row major output (A0 beside B0 in memory): +// A0 B0 +// A1 B1 +// A2 B2 +// A3 B3 +// A4 B4 +// A5 B5 +// A6 B6 +// A7 B7 +// ... +// +// The purpose is to collect m rows of size k. Two elements of the same +// row are arranged contiguously because madd performs an adjacent addition +// in the kernel. + +template +struct gemm_pack_lhs { + EIGEN_DONT_INLINE void operator()(QInt16* blockA, const DataMapper& lhs, + Index depth, Index rows, Index stride = 0, + Index offset = 0); +}; + +template +EIGEN_DONT_INLINE void +gemm_pack_lhs::operator()(QInt16* blockA, + const DataMapper& lhs, + Index depth, Index rows, + Index stride, Index offset) { + eigen_assert(stride == 0); + eigen_assert(offset == 0); + + typedef typename packet_traits::type Packet; + + // Use alternate function for weird sizes + if (rows % 16 != 0 || depth % 16 != 0) { + eigen_assert(false && + "only depths and rows that are a multiple of 16 are currently " + "supported"); + // gemm_pack_lhs_any lhs_pack; + // return lhs_pack(blockA, lhs, depth, rows, stride, offset); + } + + // Get vector pointer + __m256i* blockA_256 = reinterpret_cast<__m256i*>(blockA); + + // Pack rows in sets of 16 + for (Index m = 0; m < rows; m += 16) { + // Pack depth in sets of 4 + for (Index k = 0; k < depth; k += 4) { + // Load vectors + __m256i L_A = lhs.template loadPacket(m, k); + __m256i L_B = lhs.template loadPacket(m, k + 1); + __m256i L_C = lhs.template loadPacket(m, k + 2); + __m256i L_D = lhs.template loadPacket(m, k + 3); + + // Rearrange the inputs as required by the kernel + __m256i L_AB0_AB7 = _mm256_unpacklo_epi16(L_A, L_B); + __m256i L_AB8_AB15 = _mm256_unpackhi_epi16(L_A, L_B); + __m256i L_CD0_CD7 = _mm256_unpacklo_epi16(L_C, L_D); + __m256i L_CD8_CD15 = _mm256_unpackhi_epi16(L_C, L_D); + + __m256i L_AD0 = _mm256_permute2x128_si256(L_AB0_AB7, L_AB8_AB15, 0x20); + _mm256_store_si256(blockA_256++, L_AD0); + __m256i L_AD8 = _mm256_permute2x128_si256(L_CD0_CD7, L_CD8_CD15, 0x20); + _mm256_store_si256(blockA_256++, L_AD8); + __m256i L_AD16 = _mm256_permute2x128_si256(L_AB0_AB7, L_AB8_AB15, 0x31); + _mm256_store_si256(blockA_256++, L_AD16); + __m256i L_AD24 = _mm256_permute2x128_si256(L_CD0_CD7, L_CD8_CD15, 0x31); + _mm256_store_si256(blockA_256++, L_AD24); + } + } +} + +// Arrange a block of the right input matrix in contiguous memory. +// +// Given column major input (A0 beside A1 in memory): +// A0 B0 C0 D0 E0 F0 G0 H0 ... +// A1 B1 C1 D1 E1 F1 G1 H1 ... +// A2 B2 C2 D2 E2 F2 G2 H2 ... +// A3 B3 C3 D3 E3 F3 G3 H3 ... +// A4 B4 C4 D4 E4 F4 G4 H4 ... +// A5 B5 C5 D5 E5 F5 G5 H5 ... +// A6 B6 C6 D6 E6 F6 G6 H6 ... +// A7 B7 C7 D7 E7 F7 G7 H7 ... +// A8 ... +// ... +// Packing yields row major output (A0 beside A1 in memory): +// A0 A1 A2 A3 A4 A5 A6 A7 +// B0 B1 B2 B3 B4 B5 B6 B7 +// ... +// +// At least two elements of the same col are arranged contiguously because +// maddubs and madd both perform an adjacent addition in the kernel. We can +// save work by leaving 4 adjacent elements because kr = 4. +// The purpose is to collect n cols of size k. Two elements of the same +// col are arranged contiguously because madd performs an adjacent addition +// in the kernel. +template +struct gemm_pack_rhs { + EIGEN_DONT_INLINE void operator()(QInt16* blockB, const DataMapper& rhs, + Index depth, Index cols, Index stride = 0, + Index offset = 0); +}; + +template +EIGEN_DONT_INLINE void +gemm_pack_rhs::operator()(QInt16* blockB, const DataMapper& rhs, + Index depth, Index cols, Index stride, + Index offset) { + eigen_assert(stride == 0); + eigen_assert(offset == 0); + + typedef typename packet_traits::type Packet; + + // Use alternate function for weird sizes + if (cols % 16 != 0 || depth % 16 != 0) { + eigen_assert(false && + "only depths and cols that are a multiple of 16 are currently " + "supported"); + // gemm_pack_rhs_any rhs_pack; + // return rhs_pack(blockB, rhs, depth, cols, stride, offset); + } + + // Get vector pointer + __m256i* blockB_256 = reinterpret_cast<__m256i*>(blockB); + + // Perform a step of the packing for 4 columns + __m256i R_AB_L, R_AB_H, R_CD_L, R_CD_H, R_AD_0, R_AD_4, R_AD_8, R_AD_12; +#define PACK_STEP \ + R_AB_L = _mm256_unpacklo_epi64(R_A, R_B); \ + R_CD_L = _mm256_unpacklo_epi64(R_C, R_D); \ + R_AB_H = _mm256_unpackhi_epi64(R_A, R_B); \ + R_CD_H = _mm256_unpackhi_epi64(R_C, R_D); \ + R_AD_0 = _mm256_permute2x128_si256(R_AB_L, R_CD_L, 0x20); \ + R_AD_8 = _mm256_permute2x128_si256(R_AB_L, R_CD_L, 0x31); \ + R_AD_4 = _mm256_permute2x128_si256(R_AB_H, R_CD_H, 0x20); \ + R_AD_12 = _mm256_permute2x128_si256(R_AB_H, R_CD_H, 0x31); \ + _mm256_store_si256(blockB_256, R_AD_0); \ + _mm256_store_si256(blockB_256 + 4, R_AD_4); \ + _mm256_store_si256(blockB_256 + 8, R_AD_8); \ + _mm256_store_si256(blockB_256 + 12, R_AD_12); \ + blockB_256++; + + // Pack cols in sets of 16 + for (Index n = 0; n < cols; n += 16) { + // Pack depth in sets of 16 + for (Index k = 0; k < depth; k += 16) { + __m256i R_A = rhs.template loadPacket(k, n); + __m256i R_B = rhs.template loadPacket(k, n + 1); + __m256i R_C = rhs.template loadPacket(k, n + 2); + __m256i R_D = rhs.template loadPacket(k, n + 3); + PACK_STEP; + + R_A = rhs.template loadPacket(k, n + 4); + R_B = rhs.template loadPacket(k, n + 5); + R_C = rhs.template loadPacket(k, n + 6); + R_D = rhs.template loadPacket(k, n + 7); + PACK_STEP; + + R_A = rhs.template loadPacket(k, n + 8); + R_B = rhs.template loadPacket(k, n + 9); + R_C = rhs.template loadPacket(k, n + 10); + R_D = rhs.template loadPacket(k, n + 11); + PACK_STEP; + + R_A = rhs.template loadPacket(k, n + 12); + R_B = rhs.template loadPacket(k, n + 13); + R_C = rhs.template loadPacket(k, n + 14); + R_D = rhs.template loadPacket(k, n + 15); + PACK_STEP; + + blockB_256 += 12; + } + } +#undef PACK_STEP +} + +// Perform the actual multiplication on packed inputs +template +struct gebp_kernel { + typedef typename DataMapper::LinearMapper LinearMapper; + + EIGEN_DONT_INLINE + void operator()(const DataMapper& res, const QInt16* blockA, + const QInt16* blockB, Index rows, Index depth, Index cols, + QInt32 alpha, Index strideA = -1, Index strideB = -1, + Index offsetA = 0, Index offsetB = 0); +}; + +template +EIGEN_DONT_INLINE void +gebp_kernel::operator()(const DataMapper& res, + const QInt16* blockA, + const QInt16* blockB, Index rows, + Index depth, Index cols, QInt32 alpha, + Index strideA, Index strideB, + Index offsetA, Index offsetB) { + EIGEN_STATIC_ASSERT(!ConjugateLhs, YOU_MADE_A_PROGRAMMING_MISTAKE); + EIGEN_STATIC_ASSERT(!ConjugateRhs, YOU_MADE_A_PROGRAMMING_MISTAKE); + eigen_assert(alpha.value == 1); + eigen_assert(strideA == -1); + eigen_assert(strideB == -1); + eigen_assert(offsetA == 0); + eigen_assert(offsetB == 0); + eigen_assert(rows > 0); + eigen_assert(cols > 0); + eigen_assert(depth > 0); + eigen_assert(blockA); + eigen_assert(blockB); + + // Use alternate function for weird sizes + if (rows % 16 != 0 || cols % 16 != 0 || depth % 16 != 0) { + eigen_assert( + false && + "only depths, cols and rows that are a multiple of 16 are currently " + "supported"); + // gebp_kernel_any gebp; + // return gebp(res, blockA, blockB, rows, depth, cols, alpha, strideA, + // strideB, offsetA, offsetB); + } + + // Create result block + QInt32* blockO = aligned_new(16 * 16); + memset(blockO, 0, 16 * 16 * sizeof(QInt32)); + + // Get vectorized pointers + __m256i* blockO_256 = reinterpret_cast<__m256i*>(blockO); + const __m256i* blockA_256 = reinterpret_cast(blockA); + const __m256i* blockB_256 = reinterpret_cast(blockB); + + // Loop over blocks of 16 columns + for (Index n = 0; n < cols; n += 16) { + // Reset index into blockA + Index indexL = 0; + // Loop over blocks of 16 rows + for (Index m = 0; m < rows; m += 16) { + // Reset index into blockB + Index indexR = n / 16 * depth; + // Loop over blocks of 4 on depth + for (Index k = 0; k < depth; k += 4) { + // Load inputs + __m256i L_AD0 = blockA_256[indexL++]; + __m256i L_AD8 = blockA_256[indexL++]; + __m256i L_EH0 = blockA_256[indexL++]; + __m256i L_EH8 = blockA_256[indexL++]; + + __m256i R_AH0 = blockB_256[indexR++]; + __m256i R_AH4 = blockB_256[indexR++]; + __m256i R_AH8 = blockB_256[indexR++]; + __m256i R_AH12 = blockB_256[indexR++]; + + // Declare variables used in COMPUTE_STEP + __m256i P_32_A, P_32_B, P_32; + +#define COMPUTE_STEP(R_INPUT_A, R_INPUT_B, OFFSET) \ + P_32_A = _mm256_madd_epi16(R_INPUT_A, L_AD0); \ + P_32_B = _mm256_madd_epi16(R_INPUT_B, L_AD8); \ + P_32 = _mm256_add_epi32(P_32_A, P_32_B); \ + _mm256_store_si256( \ + blockO_256 + 2 * OFFSET, \ + _mm256_add_epi32(_mm256_load_si256(blockO_256 + 2 * OFFSET), P_32)); \ + \ + P_32_A = _mm256_madd_epi16(R_INPUT_A, L_EH0); \ + P_32_B = _mm256_madd_epi16(R_INPUT_B, L_EH8); \ + P_32 = _mm256_add_epi32(P_32_A, P_32_B); \ + _mm256_store_si256( \ + blockO_256 + 2 * OFFSET + 1, \ + _mm256_add_epi32(_mm256_load_si256(blockO_256 + 2 * OFFSET + 1), P_32)); + + // Permute and shuffle to copy a single value across the entire vector + // Then compute the multiplication + // Replicate lower 128-bits of R_AH0 across both lanes + __m256i R_AH0_ = _mm256_permute2x128_si256(R_AH0, R_AH0, 0x00); + // Copy first two elements of R_AH0 across entire vector + __m256i R_AD0 = _mm256_shuffle_epi32(R_AH0_, 0x00); + // Copy second two elements of R_AH0 across entire vector + __m256i R_EH0 = _mm256_shuffle_epi32(R_AH0_, 0x55); + + COMPUTE_STEP(R_AD0, R_EH0, 0); + __m256i R_AD1 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + __m256i R_EH1 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD1, R_EH1, 1); + + // Replicate upper 128-bits of R_AH0 across both lanes + R_AH0_ = _mm256_permute2x128_si256(R_AH0, R_AH0, 0x11); + __m256i R_AD2 = _mm256_shuffle_epi32(R_AH0_, 0x00); + __m256i R_EH2 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD2, R_EH2, 2); + __m256i R_AD3 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + __m256i R_EH3 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD3, R_EH3, 3); + + R_AH0_ = _mm256_permute2x128_si256(R_AH4, R_AH4, 0x00); + R_AD0 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH0 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD0, R_EH0, 4); + R_AD1 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH1 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD1, R_EH1, 5); + R_AH0_ = _mm256_permute2x128_si256(R_AH4, R_AH4, 0x11); + R_AD2 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH2 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD2, R_EH2, 6); + R_AD3 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH3 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD3, R_EH3, 7); + + R_AH0_ = _mm256_permute2x128_si256(R_AH8, R_AH8, 0x00); + R_AD0 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH0 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD0, R_EH0, 8); + R_AD1 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH1 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD1, R_EH1, 9); + R_AH0_ = _mm256_permute2x128_si256(R_AH8, R_AH8, 0x11); + R_AD2 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH2 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD2, R_EH2, 10); + R_AD3 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH3 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD3, R_EH3, 11); + + R_AH0_ = _mm256_permute2x128_si256(R_AH12, R_AH12, 0x00); + R_AD0 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH0 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD0, R_EH0, 12); + R_AD1 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH1 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD1, R_EH1, 13); + R_AH0_ = _mm256_permute2x128_si256(R_AH12, R_AH12, 0x11); + R_AD2 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH2 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD2, R_EH2, 14); + R_AD3 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH3 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD3, R_EH3, 15); + +#undef COMPUTE_STEP + } + + // Transfer the results to the result matrix + Index i = 0; + for (Index j = n; j < n + 16; j++) { + LinearMapper r0 = res.getLinearMapper(m, j); + LinearMapper r1 = res.getLinearMapper(m + 8, j); + typedef typename packet_traits::type Packet; + r0.template storePacket( + 0, _mm256_add_epi32(blockO_256[i++], + r0.template loadPacket(0))); + r1.template storePacket( + 0, _mm256_add_epi32(blockO_256[i++], + r1.template loadPacket(0))); + } + + // Zero the result block so it can be reused + memset(blockO, 0, 16 * 16 * sizeof(QInt32)); + } + } + aligned_delete(blockO, 16 * 16); +} + +#endif + +// AVX2 optimized implementation of Mat-Mat product. +// LHS is encoded using signed 8-bit integers. +// RHS is encoded using unsigned 8-bit integers. +#ifdef EIGEN_USE_OPTIMIZED_INT8_UINT8_MAT_MAT_PRODUCT + +// Define quantized traits +template +class gebp_traits { + public: + typedef QInt8 LhsScalar; + typedef QUInt8 RhsScalar; + typedef QInt32 ResScalar; + + typedef typename packet_traits::type LhsPacket; + typedef LhsPacket LhsPacket4Packing; + + enum { + // Define register blocking scheme. + nr = 32, + mr = 32, + kr = 8, + // Ignore progress tracking per loop iteration. + LhsProgress = -1, + RhsProgress = -1 + }; +}; + +// Specialized blocking for quantized implementations. +// Used by TensorContractionThreadPool, inputs must have dimensions that are +// multiples of 32. +template +class TensorContractionBlocking< + ResScalar, + TensorContractionInputMapper< + QInt8, Index, Lhs, LeftTensor, left_nocontract_t, left_contract_t, 32, + left_inner_dim_contiguous, left_inner_dim_reordered, LeftAlignment>, + TensorContractionInputMapper, + Index, ShardingType> { + public: + typedef QInt8 LhsScalar; + typedef QUInt8 RhsScalar; + + TensorContractionBlocking(Index k, Index m, Index n, Index num_threads = 1) + : kc_(k), mc_(m), nc_(n) { + eigen_assert(m % 32 == 0); + eigen_assert(k % 32 == 0); + if (!k || !m || !n) { + return; + } + + if (ShardingType == ShardByCol) { + eigen_assert(n % 32 == 0); + nc_ = (((n / num_threads) + 31) / 32) * 32; + } else { + eigen_assert(n % 32 == 0 || n == 1); + // Special case to avoid breaking the unimplemented matrix-vector case + if (n == 1) { + nc_ = 32; + } + mc_ = (((m / num_threads) + 31) / 32) * 32; + } + } + + EIGEN_ALWAYS_INLINE Index kc() const { return kc_; } + EIGEN_ALWAYS_INLINE Index mc() const { return mc_; } + EIGEN_ALWAYS_INLINE Index nc() const { return nc_; } + + private: + Index kc_; + Index mc_; + Index nc_; +}; + +// Specialized blocking for quantized implementations. +// Used by TensorContraction and GeneralMatrixMatrix, inputs are padded to +// multiples of 32. +template +class gemm_blocking_space + : public level3_blocking { + DenseIndex m_sizeA; + DenseIndex m_sizeB; + + public: + gemm_blocking_space(DenseIndex rows, DenseIndex cols, DenseIndex depth, + DenseIndex /*num_threads*/, bool /*l3_blocking*/) { + this->m_mc = ((rows + 31) / 32) * 32; + this->m_nc = ((cols + 31) / 32) * 32; + this->m_kc = ((depth + 31) / 32) * 32; + m_sizeA = this->m_mc * this->m_kc; + m_sizeB = this->m_kc * this->m_nc; + } + void allocateA() { + if (this->m_blockA == 0) this->m_blockA = aligned_new(m_sizeA); + } + void allocateB() { + if (this->m_blockB == 0) this->m_blockB = aligned_new(m_sizeB); + } + void allocateAll() { + allocateA(); + allocateB(); + } + ~gemm_blocking_space() { + aligned_delete(this->m_blockA, m_sizeA); + aligned_delete(this->m_blockB, m_sizeB); + } +}; + +template +class gemm_blocking_space + : public level3_blocking { + DenseIndex m_sizeA; + DenseIndex m_sizeB; + + public: + gemm_blocking_space(DenseIndex rows, DenseIndex cols, DenseIndex depth, + DenseIndex /*num_threads*/, bool /*l3_blocking*/) { + this->m_mc = ((rows + 31) / 32) * 32; + this->m_nc = ((cols + 31) / 32) * 32; + this->m_kc = ((depth + 31) / 32) * 32; + m_sizeA = this->m_mc * this->m_kc; + m_sizeB = this->m_kc * this->m_nc; + } + void allocateA() { + if (this->m_blockA == 0) this->m_blockA = aligned_new(m_sizeA); + } + void allocateB() { + if (this->m_blockB == 0) this->m_blockB = aligned_new(m_sizeB); + } + void allocateAll() { + allocateA(); + allocateB(); + } + ~gemm_blocking_space() { + aligned_delete(this->m_blockA, m_sizeA); + aligned_delete(this->m_blockB, m_sizeB); + } +}; + +// Alternate templates for any input sizes +template +struct gemm_pack_lhs_any; +template +struct gemm_pack_lhs_any { + EIGEN_DONT_INLINE void operator()(QInt8* blockA, const DataMapper& lhs, + Index depth, Index rows, Index stride = 0, + Index offset = 0); +}; + +template +struct gemm_pack_rhs_any; +template +struct gemm_pack_rhs_any { + EIGEN_DONT_INLINE void operator()(QUInt8* blockB, const DataMapper& rhs, + Index depth, Index cols, Index stride = 0, + Index offset = 0); +}; + +template +struct gebp_kernel_any; +template +struct gebp_kernel_any { + typedef typename DataMapper::LinearMapper LinearMapper; + + EIGEN_DONT_INLINE + void operator()(const DataMapper& res, const QInt8* blockA, + const QUInt8* blockB, Index rows, Index depth, Index cols, + QInt32 alpha, Index strideA = -1, Index strideB = -1, + Index offsetA = 0, Index offsetB = 0); +}; + +// Alternate implementations for any input sizes +template +EIGEN_DONT_INLINE void +gemm_pack_lhs_any::operator()(QInt8* blockA, const DataMapper& lhs, + Index depth, Index rows, Index stride, + Index offset) { + eigen_assert(stride == 0); + eigen_assert(offset == 0); + + typedef typename packet_traits::type Packet; + + // Get vector pointer + __m256i* blockA_256 = reinterpret_cast<__m256i*>(blockA); + + // Get even multiples of the dimensions + Index rows_32 = (rows / 32) * 32; + Index depth_8 = (depth / 8) * 8; + + // Get padding for when depth is not a multiple of 32 + int padding = 0; + if (depth % 32 != 0) { + int depth_32 = (depth / 32) * 32; + int extra_depth = depth - depth_32; + int extra_depth_8 = ((extra_depth + 7) / 8) * 8; + padding = 32 - extra_depth_8; + } + + // Pack rows in sets of 32 + for (Index m = 0; m < rows_32; m += 32) { + // Pack depth in sets of 8 + for (Index k = 0; k < depth_8; k += 8) { + // Load vectors + __m256i L_A = lhs.template loadPacket(m, k); + __m256i L_B = lhs.template loadPacket(m, k + 1); + + // Interleave 8-bit elements + __m256i L_AB0_AB16 = _mm256_unpacklo_epi8(L_A, L_B); + __m256i L_AB8_AB24 = _mm256_unpackhi_epi8(L_A, L_B); + + __m256i L_C = lhs.template loadPacket(m, k + 2); + __m256i L_D = lhs.template loadPacket(m, k + 3); + __m256i L_CD0_CD16 = _mm256_unpacklo_epi8(L_C, L_D); + __m256i L_CD8_CD24 = _mm256_unpackhi_epi8(L_C, L_D); + + // Interleave 16-bit elements + __m256i L_AD0_AD16 = _mm256_unpacklo_epi16(L_AB0_AB16, L_CD0_CD16); + __m256i L_AD4_AD20 = _mm256_unpackhi_epi16(L_AB0_AB16, L_CD0_CD16); + + // Use permute before we store to cross 128-bit lanes + __m256i L_AD0 = _mm256_permute2x128_si256(L_AD0_AD16, L_AD4_AD20, 0x20); + _mm256_store_si256(blockA_256++, L_AD0); + + // Complete packing for 32 x 8 block + __m256i L_AD16 = _mm256_permute2x128_si256(L_AD0_AD16, L_AD4_AD20, 0x31); + __m256i L_AD8_AD24 = _mm256_unpacklo_epi16(L_AB8_AB24, L_CD8_CD24); + __m256i L_AD12_AD28 = _mm256_unpackhi_epi16(L_AB8_AB24, L_CD8_CD24); + __m256i L_AD8 = _mm256_permute2x128_si256(L_AD8_AD24, L_AD12_AD28, 0x20); + _mm256_store_si256(blockA_256++, L_AD8); + _mm256_store_si256(blockA_256++, L_AD16); + __m256i L_AD24 = _mm256_permute2x128_si256(L_AD8_AD24, L_AD12_AD28, 0x31); + _mm256_store_si256(blockA_256++, L_AD24); + __m256i L_E = lhs.template loadPacket(m, k + 4); + __m256i L_F = lhs.template loadPacket(m, k + 5); + __m256i L_EF0_EF16 = _mm256_unpacklo_epi8(L_E, L_F); + __m256i L_EF8_EF24 = _mm256_unpackhi_epi8(L_E, L_F); + __m256i L_G = lhs.template loadPacket(m, k + 6); + __m256i L_H = lhs.template loadPacket(m, k + 7); + __m256i L_GH0_GH16 = _mm256_unpacklo_epi8(L_G, L_H); + __m256i L_GH8_GH24 = _mm256_unpackhi_epi8(L_G, L_H); + __m256i L_EH0_EH16 = _mm256_unpacklo_epi16(L_EF0_EF16, L_GH0_GH16); + __m256i L_EH4_EH20 = _mm256_unpackhi_epi16(L_EF0_EF16, L_GH0_GH16); + __m256i L_EH0 = _mm256_permute2x128_si256(L_EH0_EH16, L_EH4_EH20, 0x20); + _mm256_store_si256(blockA_256++, L_EH0); + __m256i L_EH16 = _mm256_permute2x128_si256(L_EH0_EH16, L_EH4_EH20, 0x31); + __m256i L_EH8_EH24 = _mm256_unpacklo_epi16(L_EF8_EF24, L_GH8_GH24); + __m256i L_EH12_EH28 = _mm256_unpackhi_epi16(L_EF8_EF24, L_GH8_GH24); + __m256i L_EH8 = _mm256_permute2x128_si256(L_EH8_EH24, L_EH12_EH28, 0x20); + _mm256_store_si256(blockA_256++, L_EH8); + _mm256_store_si256(blockA_256++, L_EH16); + __m256i L_EH24 = _mm256_permute2x128_si256(L_EH8_EH24, L_EH12_EH28, 0x31); + _mm256_store_si256(blockA_256++, L_EH24); + } + + // Finish the k dimension, padding with zeros + if (depth_8 < depth) { + __m256i L_A, L_B, L_C, L_D, L_E, L_F, L_G, L_H; + switch (depth - depth_8) { + case 1: + L_A = lhs.template loadPacket(m, depth_8); + L_B = _mm256_setzero_si256(); + L_C = _mm256_setzero_si256(); + L_D = _mm256_setzero_si256(); + L_E = _mm256_setzero_si256(); + L_F = _mm256_setzero_si256(); + L_G = _mm256_setzero_si256(); + L_H = _mm256_setzero_si256(); + break; + case 2: + L_A = lhs.template loadPacket(m, depth_8); + L_B = lhs.template loadPacket(m, depth_8 + 1); + L_C = _mm256_setzero_si256(); + L_D = _mm256_setzero_si256(); + L_E = _mm256_setzero_si256(); + L_F = _mm256_setzero_si256(); + L_G = _mm256_setzero_si256(); + L_H = _mm256_setzero_si256(); + break; + case 3: + L_A = lhs.template loadPacket(m, depth_8); + L_B = lhs.template loadPacket(m, depth_8 + 1); + L_C = lhs.template loadPacket(m, depth_8 + 2); + L_D = _mm256_setzero_si256(); + L_E = _mm256_setzero_si256(); + L_F = _mm256_setzero_si256(); + L_G = _mm256_setzero_si256(); + L_H = _mm256_setzero_si256(); + break; + case 4: + L_A = lhs.template loadPacket(m, depth_8); + L_B = lhs.template loadPacket(m, depth_8 + 1); + L_C = lhs.template loadPacket(m, depth_8 + 2); + L_D = lhs.template loadPacket(m, depth_8 + 3); + L_E = _mm256_setzero_si256(); + L_F = _mm256_setzero_si256(); + L_G = _mm256_setzero_si256(); + L_H = _mm256_setzero_si256(); + break; + case 5: + L_A = lhs.template loadPacket(m, depth_8); + L_B = lhs.template loadPacket(m, depth_8 + 1); + L_C = lhs.template loadPacket(m, depth_8 + 2); + L_D = lhs.template loadPacket(m, depth_8 + 3); + L_E = lhs.template loadPacket(m, depth_8 + 4); + L_F = _mm256_setzero_si256(); + L_G = _mm256_setzero_si256(); + L_H = _mm256_setzero_si256(); + break; + case 6: + L_A = lhs.template loadPacket(m, depth_8); + L_B = lhs.template loadPacket(m, depth_8 + 1); + L_C = lhs.template loadPacket(m, depth_8 + 2); + L_D = lhs.template loadPacket(m, depth_8 + 3); + L_E = lhs.template loadPacket(m, depth_8 + 4); + L_F = lhs.template loadPacket(m, depth_8 + 5); + L_G = _mm256_setzero_si256(); + L_H = _mm256_setzero_si256(); + break; + case 7: + L_A = lhs.template loadPacket(m, depth_8); + L_B = lhs.template loadPacket(m, depth_8 + 1); + L_C = lhs.template loadPacket(m, depth_8 + 2); + L_D = lhs.template loadPacket(m, depth_8 + 3); + L_E = lhs.template loadPacket(m, depth_8 + 4); + L_F = lhs.template loadPacket(m, depth_8 + 5); + L_G = lhs.template loadPacket(m, depth_8 + 6); + L_H = _mm256_setzero_si256(); + break; + } + + // Interleave 8-bit elements + __m256i L_AB0_AB16 = _mm256_unpacklo_epi8(L_A, L_B); + __m256i L_AB8_AB24 = _mm256_unpackhi_epi8(L_A, L_B); + + __m256i L_CD0_CD16 = _mm256_unpacklo_epi8(L_C, L_D); + __m256i L_CD8_CD24 = _mm256_unpackhi_epi8(L_C, L_D); + + // Interleave 16-bit elements + __m256i L_AD0_AD16 = _mm256_unpacklo_epi16(L_AB0_AB16, L_CD0_CD16); + __m256i L_AD4_AD20 = _mm256_unpackhi_epi16(L_AB0_AB16, L_CD0_CD16); + + // Use permute before we store to cross 128-bit lanes + __m256i L_AD0 = _mm256_permute2x128_si256(L_AD0_AD16, L_AD4_AD20, 0x20); + _mm256_store_si256(blockA_256++, L_AD0); + + // Complete packing + __m256i L_AD16 = _mm256_permute2x128_si256(L_AD0_AD16, L_AD4_AD20, 0x31); + __m256i L_AD8_AD24 = _mm256_unpacklo_epi16(L_AB8_AB24, L_CD8_CD24); + __m256i L_AD12_AD28 = _mm256_unpackhi_epi16(L_AB8_AB24, L_CD8_CD24); + __m256i L_AD8 = _mm256_permute2x128_si256(L_AD8_AD24, L_AD12_AD28, 0x20); + _mm256_store_si256(blockA_256++, L_AD8); + _mm256_store_si256(blockA_256++, L_AD16); + __m256i L_AD24 = _mm256_permute2x128_si256(L_AD8_AD24, L_AD12_AD28, 0x31); + _mm256_store_si256(blockA_256++, L_AD24); + __m256i L_EF0_EF16 = _mm256_unpacklo_epi8(L_E, L_F); + __m256i L_EF8_EF24 = _mm256_unpackhi_epi8(L_E, L_F); + __m256i L_GH0_GH16 = _mm256_unpacklo_epi8(L_G, L_H); + __m256i L_GH8_GH24 = _mm256_unpackhi_epi8(L_G, L_H); + __m256i L_EH0_EH16 = _mm256_unpacklo_epi16(L_EF0_EF16, L_GH0_GH16); + __m256i L_EH4_EH20 = _mm256_unpackhi_epi16(L_EF0_EF16, L_GH0_GH16); + __m256i L_EH0 = _mm256_permute2x128_si256(L_EH0_EH16, L_EH4_EH20, 0x20); + _mm256_store_si256(blockA_256++, L_EH0); + __m256i L_EH16 = _mm256_permute2x128_si256(L_EH0_EH16, L_EH4_EH20, 0x31); + __m256i L_EH8_EH24 = _mm256_unpacklo_epi16(L_EF8_EF24, L_GH8_GH24); + __m256i L_EH12_EH28 = _mm256_unpackhi_epi16(L_EF8_EF24, L_GH8_GH24); + __m256i L_EH8 = _mm256_permute2x128_si256(L_EH8_EH24, L_EH12_EH28, 0x20); + _mm256_store_si256(blockA_256++, L_EH8); + _mm256_store_si256(blockA_256++, L_EH16); + __m256i L_EH24 = _mm256_permute2x128_si256(L_EH8_EH24, L_EH12_EH28, 0x31); + _mm256_store_si256(blockA_256++, L_EH24); + } + blockA_256 += padding; + } + + // Finish the m dimension, padding with zeros + if (rows_32 < rows) { + // Pack depth in sets of 8 + for (Index k = 0; k < depth_8; k += 8) { + // Load vectors + __m256i L_A = _mm256_setzero_si256(); + __m256i L_B = _mm256_setzero_si256(); + __m256i L_C = _mm256_setzero_si256(); + __m256i L_D = _mm256_setzero_si256(); + __m256i L_E = _mm256_setzero_si256(); + __m256i L_F = _mm256_setzero_si256(); + __m256i L_G = _mm256_setzero_si256(); + __m256i L_H = _mm256_setzero_si256(); + for (Index m = 0; m < rows - rows_32; m++) { + QInt8* ptr = (QInt8*)&L_A; + ptr[m] = lhs(rows_32 + m, k); + ptr = (QInt8*)&L_B; + ptr[m] = lhs(rows_32 + m, k + 1); + ptr = (QInt8*)&L_C; + ptr[m] = lhs(rows_32 + m, k + 2); + ptr = (QInt8*)&L_D; + ptr[m] = lhs(rows_32 + m, k + 3); + ptr = (QInt8*)&L_E; + ptr[m] = lhs(rows_32 + m, k + 4); + ptr = (QInt8*)&L_F; + ptr[m] = lhs(rows_32 + m, k + 5); + ptr = (QInt8*)&L_G; + ptr[m] = lhs(rows_32 + m, k + 6); + ptr = (QInt8*)&L_H; + ptr[m] = lhs(rows_32 + m, k + 7); + } + + // Interleave 8-bit elements + __m256i L_AB0_AB16 = _mm256_unpacklo_epi8(L_A, L_B); + __m256i L_AB8_AB24 = _mm256_unpackhi_epi8(L_A, L_B); + __m256i L_CD0_CD16 = _mm256_unpacklo_epi8(L_C, L_D); + __m256i L_CD8_CD24 = _mm256_unpackhi_epi8(L_C, L_D); + + // Interleave 16-bit elements + __m256i L_AD0_AD16 = _mm256_unpacklo_epi16(L_AB0_AB16, L_CD0_CD16); + __m256i L_AD4_AD20 = _mm256_unpackhi_epi16(L_AB0_AB16, L_CD0_CD16); + + // Use permute before we store to cross 128-bit lanes + __m256i L_AD0 = _mm256_permute2x128_si256(L_AD0_AD16, L_AD4_AD20, 0x20); + _mm256_store_si256(blockA_256++, L_AD0); + + // Complete packing for 32 x 8 block + __m256i L_AD16 = _mm256_permute2x128_si256(L_AD0_AD16, L_AD4_AD20, 0x31); + __m256i L_AD8_AD24 = _mm256_unpacklo_epi16(L_AB8_AB24, L_CD8_CD24); + __m256i L_AD12_AD28 = _mm256_unpackhi_epi16(L_AB8_AB24, L_CD8_CD24); + __m256i L_AD8 = _mm256_permute2x128_si256(L_AD8_AD24, L_AD12_AD28, 0x20); + _mm256_store_si256(blockA_256++, L_AD8); + _mm256_store_si256(blockA_256++, L_AD16); + __m256i L_AD24 = _mm256_permute2x128_si256(L_AD8_AD24, L_AD12_AD28, 0x31); + _mm256_store_si256(blockA_256++, L_AD24); + __m256i L_EF0_EF16 = _mm256_unpacklo_epi8(L_E, L_F); + __m256i L_EF8_EF24 = _mm256_unpackhi_epi8(L_E, L_F); + __m256i L_GH0_GH16 = _mm256_unpacklo_epi8(L_G, L_H); + __m256i L_GH8_GH24 = _mm256_unpackhi_epi8(L_G, L_H); + __m256i L_EH0_EH16 = _mm256_unpacklo_epi16(L_EF0_EF16, L_GH0_GH16); + __m256i L_EH4_EH20 = _mm256_unpackhi_epi16(L_EF0_EF16, L_GH0_GH16); + __m256i L_EH0 = _mm256_permute2x128_si256(L_EH0_EH16, L_EH4_EH20, 0x20); + _mm256_store_si256(blockA_256++, L_EH0); + __m256i L_EH16 = _mm256_permute2x128_si256(L_EH0_EH16, L_EH4_EH20, 0x31); + __m256i L_EH8_EH24 = _mm256_unpacklo_epi16(L_EF8_EF24, L_GH8_GH24); + __m256i L_EH12_EH28 = _mm256_unpackhi_epi16(L_EF8_EF24, L_GH8_GH24); + __m256i L_EH8 = _mm256_permute2x128_si256(L_EH8_EH24, L_EH12_EH28, 0x20); + _mm256_store_si256(blockA_256++, L_EH8); + _mm256_store_si256(blockA_256++, L_EH16); + __m256i L_EH24 = _mm256_permute2x128_si256(L_EH8_EH24, L_EH12_EH28, 0x31); + _mm256_store_si256(blockA_256++, L_EH24); + } + + // Finish the k dimension, padding with zeros + if (depth_8 < depth) { + __m256i L_A, L_B, L_C, L_D, L_E, L_F, L_G, L_H; + QInt8* ptr; + switch (depth - depth_8) { + case 1: + L_A = _mm256_setzero_si256(); + L_B = _mm256_setzero_si256(); + L_C = _mm256_setzero_si256(); + L_D = _mm256_setzero_si256(); + L_E = _mm256_setzero_si256(); + L_F = _mm256_setzero_si256(); + L_G = _mm256_setzero_si256(); + L_H = _mm256_setzero_si256(); + for (Index m = 0; m < rows - rows_32; m++) { + QInt8* ptr = (QInt8*)&L_A; + ptr[m] = lhs(rows_32 + m, depth_8); + } + break; + case 2: + L_A = _mm256_setzero_si256(); + L_B = _mm256_setzero_si256(); + L_C = _mm256_setzero_si256(); + L_D = _mm256_setzero_si256(); + L_E = _mm256_setzero_si256(); + L_F = _mm256_setzero_si256(); + L_G = _mm256_setzero_si256(); + L_H = _mm256_setzero_si256(); + for (Index m = 0; m < rows - rows_32; m++) { + ptr = (QInt8*)&L_A; + ptr[m] = lhs(rows_32 + m, depth_8); + ptr = (QInt8*)&L_B; + ptr[m] = lhs(rows_32 + m, depth_8 + 1); + } + break; + case 3: + L_A = _mm256_setzero_si256(); + L_B = _mm256_setzero_si256(); + L_C = _mm256_setzero_si256(); + L_D = _mm256_setzero_si256(); + L_E = _mm256_setzero_si256(); + L_F = _mm256_setzero_si256(); + L_G = _mm256_setzero_si256(); + L_H = _mm256_setzero_si256(); + for (Index m = 0; m < rows - rows_32; m++) { + ptr = (QInt8*)&L_A; + ptr[m] = lhs(rows_32 + m, depth_8); + ptr = (QInt8*)&L_B; + ptr[m] = lhs(rows_32 + m, depth_8 + 1); + ptr = (QInt8*)&L_C; + ptr[m] = lhs(rows_32 + m, depth_8 + 2); + } + break; + case 4: + L_A = _mm256_setzero_si256(); + L_B = _mm256_setzero_si256(); + L_C = _mm256_setzero_si256(); + L_D = _mm256_setzero_si256(); + L_E = _mm256_setzero_si256(); + L_F = _mm256_setzero_si256(); + L_G = _mm256_setzero_si256(); + L_H = _mm256_setzero_si256(); + for (Index m = 0; m < rows - rows_32; m++) { + ptr = (QInt8*)&L_A; + ptr[m] = lhs(rows_32 + m, depth_8); + ptr = (QInt8*)&L_B; + ptr[m] = lhs(rows_32 + m, depth_8 + 1); + ptr = (QInt8*)&L_C; + ptr[m] = lhs(rows_32 + m, depth_8 + 2); + ptr = (QInt8*)&L_D; + ptr[m] = lhs(rows_32 + m, depth_8 + 3); + } + break; + case 5: + L_A = _mm256_setzero_si256(); + L_B = _mm256_setzero_si256(); + L_C = _mm256_setzero_si256(); + L_D = _mm256_setzero_si256(); + L_E = _mm256_setzero_si256(); + L_F = _mm256_setzero_si256(); + L_G = _mm256_setzero_si256(); + L_H = _mm256_setzero_si256(); + for (Index m = 0; m < rows - rows_32; m++) { + ptr = (QInt8*)&L_A; + ptr[m] = lhs(rows_32 + m, depth_8); + ptr = (QInt8*)&L_B; + ptr[m] = lhs(rows_32 + m, depth_8 + 1); + ptr = (QInt8*)&L_C; + ptr[m] = lhs(rows_32 + m, depth_8 + 2); + ptr = (QInt8*)&L_D; + ptr[m] = lhs(rows_32 + m, depth_8 + 3); + ptr = (QInt8*)&L_E; + ptr[m] = lhs(rows_32 + m, depth_8 + 4); + } + break; + case 6: + L_A = _mm256_setzero_si256(); + L_B = _mm256_setzero_si256(); + L_C = _mm256_setzero_si256(); + L_D = _mm256_setzero_si256(); + L_E = _mm256_setzero_si256(); + L_F = _mm256_setzero_si256(); + L_G = _mm256_setzero_si256(); + L_H = _mm256_setzero_si256(); + for (Index m = 0; m < rows - rows_32; m++) { + ptr = (QInt8*)&L_A; + ptr[m] = lhs(rows_32 + m, depth_8); + ptr = (QInt8*)&L_B; + ptr[m] = lhs(rows_32 + m, depth_8 + 1); + ptr = (QInt8*)&L_C; + ptr[m] = lhs(rows_32 + m, depth_8 + 2); + ptr = (QInt8*)&L_D; + ptr[m] = lhs(rows_32 + m, depth_8 + 3); + ptr = (QInt8*)&L_E; + ptr[m] = lhs(rows_32 + m, depth_8 + 4); + ptr = (QInt8*)&L_F; + ptr[m] = lhs(rows_32 + m, depth_8 + 5); + } + break; + case 7: + L_A = _mm256_setzero_si256(); + L_B = _mm256_setzero_si256(); + L_C = _mm256_setzero_si256(); + L_D = _mm256_setzero_si256(); + L_E = _mm256_setzero_si256(); + L_F = _mm256_setzero_si256(); + L_G = _mm256_setzero_si256(); + L_H = _mm256_setzero_si256(); + for (Index m = 0; m < rows - rows_32; m++) { + ptr = (QInt8*)&L_A; + ptr[m] = lhs(rows_32 + m, depth_8); + ptr = (QInt8*)&L_B; + ptr[m] = lhs(rows_32 + m, depth_8 + 1); + ptr = (QInt8*)&L_C; + ptr[m] = lhs(rows_32 + m, depth_8 + 2); + ptr = (QInt8*)&L_D; + ptr[m] = lhs(rows_32 + m, depth_8 + 3); + ptr = (QInt8*)&L_E; + ptr[m] = lhs(rows_32 + m, depth_8 + 4); + ptr = (QInt8*)&L_F; + ptr[m] = lhs(rows_32 + m, depth_8 + 5); + ptr = (QInt8*)&L_G; + ptr[m] = lhs(rows_32 + m, depth_8 + 6); + } + break; + } + + // Interleave 8-bit elements + __m256i L_AB0_AB16 = _mm256_unpacklo_epi8(L_A, L_B); + __m256i L_AB8_AB24 = _mm256_unpackhi_epi8(L_A, L_B); + __m256i L_CD0_CD16 = _mm256_unpacklo_epi8(L_C, L_D); + __m256i L_CD8_CD24 = _mm256_unpackhi_epi8(L_C, L_D); + + // Interleave 16-bit elements + __m256i L_AD0_AD16 = _mm256_unpacklo_epi16(L_AB0_AB16, L_CD0_CD16); + __m256i L_AD4_AD20 = _mm256_unpackhi_epi16(L_AB0_AB16, L_CD0_CD16); + + // Use permute before we store to cross 128-bit lanes + __m256i L_AD0 = _mm256_permute2x128_si256(L_AD0_AD16, L_AD4_AD20, 0x20); + _mm256_store_si256(blockA_256++, L_AD0); + + // Complete packing + __m256i L_AD16 = _mm256_permute2x128_si256(L_AD0_AD16, L_AD4_AD20, 0x31); + __m256i L_AD8_AD24 = _mm256_unpacklo_epi16(L_AB8_AB24, L_CD8_CD24); + __m256i L_AD12_AD28 = _mm256_unpackhi_epi16(L_AB8_AB24, L_CD8_CD24); + __m256i L_AD8 = _mm256_permute2x128_si256(L_AD8_AD24, L_AD12_AD28, 0x20); + _mm256_store_si256(blockA_256++, L_AD8); + _mm256_store_si256(blockA_256++, L_AD16); + __m256i L_AD24 = _mm256_permute2x128_si256(L_AD8_AD24, L_AD12_AD28, 0x31); + _mm256_store_si256(blockA_256++, L_AD24); + __m256i L_EF0_EF16 = _mm256_unpacklo_epi8(L_E, L_F); + __m256i L_EF8_EF24 = _mm256_unpackhi_epi8(L_E, L_F); + __m256i L_GH0_GH16 = _mm256_unpacklo_epi8(L_G, L_H); + __m256i L_GH8_GH24 = _mm256_unpackhi_epi8(L_G, L_H); + __m256i L_EH0_EH16 = _mm256_unpacklo_epi16(L_EF0_EF16, L_GH0_GH16); + __m256i L_EH4_EH20 = _mm256_unpackhi_epi16(L_EF0_EF16, L_GH0_GH16); + __m256i L_EH0 = _mm256_permute2x128_si256(L_EH0_EH16, L_EH4_EH20, 0x20); + _mm256_store_si256(blockA_256++, L_EH0); + __m256i L_EH16 = _mm256_permute2x128_si256(L_EH0_EH16, L_EH4_EH20, 0x31); + __m256i L_EH8_EH24 = _mm256_unpacklo_epi16(L_EF8_EF24, L_GH8_GH24); + __m256i L_EH12_EH28 = _mm256_unpackhi_epi16(L_EF8_EF24, L_GH8_GH24); + __m256i L_EH8 = _mm256_permute2x128_si256(L_EH8_EH24, L_EH12_EH28, 0x20); + _mm256_store_si256(blockA_256++, L_EH8); + _mm256_store_si256(blockA_256++, L_EH16); + __m256i L_EH24 = _mm256_permute2x128_si256(L_EH8_EH24, L_EH12_EH28, 0x31); + _mm256_store_si256(blockA_256++, L_EH24); + } + } +} + +template +EIGEN_DONT_INLINE void +gemm_pack_rhs_any::operator()(QUInt8* blockB, const DataMapper& rhs, + Index depth, Index cols, Index stride, + Index offset) { + eigen_assert(stride == 0); + eigen_assert(offset == 0); + + typedef typename packet_traits::type Packet; + + // Get vector pointer + __m256i* blockB_256 = reinterpret_cast<__m256i*>(blockB); + + // Get even multiples of the dimensions + Index cols_32 = (cols / 32) * 32; + Index depth_32 = (depth / 32) * 32; + + // Perform a step of the packing for 4 columns + __m256i R_AB_L, R_AB_H, R_CD_L, R_CD_H, R_AD_0, R_AD_8, R_AD_16, R_AD_24; +#define PACK_STEP \ + R_AB_L = _mm256_unpacklo_epi64(R_A, R_B); \ + R_CD_L = _mm256_unpacklo_epi64(R_C, R_D); \ + R_AB_H = _mm256_unpackhi_epi64(R_A, R_B); \ + R_CD_H = _mm256_unpackhi_epi64(R_C, R_D); \ + R_AD_0 = _mm256_permute2x128_si256(R_AB_L, R_CD_L, 0x20); \ + R_AD_16 = _mm256_permute2x128_si256(R_AB_L, R_CD_L, 0x31); \ + R_AD_8 = _mm256_permute2x128_si256(R_AB_H, R_CD_H, 0x20); \ + R_AD_24 = _mm256_permute2x128_si256(R_AB_H, R_CD_H, 0x31); \ + _mm256_store_si256(blockB_256, R_AD_0); \ + _mm256_store_si256(blockB_256 + 8, R_AD_8); \ + _mm256_store_si256(blockB_256 + 16, R_AD_16); \ + _mm256_store_si256(blockB_256 + 24, R_AD_24); \ + blockB_256++; + + // Pack cols in sets of 32 + for (Index n = 0; n < cols_32; n += 32) { + // Pack depth in sets of 32 + for (Index k = 0; k < depth_32; k += 32) { + __m256i R_A = rhs.template loadPacket(k, n); + __m256i R_B = rhs.template loadPacket(k, n + 1); + __m256i R_C = rhs.template loadPacket(k, n + 2); + __m256i R_D = rhs.template loadPacket(k, n + 3); + PACK_STEP; + + R_A = rhs.template loadPacket(k, n + 4); + R_B = rhs.template loadPacket(k, n + 5); + R_C = rhs.template loadPacket(k, n + 6); + R_D = rhs.template loadPacket(k, n + 7); + PACK_STEP; + + R_A = rhs.template loadPacket(k, n + 8); + R_B = rhs.template loadPacket(k, n + 9); + R_C = rhs.template loadPacket(k, n + 10); + R_D = rhs.template loadPacket(k, n + 11); + PACK_STEP; + + R_A = rhs.template loadPacket(k, n + 12); + R_B = rhs.template loadPacket(k, n + 13); + R_C = rhs.template loadPacket(k, n + 14); + R_D = rhs.template loadPacket(k, n + 15); + PACK_STEP; + + R_A = rhs.template loadPacket(k, n + 16); + R_B = rhs.template loadPacket(k, n + 17); + R_C = rhs.template loadPacket(k, n + 18); + R_D = rhs.template loadPacket(k, n + 19); + PACK_STEP; + + R_A = rhs.template loadPacket(k, n + 20); + R_B = rhs.template loadPacket(k, n + 21); + R_C = rhs.template loadPacket(k, n + 22); + R_D = rhs.template loadPacket(k, n + 23); + PACK_STEP; + + R_A = rhs.template loadPacket(k, n + 24); + R_B = rhs.template loadPacket(k, n + 25); + R_C = rhs.template loadPacket(k, n + 26); + R_D = rhs.template loadPacket(k, n + 27); + PACK_STEP; + + R_A = rhs.template loadPacket(k, n + 28); + R_B = rhs.template loadPacket(k, n + 29); + R_C = rhs.template loadPacket(k, n + 30); + R_D = rhs.template loadPacket(k, n + 31); + PACK_STEP; + + blockB_256 += 24; + } + + if (depth_32 < depth) { + QUInt8* ptr; + __m256i R_A = _mm256_setzero_si256(); + __m256i R_B = _mm256_setzero_si256(); + __m256i R_C = _mm256_setzero_si256(); + __m256i R_D = _mm256_setzero_si256(); + for (Index k = depth_32; k < depth; k++) { + ptr = (QUInt8*)&R_A; + ptr[k - depth_32] = rhs(k, n); + ptr = (QUInt8*)&R_B; + ptr[k - depth_32] = rhs(k, n + 1); + ptr = (QUInt8*)&R_C; + ptr[k - depth_32] = rhs(k, n + 2); + ptr = (QUInt8*)&R_D; + ptr[k - depth_32] = rhs(k, n + 3); + } + PACK_STEP; + + R_A = _mm256_setzero_si256(); + R_B = _mm256_setzero_si256(); + R_C = _mm256_setzero_si256(); + R_D = _mm256_setzero_si256(); + for (Index k = depth_32; k < depth; k++) { + ptr = (QUInt8*)&R_A; + ptr[k - depth_32] = rhs(k, n + 4); + ptr = (QUInt8*)&R_B; + ptr[k - depth_32] = rhs(k, n + 5); + ptr = (QUInt8*)&R_C; + ptr[k - depth_32] = rhs(k, n + 6); + ptr = (QUInt8*)&R_D; + ptr[k - depth_32] = rhs(k, n + 7); + } + PACK_STEP; + + R_A = _mm256_setzero_si256(); + R_B = _mm256_setzero_si256(); + R_C = _mm256_setzero_si256(); + R_D = _mm256_setzero_si256(); + for (Index k = depth_32; k < depth; k++) { + ptr = (QUInt8*)&R_A; + ptr[k - depth_32] = rhs(k, n + 8); + ptr = (QUInt8*)&R_B; + ptr[k - depth_32] = rhs(k, n + 9); + ptr = (QUInt8*)&R_C; + ptr[k - depth_32] = rhs(k, n + 10); + ptr = (QUInt8*)&R_D; + ptr[k - depth_32] = rhs(k, n + 11); + } + PACK_STEP; + + R_A = _mm256_setzero_si256(); + R_B = _mm256_setzero_si256(); + R_C = _mm256_setzero_si256(); + R_D = _mm256_setzero_si256(); + for (Index k = depth_32; k < depth; k++) { + ptr = (QUInt8*)&R_A; + ptr[k - depth_32] = rhs(k, n + 12); + ptr = (QUInt8*)&R_B; + ptr[k - depth_32] = rhs(k, n + 13); + ptr = (QUInt8*)&R_C; + ptr[k - depth_32] = rhs(k, n + 14); + ptr = (QUInt8*)&R_D; + ptr[k - depth_32] = rhs(k, n + 15); + } + PACK_STEP; + + R_A = _mm256_setzero_si256(); + R_B = _mm256_setzero_si256(); + R_C = _mm256_setzero_si256(); + R_D = _mm256_setzero_si256(); + for (Index k = depth_32; k < depth; k++) { + ptr = (QUInt8*)&R_A; + ptr[k - depth_32] = rhs(k, n + 16); + ptr = (QUInt8*)&R_B; + ptr[k - depth_32] = rhs(k, n + 17); + ptr = (QUInt8*)&R_C; + ptr[k - depth_32] = rhs(k, n + 18); + ptr = (QUInt8*)&R_D; + ptr[k - depth_32] = rhs(k, n + 19); + } + PACK_STEP; + + R_A = _mm256_setzero_si256(); + R_B = _mm256_setzero_si256(); + R_C = _mm256_setzero_si256(); + R_D = _mm256_setzero_si256(); + for (Index k = depth_32; k < depth; k++) { + ptr = (QUInt8*)&R_A; + ptr[k - depth_32] = rhs(k, n + 20); + ptr = (QUInt8*)&R_B; + ptr[k - depth_32] = rhs(k, n + 21); + ptr = (QUInt8*)&R_C; + ptr[k - depth_32] = rhs(k, n + 22); + ptr = (QUInt8*)&R_D; + ptr[k - depth_32] = rhs(k, n + 23); + } + PACK_STEP; + + R_A = _mm256_setzero_si256(); + R_B = _mm256_setzero_si256(); + R_C = _mm256_setzero_si256(); + R_D = _mm256_setzero_si256(); + for (Index k = depth_32; k < depth; k++) { + ptr = (QUInt8*)&R_A; + ptr[k - depth_32] = rhs(k, n + 24); + ptr = (QUInt8*)&R_B; + ptr[k - depth_32] = rhs(k, n + 25); + ptr = (QUInt8*)&R_C; + ptr[k - depth_32] = rhs(k, n + 26); + ptr = (QUInt8*)&R_D; + ptr[k - depth_32] = rhs(k, n + 27); + } + PACK_STEP; + + R_A = _mm256_setzero_si256(); + R_B = _mm256_setzero_si256(); + R_C = _mm256_setzero_si256(); + R_D = _mm256_setzero_si256(); + for (Index k = depth_32; k < depth; k++) { + ptr = (QUInt8*)&R_A; + ptr[k - depth_32] = rhs(k, n + 28); + ptr = (QUInt8*)&R_B; + ptr[k - depth_32] = rhs(k, n + 29); + ptr = (QUInt8*)&R_C; + ptr[k - depth_32] = rhs(k, n + 30); + ptr = (QUInt8*)&R_D; + ptr[k - depth_32] = rhs(k, n + 31); + } + PACK_STEP; + blockB_256 += 24; + } + } + + // Finish packing cols + if (cols_32 < cols) { + // Pack depth in sets of 32 + for (Index k = 0; k < depth_32; k += 32) { + __m256i R_A, R_B, R_C, R_D; + Index n; + for (n = cols_32; n < cols; n += 4) { + switch (cols - n) { + case 1: + R_A = rhs.template loadPacket(k, n); + R_B = _mm256_setzero_si256(); + R_C = _mm256_setzero_si256(); + R_D = _mm256_setzero_si256(); + PACK_STEP; + break; + case 2: + R_A = rhs.template loadPacket(k, n); + R_B = rhs.template loadPacket(k, n + 1); + R_C = _mm256_setzero_si256(); + R_D = _mm256_setzero_si256(); + PACK_STEP; + break; + case 3: + R_A = rhs.template loadPacket(k, n); + R_B = rhs.template loadPacket(k, n + 1); + R_C = rhs.template loadPacket(k, n + 2); + R_D = _mm256_setzero_si256(); + PACK_STEP; + break; + default: + R_A = rhs.template loadPacket(k, n); + R_B = rhs.template loadPacket(k, n + 1); + R_C = rhs.template loadPacket(k, n + 2); + R_D = rhs.template loadPacket(k, n + 3); + PACK_STEP; + break; + } + } + + // Increment the block pointer. + // We must pad if cols is not a multiple of 32. + blockB_256 += 32 - (n - cols_32) / 4; + } + + if (depth_32 < depth) { + for (Index n = cols_32; n < cols; n += 4) { + QUInt8* ptr; + __m256i R_A = _mm256_setzero_si256(); + __m256i R_B = _mm256_setzero_si256(); + __m256i R_C = _mm256_setzero_si256(); + __m256i R_D = _mm256_setzero_si256(); + switch (cols - n) { + case 1: + for (Index k = depth_32; k < depth; k++) { + ptr = (QUInt8*)&R_A; + ptr[k - depth_32] = rhs(k, n); + } + PACK_STEP; + break; + case 2: + for (Index k = depth_32; k < depth; k++) { + ptr = (QUInt8*)&R_A; + ptr[k - depth_32] = rhs(k, n); + ptr = (QUInt8*)&R_B; + ptr[k - depth_32] = rhs(k, n + 1); + } + PACK_STEP; + break; + case 3: + for (Index k = depth_32; k < depth; k++) { + ptr = (QUInt8*)&R_A; + ptr[k - depth_32] = rhs(k, n); + ptr = (QUInt8*)&R_B; + ptr[k - depth_32] = rhs(k, n + 1); + ptr = (QUInt8*)&R_C; + ptr[k - depth_32] = rhs(k, n + 2); + } + PACK_STEP; + break; + default: + for (Index k = depth_32; k < depth; k++) { + ptr = (QUInt8*)&R_A; + ptr[k - depth_32] = rhs(k, n); + ptr = (QUInt8*)&R_B; + ptr[k - depth_32] = rhs(k, n + 1); + ptr = (QUInt8*)&R_C; + ptr[k - depth_32] = rhs(k, n + 2); + ptr = (QUInt8*)&R_D; + ptr[k - depth_32] = rhs(k, n + 3); + } + PACK_STEP; + break; + } + } + } + } +#undef PACK_STEP +} + +template +EIGEN_DONT_INLINE void +gebp_kernel_any::operator()(const DataMapper& res, + const QInt8* blockA, + const QUInt8* blockB, Index rows, + Index depth, Index cols, QInt32 alpha, + Index strideA, Index strideB, + Index offsetA, Index offsetB) { + EIGEN_STATIC_ASSERT(!ConjugateLhs, YOU_MADE_A_PROGRAMMING_MISTAKE); + EIGEN_STATIC_ASSERT(!ConjugateRhs, YOU_MADE_A_PROGRAMMING_MISTAKE); + eigen_assert(alpha.value == 1); + eigen_assert(strideA == -1); + eigen_assert(strideB == -1); + eigen_assert(offsetA == 0); + eigen_assert(offsetB == 0); + eigen_assert(rows > 0); + eigen_assert(cols > 0); + eigen_assert(depth > 0); + eigen_assert(blockA); + eigen_assert(blockB); + + Index rows_32 = ((rows + 31) / 32) * 32; + Index cols_32 = ((cols + 31) / 32) * 32; + Index depth_32 = ((depth + 31) / 32) * 32; + + // Create result block + ei_declare_aligned_stack_constructed_variable(QInt32, blockO, 32 * 32, 0); + memset(blockO, 0, 32 * 32 * sizeof(QInt32)); + + // Get vectorized pointers + __m256i* blockO_256 = reinterpret_cast<__m256i*>(blockO); + const __m256i* blockA_256 = reinterpret_cast(blockA); + const __m256i* blockB_256 = reinterpret_cast(blockB); + + // Loop over blocks of 32 columns + for (Index n = 0; n < cols_32; n += 32) { + // Reset index into blockA + Index indexL = 0; + // Loop over blocks of 32 rows + for (Index m = 0; m < rows_32; m += 32) { + // Reset index into blockB + Index indexR = n / 32 * depth_32; + // Loop over blocks of 8 on depth + for (Index k = 0; k < depth_32; k += 8) { + // Load inputs + __m256i L_AD0 = blockA_256[indexL++]; + __m256i L_AD8 = blockA_256[indexL++]; + __m256i L_AD16 = blockA_256[indexL++]; + __m256i L_AD24 = blockA_256[indexL++]; + __m256i L_EH0 = blockA_256[indexL++]; + __m256i L_EH8 = blockA_256[indexL++]; + __m256i L_EH16 = blockA_256[indexL++]; + __m256i L_EH24 = blockA_256[indexL++]; + __m256i R_AH0 = blockB_256[indexR++]; + __m256i R_AH4 = blockB_256[indexR++]; + __m256i R_AH8 = blockB_256[indexR++]; + __m256i R_AH12 = blockB_256[indexR++]; + __m256i R_AH16 = blockB_256[indexR++]; + __m256i R_AH20 = blockB_256[indexR++]; + __m256i R_AH24 = blockB_256[indexR++]; + __m256i R_AH28 = blockB_256[indexR++]; + + // This constant is used with madd to convert 16 bit to 32 bit + const __m256i ONE = _mm256_set1_epi32(0x00010001); + + // Declare variables used in COMPUTE_STEP + __m256i P_16_A, P_16_B, P_32_A, P_32_B, P_32; + +#define COMPUTE_STEP(R_INPUT_A, R_INPUT_B, OFFSET) \ + P_16_A = _mm256_maddubs_epi16(R_INPUT_A, L_AD0); \ + P_32_A = _mm256_madd_epi16(P_16_A, ONE); \ + P_16_B = _mm256_maddubs_epi16(R_INPUT_B, L_EH0); \ + P_32_B = _mm256_madd_epi16(P_16_B, ONE); \ + P_32 = _mm256_add_epi32(P_32_A, P_32_B); \ + _mm256_store_si256( \ + blockO_256 + 4 * OFFSET, \ + _mm256_add_epi32(_mm256_load_si256(blockO_256 + 4 * OFFSET), P_32)); \ + \ + P_16_A = _mm256_maddubs_epi16(R_INPUT_A, L_AD8); \ + P_32_A = _mm256_madd_epi16(P_16_A, ONE); \ + P_16_B = _mm256_maddubs_epi16(R_INPUT_B, L_EH8); \ + P_32_B = _mm256_madd_epi16(P_16_B, ONE); \ + P_32 = _mm256_add_epi32(P_32_A, P_32_B); \ + _mm256_store_si256( \ + blockO_256 + 4 * OFFSET + 1, \ + _mm256_add_epi32(_mm256_load_si256(blockO_256 + 4 * OFFSET + 1), P_32)); \ + \ + P_16_A = _mm256_maddubs_epi16(R_INPUT_A, L_AD16); \ + P_32_A = _mm256_madd_epi16(P_16_A, ONE); \ + P_16_B = _mm256_maddubs_epi16(R_INPUT_B, L_EH16); \ + P_32_B = _mm256_madd_epi16(P_16_B, ONE); \ + P_32 = _mm256_add_epi32(P_32_A, P_32_B); \ + _mm256_store_si256( \ + blockO_256 + 4 * OFFSET + 2, \ + _mm256_add_epi32(_mm256_load_si256(blockO_256 + 4 * OFFSET + 2), P_32)); \ + \ + P_16_A = _mm256_maddubs_epi16(R_INPUT_A, L_AD24); \ + P_32_A = _mm256_madd_epi16(P_16_A, ONE); \ + P_16_B = _mm256_maddubs_epi16(R_INPUT_B, L_EH24); \ + P_32_B = _mm256_madd_epi16(P_16_B, ONE); \ + P_32 = _mm256_add_epi32(P_32_A, P_32_B); \ + _mm256_store_si256( \ + blockO_256 + 4 * OFFSET + 3, \ + _mm256_add_epi32(_mm256_load_si256(blockO_256 + 4 * OFFSET + 3), P_32)); + + // Permute and shuffle to copy a single value across the entire vector + // Then compute the multiplication + __m256i R_AH0_ = _mm256_permute2x128_si256(R_AH0, R_AH0, 0x00); + __m256i R_AD0 = _mm256_shuffle_epi32(R_AH0_, 0x00); + __m256i R_EH0 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD0, R_EH0, 0); + __m256i R_AD1 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + __m256i R_EH1 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD1, R_EH1, 1); + R_AH0_ = _mm256_permute2x128_si256(R_AH0, R_AH0, 0x11); + __m256i R_AD2 = _mm256_shuffle_epi32(R_AH0_, 0x00); + __m256i R_EH2 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD2, R_EH2, 2); + __m256i R_AD3 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + __m256i R_EH3 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD3, R_EH3, 3); + + R_AH0_ = _mm256_permute2x128_si256(R_AH4, R_AH4, 0x00); + R_AD0 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH0 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD0, R_EH0, 4); + R_AD1 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH1 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD1, R_EH1, 5); + R_AH0_ = _mm256_permute2x128_si256(R_AH4, R_AH4, 0x11); + R_AD2 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH2 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD2, R_EH2, 6); + R_AD3 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH3 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD3, R_EH3, 7); + + R_AH0_ = _mm256_permute2x128_si256(R_AH8, R_AH8, 0x00); + R_AD0 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH0 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD0, R_EH0, 8); + R_AD1 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH1 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD1, R_EH1, 9); + R_AH0_ = _mm256_permute2x128_si256(R_AH8, R_AH8, 0x11); + R_AD2 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH2 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD2, R_EH2, 10); + R_AD3 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH3 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD3, R_EH3, 11); + + R_AH0_ = _mm256_permute2x128_si256(R_AH12, R_AH12, 0x00); + R_AD0 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH0 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD0, R_EH0, 12); + R_AD1 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH1 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD1, R_EH1, 13); + R_AH0_ = _mm256_permute2x128_si256(R_AH12, R_AH12, 0x11); + R_AD2 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH2 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD2, R_EH2, 14); + R_AD3 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH3 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD3, R_EH3, 15); + + R_AH0_ = _mm256_permute2x128_si256(R_AH16, R_AH16, 0x00); + R_AD0 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH0 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD0, R_EH0, 16); + R_AD1 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH1 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD1, R_EH1, 17); + R_AH0_ = _mm256_permute2x128_si256(R_AH16, R_AH16, 0x11); + R_AD2 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH2 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD2, R_EH2, 18); + R_AD3 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH3 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD3, R_EH3, 19); + + R_AH0_ = _mm256_permute2x128_si256(R_AH20, R_AH20, 0x00); + R_AD0 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH0 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD0, R_EH0, 20); + R_AD1 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH1 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD1, R_EH1, 21); + R_AH0_ = _mm256_permute2x128_si256(R_AH20, R_AH20, 0x11); + R_AD2 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH2 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD2, R_EH2, 22); + R_AD3 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH3 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD3, R_EH3, 23); + + R_AH0_ = _mm256_permute2x128_si256(R_AH24, R_AH24, 0x00); + R_AD0 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH0 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD0, R_EH0, 24); + R_AD1 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH1 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD1, R_EH1, 25); + R_AH0_ = _mm256_permute2x128_si256(R_AH24, R_AH24, 0x11); + R_AD2 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH2 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD2, R_EH2, 26); + R_AD3 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH3 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD3, R_EH3, 27); + + R_AH0_ = _mm256_permute2x128_si256(R_AH28, R_AH28, 0x00); + R_AD0 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH0 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD0, R_EH0, 28); + R_AD1 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH1 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD1, R_EH1, 29); + R_AH0_ = _mm256_permute2x128_si256(R_AH28, R_AH28, 0x11); + R_AD2 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH2 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD2, R_EH2, 30); + R_AD3 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH3 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD3, R_EH3, 31); + +#undef COMPUTE_STEP + } + + // Transfer the results to the result matrix. + if (m + 32 <= rows && n + 32 <= cols) { + Index i = 0; + for (Index j = n; j < n + 32; j++) { + LinearMapper r0 = res.getLinearMapper(m, j); + LinearMapper r1 = res.getLinearMapper(m + 8, j); + LinearMapper r2 = res.getLinearMapper(m + 16, j); + LinearMapper r3 = res.getLinearMapper(m + 24, j); + typedef typename packet_traits::type Packet; + r0.template storePacket( + 0, _mm256_add_epi32(blockO_256[i++], + r0.template loadPacket(0))); + r1.template storePacket( + 0, _mm256_add_epi32(blockO_256[i++], + r1.template loadPacket(0))); + r2.template storePacket( + 0, _mm256_add_epi32(blockO_256[i++], + r2.template loadPacket(0))); + r3.template storePacket( + 0, _mm256_add_epi32(blockO_256[i++], + r3.template loadPacket(0))); + } + } else { + for (Index j = n; j < cols; j++) { + for (Index i = m; i < rows; i++) { + res(i, j) = blockO[(j - n) * 32 + (i - m)]; + } + } + } + + // Zero the result block so it can be reused + memset(blockO, 0, 32 * 32 * sizeof(QInt32)); + } + } +} + +// Below are the fully optimized versions that are correct only for sizes that +// are multiple of 32. It is about a 10% performance benefit to keep these +// implementations separate. + +// Arrange a block of the left input matrix in contiguous memory. +// +// Given column major input (A0 beside A1 in memory): +// A0 B0 C0 D0 E0 F0 G0 H0 ... +// A1 B1 C1 D1 E1 F1 G1 H1 ... +// A2 B2 C2 D2 E2 F2 G2 H2 ... +// A3 B3 C3 D3 E3 F3 G3 H3 ... +// A4 B4 C4 D4 E4 F4 G4 H4 ... +// A5 B5 C5 D5 E5 F5 G5 H5 ... +// A6 B6 C6 D6 E6 F6 G6 H6 ... +// A7 B7 C7 D7 E7 F7 G7 H7 ... +// A8 ... +// ... +// +// Packing yields output (A0 beside B0 in memory): +// A0 B0 C0 D0 +// A1 B1 C1 D1 +// A2 B2 C2 D2 +// A3 B3 C3 D3 +// A4 B4 C4 D4 +// A5 B5 C5 D5 +// A6 B6 C6 D6 +// A7 B7 C7 D7 +// ... +// A31 B31 C31 D31 +// E0 F0 G0 H0 +// E1 F1 G1 H1 +// E2 F2 G2 H2 +// E3 F3 G3 H3 +// E4 F4 G4 H4 +// E5 F5 G5 H5 +// E6 F6 G6 H6 +// E7 F7 G7 H7 +// ... +// +// Four elements of the same row are arranged contiguously because maddubs and +// madd both perform an adjacent addition in the kernel. +template +struct gemm_pack_lhs { + EIGEN_DONT_INLINE void operator()(QInt8* blockA, const DataMapper& lhs, + Index depth, Index rows, Index stride = 0, + Index offset = 0); +}; + +template +EIGEN_DONT_INLINE void +gemm_pack_lhs::operator()(QInt8* blockA, + const DataMapper& lhs, + Index depth, Index rows, + Index stride, Index offset) { + eigen_assert(stride == 0); + eigen_assert(offset == 0); + + typedef typename packet_traits::type Packet; + + // Use alternate function for weird sizes + if (rows % 32 != 0 || depth % 32 != 0) { + gemm_pack_lhs_any + lhs_pack; + return lhs_pack(blockA, lhs, depth, rows, stride, offset); + } + + // Get vector pointer + __m256i* blockA_256 = reinterpret_cast<__m256i*>(blockA); + + // Pack rows in sets of 32 + for (Index m = 0; m < rows; m += 32) { + // Pack depth in sets of 8 + for (Index k = 0; k < depth; k += 8) { + // Load vectors + __m256i L_A = lhs.template loadPacket(m, k); + __m256i L_B = lhs.template loadPacket(m, k + 1); + + // Interleave 8-bit elements + __m256i L_AB0_AB16 = _mm256_unpacklo_epi8(L_A, L_B); + __m256i L_AB8_AB24 = _mm256_unpackhi_epi8(L_A, L_B); + + __m256i L_C = lhs.template loadPacket(m, k + 2); + __m256i L_D = lhs.template loadPacket(m, k + 3); + __m256i L_CD0_CD16 = _mm256_unpacklo_epi8(L_C, L_D); + __m256i L_CD8_CD24 = _mm256_unpackhi_epi8(L_C, L_D); + + // Interleave 16-bit elements + __m256i L_AD0_AD16 = _mm256_unpacklo_epi16(L_AB0_AB16, L_CD0_CD16); + __m256i L_AD4_AD20 = _mm256_unpackhi_epi16(L_AB0_AB16, L_CD0_CD16); + + // Use permute before we store to cross 128-bit lanes + __m256i L_AD0 = _mm256_permute2x128_si256(L_AD0_AD16, L_AD4_AD20, 0x20); + _mm256_store_si256(blockA_256++, L_AD0); + + // Complete packing for 32 x 8 block + __m256i L_AD16 = _mm256_permute2x128_si256(L_AD0_AD16, L_AD4_AD20, 0x31); + __m256i L_AD8_AD24 = _mm256_unpacklo_epi16(L_AB8_AB24, L_CD8_CD24); + __m256i L_AD12_AD28 = _mm256_unpackhi_epi16(L_AB8_AB24, L_CD8_CD24); + __m256i L_AD8 = _mm256_permute2x128_si256(L_AD8_AD24, L_AD12_AD28, 0x20); + _mm256_store_si256(blockA_256++, L_AD8); + _mm256_store_si256(blockA_256++, L_AD16); + __m256i L_AD24 = _mm256_permute2x128_si256(L_AD8_AD24, L_AD12_AD28, 0x31); + _mm256_store_si256(blockA_256++, L_AD24); + __m256i L_E = lhs.template loadPacket(m, k + 4); + __m256i L_F = lhs.template loadPacket(m, k + 5); + __m256i L_EF0_EF16 = _mm256_unpacklo_epi8(L_E, L_F); + __m256i L_EF8_EF24 = _mm256_unpackhi_epi8(L_E, L_F); + __m256i L_G = lhs.template loadPacket(m, k + 6); + __m256i L_H = lhs.template loadPacket(m, k + 7); + __m256i L_GH0_GH16 = _mm256_unpacklo_epi8(L_G, L_H); + __m256i L_GH8_GH24 = _mm256_unpackhi_epi8(L_G, L_H); + __m256i L_EH0_EH16 = _mm256_unpacklo_epi16(L_EF0_EF16, L_GH0_GH16); + __m256i L_EH4_EH20 = _mm256_unpackhi_epi16(L_EF0_EF16, L_GH0_GH16); + __m256i L_EH0 = _mm256_permute2x128_si256(L_EH0_EH16, L_EH4_EH20, 0x20); + _mm256_store_si256(blockA_256++, L_EH0); + __m256i L_EH16 = _mm256_permute2x128_si256(L_EH0_EH16, L_EH4_EH20, 0x31); + __m256i L_EH8_EH24 = _mm256_unpacklo_epi16(L_EF8_EF24, L_GH8_GH24); + __m256i L_EH12_EH28 = _mm256_unpackhi_epi16(L_EF8_EF24, L_GH8_GH24); + __m256i L_EH8 = _mm256_permute2x128_si256(L_EH8_EH24, L_EH12_EH28, 0x20); + _mm256_store_si256(blockA_256++, L_EH8); + _mm256_store_si256(blockA_256++, L_EH16); + __m256i L_EH24 = _mm256_permute2x128_si256(L_EH8_EH24, L_EH12_EH28, 0x31); + _mm256_store_si256(blockA_256++, L_EH24); + } + } +} + +// Arrange a block of the right input matrix in contiguous memory. +// +// Given column major input (A0 beside A1 in memory): +// A0 B0 C0 D0 E0 F0 G0 H0 ... +// A1 B1 C1 D1 E1 F1 G1 H1 ... +// A2 B2 C2 D2 E2 F2 G2 H2 ... +// A3 B3 C3 D3 E3 F3 G3 H3 ... +// A4 B4 C4 D4 E4 F4 G4 H4 ... +// A5 B5 C5 D5 E5 F5 G5 H5 ... +// A6 B6 C6 D6 E6 F6 G6 H6 ... +// A7 B7 C7 D7 E7 F7 G7 H7 ... +// A8 ... +// ... +// +// Packing yields row major output (A0 beside A1 in memory): +// A0 A1 A2 A3 A4 A5 A6 A7 +// B0 B1 B2 B3 B4 B5 B6 B7 +// ... +// +// At least four elements of the same col are arranged contiguously because +// maddubs and madd both perform an adjacent addition in the kernel. We can +// save work by leaving 8 adjacent elements because kr = 8. +template +struct gemm_pack_rhs { + EIGEN_DONT_INLINE void operator()(QUInt8* blockB, const DataMapper& rhs, + Index depth, Index cols, Index stride = 0, + Index offset = 0); +}; + +template +EIGEN_DONT_INLINE void +gemm_pack_rhs::operator()(QUInt8* blockB, const DataMapper& rhs, + Index depth, Index cols, Index stride, + Index offset) { + eigen_assert(stride == 0); + eigen_assert(offset == 0); + + typedef typename packet_traits::type Packet; + + // Use alternate function for weird sizes + if (cols % 32 != 0 || depth % 32 != 0) { + gemm_pack_rhs_any + rhs_pack; + return rhs_pack(blockB, rhs, depth, cols, stride, offset); + } + + // Get vector pointer + __m256i* blockB_256 = reinterpret_cast<__m256i*>(blockB); + + // Perform a step of the packing for 4 columns + __m256i R_AB_L, R_AB_H, R_CD_L, R_CD_H, R_AD_0, R_AD_8, R_AD_16, R_AD_24; +#define PACK_STEP \ + R_AB_L = _mm256_unpacklo_epi64(R_A, R_B); \ + R_CD_L = _mm256_unpacklo_epi64(R_C, R_D); \ + R_AB_H = _mm256_unpackhi_epi64(R_A, R_B); \ + R_CD_H = _mm256_unpackhi_epi64(R_C, R_D); \ + R_AD_0 = _mm256_permute2x128_si256(R_AB_L, R_CD_L, 0x20); \ + R_AD_16 = _mm256_permute2x128_si256(R_AB_L, R_CD_L, 0x31); \ + R_AD_8 = _mm256_permute2x128_si256(R_AB_H, R_CD_H, 0x20); \ + R_AD_24 = _mm256_permute2x128_si256(R_AB_H, R_CD_H, 0x31); \ + _mm256_store_si256(blockB_256, R_AD_0); \ + _mm256_store_si256(blockB_256 + 8, R_AD_8); \ + _mm256_store_si256(blockB_256 + 16, R_AD_16); \ + _mm256_store_si256(blockB_256 + 24, R_AD_24); \ + blockB_256++; + + // Pack cols in sets of 32 + for (Index n = 0; n < cols; n += 32) { + // Pack depth in sets of 32 + for (Index k = 0; k < depth; k += 32) { + __m256i R_A = rhs.template loadPacket(k, n); + __m256i R_B = rhs.template loadPacket(k, n + 1); + __m256i R_C = rhs.template loadPacket(k, n + 2); + __m256i R_D = rhs.template loadPacket(k, n + 3); + PACK_STEP; + + R_A = rhs.template loadPacket(k, n + 4); + R_B = rhs.template loadPacket(k, n + 5); + R_C = rhs.template loadPacket(k, n + 6); + R_D = rhs.template loadPacket(k, n + 7); + PACK_STEP; + + R_A = rhs.template loadPacket(k, n + 8); + R_B = rhs.template loadPacket(k, n + 9); + R_C = rhs.template loadPacket(k, n + 10); + R_D = rhs.template loadPacket(k, n + 11); + PACK_STEP; + + R_A = rhs.template loadPacket(k, n + 12); + R_B = rhs.template loadPacket(k, n + 13); + R_C = rhs.template loadPacket(k, n + 14); + R_D = rhs.template loadPacket(k, n + 15); + PACK_STEP; + + R_A = rhs.template loadPacket(k, n + 16); + R_B = rhs.template loadPacket(k, n + 17); + R_C = rhs.template loadPacket(k, n + 18); + R_D = rhs.template loadPacket(k, n + 19); + PACK_STEP; + + R_A = rhs.template loadPacket(k, n + 20); + R_B = rhs.template loadPacket(k, n + 21); + R_C = rhs.template loadPacket(k, n + 22); + R_D = rhs.template loadPacket(k, n + 23); + PACK_STEP; + + R_A = rhs.template loadPacket(k, n + 24); + R_B = rhs.template loadPacket(k, n + 25); + R_C = rhs.template loadPacket(k, n + 26); + R_D = rhs.template loadPacket(k, n + 27); + PACK_STEP; + + R_A = rhs.template loadPacket(k, n + 28); + R_B = rhs.template loadPacket(k, n + 29); + R_C = rhs.template loadPacket(k, n + 30); + R_D = rhs.template loadPacket(k, n + 31); + PACK_STEP; + + blockB_256 += 24; + } + } +#undef PACK_STEP +} + +// Perform the actual multiplication on packed inputs +template +struct gebp_kernel { + typedef typename DataMapper::LinearMapper LinearMapper; + + EIGEN_DONT_INLINE + void operator()(const DataMapper& res, const QInt8* blockA, + const QUInt8* blockB, Index rows, Index depth, Index cols, + QInt32 alpha, Index strideA = -1, Index strideB = -1, + Index offsetA = 0, Index offsetB = 0); +}; + +template +EIGEN_DONT_INLINE void +gebp_kernel::operator()(const DataMapper& res, + const QInt8* blockA, const QUInt8* blockB, + Index rows, Index depth, Index cols, + QInt32 alpha, Index strideA, + Index strideB, Index offsetA, + Index offsetB) { + EIGEN_STATIC_ASSERT(!ConjugateLhs, YOU_MADE_A_PROGRAMMING_MISTAKE); + EIGEN_STATIC_ASSERT(!ConjugateRhs, YOU_MADE_A_PROGRAMMING_MISTAKE); + eigen_assert(alpha.value == 1); + eigen_assert(strideA == -1); + eigen_assert(strideB == -1); + eigen_assert(offsetA == 0); + eigen_assert(offsetB == 0); + eigen_assert(rows > 0); + eigen_assert(cols > 0); + eigen_assert(depth > 0); + eigen_assert(blockA); + eigen_assert(blockB); + + // Use alternate function for weird sizes + if (rows % 32 != 0 || cols % 32 != 0 || depth % 32 != 0) { + gebp_kernel_any + gebp; + return gebp(res, blockA, blockB, rows, depth, cols, alpha, strideA, strideB, + offsetA, offsetB); + } + + // Create result block + QInt32* blockO = aligned_new(32 * 32); + // Allocating the result block is about 5-10% faster than declaring stack + // space. It is unclear why this is the case. + // ei_declare_aligned_stack_constructed_variable(QInt32, blockO, 32 * 32, 0); + memset(blockO, 0, 32 * 32 * sizeof(QInt32)); + + // Get vectorized pointers + __m256i* blockO_256 = reinterpret_cast<__m256i*>(blockO); + const __m256i* blockA_256 = reinterpret_cast(blockA); + const __m256i* blockB_256 = reinterpret_cast(blockB); + + // Loop over blocks of 32 columns + for (Index n = 0; n < cols; n += 32) { + // Reset index into blockA + Index indexL = 0; + // Loop over blocks of 32 rows + for (Index m = 0; m < rows; m += 32) { + // Reset index into blockB + Index indexR = n / 32 * depth; + // Loop over blocks of 8 on depth + for (Index k = 0; k < depth; k += 8) { + // Load inputs + __m256i L_AD0 = blockA_256[indexL++]; + __m256i L_AD8 = blockA_256[indexL++]; + __m256i L_AD16 = blockA_256[indexL++]; + __m256i L_AD24 = blockA_256[indexL++]; + __m256i L_EH0 = blockA_256[indexL++]; + __m256i L_EH8 = blockA_256[indexL++]; + __m256i L_EH16 = blockA_256[indexL++]; + __m256i L_EH24 = blockA_256[indexL++]; + __m256i R_AH0 = blockB_256[indexR++]; + __m256i R_AH4 = blockB_256[indexR++]; + __m256i R_AH8 = blockB_256[indexR++]; + __m256i R_AH12 = blockB_256[indexR++]; + __m256i R_AH16 = blockB_256[indexR++]; + __m256i R_AH20 = blockB_256[indexR++]; + __m256i R_AH24 = blockB_256[indexR++]; + __m256i R_AH28 = blockB_256[indexR++]; + + // This constant is used with madd to convert 16 bit to 32 bit + const __m256i ONE = _mm256_set1_epi32(0x00010001); + + // Declare variables used in COMPUTE_STEP + __m256i P_16_A, P_16_B, P_32_A, P_32_B, P_32; + +#define COMPUTE_STEP(R_INPUT_A, R_INPUT_B, OFFSET) \ + P_16_A = _mm256_maddubs_epi16(R_INPUT_A, L_AD0); \ + P_32_A = _mm256_madd_epi16(P_16_A, ONE); \ + P_16_B = _mm256_maddubs_epi16(R_INPUT_B, L_EH0); \ + P_32_B = _mm256_madd_epi16(P_16_B, ONE); \ + P_32 = _mm256_add_epi32(P_32_A, P_32_B); \ + _mm256_store_si256( \ + blockO_256 + 4 * OFFSET, \ + _mm256_add_epi32(_mm256_load_si256(blockO_256 + 4 * OFFSET), P_32)); \ + \ + P_16_A = _mm256_maddubs_epi16(R_INPUT_A, L_AD8); \ + P_32_A = _mm256_madd_epi16(P_16_A, ONE); \ + P_16_B = _mm256_maddubs_epi16(R_INPUT_B, L_EH8); \ + P_32_B = _mm256_madd_epi16(P_16_B, ONE); \ + P_32 = _mm256_add_epi32(P_32_A, P_32_B); \ + _mm256_store_si256( \ + blockO_256 + 4 * OFFSET + 1, \ + _mm256_add_epi32(_mm256_load_si256(blockO_256 + 4 * OFFSET + 1), P_32)); \ + \ + P_16_A = _mm256_maddubs_epi16(R_INPUT_A, L_AD16); \ + P_32_A = _mm256_madd_epi16(P_16_A, ONE); \ + P_16_B = _mm256_maddubs_epi16(R_INPUT_B, L_EH16); \ + P_32_B = _mm256_madd_epi16(P_16_B, ONE); \ + P_32 = _mm256_add_epi32(P_32_A, P_32_B); \ + _mm256_store_si256( \ + blockO_256 + 4 * OFFSET + 2, \ + _mm256_add_epi32(_mm256_load_si256(blockO_256 + 4 * OFFSET + 2), P_32)); \ + \ + P_16_A = _mm256_maddubs_epi16(R_INPUT_A, L_AD24); \ + P_32_A = _mm256_madd_epi16(P_16_A, ONE); \ + P_16_B = _mm256_maddubs_epi16(R_INPUT_B, L_EH24); \ + P_32_B = _mm256_madd_epi16(P_16_B, ONE); \ + P_32 = _mm256_add_epi32(P_32_A, P_32_B); \ + _mm256_store_si256( \ + blockO_256 + 4 * OFFSET + 3, \ + _mm256_add_epi32(_mm256_load_si256(blockO_256 + 4 * OFFSET + 3), P_32)); + + // Permute and shuffle to copy a single value across the entire vector + // Then compute the multiplication + __m256i R_AH0_ = _mm256_permute2x128_si256(R_AH0, R_AH0, 0x00); + __m256i R_AD0 = _mm256_shuffle_epi32(R_AH0_, 0x00); + __m256i R_EH0 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD0, R_EH0, 0); + __m256i R_AD1 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + __m256i R_EH1 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD1, R_EH1, 1); + R_AH0_ = _mm256_permute2x128_si256(R_AH0, R_AH0, 0x11); + __m256i R_AD2 = _mm256_shuffle_epi32(R_AH0_, 0x00); + __m256i R_EH2 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD2, R_EH2, 2); + __m256i R_AD3 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + __m256i R_EH3 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD3, R_EH3, 3); + + R_AH0_ = _mm256_permute2x128_si256(R_AH4, R_AH4, 0x00); + R_AD0 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH0 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD0, R_EH0, 4); + R_AD1 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH1 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD1, R_EH1, 5); + R_AH0_ = _mm256_permute2x128_si256(R_AH4, R_AH4, 0x11); + R_AD2 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH2 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD2, R_EH2, 6); + R_AD3 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH3 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD3, R_EH3, 7); + + R_AH0_ = _mm256_permute2x128_si256(R_AH8, R_AH8, 0x00); + R_AD0 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH0 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD0, R_EH0, 8); + R_AD1 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH1 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD1, R_EH1, 9); + R_AH0_ = _mm256_permute2x128_si256(R_AH8, R_AH8, 0x11); + R_AD2 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH2 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD2, R_EH2, 10); + R_AD3 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH3 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD3, R_EH3, 11); + + R_AH0_ = _mm256_permute2x128_si256(R_AH12, R_AH12, 0x00); + R_AD0 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH0 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD0, R_EH0, 12); + R_AD1 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH1 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD1, R_EH1, 13); + R_AH0_ = _mm256_permute2x128_si256(R_AH12, R_AH12, 0x11); + R_AD2 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH2 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD2, R_EH2, 14); + R_AD3 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH3 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD3, R_EH3, 15); + + R_AH0_ = _mm256_permute2x128_si256(R_AH16, R_AH16, 0x00); + R_AD0 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH0 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD0, R_EH0, 16); + R_AD1 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH1 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD1, R_EH1, 17); + R_AH0_ = _mm256_permute2x128_si256(R_AH16, R_AH16, 0x11); + R_AD2 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH2 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD2, R_EH2, 18); + R_AD3 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH3 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD3, R_EH3, 19); + + R_AH0_ = _mm256_permute2x128_si256(R_AH20, R_AH20, 0x00); + R_AD0 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH0 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD0, R_EH0, 20); + R_AD1 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH1 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD1, R_EH1, 21); + R_AH0_ = _mm256_permute2x128_si256(R_AH20, R_AH20, 0x11); + R_AD2 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH2 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD2, R_EH2, 22); + R_AD3 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH3 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD3, R_EH3, 23); + + R_AH0_ = _mm256_permute2x128_si256(R_AH24, R_AH24, 0x00); + R_AD0 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH0 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD0, R_EH0, 24); + R_AD1 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH1 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD1, R_EH1, 25); + R_AH0_ = _mm256_permute2x128_si256(R_AH24, R_AH24, 0x11); + R_AD2 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH2 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD2, R_EH2, 26); + R_AD3 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH3 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD3, R_EH3, 27); + + R_AH0_ = _mm256_permute2x128_si256(R_AH28, R_AH28, 0x00); + R_AD0 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH0 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD0, R_EH0, 28); + R_AD1 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH1 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD1, R_EH1, 29); + R_AH0_ = _mm256_permute2x128_si256(R_AH28, R_AH28, 0x11); + R_AD2 = _mm256_shuffle_epi32(R_AH0_, 0x00); + R_EH2 = _mm256_shuffle_epi32(R_AH0_, 0x55); + COMPUTE_STEP(R_AD2, R_EH2, 30); + R_AD3 = _mm256_shuffle_epi32(R_AH0_, 0xAA); + R_EH3 = _mm256_shuffle_epi32(R_AH0_, 0xFF); + COMPUTE_STEP(R_AD3, R_EH3, 31); + +#undef COMPUTE_STEP + } + + // Transfer the results to the result matrix + Index i = 0; + for (Index j = n; j < n + 32; j++) { + LinearMapper r0 = res.getLinearMapper(m, j); + LinearMapper r1 = res.getLinearMapper(m + 8, j); + LinearMapper r2 = res.getLinearMapper(m + 16, j); + LinearMapper r3 = res.getLinearMapper(m + 24, j); + typedef typename packet_traits::type Packet; + r0.template storePacket( + 0, _mm256_add_epi32(blockO_256[i++], + r0.template loadPacket(0))); + r1.template storePacket( + 0, _mm256_add_epi32(blockO_256[i++], + r1.template loadPacket(0))); + r2.template storePacket( + 0, _mm256_add_epi32(blockO_256[i++], + r2.template loadPacket(0))); + r3.template storePacket( + 0, _mm256_add_epi32(blockO_256[i++], + r3.template loadPacket(0))); + } + + // Zero the result block so it can be reused + memset(blockO, 0, 32 * 32 * sizeof(QInt32)); + } + } + aligned_delete(blockO, 32 * 32); +} + +#endif // EIGEN_USE_OPTIMIZED_INT8_UINT8_MAT_MAT_PRODUCT + +} // namespace internal +} // namespace Eigen + +#endif // TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_MATMATPRODUCTAVX2_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/MatMatProductNEON.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/MatMatProductNEON.h new file mode 100644 index 0000000000000000000000000000000000000000..6166b41ad30f482f77d590f9e3004664fa026b57 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/MatMatProductNEON.h @@ -0,0 +1,316 @@ +/* Copyright 2022 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_MATMATPRODUCTNEON_H_ +#define TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_MATMATPRODUCTNEON_H_ + +namespace Eigen { +namespace internal { + +// Neon optimized implementation where both lhs and rhs are encoded using +// signed 8bit integers +#ifdef EIGEN_USE_OPTIMIZED_INT8_INT8_MAT_MAT_PRODUCT + +template +class gebp_traits { + public: + typedef QInt8 LhsScalar; + typedef QInt8 RhsScalar; + typedef QInt32 ResScalar; + + enum { + // register block size along the M and N directions + // One for the current implementation + nr = 4, + mr = 1, + // Progress made at each iteration of the product loop + // also 1 for the current implementation + LhsProgress = 1, + RhsProgress = 1 + }; +}; + +// The signed 8bit Mat-Mat product itself. +template +struct gebp_kernel { + EIGEN_DONT_INLINE + void operator()(const DataMapper& res, const QInt8* blockA, + const QInt8* blockB, Index rows, Index depth, Index cols, + QInt32 alpha, Index strideA = -1, Index strideB = -1, + Index offsetA = 0, Index offsetB = 0); +}; + +template +EIGEN_DONT_INLINE void +gebp_kernel::operator()(const DataMapper& res, + const QInt8* blockA, const QInt8* blockB, + Index rows, Index depth, Index cols, + QInt32 alpha, Index strideA, + Index strideB, Index offsetA, + Index offsetB) { + EIGEN_STATIC_ASSERT(!ConjugateLhs, YOU_MADE_A_PROGRAMMING_MISTAKE); + EIGEN_STATIC_ASSERT(!ConjugateRhs, YOU_MADE_A_PROGRAMMING_MISTAKE); + + eigen_assert(alpha.value == 1); + eigen_assert(strideA == -1); + eigen_assert(strideB == -1); + eigen_assert(offsetA == 0); + eigen_assert(offsetB == 0); + + eigen_assert(rows > 0); + eigen_assert(cols > 0); + eigen_assert(depth > 0); + eigen_assert(blockA); + eigen_assert(blockB); + + for (Index j = 0; j < cols; ++j) { + Index startB = j * depth; + + for (Index i = 0; i < rows; ++i) { + Index startA = i * depth; + + for (Index k = 0; k < depth; ++k) { + res(i, j) += blockA[startA + k] * blockB[startB + k]; + } + } + } +} +#endif + +// Neon optimized implementation of the case where the lhs is encoded using +// signed 8bit integers and the rhs using unsigned 8bit integers. +#ifdef EIGEN_USE_OPTIMIZED_INT8_UINT8_MAT_MAT_PRODUCT + +template +class gebp_traits { + public: + typedef QInt8 LhsScalar; + typedef QUInt8 RhsScalar; + typedef QInt32 ResScalar; + + enum { + // register block size along the M and N directions + nr = 4, + mr = 1, + // Progress made at each iteration of the product loop + // 1 for the current implementation + LhsProgress = 1, + RhsProgress = 1 + }; +}; + +// Mat-Mat product of a signed 8bit lhs with an unsigned 8bit rhs +template +struct gebp_kernel { + EIGEN_DONT_INLINE + void operator()(const DataMapper& res, const QInt8* blockA, + const QUInt8* blockB, Index rows, Index depth, Index cols, + QInt32 alpha, Index strideA = -1, Index strideB = -1, + Index offsetA = 0, Index offsetB = 0); +}; + +template +EIGEN_DONT_INLINE void +gebp_kernel::operator()(const DataMapper& res, + const QInt8* blockA, const QUInt8* blockB, + Index rows, Index depth, Index cols, + QInt32 alpha, Index strideA, + Index strideB, Index offsetA, + Index offsetB) { + EIGEN_STATIC_ASSERT(!ConjugateLhs, YOU_MADE_A_PROGRAMMING_MISTAKE); + EIGEN_STATIC_ASSERT(!ConjugateRhs, YOU_MADE_A_PROGRAMMING_MISTAKE); + + eigen_assert(alpha.value == 1); + eigen_assert(strideA == -1); + eigen_assert(strideB == -1); + eigen_assert(offsetA == 0); + eigen_assert(offsetB == 0); + + eigen_assert(rows > 0); + eigen_assert(cols > 0); + eigen_assert(depth > 0); + eigen_assert(blockA); + eigen_assert(blockB); + + for (Index j = 0; j < cols; ++j) { + Index startB = j * depth; + + for (Index i = 0; i < rows; ++i) { + Index startA = i * depth; + + for (Index k = 0; k < depth; ++k) { + res(i, j) += blockA[startA + k] * blockB[startB + k]; + } + } + } +} +#endif + +// Neon optimized implementation where the lhs is encoded using unsigned 8bit +// integers and the rhs using signed 8bit integers. +#ifdef EIGEN_USE_OPTIMIZED_UINT8_INT8_MAT_MAT_PRODUCT +template +class gebp_traits { + public: + typedef QUInt8 LhsScalar; + typedef QInt8 RhsScalar; + typedef QInt32 ResScalar; + + enum { + // register block size along the M and N directions + nr = 4, + mr = 1, + // Progress made at each iteration of the product loop + // 1 for the current implementation + LhsProgress = 1, + RhsProgress = 1 + }; +}; + +// Mat-Mat product of an unsigned 8bit lhs with a signed 8bit rhs +template +struct gebp_kernel { + EIGEN_DONT_INLINE + void operator()(const DataMapper& res, const QUInt8* blockA, + const QInt8* blockB, Index rows, Index depth, Index cols, + QInt32 alpha, Index strideA = -1, Index strideB = -1, + Index offsetA = 0, Index offsetB = 0); +}; + +template +EIGEN_DONT_INLINE void +gebp_kernel::operator()(const DataMapper& res, + const QUInt8* blockA, const QInt8* blockB, + Index rows, Index depth, Index cols, + QInt32 alpha, Index strideA, + Index strideB, Index offsetA, + Index offsetB) { + EIGEN_STATIC_ASSERT(!ConjugateLhs, YOU_MADE_A_PROGRAMMING_MISTAKE); + EIGEN_STATIC_ASSERT(!ConjugateRhs, YOU_MADE_A_PROGRAMMING_MISTAKE); + + eigen_assert(alpha.value == 1); + eigen_assert(strideA == -1); + eigen_assert(strideB == -1); + eigen_assert(offsetA == 0); + eigen_assert(offsetB == 0); + + eigen_assert(rows > 0); + eigen_assert(cols > 0); + eigen_assert(depth > 0); + eigen_assert(blockA); + eigen_assert(blockB); + + for (Index j = 0; j < cols; ++j) { + Index startB = j * depth; + + for (Index i = 0; i < rows; ++i) { + Index startA = i * depth; + + for (Index k = 0; k < depth; ++k) { + res(i, j) += blockA[startA + k] * blockB[startB + k]; + } + } + } +} +#endif + +#ifdef EIGEN_USE_OPTIMIZED_INT16_INT16_MAT_MAT_PRODUCT + +template +class gebp_traits { + public: + typedef QInt16 LhsScalar; + typedef QInt16 RhsScalar; + typedef QInt32 ResScalar; + + enum { + // register block size along the M and N directions + // One for the current implementation + nr = 4, + mr = 1, + // Progress made at each iteration of the product loop + // also 1 for the current implementation + LhsProgress = 1, + RhsProgress = 1 + }; +}; + +// The signed 16bit Mat-Mat product itself. +template +struct gebp_kernel { + EIGEN_DONT_INLINE + void operator()(const DataMapper& res, const QInt16* blockA, + const QInt16* blockB, Index rows, Index depth, Index cols, + QInt32 alpha, Index strideA = -1, Index strideB = -1, + Index offsetA = 0, Index offsetB = 0); +}; + +template +EIGEN_DONT_INLINE void +gebp_kernel::operator()(const DataMapper& res, + const QInt16* blockA, + const QInt16* blockB, Index rows, + Index depth, Index cols, QInt32 alpha, + Index strideA, Index strideB, + Index offsetA, Index offsetB) { + EIGEN_STATIC_ASSERT(!ConjugateLhs, YOU_MADE_A_PROGRAMMING_MISTAKE); + EIGEN_STATIC_ASSERT(!ConjugateRhs, YOU_MADE_A_PROGRAMMING_MISTAKE); + + eigen_assert(alpha.value == 1); + eigen_assert(strideA == -1); + eigen_assert(strideB == -1); + eigen_assert(offsetA == 0); + eigen_assert(offsetB == 0); + + eigen_assert(rows > 0); + eigen_assert(cols > 0); + eigen_assert(depth > 0); + eigen_assert(blockA); + eigen_assert(blockB); + + for (Index j = 0; j < cols; ++j) { + Index startB = j * depth; + + for (Index i = 0; i < rows; ++i) { + Index startA = i * depth; + + for (Index k = 0; k < depth; ++k) { + res(i, j) += blockA[startA + k] * blockB[startB + k]; + } + } + } +} +#endif + +} // namespace internal +} // namespace Eigen + +#endif // TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_MATMATPRODUCTNEON_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/MatVecProduct.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/MatVecProduct.h new file mode 100644 index 0000000000000000000000000000000000000000..1653df856f01ce4b1a40976cbc5e000e94e555a4 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/MatVecProduct.h @@ -0,0 +1,151 @@ +/* Copyright 2022 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_MATVECPRODUCT_H_ +#define TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_MATVECPRODUCT_H_ + +namespace Eigen { +namespace internal { + +// Mat-Vec product +// Both lhs and rhs are encoded as 8bit signed integers +template +struct general_matrix_vector_product { + EIGEN_DONT_INLINE static void run(Index rows, Index cols, + const LhsMapper& lhs, const RhsMapper& rhs, + QInt32* res, Index resIncr, QInt8 alpha); +}; + +template +EIGEN_DONT_INLINE void general_matrix_vector_product< + Index, QInt8, LhsMapper, ColMajor, ConjugateLhs, QInt8, RhsMapper, + ConjugateRhs, Version>::run(Index rows, Index cols, const LhsMapper& lhs, + const RhsMapper& rhs, QInt32* res, + Index resIncr, QInt8 alpha) { + eigen_assert(alpha.value == 1); + eigen_assert(resIncr == 1); + eigen_assert(rows > 0); + eigen_assert(cols > 0); + + for (Index i = 0; i < rows; ++i) { + for (Index j = 0; j < cols; ++j) { + res[i] += lhs(i, j) * rhs(j, 0); + } + } +} + +// Mat-Vec product +// Both lhs and rhs are encoded as 16bit signed integers +template +struct general_matrix_vector_product { + EIGEN_DONT_INLINE static void run(Index rows, Index cols, + const LhsMapper& lhs, const RhsMapper& rhs, + QInt32* res, Index resIncr, QInt16 alpha); +}; + +template +EIGEN_DONT_INLINE void general_matrix_vector_product< + Index, QInt16, LhsMapper, ColMajor, ConjugateLhs, QInt16, RhsMapper, + ConjugateRhs, Version>::run(Index rows, Index cols, const LhsMapper& lhs, + const RhsMapper& rhs, QInt32* res, + Index resIncr, QInt16 alpha) { + eigen_assert(alpha.value == 1); + eigen_assert(resIncr == 1); + eigen_assert(rows > 0); + eigen_assert(cols > 0); + + for (Index i = 0; i < rows; ++i) { + for (Index j = 0; j < cols; ++j) { + res[i] += lhs(i, j) * rhs(j, 0); + } + } +} + +// Mat-Vec product +// The lhs is encoded using 8bit signed integers, the rhs using 8bit unsigned +// integers +template +struct general_matrix_vector_product { + EIGEN_DONT_INLINE static void run(Index rows, Index cols, + const LhsMapper& lhs, const RhsMapper& rhs, + QInt32* res, Index resIncr, QUInt8 alpha); +}; + +template +EIGEN_DONT_INLINE void general_matrix_vector_product< + Index, QInt8, LhsMapper, ColMajor, ConjugateLhs, QUInt8, RhsMapper, + ConjugateRhs, Version>::run(Index rows, Index cols, const LhsMapper& lhs, + const RhsMapper& rhs, QInt32* res, + Index resIncr, QUInt8 alpha) { + eigen_assert(alpha.value == 1); + eigen_assert(resIncr == 1); + eigen_assert(rows > 0); + eigen_assert(cols > 0); + + for (Index i = 0; i < rows; ++i) { + for (Index j = 0; j < cols; ++j) { + res[i] += lhs(i, j) * rhs(j, 0); + } + } +} + +// Mat-Vec product +// The lhs is encoded using bit unsigned integers, the rhs using 8bit signed +// integers +template +struct general_matrix_vector_product { + EIGEN_DONT_INLINE static void run(Index rows, Index cols, + const LhsMapper& lhs, const RhsMapper& rhs, + QInt32* res, Index resIncr, QInt8 alpha); +}; + +template +EIGEN_DONT_INLINE void general_matrix_vector_product< + Index, QUInt8, LhsMapper, ColMajor, ConjugateLhs, QInt8, RhsMapper, + ConjugateRhs, Version>::run(Index rows, Index cols, const LhsMapper& lhs, + const RhsMapper& rhs, QInt32* res, + Index resIncr, QInt8 alpha) { + eigen_assert(alpha.value == 1); + eigen_assert(resIncr == 1); + eigen_assert(rows > 0); + eigen_assert(cols > 0); + + for (Index i = 0; i < rows; ++i) { + for (Index j = 0; j < cols; ++j) { + res[i] += lhs(i, j) * rhs(j, 0); + } + } +} + +} // namespace internal +} // namespace Eigen + +#endif // TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_MATVECPRODUCT_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/PacketMathAVX.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/PacketMathAVX.h new file mode 100644 index 0000000000000000000000000000000000000000..12c60405045df809d491c349345cf5aca4b6ad31 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/PacketMathAVX.h @@ -0,0 +1,164 @@ +/* Copyright 2022 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_PACKETMATHAVX_H_ +#define TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_PACKETMATHAVX_H_ +#ifdef _MSC_VER + +#include +#include +#include + +#endif + +namespace Eigen { +namespace internal { + +typedef eigen_packet_wrapper<__m256i, 10> Packet32q8i; +typedef eigen_packet_wrapper<__m128i, 11> Packet16q8i; + +template <> +struct packet_traits : default_packet_traits { + typedef Packet32q8i type; + typedef Packet16q8i half; + enum { + Vectorizable = 1, + AlignedOnScalar = 1, + size = 32, + }; + enum { + HasAdd = 0, + HasSub = 0, + HasMul = 0, + HasNegate = 0, + HasAbs = 0, + HasAbs2 = 0, + HasMin = 0, + HasMax = 0, + HasConj = 0, + HasSetLinear = 0 + }; +}; + +template <> +struct unpacket_traits { + typedef QInt8 type; + typedef Packet16q8i half; + enum { + size = 32, + alignment = Aligned32, + vectorizable = true, + masked_load_available = false, + masked_store_available = false + }; +}; + +template <> +struct unpacket_traits { + typedef QInt8 type; + typedef Packet16q8i half; + enum { + size = 16, + alignment = Aligned32, + vectorizable = true, + masked_load_available = false, + masked_store_available = false + }; +}; +template <> +EIGEN_STRONG_INLINE Packet32q8i pset1(const QInt8& from) { + return _mm256_set1_epi8(from.value); +} +template <> +EIGEN_STRONG_INLINE Packet32q8i ploadu(const QInt8* from) { + EIGEN_DEBUG_UNALIGNED_LOAD return _mm256_loadu_si256( + reinterpret_cast(from)); +} +template <> +EIGEN_STRONG_INLINE Packet16q8i ploadu(const QInt8* from) { + EIGEN_DEBUG_UNALIGNED_LOAD return _mm_loadu_si128( + reinterpret_cast(from)); +} + +template <> +EIGEN_STRONG_INLINE Packet32q8i pload(const QInt8* from) { + EIGEN_DEBUG_ALIGNED_LOAD return _mm256_load_si256( + reinterpret_cast(from)); +} +template <> +EIGEN_STRONG_INLINE Packet16q8i pload(const QInt8* from) { + EIGEN_DEBUG_ALIGNED_LOAD return _mm_load_si128( + reinterpret_cast(from)); +} + +template <> +EIGEN_STRONG_INLINE void pstoreu(QInt8* to, const Packet32q8i& from) { + EIGEN_DEBUG_UNALIGNED_STORE _mm256_storeu_si256( + reinterpret_cast<__m256i*>(to), from.m_val); +} +template <> +EIGEN_STRONG_INLINE void pstoreu(QInt8* to, const Packet16q8i& from) { + EIGEN_DEBUG_UNALIGNED_STORE _mm_storeu_si128(reinterpret_cast<__m128i*>(to), + from.m_val); +} + +template <> +EIGEN_STRONG_INLINE void pstore(QInt8* to, const Packet32q8i& from) { + EIGEN_DEBUG_ALIGNED_STORE _mm256_store_si256(reinterpret_cast<__m256i*>(to), + from.m_val); +} +template <> +EIGEN_STRONG_INLINE void pstore(QInt8* to, const Packet16q8i& from) { + EIGEN_DEBUG_ALIGNED_STORE _mm_store_si128(reinterpret_cast<__m128i*>(to), + from.m_val); +} + +typedef __m256 Packet8f; + +template <> +struct type_casting_traits { + enum { VectorizedCast = 1, SrcCoeffRatio = 4, TgtCoeffRatio = 1 }; +}; + +template <> +EIGEN_STRONG_INLINE Packet32q8i +pcast(const Packet8f& a, const Packet8f& b, + const Packet8f& c, const Packet8f& d) { + const __m256i a_conv = _mm256_cvtps_epi32(a); + const __m256i b_conv = _mm256_cvtps_epi32(b); + const __m256i c_conv = _mm256_cvtps_epi32(c); + const __m256i d_conv = _mm256_cvtps_epi32(d); + __m128i low = _mm256_castsi256_si128(a_conv); + __m128i high = _mm256_extractf128_si256(a_conv, 1); + __m128i tmp = _mm_packs_epi32(low, high); + __m128i low2 = _mm256_castsi256_si128(b_conv); + __m128i high2 = _mm256_extractf128_si256(b_conv, 1); + __m128i tmp2 = _mm_packs_epi32(low2, high2); + __m128i converted_low = _mm_packs_epi16(tmp, tmp2); + low = _mm256_castsi256_si128(c_conv); + high = _mm256_extractf128_si256(c_conv, 1); + tmp = _mm_packs_epi32(low, high); + low2 = _mm256_castsi256_si128(d_conv); + high2 = _mm256_extractf128_si256(d_conv, 1); + tmp2 = _mm_packs_epi32(low2, high2); + __m128i converted_high = _mm_packs_epi16(tmp, tmp2); + return _mm256_insertf128_si256(_mm256_castsi128_si256(converted_low), + converted_high, 1); +} + +} // end namespace internal +} // end namespace Eigen + +#endif // TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_PACKETMATHAVX_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/PacketMathAVX2.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/PacketMathAVX2.h new file mode 100644 index 0000000000000000000000000000000000000000..1c9139fd1d95a58f1a199596f422fc93b2c08a2a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/PacketMathAVX2.h @@ -0,0 +1,560 @@ +/* Copyright 2022 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_PACKETMATHAVX2_H_ +#define TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_PACKETMATHAVX2_H_ +#ifdef _MSC_VER + +#include +#include +#include + +#endif + +inline int _mm256_extract_epi16_N0(const __m256i X) { + return _mm_extract_epi16(_mm256_extractf128_si256(X, 0 >> 3), 0 % 8); +} + +inline int _mm256_extract_epi16_N1(const __m256i X) { + return _mm_extract_epi16(_mm256_extractf128_si256(X, 1 >> 3), 1 % 8); +} + +inline int _mm256_extract_epi8_N0(const __m256i X) { + return _mm_extract_epi8(_mm256_extractf128_si256((X), 0 >> 4), 0 % 16); +} + +inline int _mm256_extract_epi8_N1(const __m256i X) { + return _mm_extract_epi8(_mm256_extractf128_si256((X), 1 >> 4), 1 % 16); +} + +namespace Eigen { +namespace internal { + +typedef eigen_packet_wrapper<__m256i, 20> Packet32q8i; +typedef eigen_packet_wrapper<__m256i, 21> Packet16q16i; +typedef eigen_packet_wrapper<__m256i, 22> Packet32q8u; +typedef eigen_packet_wrapper<__m128i, 23> Packet16q8i; +typedef eigen_packet_wrapper<__m128i, 25> Packet16q8u; +typedef eigen_packet_wrapper<__m128i, 26> Packet8q16i; +typedef eigen_packet_wrapper<__m256i, 27> Packet8q32i; +typedef eigen_packet_wrapper<__m128i, 28> Packet4q32i; + +#ifndef EIGEN_VECTORIZE_AVX512 +template <> +struct packet_traits : default_packet_traits { + typedef Packet32q8i type; + typedef Packet16q8i half; + enum { + Vectorizable = 1, + AlignedOnScalar = 1, + size = 32, + }; + enum { + HasAdd = 0, + HasSub = 0, + HasMul = 0, + HasNegate = 0, + HasAbs = 0, + HasAbs2 = 0, + HasMin = 1, + HasMax = 1, + HasConj = 0, + HasSetLinear = 0 + }; +}; +template <> +struct packet_traits : default_packet_traits { + typedef Packet32q8u type; + typedef Packet16q8u half; + enum { + Vectorizable = 1, + AlignedOnScalar = 1, + size = 32, + }; + enum { + HasAdd = 0, + HasSub = 0, + HasMul = 0, + HasNegate = 0, + HasAbs = 0, + HasAbs2 = 0, + HasMin = 1, + HasMax = 1, + HasConj = 0, + HasSetLinear = 0 + }; +}; +template <> +struct packet_traits : default_packet_traits { + typedef Packet16q16i type; + typedef Packet8q16i half; + enum { + Vectorizable = 1, + AlignedOnScalar = 1, + size = 16, + }; + enum { + HasAdd = 0, + HasSub = 0, + HasMul = 0, + HasNegate = 0, + HasAbs = 0, + HasAbs2 = 0, + HasMin = 1, + HasMax = 1, + HasConj = 0, + HasSetLinear = 0 + }; +}; +template <> +struct packet_traits : default_packet_traits { + typedef Packet8q32i type; + typedef Packet4q32i half; + enum { + Vectorizable = 1, + AlignedOnScalar = 1, + size = 8, + }; + enum { + HasAdd = 1, + HasSub = 1, + HasMul = 1, + HasNegate = 1, + HasAbs = 0, + HasAbs2 = 0, + HasMin = 1, + HasMax = 1, + HasConj = 0, + HasSetLinear = 0 + }; +}; +#endif + +template <> +struct unpacket_traits { + typedef QInt8 type; + typedef Packet16q8i half; + enum { + size = 32, + alignment = Aligned32, + vectorizable = true, + masked_load_available = false, + masked_store_available = false + }; +}; +template <> +struct unpacket_traits { + typedef QInt8 type; + typedef Packet16q8i half; + enum { + size = 16, + alignment = Aligned32, + vectorizable = true, + masked_load_available = false, + masked_store_available = false + }; +}; +template <> +struct unpacket_traits { + typedef QInt16 type; + typedef Packet8q16i half; + enum { + size = 16, + alignment = Aligned32, + vectorizable = true, + masked_load_available = false, + masked_store_available = false + }; +}; +template <> +struct unpacket_traits { + typedef QInt16 type; + typedef Packet8q16i half; + enum { + size = 8, + alignment = Aligned32, + vectorizable = true, + masked_load_available = false, + masked_store_available = false + }; +}; +template <> +struct unpacket_traits { + typedef QUInt8 type; + typedef Packet16q8u half; + enum { + size = 32, + alignment = Aligned32, + vectorizable = true, + masked_load_available = false, + masked_store_available = false + }; +}; +template <> +struct unpacket_traits { + typedef QInt32 type; + typedef Packet4q32i half; + enum { + size = 8, + alignment = Aligned32, + vectorizable = true, + masked_load_available = false, + masked_store_available = false + }; +}; + +// Unaligned load +template <> +EIGEN_STRONG_INLINE Packet32q8i ploadu(const QInt8* from) { + EIGEN_DEBUG_UNALIGNED_LOAD return _mm256_loadu_si256( + reinterpret_cast(from)); +} +template <> +EIGEN_STRONG_INLINE Packet16q8i ploadu(const QInt8* from) { + EIGEN_DEBUG_UNALIGNED_LOAD return _mm_loadu_si128( + reinterpret_cast(from)); +} +template <> +EIGEN_STRONG_INLINE Packet32q8u ploadu(const QUInt8* from) { + EIGEN_DEBUG_UNALIGNED_LOAD return _mm256_loadu_si256( + reinterpret_cast(from)); +} +template <> +EIGEN_STRONG_INLINE Packet16q16i ploadu(const QInt16* from) { + EIGEN_DEBUG_UNALIGNED_LOAD return _mm256_loadu_si256( + reinterpret_cast(from)); +} +template <> +EIGEN_STRONG_INLINE Packet8q16i ploadu(const QInt16* from) { + EIGEN_DEBUG_UNALIGNED_LOAD return _mm_loadu_si128( + reinterpret_cast(from)); +} +template <> +EIGEN_STRONG_INLINE Packet8q32i ploadu(const QInt32* from) { + EIGEN_DEBUG_UNALIGNED_LOAD return _mm256_loadu_si256( + reinterpret_cast(from)); +} + +// Aligned load +template <> +EIGEN_STRONG_INLINE Packet32q8i pload(const QInt8* from) { + EIGEN_DEBUG_ALIGNED_LOAD return _mm256_load_si256( + reinterpret_cast(from)); +} +template <> +EIGEN_STRONG_INLINE Packet16q8i pload(const QInt8* from) { + EIGEN_DEBUG_ALIGNED_LOAD return _mm_load_si128( + reinterpret_cast(from)); +} +template <> +EIGEN_STRONG_INLINE Packet32q8u pload(const QUInt8* from) { + EIGEN_DEBUG_ALIGNED_LOAD return _mm256_load_si256( + reinterpret_cast(from)); +} +template <> +EIGEN_STRONG_INLINE Packet16q16i pload(const QInt16* from) { + EIGEN_DEBUG_ALIGNED_LOAD return _mm256_load_si256( + reinterpret_cast(from)); +} +template <> +EIGEN_STRONG_INLINE Packet8q16i pload(const QInt16* from) { + EIGEN_DEBUG_ALIGNED_LOAD return _mm_load_si128( + reinterpret_cast(from)); +} +template <> +EIGEN_STRONG_INLINE Packet8q32i pload(const QInt32* from) { + EIGEN_DEBUG_ALIGNED_LOAD return _mm256_load_si256( + reinterpret_cast(from)); +} + +// Unaligned store +template <> +EIGEN_STRONG_INLINE void pstoreu(QInt8* to, const Packet32q8i& from) { + EIGEN_DEBUG_UNALIGNED_STORE _mm256_storeu_si256( + reinterpret_cast<__m256i*>(to), from.m_val); +} +template <> +EIGEN_STRONG_INLINE void pstoreu(QInt8* to, const Packet16q8i& from) { + EIGEN_DEBUG_UNALIGNED_STORE _mm_storeu_si128(reinterpret_cast<__m128i*>(to), + from.m_val); +} +template <> +EIGEN_STRONG_INLINE void pstoreu(QUInt8* to, const Packet32q8u& from) { + EIGEN_DEBUG_UNALIGNED_STORE _mm256_storeu_si256( + reinterpret_cast<__m256i*>(to), from.m_val); +} +template <> +EIGEN_STRONG_INLINE void pstoreu(QInt16* to, const Packet16q16i& from) { + EIGEN_DEBUG_UNALIGNED_STORE _mm256_storeu_si256( + reinterpret_cast<__m256i*>(to), from.m_val); +} +template <> +EIGEN_STRONG_INLINE void pstoreu(QInt16* to, const Packet8q16i& from) { + EIGEN_DEBUG_UNALIGNED_STORE _mm_storeu_si128(reinterpret_cast<__m128i*>(to), + from.m_val); +} +template <> +EIGEN_STRONG_INLINE void pstoreu(QInt32* to, const Packet8q32i& from) { + EIGEN_DEBUG_UNALIGNED_STORE _mm256_storeu_si256( + reinterpret_cast<__m256i*>(to), from.m_val); +} + +// Aligned store +template <> +EIGEN_STRONG_INLINE void pstore(QInt32* to, const Packet8q32i& from) { + EIGEN_DEBUG_ALIGNED_STORE _mm256_store_si256(reinterpret_cast<__m256i*>(to), + from.m_val); +} +template <> +EIGEN_STRONG_INLINE void pstore(QInt16* to, const Packet16q16i& from) { + EIGEN_DEBUG_ALIGNED_STORE _mm256_store_si256(reinterpret_cast<__m256i*>(to), + from.m_val); +} +template <> +EIGEN_STRONG_INLINE void pstore(QInt16* to, const Packet8q16i& from) { + EIGEN_DEBUG_ALIGNED_STORE _mm_store_si128(reinterpret_cast<__m128i*>(to), + from.m_val); +} +template <> +EIGEN_STRONG_INLINE void pstore(QUInt8* to, const Packet32q8u& from) { + EIGEN_DEBUG_ALIGNED_STORE _mm256_store_si256(reinterpret_cast<__m256i*>(to), + from.m_val); +} +template <> +EIGEN_STRONG_INLINE void pstore(QInt8* to, const Packet32q8i& from) { + EIGEN_DEBUG_ALIGNED_STORE _mm256_store_si256(reinterpret_cast<__m256i*>(to), + from.m_val); +} +template <> +EIGEN_STRONG_INLINE void pstore(QInt8* to, const Packet16q8i& from) { + EIGEN_DEBUG_ALIGNED_STORE _mm_store_si128(reinterpret_cast<__m128i*>(to), + from.m_val); +} + +// Extract first element. +template <> +EIGEN_STRONG_INLINE QInt32 pfirst(const Packet8q32i& a) { + return _mm_cvtsi128_si32(_mm256_castsi256_si128(a)); +} +template <> +EIGEN_STRONG_INLINE QInt16 pfirst(const Packet16q16i& a) { + return _mm256_extract_epi16_N0(a.m_val); +} +template <> +EIGEN_STRONG_INLINE QUInt8 pfirst(const Packet32q8u& a) { + return static_cast(_mm256_extract_epi8_N0(a.m_val)); +} +template <> +EIGEN_STRONG_INLINE QInt8 pfirst(const Packet32q8i& a) { + return _mm256_extract_epi8_N0(a.m_val); +} + +// Initialize to constant value. +template <> +EIGEN_STRONG_INLINE Packet32q8i pset1(const QInt8& from) { + return _mm256_set1_epi8(from.value); +} +template <> +EIGEN_STRONG_INLINE Packet32q8u pset1(const QUInt8& from) { + return _mm256_set1_epi8(static_cast(from.value)); +} +template <> +EIGEN_STRONG_INLINE Packet8q32i pset1(const QInt32& from) { + return _mm256_set1_epi32(from.value); +} + +// Basic arithmetic packet ops for QInt32. +template <> +EIGEN_STRONG_INLINE Packet8q32i padd(const Packet8q32i& a, + const Packet8q32i& b) { + return _mm256_add_epi32(a.m_val, b.m_val); +} +template <> +EIGEN_STRONG_INLINE Packet16q16i pset1(const QInt16& from) { + return _mm256_set1_epi16(from.value); +} +template <> +EIGEN_STRONG_INLINE Packet8q32i psub(const Packet8q32i& a, + const Packet8q32i& b) { + return _mm256_sub_epi32(a.m_val, b.m_val); +} +// Note: mullo truncates the result to 32 bits. +template <> +EIGEN_STRONG_INLINE Packet8q32i pmul(const Packet8q32i& a, + const Packet8q32i& b) { + return _mm256_mullo_epi32(a.m_val, b.m_val); +} +template <> +EIGEN_STRONG_INLINE Packet8q32i pnegate(const Packet8q32i& a) { + return _mm256_sub_epi32(_mm256_setzero_si256(), a.m_val); +} + +// Min and max. +template <> +EIGEN_STRONG_INLINE Packet8q32i pmin(const Packet8q32i& a, + const Packet8q32i& b) { + return _mm256_min_epi32(a.m_val, b.m_val); +} +template <> +EIGEN_STRONG_INLINE Packet8q32i pmax(const Packet8q32i& a, + const Packet8q32i& b) { + return _mm256_max_epi32(a.m_val, b.m_val); +} + +template <> +EIGEN_STRONG_INLINE Packet16q16i pmin(const Packet16q16i& a, + const Packet16q16i& b) { + return _mm256_min_epi16(a.m_val, b.m_val); +} +template <> +EIGEN_STRONG_INLINE Packet16q16i pmax(const Packet16q16i& a, + const Packet16q16i& b) { + return _mm256_max_epi16(a.m_val, b.m_val); +} + +template <> +EIGEN_STRONG_INLINE Packet32q8u pmin(const Packet32q8u& a, + const Packet32q8u& b) { + return _mm256_min_epu8(a.m_val, b.m_val); +} +template <> +EIGEN_STRONG_INLINE Packet32q8u pmax(const Packet32q8u& a, + const Packet32q8u& b) { + return _mm256_max_epu8(a.m_val, b.m_val); +} + +template <> +EIGEN_STRONG_INLINE Packet32q8i pmin(const Packet32q8i& a, + const Packet32q8i& b) { + return _mm256_min_epi8(a.m_val, b.m_val); +} +template <> +EIGEN_STRONG_INLINE Packet32q8i pmax(const Packet32q8i& a, + const Packet32q8i& b) { + return _mm256_max_epi8(a.m_val, b.m_val); +} + +// Reductions. +template <> +EIGEN_STRONG_INLINE QInt32 predux_min(const Packet8q32i& a) { + __m256i tmp = _mm256_min_epi32(a, _mm256_permute2f128_si256(a, a, 1)); + tmp = + _mm256_min_epi32(tmp, _mm256_shuffle_epi32(tmp, _MM_SHUFFLE(1, 0, 3, 2))); + return pfirst( + _mm256_min_epi32(tmp, _mm256_shuffle_epi32(tmp, 1))); +} +template <> +EIGEN_STRONG_INLINE QInt32 predux_max(const Packet8q32i& a) { + __m256i tmp = _mm256_max_epi32(a, _mm256_permute2f128_si256(a, a, 1)); + tmp = + _mm256_max_epi32(tmp, _mm256_shuffle_epi32(tmp, _MM_SHUFFLE(1, 0, 3, 2))); + return pfirst( + _mm256_max_epi32(tmp, _mm256_shuffle_epi32(tmp, 1))); +} + +template <> +EIGEN_STRONG_INLINE QInt16 predux_min(const Packet16q16i& a) { + __m256i tmp = _mm256_min_epi16(a, _mm256_permute2f128_si256(a, a, 1)); + tmp = + _mm256_min_epi16(tmp, _mm256_shuffle_epi32(tmp, _MM_SHUFFLE(1, 0, 3, 2))); + tmp = _mm256_min_epi16(tmp, _mm256_shuffle_epi32(tmp, 1)); + return std::min(_mm256_extract_epi16_N0(tmp), _mm256_extract_epi16_N1(tmp)); +} +template <> +EIGEN_STRONG_INLINE QInt16 predux_max(const Packet16q16i& a) { + __m256i tmp = _mm256_max_epi16(a, _mm256_permute2f128_si256(a, a, 1)); + tmp = + _mm256_max_epi16(tmp, _mm256_shuffle_epi32(tmp, _MM_SHUFFLE(1, 0, 3, 2))); + tmp = _mm256_max_epi16(tmp, _mm256_shuffle_epi32(tmp, 1)); + return std::max(_mm256_extract_epi16_N0(tmp), _mm256_extract_epi16_N1(tmp)); +} + +template <> +EIGEN_STRONG_INLINE QUInt8 predux_min(const Packet32q8u& a) { + __m256i tmp = _mm256_min_epu8(a, _mm256_permute2f128_si256(a, a, 1)); + tmp = + _mm256_min_epu8(tmp, _mm256_shuffle_epi32(tmp, _MM_SHUFFLE(1, 0, 3, 2))); + tmp = _mm256_min_epu8(tmp, _mm256_shuffle_epi32(tmp, 1)); + tmp = _mm256_min_epu8(tmp, + _mm256_shufflelo_epi16(tmp, _MM_SHUFFLE(1, 0, 3, 2))); + return std::min(static_cast(_mm256_extract_epi8_N0(tmp)), + static_cast(_mm256_extract_epi8_N1(tmp))); +} +template <> +EIGEN_STRONG_INLINE QUInt8 predux_max(const Packet32q8u& a) { + __m256i tmp = _mm256_max_epu8(a, _mm256_permute2f128_si256(a, a, 1)); + tmp = + _mm256_max_epu8(tmp, _mm256_shuffle_epi32(tmp, _MM_SHUFFLE(1, 0, 3, 2))); + tmp = _mm256_max_epu8(tmp, _mm256_shuffle_epi32(tmp, 1)); + tmp = _mm256_max_epu8(tmp, + _mm256_shufflelo_epi16(tmp, _MM_SHUFFLE(1, 0, 3, 2))); + return std::max(static_cast(_mm256_extract_epi8_N0(tmp)), + static_cast(_mm256_extract_epi8_N1(tmp))); +} + +template <> +EIGEN_STRONG_INLINE QInt8 predux_min(const Packet32q8i& a) { + __m256i tmp = _mm256_min_epi8(a, _mm256_permute2f128_si256(a, a, 1)); + tmp = + _mm256_min_epi8(tmp, _mm256_shuffle_epi32(tmp, _MM_SHUFFLE(1, 0, 3, 2))); + tmp = _mm256_min_epi8(tmp, _mm256_shuffle_epi32(tmp, 1)); + tmp = _mm256_min_epi8(tmp, + _mm256_shufflelo_epi16(tmp, _MM_SHUFFLE(1, 0, 3, 2))); + return std::min(_mm256_extract_epi8_N0(tmp), _mm256_extract_epi8_N1(tmp)); +} +template <> +EIGEN_STRONG_INLINE QInt8 predux_max(const Packet32q8i& a) { + __m256i tmp = _mm256_max_epi8(a, _mm256_permute2f128_si256(a, a, 1)); + tmp = + _mm256_max_epi8(tmp, _mm256_shuffle_epi32(tmp, _MM_SHUFFLE(1, 0, 3, 2))); + tmp = _mm256_max_epi8(tmp, _mm256_shuffle_epi32(tmp, 1)); + tmp = _mm256_max_epi8(tmp, + _mm256_shufflelo_epi16(tmp, _MM_SHUFFLE(1, 0, 3, 2))); + return std::max(_mm256_extract_epi8_N0(tmp), _mm256_extract_epi8_N1(tmp)); +} + +// Vectorized scaling of Packet32q8i by float. +template <> +struct scalar_product_op : binary_op_base { + typedef typename ScalarBinaryOpTraits::ReturnType result_type; +#ifdef EIGEN_SCALAR_BINARY_OP_PLUGIN + scalar_product_op(){EIGEN_SCALAR_BINARY_OP_PLUGIN} +#endif + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type + operator()(const QInt32& a, const double& b) const { + return a * b; + } + + EIGEN_STRONG_INLINE const Packet8q32i packetOp(const Packet8q32i& a, + const double& b) const { + __m256d scale = _mm256_set1_pd(b); + __m256d a_lo = _mm256_cvtepi32_pd(_mm256_castsi256_si128(a)); + __m128i result_lo = _mm256_cvtpd_epi32(_mm256_mul_pd(scale, a_lo)); + __m256d a_hi = _mm256_cvtepi32_pd(_mm256_extracti128_si256(a, 1)); + __m128i result_hi = _mm256_cvtpd_epi32(_mm256_mul_pd(scale, a_hi)); + return _mm256_insertf128_si256(_mm256_castsi128_si256(result_lo), result_hi, + 1); + } +}; + +template <> +struct functor_traits> { + enum { Cost = 4 * NumTraits::MulCost, PacketAccess = true }; +}; + +} // end namespace internal +} // end namespace Eigen + +#endif // TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_PACKETMATHAVX2_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/PacketMathAVX512.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/PacketMathAVX512.h new file mode 100644 index 0000000000000000000000000000000000000000..af02ac0ed2fd1d1ed5a2634ea63a7be3e572fdb9 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/PacketMathAVX512.h @@ -0,0 +1,531 @@ +/* Copyright 2022 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_PACKETMATHAVX512_H_ +#define TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_PACKETMATHAVX512_H_ + +#include "PacketMathAVX2.h" + +namespace Eigen { +namespace internal { + +typedef eigen_packet_wrapper<__m512i, 30> Packet64q8i; +typedef eigen_packet_wrapper<__m512i, 31> Packet32q16i; +typedef eigen_packet_wrapper<__m512i, 32> Packet64q8u; +typedef eigen_packet_wrapper<__m512i, 33> Packet16q32i; + +template <> +struct packet_traits : default_packet_traits { + typedef Packet64q8i type; + typedef Packet32q8i half; + enum { + Vectorizable = 1, + AlignedOnScalar = 1, + size = 64, + }; + enum { + HasAdd = 0, + HasSub = 0, + HasMul = 0, + HasNegate = 0, + HasAbs = 0, + HasAbs2 = 0, + HasMin = 1, + HasMax = 1, + HasConj = 0, + HasSetLinear = 0 + }; +}; +template <> +struct packet_traits : default_packet_traits { + typedef Packet64q8u type; + typedef Packet32q8u half; + enum { + Vectorizable = 1, + AlignedOnScalar = 1, + size = 64, + }; + enum { + HasAdd = 0, + HasSub = 0, + HasMul = 0, + HasNegate = 0, + HasAbs = 0, + HasAbs2 = 0, + HasMin = 1, + HasMax = 1, + HasConj = 0, + HasSetLinear = 0 + }; +}; +template <> +struct packet_traits : default_packet_traits { + typedef Packet32q16i type; + typedef Packet16q16i half; + enum { + Vectorizable = 1, + AlignedOnScalar = 1, + size = 32, + }; + enum { + HasAdd = 0, + HasSub = 0, + HasMul = 0, + HasNegate = 0, + HasAbs = 0, + HasAbs2 = 0, + HasMin = 1, + HasMax = 1, + HasConj = 0, + HasSetLinear = 0 + }; +}; +template <> +struct packet_traits : default_packet_traits { + typedef Packet16q32i type; + typedef Packet8q32i half; + enum { + Vectorizable = 1, + AlignedOnScalar = 1, + size = 16, + }; + enum { + HasAdd = 1, + HasSub = 1, + HasMul = 1, + HasNegate = 1, + HasAbs = 0, + HasAbs2 = 0, + HasMin = 1, + HasMax = 1, + HasConj = 0, + HasSetLinear = 0 + }; +}; + +template <> +struct unpacket_traits { + typedef QInt8 type; + typedef Packet32q8i half; + enum { + size = 64, + alignment = Aligned64, + masked_load_available = false, + masked_store_available = false + }; +}; +template <> +struct unpacket_traits { + typedef QInt16 type; + typedef Packet16q16i half; + enum { + size = 32, + alignment = Aligned64, + masked_load_available = false, + masked_store_available = false + }; +}; +template <> +struct unpacket_traits { + typedef QUInt8 type; + typedef Packet32q8u half; + enum { + size = 64, + alignment = Aligned64, + masked_load_available = false, + masked_store_available = false + }; +}; +template <> +struct unpacket_traits { + typedef QInt32 type; + typedef Packet8q32i half; + enum { + size = 16, + alignment = Aligned64, + masked_load_available = false, + masked_store_available = false + }; +}; + +// Unaligned load +template <> +EIGEN_STRONG_INLINE Packet64q8i ploadu(const QInt8* from) { + EIGEN_DEBUG_UNALIGNED_LOAD return _mm512_loadu_si512( + reinterpret_cast(from)); +} +template <> +EIGEN_STRONG_INLINE Packet32q16i ploadu(const QInt16* from) { + EIGEN_DEBUG_UNALIGNED_LOAD return _mm512_loadu_si512( + reinterpret_cast(from)); +} +template <> +EIGEN_STRONG_INLINE Packet64q8u ploadu(const QUInt8* from) { + EIGEN_DEBUG_UNALIGNED_LOAD return _mm512_loadu_si512( + reinterpret_cast(from)); +} +template <> +EIGEN_STRONG_INLINE Packet16q32i ploadu(const QInt32* from) { + EIGEN_DEBUG_UNALIGNED_LOAD return _mm512_loadu_si512( + reinterpret_cast(from)); +} + +// Aligned load +template <> +EIGEN_STRONG_INLINE Packet64q8i pload(const QInt8* from) { + EIGEN_DEBUG_ALIGNED_LOAD return _mm512_load_si512( + reinterpret_cast(from)); +} +template <> +EIGEN_STRONG_INLINE Packet32q16i pload(const QInt16* from) { + EIGEN_DEBUG_ALIGNED_LOAD return _mm512_load_si512( + reinterpret_cast(from)); +} +template <> +EIGEN_STRONG_INLINE Packet64q8u pload(const QUInt8* from) { + EIGEN_DEBUG_ALIGNED_LOAD return _mm512_load_si512( + reinterpret_cast(from)); +} +template <> +EIGEN_STRONG_INLINE Packet16q32i pload(const QInt32* from) { + EIGEN_DEBUG_ALIGNED_LOAD return _mm512_load_si512( + reinterpret_cast(from)); +} + +// Unaligned store +template <> +EIGEN_STRONG_INLINE void pstoreu(QInt8* to, const Packet64q8i& from) { + EIGEN_DEBUG_UNALIGNED_STORE _mm512_storeu_si512( + reinterpret_cast<__m512i*>(to), from.m_val); +} +template <> +EIGEN_STRONG_INLINE void pstoreu(QInt16* to, const Packet32q16i& from) { + EIGEN_DEBUG_UNALIGNED_STORE _mm512_storeu_si512( + reinterpret_cast<__m512i*>(to), from.m_val); +} +template <> +EIGEN_STRONG_INLINE void pstoreu(QUInt8* to, const Packet64q8u& from) { + EIGEN_DEBUG_UNALIGNED_STORE _mm512_storeu_si512( + reinterpret_cast<__m512i*>(to), from.m_val); +} +template <> +EIGEN_STRONG_INLINE void pstoreu(QInt32* to, const Packet16q32i& from) { + EIGEN_DEBUG_UNALIGNED_STORE _mm512_storeu_si512( + reinterpret_cast<__m512i*>(to), from.m_val); +} + +// Aligned store +template <> +EIGEN_STRONG_INLINE void pstore(QInt32* to, const Packet16q32i& from) { + EIGEN_DEBUG_ALIGNED_STORE _mm512_store_si512(reinterpret_cast<__m512i*>(to), + from.m_val); +} +template <> +EIGEN_STRONG_INLINE void pstore(QUInt8* to, const Packet64q8u& from) { + EIGEN_DEBUG_ALIGNED_STORE _mm512_store_si512(reinterpret_cast<__m512i*>(to), + from.m_val); +} +template <> +EIGEN_STRONG_INLINE void pstore(QInt8* to, const Packet64q8i& from) { + EIGEN_DEBUG_ALIGNED_STORE _mm512_store_si512(reinterpret_cast<__m512i*>(to), + from.m_val); +} +template <> +EIGEN_STRONG_INLINE void pstore(QInt16* to, const Packet32q16i& from) { + EIGEN_DEBUG_ALIGNED_STORE _mm512_store_si512(reinterpret_cast<__m512i*>(to), + from.m_val); +} + +// Extract first element. +template <> +EIGEN_STRONG_INLINE QInt32 pfirst(const Packet16q32i& a) { + return _mm_cvtsi128_si32(_mm512_extracti32x4_epi32(a, 0)); +} +template <> +EIGEN_STRONG_INLINE QUInt8 pfirst(const Packet64q8u& a) { + return static_cast( + _mm_extract_epi8(_mm512_extracti32x4_epi32(a.m_val, 0), 0)); +} +template <> +EIGEN_STRONG_INLINE QInt8 pfirst(const Packet64q8i& a) { + return _mm_extract_epi8(_mm512_extracti32x4_epi32(a.m_val, 0), 0); +} +template <> +EIGEN_STRONG_INLINE QInt16 pfirst(const Packet32q16i& a) { + return _mm_extract_epi16(_mm512_extracti32x4_epi32(a.m_val, 0), 0); +} + +// Initialize to constant value. +template <> +EIGEN_STRONG_INLINE Packet64q8i pset1(const QInt8& from) { + return _mm512_set1_epi8(from.value); +} +template <> +EIGEN_STRONG_INLINE Packet32q16i pset1(const QInt16& from) { + return _mm512_set1_epi16(from.value); +} +template <> +EIGEN_STRONG_INLINE Packet64q8u pset1(const QUInt8& from) { + return _mm512_set1_epi8(static_cast(from.value)); +} +template <> +EIGEN_STRONG_INLINE Packet16q32i pset1(const QInt32& from) { + return _mm512_set1_epi32(from.value); +} + +// Basic arithmetic packet ops for QInt32. +template <> +EIGEN_STRONG_INLINE Packet16q32i padd(const Packet16q32i& a, + const Packet16q32i& b) { + return _mm512_add_epi32(a.m_val, b.m_val); +} +template <> +EIGEN_STRONG_INLINE Packet16q32i psub(const Packet16q32i& a, + const Packet16q32i& b) { + return _mm512_sub_epi32(a.m_val, b.m_val); +} +// Note: mullo truncates the result to 32 bits. +template <> +EIGEN_STRONG_INLINE Packet16q32i pmul(const Packet16q32i& a, + const Packet16q32i& b) { + return _mm512_mullo_epi32(a.m_val, b.m_val); +} +template <> +EIGEN_STRONG_INLINE Packet16q32i pnegate(const Packet16q32i& a) { + return _mm512_sub_epi32(_mm512_setzero_si512(), a.m_val); +} + +// Min and max. +template <> +EIGEN_STRONG_INLINE Packet16q32i pmin(const Packet16q32i& a, + const Packet16q32i& b) { + return _mm512_min_epi32(a.m_val, b.m_val); +} +template <> +EIGEN_STRONG_INLINE Packet16q32i pmax(const Packet16q32i& a, + const Packet16q32i& b) { + return _mm512_max_epi32(a.m_val, b.m_val); +} + +template <> +EIGEN_STRONG_INLINE Packet64q8u pmin(const Packet64q8u& a, + const Packet64q8u& b) { +#ifdef EIGEN_VECTORIZE_AVX512BW + return _mm512_min_epu8(a.m_val, b.m_val); +#else + __m256i ap0 = _mm512_extracti32x8_epi32(a.m_val, 0); + __m256i ap1 = _mm512_extracti32x8_epi32(a.m_val, 1); + __m256i bp0 = _mm512_extracti32x8_epi32(b.m_val, 0); + __m256i bp1 = _mm512_extracti32x8_epi32(b.m_val, 1); + __m256i r0 = _mm256_min_epu8(ap0, bp0); + __m256i r1 = _mm256_min_epu8(ap1, bp1); + return _mm512_inserti32x8(_mm512_castsi256_si512(r0), r1, 1); +#endif +} +template <> +EIGEN_STRONG_INLINE Packet64q8u pmax(const Packet64q8u& a, + const Packet64q8u& b) { +#ifdef EIGEN_VECTORIZE_AVX512BW + return _mm512_max_epu8(a.m_val, b.m_val); +#else + __m256i ap0 = _mm512_extracti32x8_epi32(a.m_val, 0); + __m256i ap1 = _mm512_extracti32x8_epi32(a.m_val, 1); + __m256i bp0 = _mm512_extracti32x8_epi32(b.m_val, 0); + __m256i bp1 = _mm512_extracti32x8_epi32(b.m_val, 1); + __m256i r0 = _mm256_max_epu8(ap0, bp0); + __m256i r1 = _mm256_max_epu8(ap1, bp1); + return _mm512_inserti32x8(_mm512_castsi256_si512(r0), r1, 1); +#endif +} + +template <> +EIGEN_STRONG_INLINE Packet64q8i pmin(const Packet64q8i& a, + const Packet64q8i& b) { +#ifdef EIGEN_VECTORIZE_AVX512BW + return _mm512_min_epi8(a.m_val, b.m_val); +#else + __m256i ap0 = _mm512_extracti32x8_epi32(a.m_val, 0); + __m256i ap1 = _mm512_extracti32x8_epi32(a.m_val, 1); + __m256i bp0 = _mm512_extracti32x8_epi32(b.m_val, 0); + __m256i bp1 = _mm512_extracti32x8_epi32(b.m_val, 1); + __m256i r0 = _mm256_min_epi8(ap0, bp0); + __m256i r1 = _mm256_min_epi8(ap1, bp1); + return _mm512_inserti32x8(_mm512_castsi256_si512(r0), r1, 1); +#endif +} +template <> +EIGEN_STRONG_INLINE Packet32q16i pmin(const Packet32q16i& a, + const Packet32q16i& b) { +#ifdef EIGEN_VECTORIZE_AVX512BW + return _mm512_min_epi16(a.m_val, b.m_val); +#else + __m256i ap0 = _mm512_extracti32x8_epi32(a.m_val, 0); + __m256i ap1 = _mm512_extracti32x8_epi32(a.m_val, 1); + __m256i bp0 = _mm512_extracti32x8_epi32(b.m_val, 0); + __m256i bp1 = _mm512_extracti32x8_epi32(b.m_val, 1); + __m256i r0 = _mm256_min_epi16(ap0, bp0); + __m256i r1 = _mm256_min_epi16(ap1, bp1); + return _mm512_inserti32x8(_mm512_castsi256_si512(r0), r1, 1); +#endif +} +template <> +EIGEN_STRONG_INLINE Packet64q8i pmax(const Packet64q8i& a, + const Packet64q8i& b) { +#ifdef EIGEN_VECTORIZE_AVX512BW + return _mm512_max_epi8(a.m_val, b.m_val); +#else + __m256i ap0 = _mm512_extracti32x8_epi32(a.m_val, 0); + __m256i ap1 = _mm512_extracti32x8_epi32(a.m_val, 1); + __m256i bp0 = _mm512_extracti32x8_epi32(b.m_val, 0); + __m256i bp1 = _mm512_extracti32x8_epi32(b.m_val, 1); + __m256i r0 = _mm256_max_epi8(ap0, bp0); + __m256i r1 = _mm256_max_epi8(ap1, bp1); + return _mm512_inserti32x8(_mm512_castsi256_si512(r0), r1, 1); +#endif +} +template <> +EIGEN_STRONG_INLINE Packet32q16i pmax(const Packet32q16i& a, + const Packet32q16i& b) { +#ifdef EIGEN_VECTORIZE_AVX512BW + return _mm512_max_epi16(a.m_val, b.m_val); +#else + __m256i ap0 = _mm512_extracti32x8_epi32(a.m_val, 0); + __m256i ap1 = _mm512_extracti32x8_epi32(a.m_val, 1); + __m256i bp0 = _mm512_extracti32x8_epi32(b.m_val, 0); + __m256i bp1 = _mm512_extracti32x8_epi32(b.m_val, 1); + __m256i r0 = _mm256_max_epi16(ap0, bp0); + __m256i r1 = _mm256_max_epi16(ap1, bp1); + return _mm512_inserti32x8(_mm512_castsi256_si512(r0), r1, 1); +#endif +} + +// Reductions. +template <> +EIGEN_STRONG_INLINE QInt32 predux_min(const Packet16q32i& a) { + Packet4i lane0 = _mm512_extracti32x4_epi32(a.m_val, 0); + Packet4i lane1 = _mm512_extracti32x4_epi32(a.m_val, 1); + Packet4i lane2 = _mm512_extracti32x4_epi32(a.m_val, 2); + Packet4i lane3 = _mm512_extracti32x4_epi32(a.m_val, 3); + Packet4i res = + _mm_min_epi32(_mm_min_epi32(lane0, lane1), _mm_min_epi32(lane2, lane3)); + res = _mm_min_epi32(res, _mm_shuffle_epi32(res, _MM_SHUFFLE(0, 0, 3, 2))); + res = _mm_min_epi32(res, _mm_shuffle_epi32(res, _MM_SHUFFLE(0, 0, 0, 1))); + return pfirst(res); +} +template <> +EIGEN_STRONG_INLINE QInt32 predux_max(const Packet16q32i& a) { + Packet4i lane0 = _mm512_extracti32x4_epi32(a.m_val, 0); + Packet4i lane1 = _mm512_extracti32x4_epi32(a.m_val, 1); + Packet4i lane2 = _mm512_extracti32x4_epi32(a.m_val, 2); + Packet4i lane3 = _mm512_extracti32x4_epi32(a.m_val, 3); + Packet4i res = + _mm_max_epi32(_mm_max_epi32(lane0, lane1), _mm_max_epi32(lane2, lane3)); + res = _mm_max_epi32(res, _mm_shuffle_epi32(res, _MM_SHUFFLE(0, 0, 3, 2))); + res = _mm_max_epi32(res, _mm_shuffle_epi32(res, _MM_SHUFFLE(0, 0, 0, 1))); + return pfirst(res); +} +template <> +EIGEN_STRONG_INLINE QInt16 predux_min(const Packet32q16i& a) { + Packet4i lane0 = _mm512_extracti32x4_epi32(a.m_val, 0); + Packet4i lane1 = _mm512_extracti32x4_epi32(a.m_val, 1); + Packet4i lane2 = _mm512_extracti32x4_epi32(a.m_val, 2); + Packet4i lane3 = _mm512_extracti32x4_epi32(a.m_val, 3); + Packet4i res = + _mm_min_epi16(_mm_min_epi16(lane0, lane1), _mm_min_epi16(lane2, lane3)); + res = _mm_min_epi16(res, _mm_shuffle_epi32(res, _MM_SHUFFLE(0, 0, 3, 2))); + res = _mm_min_epi16(res, _mm_shuffle_epi32(res, _MM_SHUFFLE(0, 0, 0, 1))); + std::uint32_t w = pfirst(res); + return std::min( + {static_cast(w >> 16), static_cast(w)}); +} +template <> +EIGEN_STRONG_INLINE QInt16 predux_max(const Packet32q16i& a) { + Packet4i lane0 = _mm512_extracti32x4_epi32(a.m_val, 0); + Packet4i lane1 = _mm512_extracti32x4_epi32(a.m_val, 1); + Packet4i lane2 = _mm512_extracti32x4_epi32(a.m_val, 2); + Packet4i lane3 = _mm512_extracti32x4_epi32(a.m_val, 3); + Packet4i res = + _mm_max_epi16(_mm_max_epi16(lane0, lane1), _mm_max_epi16(lane2, lane3)); + res = _mm_max_epi16(res, _mm_shuffle_epi32(res, _MM_SHUFFLE(0, 0, 3, 2))); + res = _mm_max_epi16(res, _mm_shuffle_epi32(res, _MM_SHUFFLE(0, 0, 0, 1))); + std::uint32_t w = pfirst(res); + return std::max( + {static_cast(w >> 16), static_cast(w)}); +} +template <> +EIGEN_STRONG_INLINE QUInt8 predux_min(const Packet64q8u& a) { + Packet4i lane0 = _mm512_extracti32x4_epi32(a.m_val, 0); + Packet4i lane1 = _mm512_extracti32x4_epi32(a.m_val, 1); + Packet4i lane2 = _mm512_extracti32x4_epi32(a.m_val, 2); + Packet4i lane3 = _mm512_extracti32x4_epi32(a.m_val, 3); + Packet4i res = + _mm_min_epu8(_mm_min_epu8(lane0, lane1), _mm_min_epu8(lane2, lane3)); + res = _mm_min_epu8(res, _mm_shuffle_epi32(res, _MM_SHUFFLE(0, 0, 3, 2))); + res = _mm_min_epu8(res, _mm_shuffle_epi32(res, _MM_SHUFFLE(0, 0, 0, 1))); + std::uint32_t w = pfirst(res); + return std::min( + {static_cast(w >> 24), static_cast(w >> 16), + static_cast(w >> 8), static_cast(w)}); +} +template <> +EIGEN_STRONG_INLINE QUInt8 predux_max(const Packet64q8u& a) { + Packet4i lane0 = _mm512_extracti32x4_epi32(a.m_val, 0); + Packet4i lane1 = _mm512_extracti32x4_epi32(a.m_val, 1); + Packet4i lane2 = _mm512_extracti32x4_epi32(a.m_val, 2); + Packet4i lane3 = _mm512_extracti32x4_epi32(a.m_val, 3); + Packet4i res = + _mm_max_epu8(_mm_max_epu8(lane0, lane1), _mm_max_epu8(lane2, lane3)); + res = _mm_max_epu8(res, _mm_shuffle_epi32(res, _MM_SHUFFLE(0, 0, 3, 2))); + res = _mm_max_epu8(res, _mm_shuffle_epi32(res, _MM_SHUFFLE(0, 0, 0, 1))); + std::uint32_t w = pfirst(res); + return std::max( + {static_cast(w >> 24), static_cast(w >> 16), + static_cast(w >> 8), static_cast(w)}); +} +template <> +EIGEN_STRONG_INLINE QInt8 predux_min(const Packet64q8i& a) { + Packet4i lane0 = _mm512_extracti32x4_epi32(a.m_val, 0); + Packet4i lane1 = _mm512_extracti32x4_epi32(a.m_val, 1); + Packet4i lane2 = _mm512_extracti32x4_epi32(a.m_val, 2); + Packet4i lane3 = _mm512_extracti32x4_epi32(a.m_val, 3); + Packet4i res = + _mm_min_epi8(_mm_min_epi8(lane0, lane1), _mm_min_epi8(lane2, lane3)); + res = _mm_min_epi8(res, _mm_shuffle_epi32(res, _MM_SHUFFLE(0, 0, 3, 2))); + res = _mm_min_epi8(res, _mm_shuffle_epi32(res, _MM_SHUFFLE(0, 0, 0, 1))); + std::uint32_t w = pfirst(res); + return std::min( + {static_cast(w >> 24), static_cast(w >> 16), + static_cast(w >> 8), static_cast(w)}); +} +template <> +EIGEN_STRONG_INLINE QInt8 predux_max(const Packet64q8i& a) { + Packet4i lane0 = _mm512_extracti32x4_epi32(a.m_val, 0); + Packet4i lane1 = _mm512_extracti32x4_epi32(a.m_val, 1); + Packet4i lane2 = _mm512_extracti32x4_epi32(a.m_val, 2); + Packet4i lane3 = _mm512_extracti32x4_epi32(a.m_val, 3); + Packet4i res = + _mm_max_epi8(_mm_max_epi8(lane0, lane1), _mm_max_epi8(lane2, lane3)); + res = _mm_max_epi8(res, _mm_shuffle_epi32(res, _MM_SHUFFLE(0, 0, 3, 2))); + res = _mm_max_epi8(res, _mm_shuffle_epi32(res, _MM_SHUFFLE(0, 0, 0, 1))); + std::uint32_t w = pfirst(res); + return std::min( + {static_cast(w >> 24), static_cast(w >> 16), + static_cast(w >> 8), static_cast(w)}); +} + +} // end namespace internal +} // end namespace Eigen + +#endif // TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_PACKETMATHAVX512_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/TypeCastingAVX2.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/TypeCastingAVX2.h new file mode 100644 index 0000000000000000000000000000000000000000..1e0fa8f3fe3259776f6b4135767276a825106cb1 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/TypeCastingAVX2.h @@ -0,0 +1,108 @@ +/* Copyright 2022 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_TYPECASTINGAVX2_H_ +#define TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_TYPECASTINGAVX2_H_ + +namespace Eigen { +namespace internal { + +typedef __m256 Packet8f; + +template <> +struct type_casting_traits { + enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 1 }; +}; + +template <> +EIGEN_STRONG_INLINE Packet8f pcast(const Packet8q32i& a) { + return _mm256_cvtepi32_ps(a.m_val); +} + +template <> +struct type_casting_traits { + enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 1 }; +}; + +template <> +EIGEN_STRONG_INLINE Packet8q32i pcast(const Packet8f& a) { + return _mm256_cvtps_epi32(a); +} + +template <> +struct type_casting_traits { + enum { VectorizedCast = 1, SrcCoeffRatio = 4, TgtCoeffRatio = 1 }; +}; + +template <> +EIGEN_STRONG_INLINE Packet32q8i +pcast(const Packet8q32i& a, const Packet8q32i& b, + const Packet8q32i& c, const Packet8q32i& d) { + __m256i converted = _mm256_packs_epi16(_mm256_packs_epi32(a.m_val, b.m_val), + _mm256_packs_epi32(c.m_val, d.m_val)); + // Since packs does not cross 128 bit lane boundaries, + // we have to permute to properly order the final result. + const __m256i permute_mask = _mm256_set_epi32(7, 3, 6, 2, 5, 1, 4, 0); + return _mm256_permutevar8x32_epi32(converted, permute_mask); +} + +template <> +struct type_casting_traits { + enum { VectorizedCast = 1, SrcCoeffRatio = 4, TgtCoeffRatio = 1 }; +}; + +template <> +EIGEN_STRONG_INLINE Packet32q8i +pcast(const Packet8f& a, const Packet8f& b, + const Packet8f& c, const Packet8f& d) { + const __m256i a_conv = _mm256_cvtps_epi32(a); + const __m256i b_conv = _mm256_cvtps_epi32(b); + const __m256i c_conv = _mm256_cvtps_epi32(c); + const __m256i d_conv = _mm256_cvtps_epi32(d); + __m256i converted = _mm256_packs_epi16(_mm256_packs_epi32(a_conv, b_conv), + _mm256_packs_epi32(c_conv, d_conv)); + const __m256i permute_mask = _mm256_set_epi32(7, 3, 6, 2, 5, 1, 4, 0); + return _mm256_permutevar8x32_epi32(converted, permute_mask); +} + +template <> +struct type_casting_traits { + enum { VectorizedCast = 1, SrcCoeffRatio = 4, TgtCoeffRatio = 1 }; +}; + +template <> +EIGEN_STRONG_INLINE Packet32q8u +pcast(const Packet8q32i& a, const Packet8q32i& b, + const Packet8q32i& c, const Packet8q32i& d) { + // _mm256_packus_epi32 trims negative numbers to 0 but we can't allow numbers + // that are too large because _mm256_packus_epi16 expects signed input + // (example of problem input: 0x11111111, which saturates to 0xffff = -1, + // which saturates to 0). + const __m256i a_clip = _mm256_min_epi32(a, _mm256_set1_epi32(255)); + const __m256i b_clip = _mm256_min_epi32(b, _mm256_set1_epi32(255)); + const __m256i c_clip = _mm256_min_epi32(c, _mm256_set1_epi32(255)); + const __m256i d_clip = _mm256_min_epi32(d, _mm256_set1_epi32(255)); + const __m256i converted = _mm256_packus_epi16( + _mm256_packus_epi32(a_clip, b_clip), _mm256_packus_epi32(c_clip, d_clip)); + // Since packus does not cross 128 bit lane boundaries, + // we have to permute to properly order the final result. + const __m256i permute_mask = _mm256_set_epi32(7, 3, 6, 2, 5, 1, 4, 0); + return _mm256_permutevar8x32_epi32(converted, permute_mask); +} + +} // end namespace internal +} // end namespace Eigen + +#endif // TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_TYPECASTINGAVX2_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/TypeCastingAVX512.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/TypeCastingAVX512.h new file mode 100644 index 0000000000000000000000000000000000000000..54c052d1671bd07a5f30af8984b56e560922dd39 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint/TypeCastingAVX512.h @@ -0,0 +1,206 @@ +/* Copyright 2022 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_TYPECASTINGAVX512_H_ +#define TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_TYPECASTINGAVX512_H_ + +namespace Eigen { +namespace internal { + +typedef __m512 Packet16f; +typedef __m512i Packet16i; + +template <> +struct type_casting_traits { + enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 1 }; +}; + +template <> +EIGEN_STRONG_INLINE Packet16f pcast(const Packet16q32i& a) { + return _mm512_cvtepi32_ps(a.m_val); +} + +template <> +struct type_casting_traits { + enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 1 }; +}; + +template <> +EIGEN_STRONG_INLINE Packet16q32i pcast(const Packet16f& a) { + return _mm512_cvtps_epi32(a); +} + +template <> +struct type_casting_traits { + enum { VectorizedCast = 1, SrcCoeffRatio = 2, TgtCoeffRatio = 1 }; +}; + +template <> +EIGEN_STRONG_INLINE Packet32q16i pcast(const Packet16f& a, + const Packet16f& b) { + Packet16i a_int = _mm512_cvtps_epi32(a); + Packet16i b_int = _mm512_cvtps_epi32(b); +#ifdef EIGEN_VECTORIZE_AVX512BW + return _mm512_packs_epi32(a_int, b_int); +#else + Packet8i ab_int16_low = _mm256_permute4x64_epi64( + _mm256_packs_epi32(_mm512_castsi512_si256(a_int), + _mm512_castsi512_si256(b_int)), + _MM_SHUFFLE(0, 2, 1, 3)); + Packet8i ab_int16_high = _mm256_permute4x64_epi64( + _mm256_packs_epi32(_mm512_extracti32x8_epi32(a_int, 1), + _mm512_extracti32x8_epi32(b_int, 1)), + _MM_SHUFFLE(0, 2, 1, 3)); + return _mm512_inserti32x8(_mm512_castsi256_si512(ab_int16_low), ab_int16_high, + 1); +#endif +} + +template <> +struct type_casting_traits { + enum { VectorizedCast = 1, SrcCoeffRatio = 4, TgtCoeffRatio = 1 }; +}; + +template <> +EIGEN_STRONG_INLINE Packet64q8i pcast(const Packet16f& a, + const Packet16f& b, + const Packet16f& c, + const Packet16f& d) { + Packet16i a_int = _mm512_cvtps_epi32(a); + Packet16i b_int = _mm512_cvtps_epi32(b); + Packet16i c_int = _mm512_cvtps_epi32(c); + Packet16i d_int = _mm512_cvtps_epi32(d); +#ifdef EIGEN_VECTORIZE_AVX512BW + return _mm512_packs_epi16(_mm512_packs_epi32(a_int, b_int), + _mm512_packs_epi32(c_int, d_int)); +#else + Packet8i ab_int16_low = _mm256_permute4x64_epi64( + _mm256_packs_epi32(_mm512_castsi512_si256(a_int), + _mm512_castsi512_si256(b_int)), + _MM_SHUFFLE(0, 2, 1, 3)); + Packet8i cd_int16_low = _mm256_permute4x64_epi64( + _mm256_packs_epi32(_mm512_castsi512_si256(c_int), + _mm512_castsi512_si256(d_int)), + _MM_SHUFFLE(0, 2, 1, 3)); + Packet8i ab_int16_high = _mm256_permute4x64_epi64( + _mm256_packs_epi32(_mm512_extracti32x8_epi32(a_int, 1), + _mm512_extracti32x8_epi32(b_int, 1)), + _MM_SHUFFLE(0, 2, 1, 3)); + Packet8i cd_int16_high = _mm256_permute4x64_epi64( + _mm256_packs_epi32(_mm512_extracti32x8_epi32(c_int, 1), + _mm512_extracti32x8_epi32(d_int, 1)), + _MM_SHUFFLE(0, 2, 1, 3)); + Packet8i abcd_int8_low = _mm256_permute4x64_epi64( + _mm256_packs_epi16(ab_int16_low, cd_int16_low), _MM_SHUFFLE(0, 2, 1, 3)); + Packet8i abcd_int8_high = + _mm256_permute4x64_epi64(_mm256_packs_epi16(ab_int16_high, cd_int16_high), + _MM_SHUFFLE(0, 2, 1, 3)); + return _mm512_inserti32x8(_mm512_castsi256_si512(abcd_int8_low), + abcd_int8_high, 1); +#endif +} + +template <> +struct type_casting_traits { + enum { VectorizedCast = 1, SrcCoeffRatio = 4, TgtCoeffRatio = 1 }; +}; + +template <> +struct type_casting_traits { + enum { VectorizedCast = 1, SrcCoeffRatio = 2, TgtCoeffRatio = 1 }; +}; + +template <> +EIGEN_STRONG_INLINE Packet64q8i +pcast(const Packet16q32i& a, const Packet16q32i& b, + const Packet16q32i& c, const Packet16q32i& d) { + __m128i a_part = _mm512_cvtsepi32_epi8(a); + __m128i b_part = _mm512_cvtsepi32_epi8(b); + __m128i c_part = _mm512_cvtsepi32_epi8(c); + __m128i d_part = _mm512_cvtsepi32_epi8(d); + __m256i ab = + _mm256_inserti128_si256(_mm256_castsi128_si256(a_part), b_part, 1); + __m256i cd = + _mm256_inserti128_si256(_mm256_castsi128_si256(c_part), d_part, 1); + __m512i converted = _mm512_inserti64x4(_mm512_castsi256_si512(ab), cd, 1); + return converted; +} + +template <> +EIGEN_STRONG_INLINE Packet32q16i pcast( + const Packet16q32i& a, const Packet16q32i& b) { + __m256i a_part = _mm512_cvtsepi32_epi16(a); + __m256i b_part = _mm512_cvtsepi32_epi16(b); + __m512i converted = + _mm512_inserti64x4(_mm512_castsi256_si512(a_part), b_part, 1); + return converted; +} + +template <> +struct type_casting_traits { + enum { VectorizedCast = 1, SrcCoeffRatio = 4, TgtCoeffRatio = 1 }; +}; + +template <> +EIGEN_STRONG_INLINE Packet64q8u +pcast(const Packet16q32i& a, const Packet16q32i& b, + const Packet16q32i& c, const Packet16q32i& d) { + // Brute-force saturation since there isn't a pack operation for unsigned + // numbers that keeps the elements in order. + __m128i a_part = _mm512_cvtepi32_epi8(_mm512_max_epi32( + _mm512_min_epi32(a, _mm512_set1_epi32(255)), _mm512_setzero_si512())); + __m128i b_part = _mm512_cvtepi32_epi8(_mm512_max_epi32( + _mm512_min_epi32(b, _mm512_set1_epi32(255)), _mm512_setzero_si512())); + __m128i c_part = _mm512_cvtepi32_epi8(_mm512_max_epi32( + _mm512_min_epi32(c, _mm512_set1_epi32(255)), _mm512_setzero_si512())); + __m128i d_part = _mm512_cvtepi32_epi8(_mm512_max_epi32( + _mm512_min_epi32(d, _mm512_set1_epi32(255)), _mm512_setzero_si512())); + __m256i ab = + _mm256_inserti128_si256(_mm256_castsi128_si256(a_part), b_part, 1); + __m256i cd = + _mm256_inserti128_si256(_mm256_castsi128_si256(c_part), d_part, 1); + __m512i converted = _mm512_inserti64x4(_mm512_castsi256_si512(ab), cd, 1); + return converted; +} + +#if 0 +// The type Packet32q16u does not exist for AVX-512 yet +template <> +struct type_casting_traits { + enum { VectorizedCast = 1, SrcCoeffRatio = 2, TgtCoeffRatio = 1 }; +}; + +template <> +EIGEN_STRONG_INLINE Packet32q16u +pcast(const Packet16q32i& a, + const Packet16q32i& b) { + // Brute-force saturation since there isn't a pack operation for unsigned + // numbers that keeps the elements in order. + __m256i a_part = + _mm512_cvtepi32_epi16(_mm512_max_epi32( + _mm512_min_epi32(a, _mm512_set1_epi32(65535)), _mm512_setzero_si512())); + __m256i b_part = _mm512_cvtepi32_epi16( + _mm512_max_epi32(_mm512_min_epi32(b, _mm512_set1_epi32(65535)), + _mm512_setzero_si512())); + __m512i converted = + _mm512_inserti64x4(_mm512_castsi256_si512(a_part), b_part, 1); + return converted; +} +#endif + +} // end namespace internal +} // end namespace Eigen + +#endif // TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_TYPECASTINGAVX512_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint_types.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint_types.h new file mode 100644 index 0000000000000000000000000000000000000000..5ade0b38be477de291d815eafe7cbb5089c07889 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/fixedpoint_types.h @@ -0,0 +1,354 @@ +/* Copyright 2022 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_TYPES_H_ +#define TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_TYPES_H_ + +#include + +#include +#include +#include + +namespace Eigen { + +// The mantissa part of the fixed point representation. See +// go/tensorfixedpoint for details +struct QInt8; +struct QUInt8; +struct QInt16; +struct QUInt16; +struct QInt32; + +template <> +struct NumTraits : GenericNumTraits {}; +template <> +struct NumTraits : GenericNumTraits {}; +template <> +struct NumTraits : GenericNumTraits {}; +template <> +struct NumTraits : GenericNumTraits {}; +template <> +struct NumTraits : GenericNumTraits {}; + +namespace internal { +template <> +struct scalar_product_traits { + enum { + // Cost = NumTraits::MulCost, + Defined = 1 + }; + typedef QInt32 ReturnType; +}; +} // namespace internal + +// Wrap the 8bit int into a QInt8 struct instead of using a typedef to prevent +// the compiler from silently type cast the mantissa into a bigger or a smaller +// representation. +struct QInt8 { + QInt8() : value(0) {} + QInt8(const int8_t v) : value(v) {} + QInt8(const QInt32 v); + + operator int() const { return static_cast(value); } + + int8_t value; +}; + +struct QUInt8 { + QUInt8() : value(0) {} + QUInt8(const uint8_t v) : value(v) {} + QUInt8(const QInt32 v); + + operator int() const { return static_cast(value); } + + uint8_t value; +}; + +struct QInt16 { + QInt16() : value(0) {} + QInt16(const int16_t v) : value(v) {} + QInt16(const QInt32 v); + operator int() const { return static_cast(value); } + + int16_t value; +}; + +struct QUInt16 { + QUInt16() : value(0) {} + QUInt16(const uint16_t v) : value(v) {} + QUInt16(const QInt32 v); + operator int() const { return static_cast(value); } + + uint16_t value; +}; + +struct QInt32 { + QInt32() : value(0) {} + QInt32(const int8_t v) : value(v) {} + QInt32(const int32_t v) : value(v) {} + QInt32(const uint32_t v) : value(static_cast(v)) {} + QInt32(const QInt8 v) : value(v.value) {} + QInt32(const float v) : value(static_cast(lrint(v))) {} +#ifdef EIGEN_MAKING_DOCS + // Workaround to fix build on PPC. + QInt32(unsigned long v) : value(v) {} +#endif + + operator float() const { return static_cast(value); } + + int32_t value; +}; + +EIGEN_STRONG_INLINE QInt8::QInt8(const QInt32 v) + : value(static_cast( + v.value > 127 ? 127 : (v.value < -128 ? -128 : v.value))) {} +EIGEN_STRONG_INLINE QUInt8::QUInt8(const QInt32 v) + : value(static_cast(v.value > 255 ? 255 + : (v.value < 0 ? 0 : v.value))) { +} +EIGEN_STRONG_INLINE QInt16::QInt16(const QInt32 v) + : value(static_cast( + v.value > 32767 ? 32767 : (v.value < -32768 ? -32768 : v.value))) {} +EIGEN_STRONG_INLINE QUInt16::QUInt16(const QInt32 v) + : value(static_cast( + v.value > 65535 ? 65535 : (v.value < 0 ? 0 : v.value))) {} + +// Basic widening 8-bit operations: This will be vectorized in future CLs. +EIGEN_STRONG_INLINE QInt32 operator*(const QInt8 a, const QInt8 b) { + return QInt32(static_cast(a.value) * static_cast(b.value)); +} +EIGEN_STRONG_INLINE QInt32 operator*(const QInt8 a, const QUInt8 b) { + return QInt32(static_cast(a.value) * static_cast(b.value)); +} +EIGEN_STRONG_INLINE QInt32 operator+(const QInt8 a, const QInt8 b) { + return QInt32(static_cast(a.value) + static_cast(b.value)); +} +EIGEN_STRONG_INLINE QInt32 operator-(const QInt8 a, const QInt8 b) { + return QInt32(static_cast(a.value) - static_cast(b.value)); +} + +// Basic widening 16-bit operations: This will be vectorized in future CLs. +EIGEN_STRONG_INLINE QInt32 operator*(const QInt16 a, const QInt16 b) { + return QInt32(static_cast(a.value) * static_cast(b.value)); +} +EIGEN_STRONG_INLINE QInt32 operator*(const QInt16 a, const QUInt16 b) { + return QInt32(static_cast(a.value) * static_cast(b.value)); +} +EIGEN_STRONG_INLINE QInt32 operator+(const QInt16 a, const QInt16 b) { + return QInt32(static_cast(a.value) + static_cast(b.value)); +} +EIGEN_STRONG_INLINE QInt32 operator-(const QInt16 a, const QInt16 b) { + return QInt32(static_cast(a.value) - static_cast(b.value)); +} + +// Mixed QInt32 op QInt8 operations. This will be vectorized in future CLs. +EIGEN_STRONG_INLINE QInt32 operator+(const QInt32 a, const QInt8 b) { + return QInt32(a.value + static_cast(b.value)); +} +EIGEN_STRONG_INLINE QInt32 operator+(const QInt8 a, const QInt32 b) { + return QInt32(static_cast(a.value) + b.value); +} +EIGEN_STRONG_INLINE QInt32 operator-(const QInt32 a, const QInt8 b) { + return QInt32(a.value - static_cast(b.value)); +} +EIGEN_STRONG_INLINE QInt32 operator-(const QInt8 a, const QInt32 b) { + return QInt32(static_cast(a.value) - b.value); +} +EIGEN_STRONG_INLINE QInt32 operator*(const QInt32 a, const QInt8 b) { + return QInt32(a.value * static_cast(b.value)); +} +EIGEN_STRONG_INLINE QInt32 operator*(const QInt8 a, const QInt32 b) { + return QInt32(static_cast(a.value) * b.value); +} + +// Mixed QInt32 op QInt16 operations. This will be vectorized in future CLs. +EIGEN_STRONG_INLINE QInt32 operator+(const QInt32 a, const QInt16 b) { + return QInt32(a.value + static_cast(b.value)); +} +EIGEN_STRONG_INLINE QInt32 operator+(const QInt16 a, const QInt32 b) { + return QInt32(static_cast(a.value) + b.value); +} +EIGEN_STRONG_INLINE QInt32 operator-(const QInt32 a, const QInt16 b) { + return QInt32(a.value - static_cast(b.value)); +} +EIGEN_STRONG_INLINE QInt32 operator-(const QInt16 a, const QInt32 b) { + return QInt32(static_cast(a.value) - b.value); +} +EIGEN_STRONG_INLINE QInt32 operator*(const QInt32 a, const QInt16 b) { + return QInt32(a.value * static_cast(b.value)); +} +EIGEN_STRONG_INLINE QInt32 operator*(const QInt16 a, const QInt32 b) { + return QInt32(static_cast(a.value) * b.value); +} + +// Mixed QInt32 op QUInt8 operations. This will be vectorized in future CLs. +EIGEN_STRONG_INLINE QInt32 operator+(const QInt32 a, const QUInt8 b) { + return QInt32(a.value + static_cast(b.value)); +} +EIGEN_STRONG_INLINE QInt32 operator+(const QUInt8 a, const QInt32 b) { + return QInt32(static_cast(a.value) + b.value); +} +EIGEN_STRONG_INLINE QInt32 operator-(const QInt32 a, const QUInt8 b) { + return QInt32(a.value - static_cast(b.value)); +} +EIGEN_STRONG_INLINE QInt32 operator-(const QUInt8 a, const QInt32 b) { + return QInt32(static_cast(a.value) - b.value); +} +EIGEN_STRONG_INLINE QInt32 operator*(const QInt32 a, const QUInt8 b) { + return QInt32(a.value * static_cast(b.value)); +} +EIGEN_STRONG_INLINE QInt32 operator*(const QUInt8 a, const QInt32 b) { + return QInt32(static_cast(a.value) * b.value); +} + +// Mixed QInt32 op QUInt16 operations. This will be vectorized in future CLs. +EIGEN_STRONG_INLINE QInt32 operator+(const QInt32 a, const QUInt16 b) { + return QInt32(a.value + static_cast(b.value)); +} +EIGEN_STRONG_INLINE QInt32 operator+(const QUInt16 a, const QInt32 b) { + return QInt32(static_cast(a.value) + b.value); +} +EIGEN_STRONG_INLINE QInt32 operator-(const QInt32 a, const QUInt16 b) { + return QInt32(a.value - static_cast(b.value)); +} +EIGEN_STRONG_INLINE QInt32 operator-(const QUInt16 a, const QInt32 b) { + return QInt32(static_cast(a.value) - b.value); +} +EIGEN_STRONG_INLINE QInt32 operator*(const QInt32 a, const QUInt16 b) { + return QInt32(a.value * static_cast(b.value)); +} +EIGEN_STRONG_INLINE QInt32 operator*(const QUInt16 a, const QInt32 b) { + return QInt32(static_cast(a.value) * b.value); +} + +// Basic arithmetic operations on QInt32, which behaves like a int32_t. +EIGEN_STRONG_INLINE QInt32 operator+(const QInt32 a, const QInt32 b) { + return a.value + b.value; +} +EIGEN_STRONG_INLINE QInt32 operator-(const QInt32 a, const QInt32 b) { + return a.value - b.value; +} +EIGEN_STRONG_INLINE QInt32 operator*(const QInt32 a, const QInt32 b) { + return a.value * b.value; +} +EIGEN_STRONG_INLINE QInt32 operator/(const QInt32 a, const QInt32 b) { + return a.value / b.value; +} +EIGEN_STRONG_INLINE QInt32& operator+=(QInt32& a, const QInt32 b) { + a.value += b.value; + return a; +} +EIGEN_STRONG_INLINE QInt32& operator-=(QInt32& a, const QInt32 b) { + a.value -= b.value; + return a; +} +EIGEN_STRONG_INLINE QInt32& operator*=(QInt32& a, const QInt32 b) { + a.value *= b.value; + return a; +} +EIGEN_STRONG_INLINE QInt32& operator/=(QInt32& a, const QInt32 b) { + a.value /= b.value; + return a; +} +EIGEN_STRONG_INLINE QInt32 operator-(const QInt32 a) { return -a.value; } + +// Scaling QInt32 by double. We do the arithmetic in double because +// float only has 23 bits of mantissa, so casting QInt32 to float might reduce +// accuracy by discarding up to 7 (least significant) bits. +EIGEN_STRONG_INLINE QInt32 operator*(const QInt32 a, const double b) { + return static_cast(lrint(static_cast(a.value) * b)); +} +EIGEN_STRONG_INLINE QInt32 operator*(const double a, const QInt32 b) { + return static_cast(lrint(a * static_cast(b.value))); +} +EIGEN_STRONG_INLINE QInt32& operator*=(QInt32& a, const double b) { + a.value = static_cast(lrint(static_cast(a.value) * b)); + return a; +} + +// Comparisons +EIGEN_STRONG_INLINE bool operator==(const QInt8 a, const QInt8 b) { + return a.value == b.value; +} +EIGEN_STRONG_INLINE bool operator==(const QUInt8 a, const QUInt8 b) { + return a.value == b.value; +} +EIGEN_STRONG_INLINE bool operator==(const QInt16 a, const QInt16 b) { + return a.value == b.value; +} +EIGEN_STRONG_INLINE bool operator==(const QUInt16 a, const QUInt16 b) { + return a.value == b.value; +} +EIGEN_STRONG_INLINE bool operator==(const QInt32 a, const QInt32 b) { + return a.value == b.value; +} + +EIGEN_STRONG_INLINE bool operator<(const QInt8 a, const QInt8 b) { + return a.value < b.value; +} +EIGEN_STRONG_INLINE bool operator<(const QUInt8 a, const QUInt8 b) { + return a.value < b.value; +} +EIGEN_STRONG_INLINE bool operator<(const QInt16 a, const QInt16 b) { + return a.value < b.value; +} +EIGEN_STRONG_INLINE bool operator<(const QUInt16 a, const QUInt16 b) { + return a.value < b.value; +} +EIGEN_STRONG_INLINE bool operator<(const QInt32 a, const QInt32 b) { + return a.value < b.value; +} + +EIGEN_STRONG_INLINE bool operator>(const QInt8 a, const QInt8 b) { + return a.value > b.value; +} +EIGEN_STRONG_INLINE bool operator>(const QUInt8 a, const QUInt8 b) { + return a.value > b.value; +} +EIGEN_STRONG_INLINE bool operator>(const QInt16 a, const QInt16 b) { + return a.value > b.value; +} +EIGEN_STRONG_INLINE bool operator>(const QUInt16 a, const QUInt16 b) { + return a.value > b.value; +} +EIGEN_STRONG_INLINE bool operator>(const QInt32 a, const QInt32 b) { + return a.value > b.value; +} + +EIGEN_STRONG_INLINE std::ostream& operator<<(std::ostream& os, QInt8 a) { + os << static_cast(a.value); + return os; +} +EIGEN_STRONG_INLINE std::ostream& operator<<(std::ostream& os, QUInt8 a) { + os << static_cast(a.value); + return os; +} +EIGEN_STRONG_INLINE std::ostream& operator<<(std::ostream& os, QInt16 a) { + os << static_cast(a.value); + return os; +} +EIGEN_STRONG_INLINE std::ostream& operator<<(std::ostream& os, QUInt16 a) { + os << static_cast(a.value); + return os; +} +EIGEN_STRONG_INLINE std::ostream& operator<<(std::ostream& os, QInt32 a) { + os << a.value; + return os; +} + +} // namespace Eigen + +#endif // TENSORFLOW_TSL_FRAMEWORK_FIXEDPOINT_TYPES_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/metrics.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/metrics.h new file mode 100644 index 0000000000000000000000000000000000000000..0c087f0bd3922a8f35e6d31f63be3ecb367d4acb --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/metrics.h @@ -0,0 +1,30 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_METRICS_H_ +#define TENSORFLOW_TSL_FRAMEWORK_METRICS_H_ + +#include + +namespace tsl { +namespace metrics { + +// Updates the metrics stored about time BFC allocator spents during delay. +void UpdateBfcAllocatorDelayTime(const uint64_t delay_usecs); + +} // namespace metrics +} // namespace tsl + +#endif // TENSORFLOW_TSL_FRAMEWORK_METRICS_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/numeric_types.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/numeric_types.h new file mode 100644 index 0000000000000000000000000000000000000000..fc5c7a6c62144e8a7c7185ec31915792091a21f1 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/numeric_types.h @@ -0,0 +1,74 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_NUMERIC_TYPES_H_ +#define TENSORFLOW_TSL_FRAMEWORK_NUMERIC_TYPES_H_ + +#include + +#include "tsl/framework/fixedpoint_types.h" +#include "tsl/platform/types.h" + +namespace tsl { + +// Single precision complex. +typedef std::complex complex64; +// Double precision complex. +typedef std::complex complex128; + +// We use Eigen's QInt implementations for our quantized int types. +typedef Eigen::QInt8 qint8; +typedef Eigen::QUInt8 quint8; +typedef Eigen::QInt32 qint32; +typedef Eigen::QInt16 qint16; +typedef Eigen::QUInt16 quint16; + +} // namespace tsl + +static inline tsl::bfloat16 FloatToBFloat16(float float_val) { +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + return *reinterpret_cast( + reinterpret_cast(&float_val)); +#else + return *reinterpret_cast( + &(reinterpret_cast(&float_val)[1])); +#endif +} + +namespace Eigen { +template <> +struct NumTraits : GenericNumTraits { + enum { + RequireInitialization = 1, + ReadCost = HugeCost, + AddCost = HugeCost, + MulCost = HugeCost + }; + + static constexpr inline int digits10() { return 0; } + static constexpr inline int max_digits10() { return 0; } + + private: + static inline tsl::tstring epsilon(); + static inline tsl::tstring dummy_precision(); + static inline tsl::tstring lowest(); + static inline tsl::tstring highest(); + static inline tsl::tstring infinity(); + static inline tsl::tstring quiet_NaN(); +}; + +} // namespace Eigen + +#endif // TENSORFLOW_TSL_FRAMEWORK_NUMERIC_TYPES_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/shared_counter.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/shared_counter.h new file mode 100644 index 0000000000000000000000000000000000000000..7fb584ca8a3cbef90cba76d0613a3c9cfcf1149b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/shared_counter.h @@ -0,0 +1,35 @@ +/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ +#ifndef TENSORFLOW_TSL_FRAMEWORK_SHARED_COUNTER_H_ +#define TENSORFLOW_TSL_FRAMEWORK_SHARED_COUNTER_H_ + +#include + +#include "tsl/platform/types.h" + +namespace tsl { +// A lightweight thread-safe monotone counter for establishing +// temporal ordering. +class SharedCounter { + public: + int64_t get() { return value_; } + int64_t next() { return ++value_; } + + private: + std::atomic value_{0}; +}; + +} // namespace tsl +#endif // TENSORFLOW_TSL_FRAMEWORK_SHARED_COUNTER_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/tracking_allocator.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/tracking_allocator.h new file mode 100644 index 0000000000000000000000000000000000000000..c31cb96e9aaac3f2bcd1ba58a32ad20062db8154 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/tracking_allocator.h @@ -0,0 +1,137 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_TRACKING_ALLOCATOR_H_ +#define TENSORFLOW_TSL_FRAMEWORK_TRACKING_ALLOCATOR_H_ + +#include + +#include "tsl/framework/allocator.h" +#include "tsl/lib/gtl/inlined_vector.h" +#include "tsl/platform/mutex.h" +#include "tsl/platform/thread_annotations.h" +#include "tsl/platform/types.h" + +namespace tsl { + +// TrackingAllocator is a wrapper for an Allocator. It keeps a running +// count of the number of bytes allocated through the wrapper. It is +// used by the Executor to "charge" allocations to particular Op +// executions. Each Op gets a separate TrackingAllocator wrapper +// around the underlying allocator. +// +// The implementation assumes the invariant that all calls to +// AllocateRaw by an Op (or work items spawned by the Op) will occur +// before the Op's Compute method returns. Thus the high watermark is +// established once Compute returns. +// +// DeallocateRaw can be called long after the Op has finished, +// e.g. when an output tensor is deallocated, and the wrapper cannot +// be deleted until the last of these calls has occurred. The +// TrackingAllocator keeps track of outstanding calls using a +// reference count, and deletes itself once the last call has been +// received and the high watermark has been retrieved. +struct AllocRecord { + AllocRecord(int64_t a_btyes, int64_t a_micros) + : alloc_bytes(a_btyes), alloc_micros(a_micros) {} + AllocRecord() : AllocRecord(0, 0) {} + + int64_t alloc_bytes; + int64_t alloc_micros; +}; + +class TrackingAllocator : public Allocator { + public: + explicit TrackingAllocator(Allocator* allocator, bool track_ids); + std::string Name() override { return allocator_->Name(); } + void* AllocateRaw(size_t alignment, size_t num_bytes) override { + return AllocateRaw(alignment, num_bytes, AllocationAttributes()); + } + void* AllocateRaw(size_t alignment, size_t num_bytes, + const AllocationAttributes& allocation_attr) override; + void DeallocateRaw(void* ptr) override; + bool TracksAllocationSizes() const override; + size_t RequestedSize(const void* ptr) const override; + size_t AllocatedSize(const void* ptr) const override; + int64_t AllocationId(const void* ptr) const override; + absl::optional GetStats() override; + bool ClearStats() override; + + AllocatorMemoryType GetMemoryType() const override { + return allocator_->GetMemoryType(); + } + + // If the underlying allocator tracks allocation sizes, this returns + // a tuple where the first value is the total number of bytes + // allocated through this wrapper, the second value is the high + // watermark of bytes allocated through this wrapper and the third value is + // the allocated bytes through this wrapper that are still alive. If the + // underlying allocator does not track allocation sizes the first + // value is the total number of bytes requested through this wrapper + // and the second and the third are 0. + // + std::tuple GetSizes(); + // After GetRecordsAndUnRef is called, the only further calls allowed + // on this wrapper are calls to DeallocateRaw with pointers that + // were allocated by this wrapper and have not yet been + // deallocated. After this call completes and all allocated pointers + // have been deallocated the wrapper will delete itself. + gtl::InlinedVector GetRecordsAndUnRef(); + // Returns a copy of allocation records collected so far. + gtl::InlinedVector GetCurrentRecords(); + + protected: + ~TrackingAllocator() override {} + + private: + bool UnRef() TF_EXCLUSIVE_LOCKS_REQUIRED(mu_); + + Allocator* allocator_; // not owned. + mutable mutex mu_; + // the number of calls to AllocateRaw that have not yet been matched + // by a corresponding call to DeAllocateRaw, plus 1 if the Executor + // has not yet read out the high watermark. + int ref_ TF_GUARDED_BY(mu_); + // the current number of outstanding bytes that have been allocated + // by this wrapper, or 0 if the underlying allocator does not track + // allocation sizes. + size_t allocated_ TF_GUARDED_BY(mu_); + // the maximum number of outstanding bytes that have been allocated + // by this wrapper, or 0 if the underlying allocator does not track + // allocation sizes. + size_t high_watermark_ TF_GUARDED_BY(mu_); + // the total number of bytes that have been allocated by this + // wrapper if the underlying allocator tracks allocation sizes, + // otherwise the total number of bytes that have been requested by + // this allocator. + size_t total_bytes_ TF_GUARDED_BY(mu_); + + gtl::InlinedVector allocations_ TF_GUARDED_BY(mu_); + + // Track allocations locally if requested in the constructor and the + // underlying allocator doesn't already do it for us. + const bool track_sizes_locally_; + struct Chunk { + size_t requested_size; + size_t allocated_size; + int64_t allocation_id; + }; + std::unordered_map in_use_ TF_GUARDED_BY(mu_); + int64_t next_allocation_id_ TF_GUARDED_BY(mu_); +}; + +} // end namespace tsl + +#endif // TENSORFLOW_TSL_FRAMEWORK_TRACKING_ALLOCATOR_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/type_traits.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/type_traits.h new file mode 100644 index 0000000000000000000000000000000000000000..e96334d0027f2bcd3de680347384d6fa640c4efd --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/framework/type_traits.h @@ -0,0 +1,109 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_FRAMEWORK_TYPE_TRAITS_H_ +#define TENSORFLOW_TSL_FRAMEWORK_TYPE_TRAITS_H_ + +#include +#include +#include + +#include "tsl/framework/numeric_types.h" +#include "tsl/platform/types.h" + +namespace tsl { + +// Functions to define quantization attribute of types. +struct true_type { + static constexpr bool value = true; +}; +struct false_type { + static constexpr bool value = false; +}; + +// Default is_quantized is false. +template +struct is_quantized : false_type {}; + +// Specialize the quantized types. +template <> +struct is_quantized : true_type {}; +template <> +struct is_quantized : true_type {}; +template <> +struct is_quantized : true_type {}; +template <> +struct is_quantized : true_type {}; +template <> +struct is_quantized : true_type {}; + +// Default is_complex is false. +template +struct is_complex : false_type {}; + +// Specialize std::complex and std::complex types. +template <> +struct is_complex> : true_type {}; +template <> +struct is_complex> : true_type {}; + +// is_simple_type::value if T[] can be safely constructed and destructed +// without running T() and ~T(). We do not use std::is_trivial +// directly because std::complex and std::complex are +// not trivial, but their arrays can be constructed and destructed +// without running their default ctors and dtors. +template +struct is_simple_type { + static constexpr bool value = + std::is_trivial::value || std::is_same::value || + std::is_same::value || std::is_same::value || + is_quantized::value || std::is_same::value || + std::is_same::value || + std::is_same::value || + std::is_same::value || std::is_same::value || + std::is_same::value; +}; + +} // namespace tsl + +// Define numeric limits for our quantized as subclasses of the +// standard types. +namespace std { +template <> +class numeric_limits : public numeric_limits {}; +template <> +class numeric_limits : public numeric_limits {}; +template <> +class numeric_limits : public numeric_limits {}; +template <> +class numeric_limits : public numeric_limits {}; +template <> +class numeric_limits : public numeric_limits {}; + +// Specialize is_signed for quantized types. +template <> +struct is_signed : public is_signed {}; +template <> +struct is_signed : public is_signed {}; +template <> +struct is_signed : public is_signed {}; +template <> +struct is_signed : public is_signed {}; +template <> +struct is_signed : public is_signed {}; + +} // namespace std + +#endif // TENSORFLOW_TSL_FRAMEWORK_TYPE_TRAITS_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/core/bitmap.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/core/bitmap.h new file mode 100644 index 0000000000000000000000000000000000000000..2682fd5239e7f191f1239b73fb5edb098d05875b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/core/bitmap.h @@ -0,0 +1,107 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_CORE_BITMAP_H_ +#define TENSORFLOW_TSL_LIB_CORE_BITMAP_H_ + +#include + +#include "tsl/platform/logging.h" + +namespace tsl { +namespace core { + +class Bitmap { + public: + // Create a bitmap that holds 0 bits. + Bitmap(); + + // Create a bitmap that holds n bits, all initially zero. + explicit Bitmap(size_t n); + + ~Bitmap(); + + Bitmap(const Bitmap&) = delete; + Bitmap& operator=(const Bitmap&) = delete; + + // Return the number of bits that the bitmap can hold. + size_t bits() const; + + // Replace contents of *this with a bitmap of n bits, all set to zero. + void Reset(size_t n); + + // Return the contents of the ith bit. + // REQUIRES: i < bits() + bool get(size_t i) const; + + // Set the contents of the ith bit to true. + // REQUIRES: i < bits() + void set(size_t i); + + // Set the contents of the ith bit to false. + // REQUIRES: i < bits() + void clear(size_t i); + + // Return the smallest i such that i >= start and !get(i). + // Returns bits() if no such i exists. + size_t FirstUnset(size_t start) const; + + // Returns the bitmap as an ascii string of '0' and '1' characters, bits() + // characters in length. + std::string ToString() const; + + private: + typedef uint32_t Word; + static constexpr size_t kBits = 32; + + // Return the number of words needed to store n bits. + static size_t NumWords(size_t n) { return (n + kBits - 1) / kBits; } + + // Return the mask to use for the ith bit in a word. + static Word Mask(size_t i) { return 1ull << i; } + + size_t nbits_; // Length of bitmap in bits. + Word* word_; +}; + +// Implementation details follow. Clients should ignore. + +inline Bitmap::Bitmap() : nbits_(0), word_(nullptr) {} + +inline Bitmap::Bitmap(size_t n) : Bitmap() { Reset(n); } + +inline Bitmap::~Bitmap() { delete[] word_; } + +inline size_t Bitmap::bits() const { return nbits_; } + +inline bool Bitmap::get(size_t i) const { + DCHECK_LT(i, nbits_); + return word_[i / kBits] & Mask(i % kBits); +} + +inline void Bitmap::set(size_t i) { + DCHECK_LT(i, nbits_); + word_[i / kBits] |= Mask(i % kBits); +} + +inline void Bitmap::clear(size_t i) { + DCHECK_LT(i, nbits_); + word_[i / kBits] &= ~Mask(i % kBits); +} + +} // namespace core +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_CORE_BITMAP_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/core/bits.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/core/bits.h new file mode 100644 index 0000000000000000000000000000000000000000..e4e2f700608c75926907b5bd6be4c2e921fc0604 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/core/bits.h @@ -0,0 +1,109 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_CORE_BITS_H_ +#define TENSORFLOW_TSL_LIB_CORE_BITS_H_ + +#include "tsl/platform/logging.h" +#include "tsl/platform/types.h" + +namespace tsl { + +// Return floor(log2(n)) for positive integer n. Returns -1 iff n == 0. +int Log2Floor(uint32 n); +int Log2Floor64(uint64 n); + +// Return ceiling(log2(n)) for positive integer n. Returns -1 iff n == 0. +int Log2Ceiling(uint32 n); +int Log2Ceiling64(uint64 n); + +// ------------------------------------------------------------------------ +// Implementation details follow +// ------------------------------------------------------------------------ + +#if defined(__GNUC__) + +// Return floor(log2(n)) for positive integer n. Returns -1 iff n == 0. +inline int Log2Floor(uint32 n) { return n == 0 ? -1 : 31 ^ __builtin_clz(n); } + +// Return floor(log2(n)) for positive integer n. Returns -1 iff n == 0. +inline int Log2Floor64(uint64 n) { + return n == 0 ? -1 : 63 ^ __builtin_clzll(n); +} + +#else + +// Return floor(log2(n)) for positive integer n. Returns -1 iff n == 0. +inline int Log2Floor(uint32 n) { + if (n == 0) return -1; + int log = 0; + uint32 value = n; + for (int i = 4; i >= 0; --i) { + int shift = (1 << i); + uint32 x = value >> shift; + if (x != 0) { + value = x; + log += shift; + } + } + assert(value == 1); + return log; +} + +// Return floor(log2(n)) for positive integer n. Returns -1 iff n == 0. +// Log2Floor64() is defined in terms of Log2Floor32() +inline int Log2Floor64(uint64 n) { + const uint32 topbits = static_cast(n >> 32); + if (topbits == 0) { + // Top bits are zero, so scan in bottom bits + return Log2Floor(static_cast(n)); + } else { + return 32 + Log2Floor(topbits); + } +} + +#endif + +inline int Log2Ceiling(uint32 n) { + int floor = Log2Floor(n); + if (n == (n & ~(n - 1))) // zero or a power of two + return floor; + else + return floor + 1; +} + +inline int Log2Ceiling64(uint64 n) { + int floor = Log2Floor64(n); + if (n == (n & ~(n - 1))) // zero or a power of two + return floor; + else + return floor + 1; +} + +inline uint32 NextPowerOfTwo(uint32 value) { + int exponent = Log2Ceiling(value); + DCHECK_LT(exponent, std::numeric_limits::digits); + return 1 << exponent; +} + +inline uint64 NextPowerOfTwo64(uint64 value) { + int exponent = Log2Ceiling(value); + DCHECK_LT(exponent, std::numeric_limits::digits); + return 1LL << exponent; +} + +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_CORE_BITS_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/core/status_test_util.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/core/status_test_util.h new file mode 100644 index 0000000000000000000000000000000000000000..394236495a447fbef6872e8140d7e75d2093bd5d --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/core/status_test_util.h @@ -0,0 +1,33 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_CORE_STATUS_TEST_UTIL_H_ +#define TENSORFLOW_TSL_LIB_CORE_STATUS_TEST_UTIL_H_ + +#include "tsl/platform/status.h" +#include "tsl/platform/test.h" + +// Macros for testing the results of functions that return tensorflow::Status. +#define TF_EXPECT_OK(statement) EXPECT_EQ(::tsl::OkStatus(), (statement)) +#define TF_ASSERT_OK(statement) ASSERT_EQ(::tsl::OkStatus(), (statement)) + +// There are no EXPECT_NOT_OK/ASSERT_NOT_OK macros since they would not +// provide much value (when they fail, they would just print the OK status +// which conveys no more information than EXPECT_FALSE(status.ok()); +// If you want to check for particular errors, a better alternative is with +// status matchers: +// EXPECT_THAT(s, tensorflow::testing::StatusIs(status.code(), "message")); + +#endif // TENSORFLOW_TSL_LIB_CORE_STATUS_TEST_UTIL_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/compactptrset.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/compactptrset.h new file mode 100644 index 0000000000000000000000000000000000000000..8fbb7a8560dd1bb1e08714ec464d6bc147ec97f2 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/compactptrset.h @@ -0,0 +1,209 @@ +/* Copyright 2017 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_GTL_COMPACTPTRSET_H_ +#define TENSORFLOW_TSL_LIB_GTL_COMPACTPTRSET_H_ + +#include + +#include "tsl/lib/gtl/flatset.h" + +namespace tsl { +namespace gtl { + +// CompactPointerSet is like a std::unordered_set but is optimized +// for small sets (<= 1 element). T must be a pointer type. +template +class CompactPointerSet { + private: + using BigRep = FlatSet; + + public: + using value_type = T; + + CompactPointerSet() : rep_(0) {} + + ~CompactPointerSet() { + static_assert( + std::is_pointer::value, + "CompactPointerSet can only be used with T's that are pointers"); + if (isbig()) delete big(); + } + + CompactPointerSet(const CompactPointerSet& other) : rep_(0) { *this = other; } + + CompactPointerSet& operator=(const CompactPointerSet& other) { + if (this == &other) return *this; + if (other.isbig()) { + // big => any + if (!isbig()) MakeBig(); + *big() = *other.big(); + } else if (isbig()) { + // !big => big + big()->clear(); + if (other.rep_ != 0) { + big()->insert(reinterpret_cast(other.rep_)); + } + } else { + // !big => !big + rep_ = other.rep_; + } + return *this; + } + + class iterator { + public: + typedef ssize_t difference_type; + typedef T value_type; + typedef const T* pointer; + typedef const T& reference; + typedef ::std::forward_iterator_tag iterator_category; + + explicit iterator(uintptr_t rep) + : bigrep_(false), single_(reinterpret_cast(rep)) {} + explicit iterator(typename BigRep::iterator iter) + : bigrep_(true), single_(nullptr), iter_(iter) {} + + iterator& operator++() { + if (bigrep_) { + ++iter_; + } else { + DCHECK(single_ != nullptr); + single_ = nullptr; + } + return *this; + } + // maybe post-increment? + + bool operator==(const iterator& other) const { + if (bigrep_) { + return iter_ == other.iter_; + } else { + return single_ == other.single_; + } + } + bool operator!=(const iterator& other) const { return !(*this == other); } + + const T& operator*() const { + if (bigrep_) { + return *iter_; + } else { + DCHECK(single_ != nullptr); + return single_; + } + } + + private: + friend class CompactPointerSet; + bool bigrep_; + T single_; + typename BigRep::iterator iter_; + }; + using const_iterator = iterator; + + bool empty() const { return isbig() ? big()->empty() : (rep_ == 0); } + size_t size() const { return isbig() ? big()->size() : (rep_ == 0 ? 0 : 1); } + + void clear() { + if (isbig()) { + delete big(); + } + rep_ = 0; + } + + std::pair insert(T elem) { + if (!isbig()) { + if (rep_ == 0) { + uintptr_t v = reinterpret_cast(elem); + if (v == 0 || ((v & 0x3) != 0)) { + // Cannot use small representation for nullptr. Fall through. + } else { + rep_ = v; + return {iterator(v), true}; + } + } + MakeBig(); + } + auto p = big()->insert(elem); + return {iterator(p.first), p.second}; + } + + template + void insert(InputIter begin, InputIter end) { + for (; begin != end; ++begin) { + insert(*begin); + } + } + + const_iterator begin() const { + return isbig() ? iterator(big()->begin()) : iterator(rep_); + } + const_iterator end() const { + return isbig() ? iterator(big()->end()) : iterator(0); + } + + iterator find(T elem) const { + if (rep_ == reinterpret_cast(elem)) { + return iterator(rep_); + } else if (!isbig()) { + return iterator(0); + } else { + return iterator(big()->find(elem)); + } + } + + size_t count(T elem) const { return find(elem) != end() ? 1 : 0; } + + size_t erase(T elem) { + if (!isbig()) { + if (rep_ == reinterpret_cast(elem)) { + rep_ = 0; + return 1; + } else { + return 0; + } + } else { + return big()->erase(elem); + } + } + + private: + // Size rep_ + // ------------------------------------------------------------------------- + // 0 0 + // 1 The pointer itself (bottom bits == 00) + // large Pointer to a BigRep (bottom bits == 01) + uintptr_t rep_; + + bool isbig() const { return (rep_ & 0x3) == 1; } + BigRep* big() const { + DCHECK(isbig()); + return reinterpret_cast(rep_ - 1); + } + + void MakeBig() { + DCHECK(!isbig()); + BigRep* big = new BigRep; + if (rep_ != 0) { + big->insert(reinterpret_cast(rep_)); + } + rep_ = reinterpret_cast(big) + 0x1; + } +}; + +} // namespace gtl +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_GTL_COMPACTPTRSET_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/flatmap.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/flatmap.h new file mode 100644 index 0000000000000000000000000000000000000000..f04fd0c87e8986935e45371cd4be2abe3998d9b0 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/flatmap.h @@ -0,0 +1,396 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_GTL_FLATMAP_H_ +#define TENSORFLOW_TSL_LIB_GTL_FLATMAP_H_ + +#include + +#include +#include +#include +#include + +#include "tsl/lib/gtl/flatrep.h" +#include "tsl/platform/hash.h" +#include "tsl/platform/logging.h" +#include "tsl/platform/types.h" + +namespace tsl { +namespace gtl { + +// FlatMap provides a map from K to V. +// +// The map is implemented using an open-addressed hash table. A +// single array holds entire map contents and collisions are resolved +// by probing at a sequence of locations in the array. +template , + class Eq = std::equal_to> +class FlatMap { + private: + // Forward declare some internal types needed in public section. + struct Bucket; + + // We cannot use std::pair<> since internal representation stores + // keys and values in separate arrays, so we make a custom struct + // that holds references to the internal key, value elements. + // + // We define the struct as private ValueType, and typedef it as public + // value_type, to work around a gcc bug when compiling the iterators. + struct ValueType { + typedef Key first_type; + typedef Val second_type; + + const Key& first; + Val& second; + ValueType(const Key& k, Val& v) : first(k), second(v) {} + }; + + public: + typedef Key key_type; + typedef Val mapped_type; + typedef Hash hasher; + typedef Eq key_equal; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef ValueType value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + + FlatMap() : FlatMap(1) {} + + explicit FlatMap(size_t N, const Hash& hf = Hash(), const Eq& eq = Eq()) + : rep_(N, hf, eq) {} + + FlatMap(const FlatMap& src) : rep_(src.rep_) {} + + // Move constructor leaves src in a valid but unspecified state (same as + // std::unordered_map). + FlatMap(FlatMap&& src) : rep_(std::move(src.rep_)) {} + + template + FlatMap(InputIter first, InputIter last, size_t N = 1, + const Hash& hf = Hash(), const Eq& eq = Eq()) + : FlatMap(N, hf, eq) { + insert(first, last); + } + + FlatMap(std::initializer_list> init, size_t N = 1, + const Hash& hf = Hash(), const Eq& eq = Eq()) + : FlatMap(init.begin(), init.end(), N, hf, eq) {} + + FlatMap& operator=(const FlatMap& src) { + rep_.CopyFrom(src.rep_); + return *this; + } + + // Move-assignment operator leaves src in a valid but unspecified state (same + // as std::unordered_map). + FlatMap& operator=(FlatMap&& src) { + rep_.MoveFrom(std::move(src.rep_)); + return *this; + } + + ~FlatMap() {} + + void swap(FlatMap& x) { rep_.swap(x.rep_); } + void clear_no_resize() { rep_.clear_no_resize(); } + void clear() { rep_.clear(); } + void reserve(size_t N) { rep_.Resize(std::max(N, size())); } + void rehash(size_t N) { rep_.Resize(std::max(N, size())); } + void resize(size_t N) { rep_.Resize(std::max(N, size())); } + size_t size() const { return rep_.size(); } + bool empty() const { return size() == 0; } + size_t bucket_count() const { return rep_.bucket_count(); } + hasher hash_function() const { return rep_.hash_function(); } + key_equal key_eq() const { return rep_.key_eq(); } + + class iterator { + public: + typedef typename FlatMap::difference_type difference_type; + typedef typename FlatMap::value_type value_type; + typedef typename FlatMap::pointer pointer; + typedef typename FlatMap::reference reference; + typedef ::std::forward_iterator_tag iterator_category; + + iterator() : b_(nullptr), end_(nullptr), i_(0) {} + + // Make iterator pointing at first element at or after b. + iterator(Bucket* b, Bucket* end) : b_(b), end_(end), i_(0) { SkipUnused(); } + + // Make iterator pointing exactly at ith element in b, which must exist. + iterator(Bucket* b, Bucket* end, uint32 i) : b_(b), end_(end), i_(i) { + FillValue(); + } + + reference operator*() { return *val(); } + pointer operator->() { return val(); } + bool operator==(const iterator& x) const { + return b_ == x.b_ && i_ == x.i_; + } + bool operator!=(const iterator& x) const { return !(*this == x); } + iterator& operator++() { + DCHECK(b_ != end_); + i_++; + SkipUnused(); + return *this; + } + iterator operator++(int /*indicates postfix*/) { + iterator tmp(*this); + ++*this; + return tmp; + } + + private: + friend class FlatMap; + Bucket* b_; + Bucket* end_; + char space_ alignas(value_type)[sizeof(value_type)]; + uint32 i_; + + pointer val() { return reinterpret_cast(space_); } + void FillValue() { new (space_) value_type(b_->key(i_), b_->val(i_)); } + void SkipUnused() { + while (b_ < end_) { + if (i_ >= Rep::kWidth) { + i_ = 0; + b_++; + } else if (b_->marker[i_] < 2) { + i_++; + } else { + FillValue(); + break; + } + } + } + }; + + class const_iterator { + private: + mutable iterator rep_; // Share state and logic with non-const iterator. + + public: + typedef typename FlatMap::difference_type difference_type; + typedef typename FlatMap::value_type value_type; + typedef typename FlatMap::const_pointer pointer; + typedef typename FlatMap::const_reference reference; + typedef ::std::forward_iterator_tag iterator_category; + + const_iterator() : rep_() {} + const_iterator(Bucket* start, Bucket* end) : rep_(start, end) {} + const_iterator(Bucket* b, Bucket* end, uint32 i) : rep_(b, end, i) {} + + reference operator*() const { return *rep_.val(); } + pointer operator->() const { return rep_.val(); } + bool operator==(const const_iterator& x) const { return rep_ == x.rep_; } + bool operator!=(const const_iterator& x) const { return rep_ != x.rep_; } + const_iterator& operator++() { + ++rep_; + return *this; + } + const_iterator operator++(int /*indicates postfix*/) { + const_iterator tmp(*this); + ++*this; + return tmp; + } + }; + + iterator begin() { return iterator(rep_.start(), rep_.limit()); } + iterator end() { return iterator(rep_.limit(), rep_.limit()); } + const_iterator begin() const { + return const_iterator(rep_.start(), rep_.limit()); + } + const_iterator end() const { + return const_iterator(rep_.limit(), rep_.limit()); + } + + size_t count(const Key& k) const { return rep_.Find(k).found ? 1 : 0; } + iterator find(const Key& k) { + auto r = rep_.Find(k); + return r.found ? iterator(r.b, rep_.limit(), r.index) : end(); + } + const_iterator find(const Key& k) const { + auto r = rep_.Find(k); + return r.found ? const_iterator(r.b, rep_.limit(), r.index) : end(); + } + + Val& at(const Key& k) { + auto r = rep_.Find(k); + DCHECK(r.found); + return r.b->val(r.index); + } + const Val& at(const Key& k) const { + auto r = rep_.Find(k); + DCHECK(r.found); + return r.b->val(r.index); + } + + template + std::pair insert(const P& p) { + return Insert(p.first, p.second); + } + std::pair insert(const std::pair& p) { + return Insert(p.first, p.second); + } + template + void insert(InputIter first, InputIter last) { + for (; first != last; ++first) { + insert(*first); + } + } + + Val& operator[](const Key& k) { return IndexOp(k); } + Val& operator[](Key&& k) { return IndexOp(std::forward(k)); } + + template + std::pair emplace(Args&&... args) { + return InsertPair(std::make_pair(std::forward(args)...)); + } + + size_t erase(const Key& k) { + auto r = rep_.Find(k); + if (!r.found) return 0; + rep_.Erase(r.b, r.index); + return 1; + } + iterator erase(iterator pos) { + rep_.Erase(pos.b_, pos.i_); + ++pos; + return pos; + } + iterator erase(iterator pos, iterator last) { + for (; pos != last; ++pos) { + rep_.Erase(pos.b_, pos.i_); + } + return pos; + } + + std::pair equal_range(const Key& k) { + auto pos = find(k); + if (pos == end()) { + return std::make_pair(pos, pos); + } else { + auto next = pos; + ++next; + return std::make_pair(pos, next); + } + } + std::pair equal_range(const Key& k) const { + auto pos = find(k); + if (pos == end()) { + return std::make_pair(pos, pos); + } else { + auto next = pos; + ++next; + return std::make_pair(pos, next); + } + } + + bool operator==(const FlatMap& x) const { + if (size() != x.size()) return false; + for (auto& p : x) { + auto i = find(p.first); + if (i == end()) return false; + if (i->second != p.second) return false; + } + return true; + } + bool operator!=(const FlatMap& x) const { return !(*this == x); } + + // If key exists in the table, prefetch the associated value. This + // is a hint, and may have no effect. + void prefetch_value(const Key& key) const { rep_.Prefetch(key); } + + private: + using Rep = internal::FlatRep; + + // Bucket stores kWidth triples. + // The data is organized as three parallel arrays to reduce padding. + struct Bucket { + uint8 marker[Rep::kWidth]; + + // Wrap keys and values in union to control construction and destruction. + union Storage { + struct { + Key key[Rep::kWidth]; + Val val[Rep::kWidth]; + }; + Storage() {} + ~Storage() {} + } storage; + + Key& key(uint32 i) { + DCHECK_GE(marker[i], 2); + return storage.key[i]; + } + Val& val(uint32 i) { + DCHECK_GE(marker[i], 2); + return storage.val[i]; + } + template + void InitVal(uint32 i, V&& v) { + new (&storage.val[i]) Val(std::forward(v)); + } + void Destroy(uint32 i) { + storage.key[i].Key::~Key(); + storage.val[i].Val::~Val(); + } + void MoveFrom(uint32 i, Bucket* src, uint32 src_index) { + new (&storage.key[i]) Key(std::move(src->storage.key[src_index])); + new (&storage.val[i]) Val(std::move(src->storage.val[src_index])); + } + void CopyFrom(uint32 i, Bucket* src, uint32 src_index) { + new (&storage.key[i]) Key(src->storage.key[src_index]); + new (&storage.val[i]) Val(src->storage.val[src_index]); + } + }; + + template + std::pair InsertPair(Pair&& p) { + return Insert(std::forward(p.first), + std::forward(p.second)); + } + + template + std::pair Insert(K&& k, V&& v) { + rep_.MaybeResize(); + auto r = rep_.FindOrInsert(std::forward(k)); + const bool inserted = !r.found; + if (inserted) { + r.b->InitVal(r.index, std::forward(v)); + } + return {iterator(r.b, rep_.limit(), r.index), inserted}; + } + + template + Val& IndexOp(K&& k) { + rep_.MaybeResize(); + auto r = rep_.FindOrInsert(std::forward(k)); + Val* vptr = &r.b->val(r.index); + if (!r.found) { + new (vptr) Val(); // Initialize value in new slot. + } + return *vptr; + } + + Rep rep_; +}; + +} // namespace gtl +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_GTL_FLATMAP_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/flatrep.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/flatrep.h new file mode 100644 index 0000000000000000000000000000000000000000..9e29a772c3eca69f13aa555ac0ebef451f842ca1 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/flatrep.h @@ -0,0 +1,352 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_GTL_FLATREP_H_ +#define TENSORFLOW_TSL_LIB_GTL_FLATREP_H_ + +#include + +#include + +#include "tsl/platform/prefetch.h" +#include "tsl/platform/types.h" + +namespace tsl { +namespace gtl { +namespace internal { + +// Internal representation for FlatMap and FlatSet. +// +// The representation is an open-addressed hash table. Conceptually, +// the representation is a flat array of entries. However we +// structure it as an array of buckets where each bucket holds +// kWidth entries along with metadata for the kWidth entries. The +// metadata marker is +// +// (a) kEmpty: the entry is empty +// (b) kDeleted: the entry has been deleted +// (c) other: the entry is occupied and has low-8 bits of its hash. +// These hash bits can be used to avoid potentially expensive +// key comparisons. +// +// FlatMap passes in a bucket that contains keys and values, FlatSet +// passes in a bucket that does not contain values. +template +class FlatRep { + public: + // kWidth is the number of entries stored in a bucket. + static constexpr uint32 kBase = 3; + static constexpr uint32 kWidth = (1 << kBase); + + FlatRep(size_t N, const Hash& hf, const Eq& eq) : hash_(hf), equal_(eq) { + Init(N); + } + FlatRep(const FlatRep& src) : hash_(src.hash_), equal_(src.equal_) { + Init(src.size()); + CopyEntries(src.array_, src.end_, CopyEntry()); + } + + FlatRep(FlatRep&& src) + // Copy rather than move src.hash_ and src.equal_. This is necessary to + // leave src in a valid state -- otherwise e.g. if hash_ is an + // std::function, moving it would null it out. + : hash_(src.hash_), equal_(src.equal_) { + // TODO(jlebar): Init(1) still allocates some memory, so this isn't as cheap + // as it could be. The fundamental problem is that we need to leave src in + // a valid state, and FlatRep *always* owns a nonzero amount of memory. + Init(1); + swap(src); + } + + ~FlatRep() { + clear_no_resize(); + delete[] array_; + } + + // Simple accessors. + size_t size() const { return not_empty_ - deleted_; } + size_t bucket_count() const { return mask_ + 1; } + Bucket* start() const { return array_; } + Bucket* limit() const { return end_; } + const Hash& hash_function() const { return hash_; } + const Eq& key_eq() const { return equal_; } + + // Overwrite contents of *this with contents of src. + void CopyFrom(const FlatRep& src) { + if (this != &src) { + clear_no_resize(); + delete[] array_; + Init(src.size()); + CopyEntries(src.array_, src.end_, CopyEntry()); + } + } + + void MoveFrom(FlatRep&& src) { + if (this != &src) { + swap(src); + } + } + + void clear_no_resize() { + for (Bucket* b = array_; b != end_; b++) { + for (uint32 i = 0; i < kWidth; i++) { + if (b->marker[i] >= 2) { + b->Destroy(i); + b->marker[i] = kEmpty; + } + } + } + not_empty_ = 0; + deleted_ = 0; + } + + void clear() { + clear_no_resize(); + grow_ = 0; // Consider shrinking in MaybeResize() + MaybeResize(); + } + + void swap(FlatRep& x) { + using std::swap; + swap(array_, x.array_); + swap(end_, x.end_); + swap(lglen_, x.lglen_); + swap(mask_, x.mask_); + swap(not_empty_, x.not_empty_); + swap(deleted_, x.deleted_); + swap(grow_, x.grow_); + swap(shrink_, x.shrink_); + } + + struct SearchResult { + bool found; + Bucket* b; + uint32 index; + }; + + // Hash value is partitioned as follows: + // 1. Bottom 8 bits are stored in bucket to help speed up comparisons. + // 2. Next 3 bits give index inside bucket. + // 3. Remaining bits give bucket number. + + // Find bucket/index for key k. + SearchResult Find(const Key& k) const { + size_t h = hash_(k); + const uint32 marker = Marker(h & 0xff); + size_t index = (h >> 8) & mask_; // Holds bucket num and index-in-bucket + uint32 num_probes = 1; // Needed for quadratic probing + while (true) { + uint32 bi = index & (kWidth - 1); + Bucket* b = &array_[index >> kBase]; + const uint32 x = b->marker[bi]; + if (x == marker && equal_(b->key(bi), k)) { + return {true, b, bi}; + } else if (x == kEmpty) { + return {false, nullptr, 0}; + } + index = NextIndex(index, num_probes); + num_probes++; + } + } + + // Find bucket/index for key k, creating a new one if necessary. + // + // KeyType is a template parameter so that k's type is deduced and it + // becomes a universal reference which allows the key initialization + // below to use an rvalue constructor if available. + template + SearchResult FindOrInsert(KeyType&& k) { + size_t h = hash_(k); + const uint32 marker = Marker(h & 0xff); + size_t index = (h >> 8) & mask_; // Holds bucket num and index-in-bucket + uint32 num_probes = 1; // Needed for quadratic probing + Bucket* del = nullptr; // First encountered deletion for kInsert + uint32 di = 0; + while (true) { + uint32 bi = index & (kWidth - 1); + Bucket* b = &array_[index >> kBase]; + const uint32 x = b->marker[bi]; + if (x == marker && equal_(b->key(bi), k)) { + return {true, b, bi}; + } else if (!del && x == kDeleted) { + // Remember deleted index to use for insertion. + del = b; + di = bi; + } else if (x == kEmpty) { + if (del) { + // Store in the first deleted slot we encountered + b = del; + bi = di; + deleted_--; // not_empty_ does not change + } else { + not_empty_++; + } + b->marker[bi] = marker; + new (&b->key(bi)) Key(std::forward(k)); + return {false, b, bi}; + } + index = NextIndex(index, num_probes); + num_probes++; + } + } + + void Erase(Bucket* b, uint32 i) { + b->Destroy(i); + b->marker[i] = kDeleted; + deleted_++; + grow_ = 0; // Consider shrinking on next insert + } + + void Prefetch(const Key& k) const { + size_t h = hash_(k); + size_t index = (h >> 8) & mask_; // Holds bucket num and index-in-bucket + uint32 bi = index & (kWidth - 1); + Bucket* b = &array_[index >> kBase]; + port::prefetch(&b->marker[bi]); + port::prefetch(&b->storage.key[bi]); + } + + inline void MaybeResize() { + if (not_empty_ < grow_) { + return; // Nothing to do + } + if (grow_ == 0) { + // Special value set by erase to cause shrink on next insert. + if (size() >= shrink_) { + // Not small enough to shrink. + grow_ = static_cast(bucket_count() * 0.8); + if (not_empty_ < grow_) return; + } + } + Resize(size() + 1); + } + + void Resize(size_t N) { + Bucket* old = array_; + Bucket* old_end = end_; + Init(N); + CopyEntries(old, old_end, MoveEntry()); + delete[] old; + } + + private: + enum { kEmpty = 0, kDeleted = 1 }; // Special markers for an entry. + + Hash hash_; // User-supplied hasher + Eq equal_; // User-supplied comparator + uint8 lglen_; // lg(#buckets) + Bucket* array_; // array of length (1 << lglen_) + Bucket* end_; // Points just past last bucket in array_ + size_t mask_; // (# of entries in table) - 1 + size_t not_empty_; // Count of entries with marker != kEmpty + size_t deleted_; // Count of entries with marker == kDeleted + size_t grow_; // Grow array when not_empty_ >= grow_ + size_t shrink_; // Shrink array when size() < shrink_ + + // Avoid kEmpty and kDeleted markers when computing hash values to + // store in Bucket::marker[]. + static uint32 Marker(uint32 hb) { return hb + (hb < 2 ? 2 : 0); } + + void Init(size_t N) { + // Make enough room for N elements. + size_t lg = 0; // Smallest table is just one bucket. + while (N >= 0.8 * ((1 << lg) * kWidth)) { + lg++; + } + const size_t n = (1 << lg); + Bucket* array = new Bucket[n]; + for (size_t i = 0; i < n; i++) { + Bucket* b = &array[i]; + memset(b->marker, kEmpty, kWidth); + } + const size_t capacity = (1 << lg) * kWidth; + lglen_ = lg; + mask_ = capacity - 1; + array_ = array; + end_ = array + n; + not_empty_ = 0; + deleted_ = 0; + grow_ = static_cast(capacity * 0.8); + if (lg == 0) { + // Already down to one bucket; no more shrinking. + shrink_ = 0; + } else { + shrink_ = static_cast(grow_ * 0.4); // Must be less than 0.5 + } + } + + // Used by FreshInsert when we should copy from source. + struct CopyEntry { + inline void operator()(Bucket* dst, uint32 dsti, Bucket* src, uint32 srci) { + dst->CopyFrom(dsti, src, srci); + } + }; + + // Used by FreshInsert when we should move from source. + struct MoveEntry { + inline void operator()(Bucket* dst, uint32 dsti, Bucket* src, uint32 srci) { + dst->MoveFrom(dsti, src, srci); + src->Destroy(srci); + src->marker[srci] = kDeleted; + } + }; + + template + void CopyEntries(Bucket* start, Bucket* end, Copier copier) { + for (Bucket* b = start; b != end; b++) { + for (uint32 i = 0; i < kWidth; i++) { + if (b->marker[i] >= 2) { + FreshInsert(b, i, copier); + } + } + } + } + + // Create an entry for the key numbered src_index in *src and return + // its bucket/index. Used for insertion into a fresh table. We + // assume that there are no deletions, and k does not already exist + // in the table. + template + void FreshInsert(Bucket* src, uint32 src_index, Copier copier) { + size_t h = hash_(src->key(src_index)); + const uint32 marker = Marker(h & 0xff); + size_t index = (h >> 8) & mask_; // Holds bucket num and index-in-bucket + uint32 num_probes = 1; // Needed for quadratic probing + while (true) { + uint32 bi = index & (kWidth - 1); + Bucket* b = &array_[index >> kBase]; + const uint32 x = b->marker[bi]; + if (x == 0) { + b->marker[bi] = marker; + not_empty_++; + copier(b, bi, src, src_index); + return; + } + index = NextIndex(index, num_probes); + num_probes++; + } + } + + inline size_t NextIndex(size_t i, uint32 num_probes) const { + // Quadratic probing. + return (i + num_probes) & mask_; + } +}; + +} // namespace internal +} // namespace gtl +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_GTL_FLATREP_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/flatset.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/flatset.h new file mode 100644 index 0000000000000000000000000000000000000000..ec8e9ad4be3ee2b58121e2a4eab2e943c660f3b4 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/flatset.h @@ -0,0 +1,296 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_GTL_FLATSET_H_ +#define TENSORFLOW_TSL_LIB_GTL_FLATSET_H_ + +#include + +#include +#include +#include +#include + +#include "tsl/lib/gtl/flatrep.h" +#include "tsl/platform/hash.h" +#include "tsl/platform/logging.h" +#include "tsl/platform/types.h" + +namespace tsl { +namespace gtl { + +// FlatSet provides a set of K. +// +// The map is implemented using an open-addressed hash table. A +// single array holds entire map contents and collisions are resolved +// by probing at a sequence of locations in the array. +template , class Eq = std::equal_to> +class FlatSet { + private: + // Forward declare some internal types needed in public section. + struct Bucket; + + public: + typedef Key key_type; + typedef Key value_type; + typedef Hash hasher; + typedef Eq key_equal; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + + FlatSet() : FlatSet(1) {} + + explicit FlatSet(size_t N, const Hash& hf = Hash(), const Eq& eq = Eq()) + : rep_(N, hf, eq) {} + + FlatSet(const FlatSet& src) : rep_(src.rep_) {} + + // Move constructor leaves src in a valid but unspecified state (same as + // std::unordered_set). + FlatSet(FlatSet&& src) : rep_(std::move(src.rep_)) {} + + template + FlatSet(InputIter first, InputIter last, size_t N = 1, + const Hash& hf = Hash(), const Eq& eq = Eq()) + : FlatSet(N, hf, eq) { + insert(first, last); + } + + FlatSet(std::initializer_list init, size_t N = 1, + const Hash& hf = Hash(), const Eq& eq = Eq()) + : FlatSet(init.begin(), init.end(), N, hf, eq) {} + + FlatSet& operator=(const FlatSet& src) { + rep_.CopyFrom(src.rep_); + return *this; + } + + // Move-assignment operator leaves src in a valid but unspecified state (same + // as std::unordered_set). + FlatSet& operator=(FlatSet&& src) { + rep_.MoveFrom(std::move(src.rep_)); + return *this; + } + + ~FlatSet() {} + + void swap(FlatSet& x) { rep_.swap(x.rep_); } + void clear_no_resize() { rep_.clear_no_resize(); } + void clear() { rep_.clear(); } + void reserve(size_t N) { rep_.Resize(std::max(N, size())); } + void rehash(size_t N) { rep_.Resize(std::max(N, size())); } + void resize(size_t N) { rep_.Resize(std::max(N, size())); } + size_t size() const { return rep_.size(); } + bool empty() const { return size() == 0; } + size_t bucket_count() const { return rep_.bucket_count(); } + hasher hash_function() const { return rep_.hash_function(); } + key_equal key_eq() const { return rep_.key_eq(); } + + class const_iterator { + public: + typedef typename FlatSet::difference_type difference_type; + typedef typename FlatSet::value_type value_type; + typedef typename FlatSet::const_pointer pointer; + typedef typename FlatSet::const_reference reference; + typedef ::std::forward_iterator_tag iterator_category; + + const_iterator() : b_(nullptr), end_(nullptr), i_(0) {} + + // Make iterator pointing at first element at or after b. + const_iterator(Bucket* b, Bucket* end) : b_(b), end_(end), i_(0) { + SkipUnused(); + } + + // Make iterator pointing exactly at ith element in b, which must exist. + const_iterator(Bucket* b, Bucket* end, uint32 i) + : b_(b), end_(end), i_(i) {} + + reference operator*() const { return key(); } + pointer operator->() const { return &key(); } + bool operator==(const const_iterator& x) const { + return b_ == x.b_ && i_ == x.i_; + } + bool operator!=(const const_iterator& x) const { return !(*this == x); } + const_iterator& operator++() { + DCHECK(b_ != end_); + i_++; + SkipUnused(); + return *this; + } + const_iterator operator++(int /*indicates postfix*/) { + const_iterator tmp(*this); + ++*this; + return tmp; + } + + private: + friend class FlatSet; + Bucket* b_; + Bucket* end_; + uint32 i_; + + reference key() const { return b_->key(i_); } + void SkipUnused() { + while (b_ < end_) { + if (i_ >= Rep::kWidth) { + i_ = 0; + b_++; + } else if (b_->marker[i_] < 2) { + i_++; + } else { + break; + } + } + } + }; + + typedef const_iterator iterator; + + iterator begin() { return iterator(rep_.start(), rep_.limit()); } + iterator end() { return iterator(rep_.limit(), rep_.limit()); } + const_iterator begin() const { + return const_iterator(rep_.start(), rep_.limit()); + } + const_iterator end() const { + return const_iterator(rep_.limit(), rep_.limit()); + } + + size_t count(const Key& k) const { return rep_.Find(k).found ? 1 : 0; } + iterator find(const Key& k) { + auto r = rep_.Find(k); + return r.found ? iterator(r.b, rep_.limit(), r.index) : end(); + } + const_iterator find(const Key& k) const { + auto r = rep_.Find(k); + return r.found ? const_iterator(r.b, rep_.limit(), r.index) : end(); + } + + std::pair insert(const Key& k) { return Insert(k); } + std::pair insert(Key&& k) { return Insert(std::move(k)); } + template + void insert(InputIter first, InputIter last) { + for (; first != last; ++first) { + insert(*first); + } + } + + template + std::pair emplace(Args&&... args) { + rep_.MaybeResize(); + auto r = rep_.FindOrInsert(std::forward(args)...); + const bool inserted = !r.found; + return {iterator(r.b, rep_.limit(), r.index), inserted}; + } + + size_t erase(const Key& k) { + auto r = rep_.Find(k); + if (!r.found) return 0; + rep_.Erase(r.b, r.index); + return 1; + } + iterator erase(iterator pos) { + rep_.Erase(pos.b_, pos.i_); + ++pos; + return pos; + } + iterator erase(iterator pos, iterator last) { + for (; pos != last; ++pos) { + rep_.Erase(pos.b_, pos.i_); + } + return pos; + } + + std::pair equal_range(const Key& k) { + auto pos = find(k); + if (pos == end()) { + return std::make_pair(pos, pos); + } else { + auto next = pos; + ++next; + return std::make_pair(pos, next); + } + } + std::pair equal_range(const Key& k) const { + auto pos = find(k); + if (pos == end()) { + return std::make_pair(pos, pos); + } else { + auto next = pos; + ++next; + return std::make_pair(pos, next); + } + } + + bool operator==(const FlatSet& x) const { + if (size() != x.size()) return false; + for (const auto& elem : x) { + auto i = find(elem); + if (i == end()) return false; + } + return true; + } + bool operator!=(const FlatSet& x) const { return !(*this == x); } + + // If key exists in the table, prefetch it. This is a hint, and may + // have no effect. + void prefetch_value(const Key& key) const { rep_.Prefetch(key); } + + private: + using Rep = internal::FlatRep; + + // Bucket stores kWidth triples. + // The data is organized as three parallel arrays to reduce padding. + struct Bucket { + uint8 marker[Rep::kWidth]; + + // Wrap keys in union to control construction and destruction. + union Storage { + Key key[Rep::kWidth]; + Storage() {} + ~Storage() {} + } storage; + + Key& key(uint32 i) { + DCHECK_GE(marker[i], 2); + return storage.key[i]; + } + void Destroy(uint32 i) { storage.key[i].Key::~Key(); } + void MoveFrom(uint32 i, Bucket* src, uint32 src_index) { + new (&storage.key[i]) Key(std::move(src->storage.key[src_index])); + } + void CopyFrom(uint32 i, Bucket* src, uint32 src_index) { + new (&storage.key[i]) Key(src->storage.key[src_index]); + } + }; + + template + std::pair Insert(K&& k) { + rep_.MaybeResize(); + auto r = rep_.FindOrInsert(std::forward(k)); + const bool inserted = !r.found; + return {iterator(r.b, rep_.limit(), r.index), inserted}; + } + + Rep rep_; +}; + +} // namespace gtl +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_GTL_FLATSET_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/inlined_vector.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/inlined_vector.h new file mode 100644 index 0000000000000000000000000000000000000000..324475229462e6d32063b1733d05cda3d4114801 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/inlined_vector.h @@ -0,0 +1,33 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_GTL_INLINED_VECTOR_H_ +#define TENSORFLOW_TSL_LIB_GTL_INLINED_VECTOR_H_ + +#include "absl/container/inlined_vector.h" // IWYU pragma: export +// TODO(kramerb): This is kept only because lots of targets transitively depend +// on it. Remove all targets' dependencies. +#include "tsl/platform/macros.h" +#include "tsl/platform/types.h" + +namespace tsl { +namespace gtl { + +using absl::InlinedVector; + +} // namespace gtl +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_GTL_INLINED_VECTOR_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/int_type.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/int_type.h new file mode 100644 index 0000000000000000000000000000000000000000..7a5d7935782884c8c4e863c56d33a88a25376299 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/int_type.h @@ -0,0 +1,364 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +// #status: LEGACY +// #category: Miscellaneous +// #summary: Integral types; prefer util/intops/strong_int.h +// #bugs: Infrastructure > C++ Library Team > util +// +// IntType is a simple template class mechanism for defining "logical" +// integer-like class types that support many of the same functionalities +// as native integer types, but which prevent assignment, construction, and +// other operations from other similar integer-like types. Essentially, the +// template class IntType (where ValueType assumes +// valid scalar types such as int, uint, int32, etc) has the additional +// property that it cannot be assigned to or constructed from other IntTypes +// or native integer types of equal or implicitly convertible type. +// +// The class is useful for preventing mingling of integer variables with +// different logical roles or units. Unfortunately, C++ provides relatively +// good type-safety for user-defined classes but not for integer types. It is +// essentially up to the user to use nice variable names and comments to prevent +// accidental mismatches, such as confusing a user-index with a group-index or a +// time-in-milliseconds with a time-in-seconds. The use of typedefs are limited +// in that regard as they do not enforce type-safety. +// +// USAGE ----------------------------------------------------------------------- +// +// DEFINE_INT_TYPE(IntTypeName, ValueType); +// +// where: +// IntTypeName: is the desired (unique) name for the "logical" integer type. +// ValueType: is one of the integral types as defined by base::is_integral +// (see base/type_traits.h). +// +// DISALLOWED OPERATIONS / TYPE-SAFETY ENFORCEMENT ----------------------------- +// +// Consider these definitions and variable declarations: +// DEFINE_INT_TYPE(GlobalDocID, int64); +// DEFINE_INT_TYPE(LocalDocID, int64); +// GlobalDocID global; +// LocalDocID local; +// +// The class IntType prevents: +// +// 1) Assignments of other IntTypes with different IntTypeNames. +// +// global = local; <-- Fails to compile! +// local = global; <-- Fails to compile! +// +// 2) Explicit/implicit conversion from an IntType to another IntType. +// +// LocalDocID l(global); <-- Fails to compile! +// LocalDocID l = global; <-- Fails to compile! +// +// void GetGlobalDoc(GlobalDocID global) { } +// GetGlobalDoc(global); <-- Compiles fine, types match! +// GetGlobalDoc(local); <-- Fails to compile! +// +// 3) Implicit conversion from an IntType to a native integer type. +// +// void GetGlobalDoc(int64 global) { ... +// GetGlobalDoc(global); <-- Fails to compile! +// GetGlobalDoc(local); <-- Fails to compile! +// +// void GetLocalDoc(int32 local) { ... +// GetLocalDoc(global); <-- Fails to compile! +// GetLocalDoc(local); <-- Fails to compile! +// +// +// SUPPORTED OPERATIONS -------------------------------------------------------- +// +// The following operators are supported: unary: ++ (both prefix and postfix), +// +, -, ! (logical not), ~ (one's complement); comparison: ==, !=, <, <=, >, +// >=; numerical: +, -, *, /; assignment: =, +=, -=, /=, *=; stream: <<. Each +// operator allows the same IntTypeName and the ValueType to be used on +// both left- and right-hand sides. +// +// It also supports an accessor value() returning the stored value as ValueType, +// and a templatized accessor value() method that serves as syntactic sugar +// for static_cast(var.value()). These accessors are useful when assigning +// the stored value into protocol buffer fields and using it as printf args. +// +// The class also defines a hash functor that allows the IntType to be used +// as key to hashable containers such as std::unordered_map and +// std::unordered_set. +// +// We suggest using the IntTypeIndexedContainer wrapper around FixedArray and +// STL vector (see int-type-indexed-container.h) if an IntType is intended to +// be used as an index into these containers. These wrappers are indexed in a +// type-safe manner using IntTypes to ensure type-safety. +// +// NB: this implementation does not attempt to abide by or enforce dimensional +// analysis on these scalar types. +// +// EXAMPLES -------------------------------------------------------------------- +// +// DEFINE_INT_TYPE(GlobalDocID, int64); +// GlobalDocID global = 3; +// cout << global; <-- Prints 3 to stdout. +// +// for (GlobalDocID i(0); i < global; ++i) { +// cout << i; +// } <-- Print(ln)s 0 1 2 to stdout +// +// DEFINE_INT_TYPE(LocalDocID, int64); +// LocalDocID local; +// cout << local; <-- Prints 0 to stdout it default +// initializes the value to 0. +// +// local = 5; +// local *= 2; +// LocalDocID l(local); +// cout << l + local; <-- Prints 20 to stdout. +// +// GenericSearchRequest request; +// request.set_doc_id(global.value()); <-- Uses value() to extract the value +// from the IntType class. +// +// REMARKS --------------------------------------------------------------------- +// +// The following bad usage is permissible although discouraged. Essentially, it +// involves using the value*() accessors to extract the native integer type out +// of the IntType class. Keep in mind that the primary reason for the IntType +// class is to prevent *accidental* mingling of similar logical integer types -- +// and not type casting from one type to another. +// +// DEFINE_INT_TYPE(GlobalDocID, int64); +// DEFINE_INT_TYPE(LocalDocID, int64); +// GlobalDocID global; +// LocalDocID local; +// +// global = local.value(); <-- Compiles fine. +// +// void GetGlobalDoc(GlobalDocID global) { ... +// GetGlobalDoc(local.value()); <-- Compiles fine. +// +// void GetGlobalDoc(int64 global) { ... +// GetGlobalDoc(local.value()); <-- Compiles fine. + +#ifndef TENSORFLOW_TSL_LIB_GTL_INT_TYPE_H_ +#define TENSORFLOW_TSL_LIB_GTL_INT_TYPE_H_ + +#include + +#include +#include +#include // NOLINT +#include + +#include "tsl/platform/macros.h" +#include "tsl/platform/types.h" + +namespace tsl { +namespace gtl { + +template +class IntType; + +// Defines the IntType using value_type and typedefs it to int_type_name. +// The struct int_type_name ## _tag_ trickery is needed to ensure that a new +// type is created per int_type_name. +#define TSL_LIB_GTL_DEFINE_INT_TYPE(int_type_name, value_type) \ + struct int_type_name##_tag_ {}; \ + typedef ::tsl::gtl::IntType int_type_name; + +// Holds an integer value (of type ValueType) and behaves as a ValueType by +// exposing assignment, unary, comparison, and arithmetic operators. +// +// The template parameter IntTypeName defines the name for the int type and must +// be unique within a binary (the convenient DEFINE_INT_TYPE macro at the end of +// the file generates a unique IntTypeName). The parameter ValueType defines +// the integer type value (see supported list above). +// +// This class is NOT thread-safe. +template +class IntType { + public: + typedef _ValueType ValueType; // for non-member operators + typedef IntType ThisType; // Syntactic sugar. + + // Note that this may change from time to time without notice. + struct Hasher { + size_t operator()(const IntType& arg) const { + return static_cast(arg.value()); + } + }; + + template + friend H AbslHashValue(H h, const IntType& i) { + return H::combine(std::move(h), i.value()); + } + + public: + // Default c'tor initializing value_ to 0. + constexpr IntType() : value_(0) {} + // C'tor explicitly initializing from a ValueType. + constexpr explicit IntType(ValueType value) : value_(value) {} + + // IntType uses the default copy constructor, destructor and assign operator. + // The defaults are sufficient and omitting them allows the compiler to add + // the move constructor/assignment. + + // -- ACCESSORS -------------------------------------------------------------- + // The class provides a value() accessor returning the stored ValueType value_ + // as well as a templatized accessor that is just a syntactic sugar for + // static_cast(var.value()); + constexpr ValueType value() const { return value_; } + + template + constexpr ValType value() const { + return static_cast(value_); + } + + // -- UNARY OPERATORS -------------------------------------------------------- + ThisType& operator++() { // prefix ++ + ++value_; + return *this; + } + const ThisType operator++(int v) { // postfix ++ + ThisType temp(*this); + ++value_; + return temp; + } + ThisType& operator--() { // prefix -- + --value_; + return *this; + } + const ThisType operator--(int v) { // postfix -- + ThisType temp(*this); + --value_; + return temp; + } + + constexpr bool operator!() const { return value_ == 0; } + constexpr const ThisType operator+() const { return ThisType(value_); } + constexpr const ThisType operator-() const { return ThisType(-value_); } + constexpr const ThisType operator~() const { return ThisType(~value_); } + +// -- ASSIGNMENT OPERATORS --------------------------------------------------- +// We support the following assignment operators: =, +=, -=, *=, /=, <<=, >>= +// and %= for both ThisType and ValueType. +#define INT_TYPE_ASSIGNMENT_OP(op) \ + ThisType& operator op(const ThisType& arg_value) { \ + value_ op arg_value.value(); \ + return *this; \ + } \ + ThisType& operator op(ValueType arg_value) { \ + value_ op arg_value; \ + return *this; \ + } + INT_TYPE_ASSIGNMENT_OP(+=); + INT_TYPE_ASSIGNMENT_OP(-=); + INT_TYPE_ASSIGNMENT_OP(*=); + INT_TYPE_ASSIGNMENT_OP(/=); + INT_TYPE_ASSIGNMENT_OP(<<=); // NOLINT + INT_TYPE_ASSIGNMENT_OP(>>=); // NOLINT + INT_TYPE_ASSIGNMENT_OP(%=); +#undef INT_TYPE_ASSIGNMENT_OP + + ThisType& operator=(ValueType arg_value) { + value_ = arg_value; + return *this; + } + + private: + // The integer value of type ValueType. + ValueType value_; + + static_assert(std::is_integral::value, "invalid integer type"); +} TF_PACKED; + +// -- NON-MEMBER STREAM OPERATORS ---------------------------------------------- +// We provide the << operator, primarily for logging purposes. Currently, there +// seems to be no need for an >> operator. +template +std::ostream& operator<<(std::ostream& os, // NOLINT + IntType arg) { + return os << arg.value(); +} + +// -- NON-MEMBER ARITHMETIC OPERATORS ------------------------------------------ +// We support only the +, -, *, and / operators with the same IntType and +// ValueType types. The reason is to allow simple manipulation on these IDs +// when used as indices in vectors and arrays. +// +// NB: Although it is possible to do IntType * IntType and IntType / IntType, +// it is probably non-sensical from a dimensionality analysis perspective. +#define INT_TYPE_ARITHMETIC_OP(op) \ + template \ + static inline constexpr IntType operator op( \ + IntType id_1, \ + IntType id_2) { \ + return IntType(id_1.value() op id_2.value()); \ + } \ + template \ + static inline constexpr IntType operator op( \ + IntType id, \ + typename IntType::ValueType arg_val) { \ + return IntType(id.value() op arg_val); \ + } \ + template \ + static inline constexpr IntType operator op( \ + typename IntType::ValueType arg_val, \ + IntType id) { \ + return IntType(arg_val op id.value()); \ + } +INT_TYPE_ARITHMETIC_OP(+); +INT_TYPE_ARITHMETIC_OP(-); +INT_TYPE_ARITHMETIC_OP(*); +INT_TYPE_ARITHMETIC_OP(/); +INT_TYPE_ARITHMETIC_OP(<<); // NOLINT +INT_TYPE_ARITHMETIC_OP(>>); // NOLINT +INT_TYPE_ARITHMETIC_OP(%); +#undef INT_TYPE_ARITHMETIC_OP + +// -- NON-MEMBER COMPARISON OPERATORS ------------------------------------------ +// Static inline comparison operators. We allow all comparison operators among +// the following types (OP \in [==, !=, <, <=, >, >=]: +// IntType OP IntType +// IntType OP ValueType +// ValueType OP IntType +#define INT_TYPE_COMPARISON_OP(op) \ + template \ + static inline constexpr bool operator op( \ + IntType id_1, \ + IntType id_2) { \ + return id_1.value() op id_2.value(); \ + } \ + template \ + static inline constexpr bool operator op( \ + IntType id, \ + typename IntType::ValueType val) { \ + return id.value() op val; \ + } \ + template \ + static inline constexpr bool operator op( \ + typename IntType::ValueType val, \ + IntType id) { \ + return val op id.value(); \ + } +INT_TYPE_COMPARISON_OP(==); // NOLINT +INT_TYPE_COMPARISON_OP(!=); // NOLINT +INT_TYPE_COMPARISON_OP(<); // NOLINT +INT_TYPE_COMPARISON_OP(<=); // NOLINT +INT_TYPE_COMPARISON_OP(>); // NOLINT +INT_TYPE_COMPARISON_OP(>=); // NOLINT +#undef INT_TYPE_COMPARISON_OP + +} // namespace gtl +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_GTL_INT_TYPE_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/iterator_range.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/iterator_range.h new file mode 100644 index 0000000000000000000000000000000000000000..6e420c940142cc5d4298ef27a2609bc422fb62b1 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/iterator_range.h @@ -0,0 +1,68 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +// This provides a very simple, boring adaptor for a begin and end iterator +// into a range type. This should be used to build range views that work well +// with range based for loops and range based constructors. +// +// Note that code here follows more standards-based coding conventions as it +// is mirroring proposed interfaces for standardization. +// +// Converted from chandlerc@'s code to Google style by joshl@. + +#ifndef TENSORFLOW_TSL_LIB_GTL_ITERATOR_RANGE_H_ +#define TENSORFLOW_TSL_LIB_GTL_ITERATOR_RANGE_H_ + +#include + +namespace tsl { +namespace gtl { + +// A range adaptor for a pair of iterators. +// +// This just wraps two iterators into a range-compatible interface. Nothing +// fancy at all. +template +class iterator_range { + public: + using value_type = decltype(*std::declval()); + using iterator = IteratorT; + using const_iterator = IteratorT; + + iterator_range() : begin_iterator_(), end_iterator_() {} + iterator_range(IteratorT begin_iterator, IteratorT end_iterator) + : begin_iterator_(std::move(begin_iterator)), + end_iterator_(std::move(end_iterator)) {} + + IteratorT begin() const { return begin_iterator_; } + IteratorT end() const { return end_iterator_; } + + private: + IteratorT begin_iterator_, end_iterator_; +}; + +// Convenience function for iterating over sub-ranges. +// +// This provides a bit of syntactic sugar to make using sub-ranges +// in for loops a bit easier. Analogous to std::make_pair(). +template +iterator_range make_range(T x, T y) { + return iterator_range(std::move(x), std::move(y)); +} + +} // namespace gtl +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_GTL_ITERATOR_RANGE_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/map_util.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/map_util.h new file mode 100644 index 0000000000000000000000000000000000000000..63a966228481bc1310408d21a25bdb8427e8f6ba --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/map_util.h @@ -0,0 +1,215 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +// This file provides utility functions for use with STL map-like data +// structures, such as std::map and hash_map. Some functions will also work with +// sets, such as ContainsKey(). + +#ifndef TENSORFLOW_TSL_LIB_GTL_MAP_UTIL_H_ +#define TENSORFLOW_TSL_LIB_GTL_MAP_UTIL_H_ + +#include + +#include +#include +#include +#include + +#include "tsl/lib/gtl/subtle/map_traits.h" + +namespace tsl { +namespace gtl { + +// Returns a pointer to the const value associated with the given key if it +// exists, or NULL otherwise. +template +const typename Collection::value_type::second_type* FindOrNull( + const Collection& collection, + const typename Collection::value_type::first_type& key) { + typename Collection::const_iterator it = collection.find(key); + if (it == collection.end()) { + return nullptr; + } + return &it->second; +} + +// Same as above but returns a pointer to the non-const value. +template +typename Collection::value_type::second_type* FindOrNull( + Collection& collection, // NOLINT + const typename Collection::value_type::first_type& key) { + typename Collection::iterator it = collection.find(key); + if (it == collection.end()) { + return nullptr; + } + return &it->second; +} + +// Returns the pointer value associated with the given key. If none is found, +// NULL is returned. The function is designed to be used with a map of keys to +// pointers. +// +// This function does not distinguish between a missing key and a key mapped +// to a NULL value. +template +typename Collection::value_type::second_type FindPtrOrNull( + const Collection& collection, + const typename Collection::value_type::first_type& key) { + typename Collection::const_iterator it = collection.find(key); + if (it == collection.end()) { + return typename Collection::value_type::second_type(); + } + return it->second; +} + +// Returns a const reference to the value associated with the given key if it +// exists, otherwise returns a const reference to the provided default value. +// +// WARNING: If a temporary object is passed as the default "value," +// this function will return a reference to that temporary object, +// which will be destroyed at the end of the statement. A common +// example: if you have a map with string values, and you pass a char* +// as the default "value," either use the returned value immediately +// or store it in a string (not string&). +template +const typename Collection::value_type::second_type& FindWithDefault( + const Collection& collection, + const typename Collection::value_type::first_type& key, + const typename Collection::value_type::second_type& value) { + typename Collection::const_iterator it = collection.find(key); + if (it == collection.end()) { + return value; + } + return it->second; +} + +// Inserts the given key-value pair into the collection. Returns true if and +// only if the key from the given pair didn't previously exist. Otherwise, the +// value in the map is replaced with the value from the given pair. +template +bool InsertOrUpdate(Collection* const collection, + const typename Collection::value_type& vt) { + std::pair ret = collection->insert(vt); + if (!ret.second) { + // update + ret.first->second = vt.second; + return false; + } + return true; +} + +// Same as above, except that the key and value are passed separately. +template +bool InsertOrUpdate(Collection* const collection, + const typename Collection::value_type::first_type& key, + const typename Collection::value_type::second_type& value) { + return InsertOrUpdate(collection, + typename Collection::value_type(key, value)); +} + +// Inserts the given key and value into the given collection if and only if the +// given key did NOT already exist in the collection. If the key previously +// existed in the collection, the value is not changed. Returns true if the +// key-value pair was inserted; returns false if the key was already present. +template +bool InsertIfNotPresent(Collection* const collection, + const typename Collection::value_type& vt) { + return collection->insert(vt).second; +} + +// Same as above except the key and value are passed separately. +template +bool InsertIfNotPresent( + Collection* const collection, + const typename Collection::value_type::first_type& key, + const typename Collection::value_type::second_type& value) { + return InsertIfNotPresent(collection, + typename Collection::value_type(key, value)); +} + +// Looks up a given key and value pair in a collection and inserts the key-value +// pair if it's not already present. Returns a reference to the value associated +// with the key. +template +typename Collection::value_type::second_type& LookupOrInsert( + Collection* const collection, const typename Collection::value_type& vt) { + return collection->insert(vt).first->second; +} + +// Same as above except the key-value are passed separately. +template +typename Collection::value_type::second_type& LookupOrInsert( + Collection* const collection, + const typename Collection::value_type::first_type& key, + const typename Collection::value_type::second_type& value) { + return LookupOrInsert(collection, + typename Collection::value_type(key, value)); +} + +// Saves the reverse mapping into reverse. Returns true if values could all be +// inserted. +template +bool ReverseMap(const M& m, ReverseM* reverse) { + bool all_unique = true; + for (const auto& kv : m) { + if (!InsertOrUpdate(reverse, kv.second, kv.first)) { + all_unique = false; + } + } + return all_unique; +} + +// Like ReverseMap above, but returns its output m. Return type has to +// be specified explicitly. Example: +// M::M(...) : m_(...), r_(ReverseMap(m_)) {} +template +ReverseM ReverseMap(const M& m) { + typename std::remove_const::type reverse; + ReverseMap(m, &reverse); + return reverse; +} + +// Erases the m item identified by the given key, and returns the value +// associated with that key. It is assumed that the value (i.e., the +// mapped_type) is a pointer. Returns null if the key was not found in the +// m. +// +// Examples: +// std::map my_map; +// +// One line cleanup: +// delete EraseKeyReturnValuePtr(&my_map, "abc"); +// +// Use returned value: +// std::unique_ptr value_ptr( +// EraseKeyReturnValuePtr(&my_map, "abc")); +// if (value_ptr.get()) +// value_ptr->DoSomething(); +// +template +typename Collection::value_type::second_type EraseKeyReturnValuePtr( + Collection* collection, + const typename Collection::value_type::first_type& key) { + auto it = collection->find(key); + if (it == collection->end()) return nullptr; + auto v = gtl::subtle::GetMapped(*it); + collection->erase(it); + return v; +} + +} // namespace gtl +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_GTL_MAP_UTIL_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/subtle/map_traits.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/subtle/map_traits.h new file mode 100644 index 0000000000000000000000000000000000000000..535db74402ba91cd6653b8be20b5df0c51fd3ccd --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/gtl/subtle/map_traits.h @@ -0,0 +1,65 @@ + +/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. +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. +==============================================================================*/ +// Traits classes for performing uniform lookup on different map value types. +// +// The access is computed as follows: +// +// 1. If T has a `first` or `second` field, use them. +// 2. Otherwise if it has `key()` or `value()` methods, use them. +// 3. Otherwise the program is ill-formed. +#ifndef TENSORFLOW_TSL_LIB_GTL_SUBTLE_MAP_TRAITS_H_ +#define TENSORFLOW_TSL_LIB_GTL_SUBTLE_MAP_TRAITS_H_ +#include +namespace tsl { +namespace gtl { +namespace subtle { +namespace internal_map_traits { +struct Rank1 {}; +struct Rank0 : Rank1 {}; +template +auto GetKey(V&& v, Rank0) -> decltype((std::forward(v).first)) { + return std::forward(v).first; +} +template +auto GetKey(V&& v, Rank1) -> decltype(std::forward(v).key()) { + return std::forward(v).key(); +} +template +auto GetMapped(V&& v, Rank0) -> decltype((std::forward(v).second)) { + return std::forward(v).second; +} +template +auto GetMapped(V&& v, Rank1) -> decltype(std::forward(v).value()) { + return std::forward(v).value(); +} +} // namespace internal_map_traits +// Accesses the `key_type` from a `value_type`. +template +auto GetKey(V&& v) + -> decltype(internal_map_traits::GetKey(std::forward(v), + internal_map_traits::Rank0())) { + return internal_map_traits::GetKey(std::forward(v), + internal_map_traits::Rank0()); +} +// Accesses the `mapped_type` from a `value_type`. +template +auto GetMapped(V&& v) + -> decltype(internal_map_traits::GetMapped(std::forward(v), + internal_map_traits::Rank0())) { + return internal_map_traits::GetMapped(std::forward(v), + internal_map_traits::Rank0()); +} +} // namespace subtle +} // namespace gtl +} // namespace tsl +#endif // TENSORFLOW_TSL_LIB_GTL_SUBTLE_MAP_TRAITS_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/hash/crc32c.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/hash/crc32c.h new file mode 100644 index 0000000000000000000000000000000000000000..89da8d98f3321ffb260fc87876cfa9ed4cac3665 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/hash/crc32c.h @@ -0,0 +1,65 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_HASH_CRC32C_H_ +#define TENSORFLOW_TSL_LIB_HASH_CRC32C_H_ + +#include + +#include "tsl/platform/cord.h" +#include "tsl/platform/platform.h" +#include "tsl/platform/types.h" + +namespace tsl { +namespace crc32c { + +// Return the crc32c of concat(A, buf[0,size-1]) where init_crc is the +// crc32c of some string A. Extend() is often used to maintain the +// crc32c of a stream of data. +extern uint32 Extend(uint32 init_crc, const char* buf, size_t size); + +#if defined(TF_CORD_SUPPORT) +extern uint32 Extend(uint32 init_crc, const absl::Cord& cord); +#endif + +// Return the crc32c of data[0,n-1] +inline uint32 Value(const char* data, size_t n) { return Extend(0, data, n); } + +#if defined(TF_CORD_SUPPORT) +inline uint32 Value(const absl::Cord& cord) { return Extend(0, cord); } +#endif + +static const uint32 kMaskDelta = 0xa282ead8ul; + +// Return a masked representation of crc. +// +// Motivation: it is problematic to compute the CRC of a string that +// contains embedded CRCs. Therefore we recommend that CRCs stored +// somewhere (e.g., in files) should be masked before being stored. +inline uint32 Mask(uint32 crc) { + // Rotate right by 15 bits and add a constant. + return ((crc >> 15) | (crc << 17)) + kMaskDelta; +} + +// Return the crc whose masked representation is masked_crc. +inline uint32 Unmask(uint32 masked_crc) { + uint32 rot = masked_crc - kMaskDelta; + return ((rot >> 17) | (rot << 15)); +} + +} // namespace crc32c +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_HASH_CRC32C_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/histogram/histogram.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/histogram/histogram.h new file mode 100644 index 0000000000000000000000000000000000000000..a024e2275b4d29dd0b61e2edbfa591af4a51992e --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/histogram/histogram.h @@ -0,0 +1,143 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_HISTOGRAM_HISTOGRAM_H_ +#define TENSORFLOW_TSL_LIB_HISTOGRAM_HISTOGRAM_H_ + +#include +#include + +#include "tsl/platform/macros.h" +#include "tsl/platform/mutex.h" +#include "tsl/platform/thread_annotations.h" +#include "tsl/platform/types.h" + +namespace tensorflow { +class HistogramProto; +} + +namespace tsl { +using tensorflow::HistogramProto; + +namespace histogram { + +class Histogram { + public: + // Create a histogram with a default set of bucket boundaries. + // Buckets near zero cover very small ranges (e.g. 10^-12), and each + // bucket range grows by ~10% as we head away from zero. The + // buckets cover the range from -DBL_MAX to DBL_MAX. + Histogram(); + + // Create a histogram with a custom set of bucket boundaries, + // specified in "custom_bucket_limits[0..custom_bucket_limits.size()-1]" + // REQUIRES: custom_bucket_limits[i] values are monotonically increasing. + // REQUIRES: custom_bucket_limits is not empty() + explicit Histogram(absl::Span custom_bucket_limits); + + // Restore the state of a histogram that was previously encoded + // via Histogram::EncodeToProto. Note that only the bucket boundaries + // generated by EncodeToProto will be restored. + bool DecodeFromProto(const HistogramProto& proto); + + ~Histogram() {} + + void Clear(); + void Add(double value); + + // Save the current state of the histogram to "*proto". If + // "preserve_zero_buckets" is false, only non-zero bucket values and + // ranges are saved, and the bucket boundaries of zero-valued buckets + // are lost. + void EncodeToProto(HistogramProto* proto, bool preserve_zero_buckets) const; + + // Return the median of the values in the histogram + double Median() const; + + // Return the "p"th percentile [0.0..100.0] of the values in the + // distribution + double Percentile(double p) const; + + // Return the average value of the distribution + double Average() const; + + // Return the standard deviation of values in the distribution + double StandardDeviation() const; + + // Returns a multi-line human-readable string representing the histogram + // contents. Example output: + // Count: 4 Average: 251.7475 StdDev: 432.02 + // Min: -3.0000 Median: 5.0000 Max: 1000.0000 + // ------------------------------------------------------ + // [ -5, 0 ) 1 25.000% 25.000% ##### + // [ 0, 5 ) 1 25.000% 50.000% ##### + // [ 5, 10 ) 1 25.000% 75.000% ##### + // [ 1000, 10000 ) 1 25.000% 100.000% ##### + std::string ToString() const; + + private: + double min_; + double max_; + double num_; + double sum_; + double sum_squares_; + + std::vector custom_bucket_limits_; + absl::Span bucket_limits_; + std::vector buckets_; + + double Remap(double x, double x0, double x1, double y0, double y1) const; + + Histogram(const Histogram&) = delete; + void operator=(const Histogram&) = delete; +}; + +// Wrapper around a Histogram object that is thread safe. +// +// All methods hold a lock while delegating to a Histogram object owned by the +// ThreadSafeHistogram instance. +// +// See Histogram for documentation of the methods. +class ThreadSafeHistogram { + public: + ThreadSafeHistogram() {} + explicit ThreadSafeHistogram(absl::Span custom_bucket_limits) + : histogram_(custom_bucket_limits) {} + bool DecodeFromProto(const HistogramProto& proto); + + ~ThreadSafeHistogram() {} + + void Clear(); + + // TODO(touts): It might be a good idea to provide a AddN() + // method to avoid grabbing/releasing the lock when adding many values. + void Add(double value); + + void EncodeToProto(HistogramProto* proto, bool preserve_zero_buckets) const; + double Median() const; + double Percentile(double p) const; + double Average() const; + double StandardDeviation() const; + std::string ToString() const; + + private: + mutable mutex mu_; + Histogram histogram_ TF_GUARDED_BY(mu_); +}; + +} // namespace histogram +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_HISTOGRAM_HISTOGRAM_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/block.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/block.h new file mode 100644 index 0000000000000000000000000000000000000000..b31808627157c24856bd1b1752332503c374b6e5 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/block.h @@ -0,0 +1,57 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_IO_BLOCK_H_ +#define TENSORFLOW_TSL_LIB_IO_BLOCK_H_ + +#include +#include + +#include "tsl/lib/io/iterator.h" + +namespace tsl { +namespace table { + +struct BlockContents; + +class Block { + public: + // Initialize the block with the specified contents. + explicit Block(const BlockContents& contents); + + ~Block(); + + size_t size() const { return size_; } + Iterator* NewIterator(); + + private: + uint32 NumRestarts() const; + + const char* data_; + size_t size_; + uint32 restart_offset_; // Offset in data_ of restart array + bool owned_; // Block owns data_[] + + // No copying allowed + Block(const Block&); + void operator=(const Block&); + + class Iter; +}; + +} // namespace table +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_BLOCK_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/block_builder.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/block_builder.h new file mode 100644 index 0000000000000000000000000000000000000000..4e81f72b25c29c88b6f96128e1163f5aa1f20403 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/block_builder.h @@ -0,0 +1,70 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_IO_BLOCK_BUILDER_H_ +#define TENSORFLOW_TSL_LIB_IO_BLOCK_BUILDER_H_ + +#include + +#include + +#include "tsl/platform/stringpiece.h" +#include "tsl/platform/types.h" + +namespace tsl { +namespace table { + +struct Options; + +class BlockBuilder { + public: + explicit BlockBuilder(const Options* options); + + // Reset the contents as if the BlockBuilder was just constructed. + void Reset(); + + // REQUIRES: Finish() has not been called since the last call to Reset(). + // REQUIRES: key is larger than any previously added key + void Add(const StringPiece& key, const StringPiece& value); + + // Finish building the block and return a slice that refers to the + // block contents. The returned slice will remain valid for the + // lifetime of this builder or until Reset() is called. + StringPiece Finish(); + + // Returns an estimate of the current (uncompressed) size of the block + // we are building. + size_t CurrentSizeEstimate() const; + + // Return true iff no entries have been added since the last Reset() + bool empty() const { return buffer_.empty(); } + + private: + const Options* options_; + string buffer_; // Destination buffer + std::vector restarts_; // Restart points + int counter_; // Number of entries emitted since restart + bool finished_; // Has Finish() been called? + string last_key_; + + // No copying allowed + BlockBuilder(const BlockBuilder&); + void operator=(const BlockBuilder&); +}; + +} // namespace table +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_BLOCK_BUILDER_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/buffered_file.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/buffered_file.h new file mode 100644 index 0000000000000000000000000000000000000000..5627a7228fb782935ab4c06a4cfa6105077a57ee --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/buffered_file.h @@ -0,0 +1,115 @@ +/* Copyright 2023 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_IO_BUFFERED_FILE_H_ +#define TENSORFLOW_TSL_LIB_IO_BUFFERED_FILE_H_ + +#include +#include +#include +#include + +#include "tsl/lib/hash/crc32c.h" +#include "tsl/platform/cord.h" +#include "tsl/platform/file_system.h" +#include "tsl/platform/status.h" + +namespace tsl { +class BufferedWritableFile : public WritableFile { + public: + explicit BufferedWritableFile(std::unique_ptr file, + int64_t buffer_size = kDefaultBufferSize) + : file_(std::move(file)) { + buffer_.resize(buffer_size); + } + ~BufferedWritableFile() override { Close().IgnoreError(); } + + Status Append(StringPiece str_data) override { + int64_t bytes_left = str_data.size(); + const char* data = str_data.data(); + + while (bytes_left > 0) { + int64_t append_bytes = std::min( + static_cast(buffer_.size() - buffer_pos_), bytes_left); + + // Create a copy of the current segment and compute the checksum. We + // compute the checksum on the copied section in case the underlying + // `data` buffer changes while we are writing. + std::copy_n(data, append_bytes, buffer_.begin() + buffer_pos_); + crc32_ = crc32c::Extend(crc32_, &buffer_[buffer_pos_], append_bytes); + buffer_pos_ += append_bytes; + if (buffer_pos_ == buffer_.size()) { + TF_RETURN_IF_ERROR(file_->Append(buffer_)); + buffer_pos_ = 0; + } + data = data + append_bytes; + bytes_left -= append_bytes; + } + + return OkStatus(); + } + + Status Append(const absl::Cord& data) override { + for (absl::string_view fragment : data.Chunks()) { + TF_RETURN_IF_ERROR(Append(fragment)); + } + return OkStatus(); + } + + Status Close() override { + TF_RETURN_IF_ERROR(Flush()); + return file_->Close(); + } + + Status Flush() override { + if (buffer_pos_ > 0) { + TF_RETURN_IF_ERROR(file_->Append(StringPiece(&buffer_[0], buffer_pos_))); + buffer_pos_ = 0; + } + return file_->Flush(); + } + + tsl::Status Tell(int64_t* position) override { + int64_t bytes_written; + tsl::Status status = file_->Tell(&bytes_written); + if (status.ok()) { + *position = bytes_written + buffer_pos_; + return OkStatus(); + } else { + return status; + } + } + + Status Sync() override { return file_->Sync(); } + + // For compatibilty with the TensorBundle writer, we expose CRC32 checksums. + uint32_t crc32() const { return crc32_; } + void reset_crc32() { crc32_ = 0; } + + private: + static constexpr int64_t kDefaultBufferSize = 1048576; + + std::string buffer_; + int64_t buffer_pos_ = 0; + + std::unique_ptr file_; + uint32_t crc32_ = 0; + + BufferedWritableFile(const BufferedWritableFile&) = delete; + void operator=(const BufferedWritableFile&) = delete; +}; + +} // namespace tsl +#endif // TENSORFLOW_TSL_LIB_IO_BUFFERED_FILE_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/buffered_inputstream.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/buffered_inputstream.h new file mode 100644 index 0000000000000000000000000000000000000000..5318434c63919ce613eb120c3e85b9e4ee604053 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/buffered_inputstream.h @@ -0,0 +1,127 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_IO_BUFFERED_INPUTSTREAM_H_ +#define TENSORFLOW_TSL_LIB_IO_BUFFERED_INPUTSTREAM_H_ + +#include + +#include "tsl/lib/io/inputstream_interface.h" +#include "tsl/platform/file_system.h" + +namespace tsl { +namespace io { + +// Provides a buffer on top of an InputStreamInterface. A single instance of +// BufferedInputStream is NOT safe for concurrent use by multiple threads. +class BufferedInputStream : public InputStreamInterface { + public: + // Does not take ownership of input_stream unless owns_input_stream is set + // to true. input_stream must outlive *this then. + // TODO(rohanj): Remove owns_input_stream once the constructor below is + // removed. + BufferedInputStream(InputStreamInterface* input_stream, size_t buffer_bytes, + bool owns_input_stream = false); + + // For backwards compatibility, expose an interface that is similar to what + // InputBuffer exposes. Does not take ownership of file. file must outlive + // *this. This will be removed once we migrate all uses of this class to the + // constructor above. + BufferedInputStream(RandomAccessFile* file, size_t buffer_bytes); + + ~BufferedInputStream() override; + + Status ReadNBytes(int64_t bytes_to_read, tstring* result) override; + + Status SkipNBytes(int64_t bytes_to_skip) override; + + int64_t Tell() const override; + + // Seek to this offset within the file. + // + // If we seek to somewhere within our pre-buffered data, we will re-use what + // data we can. Otherwise, Seek() throws out the current buffer and the next + // read will trigger an underlying read. + // + // Note: When seeking backwards in a stream, this implementation uses + // Reset() + SkipNBytes(), so its performance will be dependent + // largely on the performance of SkipNBytes(). + Status Seek(int64_t position); + + // Read one text line of data into "*result" until end-of-file or a + // \n is read. (The \n is not included in the result.) Overwrites + // any existing data in *result. + // + // If successful, returns OK. If we are already at the end of the + // file, we return an OUT_OF_RANGE error. Otherwise, we return + // some other non-OK status. + Status ReadLine(std::string* result); + Status ReadLine(tstring* result); + + // Returns one text line of data until end-of-file or a '\n' is read. The '\n' + // is included in the result. + // This method is a substitute for ReadLine() when called from Python which is + // the expectation in the python File::readline() API. + // Also, '\0's are treated like any other character within the line and given + // no special treatment. + std::string ReadLineAsString(); + + // Skip one text line of data. + // + // If successful, returns OK. If we are already at the end of the + // file, we return an OUT_OF_RANGE error. Otherwise, we return + // some other non-OK status. + Status SkipLine(); + + // Reads the entire contents of the file into *result. + // + // Note: the amount of memory used by this function call is unbounded, so only + // use in ops that expect that behavior. + template + Status ReadAll(T* result); + + Status Reset() override; + + private: + Status FillBuffer(); + template + Status ReadLineHelper(StringType* result, bool include_eol); + + InputStreamInterface* input_stream_; // not owned. + size_t size_; // buffer size. + tstring buf_; // the buffer itself. + // buf_[pos_, limit_) holds the valid "read ahead" data in the file. + size_t pos_ = 0; // current position in buf_. + size_t limit_ = 0; // just past the end of valid data in buf_. + bool owns_input_stream_ = false; + // When EoF is reached, file_status_ contains the status to skip unnecessary + // buffer allocations. + Status file_status_ = OkStatus(); + + BufferedInputStream(const BufferedInputStream&) = delete; + void operator=(const BufferedInputStream&) = delete; +}; + +// Explicit instantiations defined in buffered_inputstream.cc. +#ifndef SWIG +extern template Status BufferedInputStream::ReadAll( + std::string* result); +extern template Status BufferedInputStream::ReadAll(tstring* result); +#endif // SWIG + +} // namespace io +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_BUFFERED_INPUTSTREAM_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/cache.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/cache.h new file mode 100644 index 0000000000000000000000000000000000000000..60a212b4fd1b3ae241115f77e37b23e2bdfd531a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/cache.h @@ -0,0 +1,127 @@ +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_IO_CACHE_H_ +#define TENSORFLOW_TSL_LIB_IO_CACHE_H_ + +#include + +#include "tsl/platform/stringpiece.h" + +// A Cache is an interface that maps keys to values. It has internal +// synchronization and may be safely accessed concurrently from +// multiple threads. It may automatically evict entries to make room +// for new entries. Values have a specified charge against the cache +// capacity. For example, a cache where the values are variable +// length strings, may use the length of the string as the charge for +// the string. +// +// A builtin cache implementation with a least-recently-used eviction +// policy is provided. Clients may use their own implementations if +// they want something more sophisticated (like scan-resistance, a +// custom eviction policy, variable cache sizing, etc.) + +namespace tsl { + +using Slice = StringPiece; + +namespace table { + +class Cache; + +// Create a new cache with a fixed size capacity. This implementation +// of Cache uses a least-recently-used eviction policy. +Cache* NewLRUCache(size_t capacity); + +class Cache { + public: + Cache() = default; + + Cache(const Cache&) = delete; + Cache& operator=(const Cache&) = delete; + + // Destroys all existing entries by calling the "deleter" + // function that was passed to the constructor. + virtual ~Cache(); + + // Opaque handle to an entry stored in the cache. + struct Handle {}; + + // Insert a mapping from key->value into the cache and assign it + // the specified charge against the total cache capacity. + // + // Returns a handle that corresponds to the mapping. The caller + // must call this->Release(handle) when the returned mapping is no + // longer needed. + // + // When the inserted entry is no longer needed, the key and + // value will be passed to "deleter". + virtual Handle* Insert(const Slice& key, void* value, size_t charge, + void (*deleter)(const Slice& key, void* value)) = 0; + + // If the cache has no mapping for "key", returns nullptr. + // + // Else return a handle that corresponds to the mapping. The caller + // must call this->Release(handle) when the returned mapping is no + // longer needed. + virtual Handle* Lookup(const Slice& key) = 0; + + // Release a mapping returned by a previous Lookup(). + // REQUIRES: handle must not have been released yet. + // REQUIRES: handle must have been returned by a method on *this. + virtual void Release(Handle* handle) = 0; + + // Return the value encapsulated in a handle returned by a + // successful Lookup(). + // REQUIRES: handle must not have been released yet. + // REQUIRES: handle must have been returned by a method on *this. + virtual void* Value(Handle* handle) = 0; + + // If the cache contains entry for key, erase it. Note that the + // underlying entry will be kept around until all existing handles + // to it have been released. + virtual void Erase(const Slice& key) = 0; + + // Return a new numeric id. May be used by multiple clients who are + // sharing the same cache to partition the key space. Typically the + // client will allocate a new id at startup and prepend the id to + // its cache keys. + virtual uint64_t NewId() = 0; + + // Remove all cache entries that are not actively in use. Memory-constrained + // applications may wish to call this method to reduce memory usage. + // Default implementation of Prune() does nothing. Subclasses are strongly + // encouraged to override the default implementation. A future release of + // leveldb may change Prune() to a pure abstract method. + virtual void Prune() {} + + // Return an estimate of the combined charges of all elements stored in the + // cache. + virtual size_t TotalCharge() const = 0; + + private: + void LRU_Remove(Handle* e); + void LRU_Append(Handle* e); + void Unref(Handle* e); + + struct Rep; + Rep* rep_; +}; + +} // namespace table + +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_CACHE_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/compression.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/compression.h new file mode 100644 index 0000000000000000000000000000000000000000..bed94981eca9c410bc2ef45713ea1b78849e45e1 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/compression.h @@ -0,0 +1,32 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_IO_COMPRESSION_H_ +#define TENSORFLOW_TSL_LIB_IO_COMPRESSION_H_ + +namespace tsl { +namespace io { +namespace compression { + +extern const char kNone[]; +extern const char kGzip[]; +extern const char kSnappy[]; +extern const char kZlib[]; + +} // namespace compression +} // namespace io +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_COMPRESSION_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/format.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/format.h new file mode 100644 index 0000000000000000000000000000000000000000..cd8e863435f440735a1dbc60d8eabd86167cfe7e --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/format.h @@ -0,0 +1,113 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_IO_FORMAT_H_ +#define TENSORFLOW_TSL_LIB_IO_FORMAT_H_ + +#include + +#include + +#include "tsl/lib/io/table_builder.h" +#include "tsl/platform/status.h" +#include "tsl/platform/stringpiece.h" + +namespace tsl { +class RandomAccessFile; + +namespace table { + +class Block; + +// BlockHandle is a pointer to the extent of a file that stores a data +// block or a meta block. +class BlockHandle { + public: + BlockHandle(); + + // The offset of the block in the file. + uint64 offset() const { return offset_; } + void set_offset(uint64 offset) { offset_ = offset; } + + // The size of the stored block + uint64 size() const { return size_; } + void set_size(uint64 size) { size_ = size; } + + void EncodeTo(string* dst) const; + Status DecodeFrom(StringPiece* input); + + // Maximum encoding length of a BlockHandle + enum { kMaxEncodedLength = 10 + 10 }; + + private: + uint64 offset_; + uint64 size_; +}; + +// Footer encapsulates the fixed information stored at the tail +// end of every table file. +class Footer { + public: + Footer() {} + + // The block handle for the metaindex block of the table + const BlockHandle& metaindex_handle() const { return metaindex_handle_; } + void set_metaindex_handle(const BlockHandle& h) { metaindex_handle_ = h; } + + // The block handle for the index block of the table + const BlockHandle& index_handle() const { return index_handle_; } + void set_index_handle(const BlockHandle& h) { index_handle_ = h; } + + void EncodeTo(string* dst) const; + Status DecodeFrom(StringPiece* input); + + // Encoded length of a Footer. Note that the serialization of a + // Footer will always occupy exactly this many bytes. It consists + // of two block handles and a magic number. + enum { kEncodedLength = 2 * BlockHandle::kMaxEncodedLength + 8 }; + + private: + BlockHandle metaindex_handle_; + BlockHandle index_handle_; +}; + +// kTableMagicNumber was picked by running +// echo http://code.google.com/p/leveldb/ | sha1sum +// and taking the leading 64 bits. +static const uint64 kTableMagicNumber = 0xdb4775248b80fb57ull; + +// 1-byte type + 32-bit crc +static const size_t kBlockTrailerSize = 5; + +struct BlockContents { + StringPiece data; // Actual contents of data + bool cacheable; // True iff data can be cached + bool heap_allocated; // True iff caller should delete[] data.data() +}; + +// Read the block identified by "handle" from "file". On failure +// return non-OK. On success fill *result and return OK. +extern Status ReadBlock(RandomAccessFile* file, const BlockHandle& handle, + BlockContents* result); + +// Implementation details follow. Clients should ignore, + +inline BlockHandle::BlockHandle() + : offset_(~static_cast(0)), size_(~static_cast(0)) {} + +} // namespace table +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_FORMAT_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/inputbuffer.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/inputbuffer.h new file mode 100644 index 0000000000000000000000000000000000000000..e357efb5f75b532f5e96cf3b6b740303567c0a70 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/inputbuffer.h @@ -0,0 +1,151 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_IO_INPUTBUFFER_H_ +#define TENSORFLOW_TSL_LIB_IO_INPUTBUFFER_H_ + +#include + +#include "tsl/platform/coding.h" +#include "tsl/platform/env.h" +#include "tsl/platform/macros.h" +#include "tsl/platform/status.h" +#include "tsl/platform/types.h" + +namespace tsl { +namespace io { + +// An InputBuffer provides a buffer on top of a RandomAccessFile. +// A given instance of an InputBuffer is NOT safe for concurrent use +// by multiple threads +class InputBuffer { + public: + // Create an InputBuffer for "file" with a buffer size of + // "buffer_bytes" bytes. 'file' must outlive *this. + InputBuffer(RandomAccessFile* file, size_t buffer_bytes); + ~InputBuffer(); + + // Read one text line of data into "*result" until end-of-file or a + // \n is read. (The \n is not included in the result.) Overwrites + // any existing data in *result. + // + // If successful, returns OK. If we are already at the end of the + // file, we return an OUT_OF_RANGE error. Otherwise, we return + // some other non-OK status. + template + Status ReadLine(T* result); + + // Reads bytes_to_read bytes into *result, overwriting *result. + // + // If successful, returns OK. If we there are not enough bytes to + // read before the end of the file, we return an OUT_OF_RANGE error. + // Otherwise, we return some other non-OK status. + Status ReadNBytes(int64_t bytes_to_read, std::string* result); + + // An overload that writes to char*. Caller must ensure result[0, + // bytes_to_read) is valid to be overwritten. Returns OK iff "*bytes_read == + // bytes_to_read". + Status ReadNBytes(int64_t bytes_to_read, char* result, size_t* bytes_read); + + // Reads a single varint32. + Status ReadVarint32(uint32* result); + + // Reads a single varint64. + Status ReadVarint64(uint64* result); + + // Like ReadNBytes() without returning the bytes read. + Status SkipNBytes(int64_t bytes_to_skip); + + // Seek to this offset within the file. + // + // If we seek to somewhere within our pre-buffered data, we will re-use what + // data we can. Otherwise, Seek() throws out the current buffer and the next + // read will trigger a File::Read(). + Status Seek(int64_t position); + + // Provides a hint about future reads, which may improve their performance. + Status Hint(int64_t bytes_to_read); + + // Returns the position in the file. + int64_t Tell() const { return file_pos_ - (limit_ - pos_); } + + // Returns the underlying RandomAccessFile. + RandomAccessFile* file() const { return file_; } + + private: + Status FillBuffer(); + + // Internal slow-path routine used by ReadVarint32(). + Status ReadVarint32Fallback(uint32* result); + + // Internal slow-path routine used by ReadVarint64(). + Status ReadVarint64Fallback(uint64* result); + + // Helper method for reading a varint which can span at max `max_bytes`. + // If the varint is longer, a DataLoss error status is returned. + // If end of file is reached while reading, OutOfRange error is returned. + template + Status ReadVarintFallback(T* result, int max_bytes); + + RandomAccessFile* file_; // Not owned + int64_t file_pos_; // Next position to read from in "file_" + size_t size_; // Size of "buf_" + char* buf_; // The buffer itself + // [pos_,limit_) hold the "limit_ - pos_" bytes just before "file_pos_" + char* pos_; // Current position in "buf" + char* limit_; // Just past end of valid data in "buf" + + InputBuffer(const InputBuffer&) = delete; + void operator=(const InputBuffer&) = delete; +}; + +// Implementation details. + +// Explicit instantiations defined in inputbuffer.cc. +extern template Status InputBuffer::ReadLine(std::string* result); +extern template Status InputBuffer::ReadLine(tstring* result); + +// Inlined for performance. +inline Status InputBuffer::ReadVarint32(uint32* result) { + if (pos_ + core::kMaxVarint32Bytes <= limit_) { + // Fast path: directly parse from buffered data. + // Reads strictly from the range [pos_, limit_). + const char* offset = core::GetVarint32Ptr(pos_, limit_, result); + if (offset == nullptr) return errors::OutOfRange("Parsed past limit."); + pos_ = const_cast(offset); + return OkStatus(); + } else { + return ReadVarint32Fallback(result); + } +} + +// Inlined for performance. +inline Status InputBuffer::ReadVarint64(uint64* result) { + if (pos_ + core::kMaxVarint64Bytes <= limit_) { + // Fast path: directly parse from buffered data. + // Reads strictly from the range [pos_, limit_). + const char* offset = core::GetVarint64Ptr(pos_, limit_, result); + if (offset == nullptr) return errors::OutOfRange("Parsed past limit."); + pos_ = const_cast(offset); + return OkStatus(); + } else { + return ReadVarint64Fallback(result); + } +} + +} // namespace io +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_INPUTBUFFER_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/inputstream_interface.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/inputstream_interface.h new file mode 100644 index 0000000000000000000000000000000000000000..afe87a4b9cc37eb620e68b0e55aa2b5193a6d013 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/inputstream_interface.h @@ -0,0 +1,70 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_IO_INPUTSTREAM_INTERFACE_H_ +#define TENSORFLOW_TSL_LIB_IO_INPUTSTREAM_INTERFACE_H_ + +#include + +#include "tsl/platform/cord.h" +#include "tsl/platform/errors.h" +#include "tsl/platform/status.h" +#include "tsl/platform/types.h" + +namespace tsl { +namespace io { + +// An interface that defines input streaming operations. +class InputStreamInterface { + public: + InputStreamInterface() {} + virtual ~InputStreamInterface() {} + + // Reads the next bytes_to_read from the file. Typical return codes: + // * OK - in case of success. + // * OUT_OF_RANGE - not enough bytes remaining before end of file. + virtual Status ReadNBytes(int64_t bytes_to_read, tstring* result) = 0; + +#if defined(TF_CORD_SUPPORT) + // Reads the next bytes_to_read from the file. Typical return codes: + // * OK - in case of success. + // * OUT_OF_RANGE - not enough bytes remaining before end of file. + virtual Status ReadNBytes(int64_t bytes_to_read, absl::Cord* cord) { + return errors::Unimplemented( + "ReadNBytes(int64, absl::Cord*) is not implemented."); + } +#endif + + // Skips bytes_to_skip before next ReadNBytes. bytes_to_skip should be >= 0. + // Typical return codes: + // * OK - in case of success. + // * OUT_OF_RANGE - not enough bytes remaining before end of file. + virtual Status SkipNBytes(int64_t bytes_to_skip); + + // Return the offset of the current byte relative to the beginning of the + // file. + // If we Skip / Read beyond the end of the file, this should return the length + // of the file. + // If there are any errors, this must return -1. + virtual int64_t Tell() const = 0; + + // Resets the stream to the beginning. + virtual Status Reset() = 0; +}; + +} // namespace io +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_INPUTSTREAM_INTERFACE_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/iterator.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/iterator.h new file mode 100644 index 0000000000000000000000000000000000000000..bb83f41ea47dd9c617e88ad9e56cdf19701a7789 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/iterator.h @@ -0,0 +1,104 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +// An iterator yields a sequence of key/value pairs from a source. +// The following class defines the interface. Multiple implementations +// are provided by this library. In particular, iterators are provided +// to access the contents of a Table or a DB. +// +// Multiple threads can invoke const methods on an Iterator without +// external synchronization, but if any of the threads may call a +// non-const method, all threads accessing the same Iterator must use +// external synchronization. + +#ifndef TENSORFLOW_TSL_LIB_IO_ITERATOR_H_ +#define TENSORFLOW_TSL_LIB_IO_ITERATOR_H_ + +#include "tsl/platform/status.h" +#include "tsl/platform/stringpiece.h" + +namespace tsl { +namespace table { + +class Iterator { + public: + Iterator(); + virtual ~Iterator(); + + // An iterator is either positioned at a key/value pair, or + // not valid. This method returns true iff the iterator is valid. + virtual bool Valid() const = 0; + + // Position at the first key in the source. The iterator is Valid() + // after this call iff the source is not empty. + virtual void SeekToFirst() = 0; + + // Position at the first key in the source that is at or past target. + // The iterator is Valid() after this call iff the source contains + // an entry that comes at or past target. + virtual void Seek(const StringPiece& target) = 0; + + // Moves to the next entry in the source. After this call, Valid() is + // true iff the iterator was not positioned at the last entry in the source. + // REQUIRES: Valid() + virtual void Next() = 0; + + // Return the key for the current entry. The underlying storage for + // the returned slice is valid only until the next modification of + // the iterator. + // REQUIRES: Valid() + virtual StringPiece key() const = 0; + + // Return the value for the current entry. The underlying storage for + // the returned slice is valid only until the next modification of + // the iterator. + // REQUIRES: Valid() + virtual StringPiece value() const = 0; + + // If an error has occurred, return it. Else return an ok status. + virtual Status status() const = 0; + + // Clients are allowed to register function/arg1/arg2 triples that + // will be invoked when this iterator is destroyed. + // + // Note that unlike all of the preceding methods, this method is + // not abstract and therefore clients should not override it. + typedef void (*CleanupFunction)(void* arg1, void* arg2); + void RegisterCleanup(CleanupFunction function, void* arg1, void* arg2); + + private: + struct Cleanup { + CleanupFunction function; + void* arg1; + void* arg2; + Cleanup* next; + }; + Cleanup cleanup_; + + // No copying allowed + Iterator(const Iterator&); + void operator=(const Iterator&); +}; + +// Return an empty iterator (yields nothing). +extern Iterator* NewEmptyIterator(); + +// Return an empty iterator with the specified status. +extern Iterator* NewErrorIterator(const Status& status); + +} // namespace table +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_ITERATOR_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/proto_encode_helper.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/proto_encode_helper.h new file mode 100644 index 0000000000000000000000000000000000000000..bcff19339b6b9a5780ce6b5129dbc57c522b6e90 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/proto_encode_helper.h @@ -0,0 +1,99 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_IO_PROTO_ENCODE_HELPER_H_ +#define TENSORFLOW_TSL_LIB_IO_PROTO_ENCODE_HELPER_H_ + +#include "tsl/platform/coding.h" +#include "tsl/platform/logging.h" +#include "tsl/platform/protobuf.h" +#include "tsl/platform/stringpiece.h" + +// A helper class for appending various kinds of values in protocol +// buffer encoding format to a buffer. The client gives a pointer to +// a buffer and a maximum size guarantee for the number of bytes they +// will add to this buffer. +namespace tsl { +namespace io { + +class ProtoEncodeHelper { + public: + ProtoEncodeHelper(char* buf, int max_size) + : base_(buf), p_(buf), limit_(base_ + max_size) {} + + ~ProtoEncodeHelper() { + // Make sure callers didn't do operations that went over max_size promised + DCHECK_LE(p_, limit_); + } + + const char* data() const { return base_; } + size_t size() const { return p_ - base_; } + + void WriteUint64(int tag, uint64 v) { + Encode32(combine(tag, WIRETYPE_VARINT)); + Encode64(v); + } + void WriteBool(int tag, bool v) { + Encode32(combine(tag, WIRETYPE_VARINT)); + EncodeBool(v); + } + void WriteString(int tag, StringPiece v) { + Encode32(combine(tag, WIRETYPE_LENGTH_DELIMITED)); + Encode32(v.size()); + EncodeBytes(v.data(), v.size()); + } + void WriteVarlengthBeginning(int tag, uint32 len) { + Encode32(combine(tag, WIRETYPE_LENGTH_DELIMITED)); + Encode32(len); + } + void WriteRawBytes(StringPiece v) { EncodeBytes(v.data(), v.size()); } + + private: + // Note: this module's behavior must match the protocol buffer wire encoding + // format. + enum { + WIRETYPE_VARINT = 0, + WIRETYPE_LENGTH_DELIMITED = 2, + }; + static uint32 combine(uint32 tag, uint32 type) { return ((tag << 3) | type); } + inline void Encode32(uint32 v) { + if (v < 128) { + // Fast path for single-byte values. Many of the calls will use a + // constant value for v, so the comparison will get optimized away + // when Encode32 is inlined into the caller. + *p_ = v; + p_++; + } else { + p_ = core::EncodeVarint32(p_, v); + } + } + void Encode64(uint64 v) { p_ = core::EncodeVarint64(p_, v); } + void EncodeBool(bool v) { + *p_ = (v ? 1 : 0); // Equal to varint32 encoding of 0 or 1 + p_++; + } + void EncodeBytes(const char* bytes, int N) { + memcpy(p_, bytes, N); + p_ += N; + } + + char* base_; + char* p_; + char* limit_; // Just for CHECKs +}; +} // namespace io +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_PROTO_ENCODE_HELPER_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/random_inputstream.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/random_inputstream.h new file mode 100644 index 0000000000000000000000000000000000000000..9313ca591757ea7af6b0e7761510aa6c75b5e754 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/random_inputstream.h @@ -0,0 +1,62 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_IO_RANDOM_INPUTSTREAM_H_ +#define TENSORFLOW_TSL_LIB_IO_RANDOM_INPUTSTREAM_H_ + +#include "tsl/lib/io/inputstream_interface.h" +#include "tsl/platform/cord.h" +#include "tsl/platform/file_system.h" + +namespace tsl { +namespace io { + +// Wraps a RandomAccessFile in an InputStreamInterface. A given instance of +// RandomAccessInputStream is NOT safe for concurrent use by multiple threads. +class RandomAccessInputStream : public InputStreamInterface { + public: + // Does not take ownership of 'file' unless owns_file is set to true. 'file' + // must outlive *this. + RandomAccessInputStream(RandomAccessFile* file, bool owns_file = false); + + ~RandomAccessInputStream(); + + Status ReadNBytes(int64_t bytes_to_read, tstring* result) override; + +#if defined(TF_CORD_SUPPORT) + Status ReadNBytes(int64_t bytes_to_read, absl::Cord* result) override; +#endif + + Status SkipNBytes(int64_t bytes_to_skip) override; + + int64_t Tell() const override; + + Status Seek(int64_t position) { + pos_ = position; + return OkStatus(); + } + + Status Reset() override { return Seek(0); } + + private: + RandomAccessFile* file_; // Not owned. + int64_t pos_ = 0; // Tracks where we are in the file. + bool owns_file_ = false; +}; + +} // namespace io +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_RANDOM_INPUTSTREAM_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/record_reader.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/record_reader.h new file mode 100644 index 0000000000000000000000000000000000000000..282c0daff2a5a811f44f0ceee80732e0be1c204e --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/record_reader.h @@ -0,0 +1,180 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_IO_RECORD_READER_H_ +#define TENSORFLOW_TSL_LIB_IO_RECORD_READER_H_ + +#include "tsl/lib/io/inputstream_interface.h" +#include "tsl/platform/errors.h" +#include "tsl/platform/stringpiece.h" +#if !defined(IS_SLIM_BUILD) +#include "tsl/lib/io/snappy/snappy_compression_options.h" +#include "tsl/lib/io/snappy/snappy_inputstream.h" +#include "tsl/lib/io/zlib_compression_options.h" +#include "tsl/lib/io/zlib_inputstream.h" +#endif // IS_SLIM_BUILD +#include "tsl/platform/macros.h" +#include "tsl/platform/types.h" + +namespace tsl { +class RandomAccessFile; + +namespace io { + +struct RecordReaderOptions { + enum CompressionType { + NONE = 0, + ZLIB_COMPRESSION = 1, + SNAPPY_COMPRESSION = 2 + }; + CompressionType compression_type = NONE; + + // If buffer_size is non-zero, then all reads must be sequential, and no + // skipping around is permitted. (Note: this is the same behavior as reading + // compressed files.) Consider using SequentialRecordReader. + int64_t buffer_size = 0; + + static RecordReaderOptions CreateRecordReaderOptions( + const string& compression_type); + +#if !defined(IS_SLIM_BUILD) + // Options specific to compression. + ZlibCompressionOptions zlib_options; + SnappyCompressionOptions snappy_options; +#endif // IS_SLIM_BUILD +}; + +// Low-level interface to read TFRecord files. +// +// If using compression or buffering, consider using SequentialRecordReader. +// +// Note: this class is not thread safe; external synchronization required. +class RecordReader { + public: + // Format of a single record: + // uint64 length + // uint32 masked crc of length + // byte data[length] + // uint32 masked crc of data + static constexpr size_t kHeaderSize = sizeof(uint64) + sizeof(uint32); + static constexpr size_t kFooterSize = sizeof(uint32); + + // Statistics (sizes are in units of bytes) + struct Stats { + int64_t file_size = -1; + int64_t data_size = -1; + int64_t entries = -1; // Number of values + }; + + // Metadata for the TFRecord file. + struct Metadata { + Stats stats; + }; + + // Create a reader that will return log records from "*file". + // "*file" must remain live while this Reader is in use. + explicit RecordReader( + tsl::RandomAccessFile* file, + const RecordReaderOptions& options = RecordReaderOptions()); + + virtual ~RecordReader() = default; + + // Read the record at "*offset" into *record and update *offset to + // point to the offset of the next record. Returns OK on success, + // OUT_OF_RANGE for end of file, or something else for an error. + Status ReadRecord(uint64* offset, tstring* record); + + // Skip num_to_skip record starting at "*offset" and update *offset + // to point to the offset of the next num_to_skip + 1 record. + // Return OK on success, OUT_OF_RANGE for end of file, or something + // else for an error. "*num_skipped" records the number of records that + // are actually skipped. It should be equal to num_to_skip on success. + Status SkipRecords(uint64* offset, int num_to_skip, int* num_skipped); + + // Return the metadata of the Record file. + // + // The current implementation scans the file to completion, + // skipping over the data regions, to extract the metadata once + // on the first call to GetStats(). An improved implementation + // would change RecordWriter to write the metadata into TFRecord + // so that GetMetadata() could be a const method. + // + // 'metadata' must not be nullptr. + Status GetMetadata(Metadata* md); + + private: + Status ReadChecksummed(uint64 offset, size_t n, tstring* result); + Status PositionInputStream(uint64 offset); + + RecordReaderOptions options_; + std::unique_ptr input_stream_; + bool last_read_failed_; + + std::unique_ptr cached_metadata_; + + RecordReader(const RecordReader&) = delete; + void operator=(const RecordReader&) = delete; +}; + +// High-level interface to read TFRecord files. +// +// Note: this class is not thread safe; external synchronization required. +class SequentialRecordReader { + public: + // Create a reader that will return log records from "*file". + // "*file" must remain live while this Reader is in use. + explicit SequentialRecordReader( + tsl::RandomAccessFile* file, + const RecordReaderOptions& options = RecordReaderOptions()); + + virtual ~SequentialRecordReader() = default; + + // Read the next record in the file into *record. Returns OK on success, + // OUT_OF_RANGE for end of file, or something else for an error. + Status ReadRecord(tstring* record) { + return underlying_.ReadRecord(&offset_, record); + } + + // Skip the next num_to_skip record in the file. Return OK on success, + // OUT_OF_RANGE for end of file, or something else for an error. + // "*num_skipped" records the number of records that are actually skipped. + // It should be equal to num_to_skip on success. + Status SkipRecords(int num_to_skip, int* num_skipped) { + return underlying_.SkipRecords(&offset_, num_to_skip, num_skipped); + } + + // Return the current offset in the file. + uint64 TellOffset() { return offset_; } + + // Seek to this offset within the file and set this offset as the current + // offset. Trying to seek backward will throw error. + Status SeekOffset(uint64 offset) { + if (offset < offset_) + return errors::InvalidArgument( + "Trying to seek offset: ", offset, + " which is less than the current offset: ", offset_); + offset_ = offset; + return OkStatus(); + } + + private: + RecordReader underlying_; + uint64 offset_ = 0; +}; + +} // namespace io +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_RECORD_READER_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/record_writer.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/record_writer.h new file mode 100644 index 0000000000000000000000000000000000000000..b585cb9b52f70c13becd8f3b68f7dd437be71831 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/record_writer.h @@ -0,0 +1,156 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_IO_RECORD_WRITER_H_ +#define TENSORFLOW_TSL_LIB_IO_RECORD_WRITER_H_ + +#include "tsl/lib/hash/crc32c.h" +#include "tsl/platform/coding.h" +#include "tsl/platform/status.h" +#include "tsl/platform/stringpiece.h" +#if !defined(IS_SLIM_BUILD) +#include "tsl/lib/io/snappy/snappy_compression_options.h" +#include "tsl/lib/io/snappy/snappy_outputbuffer.h" +#include "tsl/lib/io/zlib_compression_options.h" +#include "tsl/lib/io/zlib_outputbuffer.h" +#endif // IS_SLIM_BUILD +#include "tsl/platform/cord.h" +#include "tsl/platform/macros.h" +#include "tsl/platform/types.h" + +namespace tsl { + +class WritableFile; + +namespace io { + +struct RecordWriterOptions { + public: + enum CompressionType { + NONE = 0, + ZLIB_COMPRESSION = 1, + SNAPPY_COMPRESSION = 2 + }; + CompressionType compression_type = NONE; + + static RecordWriterOptions CreateRecordWriterOptions( + const string& compression_type); + +#if !defined(IS_SLIM_BUILD) + // Options specific to compression. + io::ZlibCompressionOptions zlib_options; + io::SnappyCompressionOptions snappy_options; +#endif // IS_SLIM_BUILD +}; + +class RecordWriter { + public: + // Format of a single record: + // uint64 length + // uint32 masked crc of length + // byte data[length] + // uint32 masked crc of data + static constexpr size_t kHeaderSize = sizeof(uint64) + sizeof(uint32); + static constexpr size_t kFooterSize = sizeof(uint32); + + // Create a writer that will append data to "*dest". + // "*dest" must be initially empty. + // "*dest" must remain live while this Writer is in use. + explicit RecordWriter(WritableFile* dest, const RecordWriterOptions& options = + RecordWriterOptions()); + + // Calls Close() and logs if an error occurs. + // + // TODO(jhseu): Require that callers explicitly call Close() and remove the + // implicit Close() call in the destructor. + ~RecordWriter(); + + Status WriteRecord(StringPiece data); + +#if defined(TF_CORD_SUPPORT) + Status WriteRecord(const absl::Cord& data); +#endif + + // Flushes any buffered data held by underlying containers of the + // RecordWriter to the WritableFile. Does *not* flush the + // WritableFile. + Status Flush(); + + // Writes all output to the file. Does *not* close the WritableFile. + // + // After calling Close(), any further calls to `WriteRecord()` or `Flush()` + // are invalid. + Status Close(); + + // Utility method to populate TFRecord headers. Populates record-header in + // "header[0,kHeaderSize-1]". The record-header is based on data[0, n-1]. + inline static void PopulateHeader(char* header, const char* data, size_t n); + +#if defined(TF_CORD_SUPPORT) + inline static void PopulateHeader(char* header, const absl::Cord& data); +#endif + + // Utility method to populate TFRecord footers. Populates record-footer in + // "footer[0,kFooterSize-1]". The record-footer is based on data[0, n-1]. + inline static void PopulateFooter(char* footer, const char* data, size_t n); + +#if defined(TF_CORD_SUPPORT) + inline static void PopulateFooter(char* footer, const absl::Cord& data); +#endif + + private: + WritableFile* dest_; + RecordWriterOptions options_; + + inline static uint32 MaskedCrc(const char* data, size_t n) { + return crc32c::Mask(crc32c::Value(data, n)); + } + +#if defined(TF_CORD_SUPPORT) + inline static uint32 MaskedCrc(const absl::Cord& data) { + return crc32c::Mask(crc32c::Value(data)); + } +#endif + + RecordWriter(const RecordWriter&) = delete; + void operator=(const RecordWriter&) = delete; +}; + +void RecordWriter::PopulateHeader(char* header, const char* data, size_t n) { + core::EncodeFixed64(header + 0, n); + core::EncodeFixed32(header + sizeof(uint64), + MaskedCrc(header, sizeof(uint64))); +} + +void RecordWriter::PopulateFooter(char* footer, const char* data, size_t n) { + core::EncodeFixed32(footer, MaskedCrc(data, n)); +} + +#if defined(TF_CORD_SUPPORT) +void RecordWriter::PopulateHeader(char* header, const absl::Cord& data) { + core::EncodeFixed64(header + 0, data.size()); + core::EncodeFixed32(header + sizeof(uint64), + MaskedCrc(header, sizeof(uint64))); +} + +void RecordWriter::PopulateFooter(char* footer, const absl::Cord& data) { + core::EncodeFixed32(footer, MaskedCrc(data)); +} +#endif + +} // namespace io +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_RECORD_WRITER_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/snappy/snappy_compression_options.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/snappy/snappy_compression_options.h new file mode 100644 index 0000000000000000000000000000000000000000..4d1ba01e3c15d74e91233627fb33f7750c1234f6 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/snappy/snappy_compression_options.h @@ -0,0 +1,36 @@ +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_IO_SNAPPY_SNAPPY_COMPRESSION_OPTIONS_H_ +#define TENSORFLOW_TSL_LIB_IO_SNAPPY_SNAPPY_COMPRESSION_OPTIONS_H_ + +#include "tsl/platform/types.h" + +namespace tsl { +namespace io { + +struct SnappyCompressionOptions { + // Size of the buffer used for caching the data read from source file. + int64_t input_buffer_size = 256 << 10; + + // Size of the sink buffer where the compressed/decompressed data produced by + // snappy is cached. + int64_t output_buffer_size = 256 << 10; +}; + +} // namespace io +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_SNAPPY_SNAPPY_COMPRESSION_OPTIONS_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/snappy/snappy_inputbuffer.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/snappy/snappy_inputbuffer.h new file mode 100644 index 0000000000000000000000000000000000000000..e4f4144f0625dc28221523e1b4d37454aef5739a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/snappy/snappy_inputbuffer.h @@ -0,0 +1,134 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_IO_SNAPPY_SNAPPY_INPUTBUFFER_H_ +#define TENSORFLOW_TSL_LIB_IO_SNAPPY_SNAPPY_INPUTBUFFER_H_ + +#include +#include + +#include "tsl/lib/io/inputstream_interface.h" +#include "tsl/platform/env.h" +#include "tsl/platform/macros.h" +#include "tsl/platform/snappy.h" +#include "tsl/platform/status.h" +#include "tsl/platform/types.h" + +namespace tsl { +namespace io { + +// An SnappyInputBuffer provides support for reading from a file compressed +// using snappy (https://github.com/google/snappy). +// +// A given instance of an SnappyInputBuffer is NOT safe for concurrent use +// by multiple threads +class SnappyInputBuffer : public InputStreamInterface { + public: + // Create a SnappyInputBuffer for `file` with a buffer of size + // `input_buffer_bytes` bytes for reading contents from `file` and another + // buffer with size `output_buffer_bytes` for caching decompressed contents. + // Does *not* take ownership of "file". + SnappyInputBuffer(RandomAccessFile* file, size_t input_buffer_bytes, + size_t output_buffer_bytes); + + // Reads bytes_to_read bytes into *result, overwriting *result. + // + // Return Status codes: + // OK: + // If successful. + // OUT_OF_RANGE: + // If there are not enough bytes to read before the end of the file. + // DATA_LOSS: + // If uncompression failed or if the file is corrupted. + // RESOURCE_EXHAUSTED: + // If input_buffer_ is smaller in size than a compressed block. + // others: + // If reading from file failed. + Status ReadNBytes(int64_t bytes_to_read, tstring* result) override; + + int64_t Tell() const override; + + Status Reset() override; + + private: + // Reads data from `file_` and tries to fill up `input_buffer_` if enough + // unread data is left in `file_`. + // + // Looks up `next_in_` to check how much data in `input_buffer_` + // has already been read. The used data is removed and new data is added to + // after any unread data in `input_buffer_`. + // After this call `next_in` points to the start of `input_buffer_` + // and `avail_in_` stores the number of readable bytes in + // `input_buffer_`. + // + // Returns OutOfRange error if NO data could be read from file. Note that this + // won't return an OutOfRange if there wasn't sufficient data in file to + // completely fill up `input_buffer_`. + Status ReadFromFile(); + + // Reads the length of the next compressed block stored in the next 4 bytes at + // `next_in_`. Uncompresses the next compressed block and writes the output + // produced to the output_buffer_. + // Should be called only after the cached output has been consumed. + Status Inflate(); + + // Starts reading bytes at `next_out_` until either `bytes_to_read` + // bytes have been read or `next_out_` is reached. + // Returns the number of bytes read and advances the `next_out_` + // pointer to the next location to read from. + size_t ReadBytesFromCache(size_t bytes_to_read, char* result); + + // Reads the length of the next *compressed* block and stores in `length`. + // The length is stored in 4 bytes in little endian notation. + Status ReadCompressedBlockLength(uint32* length); + + RandomAccessFile* file_; // Not owned + int64_t file_pos_ = 0; // Next position to read from in `file_` + size_t input_buffer_capacity_; // Size of `input_buffer_`. + // Must be at least as big as the size of + // the largest compressed block. + size_t output_buffer_capacity_; // Size of `output_buffer_` + + // Buffer for storing contents read from compressed file. + // TODO(srbs): Consider using circular buffers. That would greatly simplify + // the implementation. + std::unique_ptr input_buffer_; + + // Buffer for storing inflated contents of `file_`. + std::unique_ptr output_buffer_; + + // Next unread byte in `input_buffer_`. + char* next_in_; + + // Next unread byte in `output_buffer_` + char* next_out_; + + // Number of unread bytes available at `next_in_` in `input_buffer_`. + size_t avail_in_ = 0; + + // Number of unread bytes available at `next_out_` in `output_buffer_`. + size_t avail_out_ = 0; + + // Number of *uncompressed* bytes that have been read from this stream. + int64_t bytes_read_; + + SnappyInputBuffer(const SnappyInputBuffer&) = delete; + void operator=(const SnappyInputBuffer&) = delete; +}; + +} // namespace io +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_SNAPPY_SNAPPY_INPUTBUFFER_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/snappy/snappy_inputstream.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/snappy/snappy_inputstream.h new file mode 100644 index 0000000000000000000000000000000000000000..f9ffe5e95378ddd580300fbbb268cf74272ea774 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/snappy/snappy_inputstream.h @@ -0,0 +1,92 @@ +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_IO_SNAPPY_SNAPPY_INPUTSTREAM_H_ +#define TENSORFLOW_TSL_LIB_IO_SNAPPY_SNAPPY_INPUTSTREAM_H_ + +#include + +#include "tsl/lib/io/inputstream_interface.h" + +namespace tsl { +namespace io { + +class SnappyInputStream : public InputStreamInterface { + public: + // Creates a SnappyInputStream for `input_stream`. + // + // Takes ownership of `input_stream` iff `owns_input_stream` is true. + SnappyInputStream(InputStreamInterface* input_stream, + size_t output_buffer_bytes, bool owns_input_stream); + + // Equivalent to the previous constructor with owns_input_stream = false. + explicit SnappyInputStream(InputStreamInterface* input_stream, + size_t output_buffer_bytes); + + ~SnappyInputStream() override; + + // Reads bytes_to_read bytes into *result, overwriting *result. + // + // Return Status codes: + // OK: If successful. + // OUT_OF_RANGE: If there are not enough bytes to read before + // the end of the stream. + // ABORTED: If inflate() fails, we return the error code with the + // error message in `z_stream_->msg`. + // others: If reading from stream failed. + Status ReadNBytes(int64_t bytes_to_read, tstring* result) override; + +#if defined(TF_CORD_SUPPORT) + Status ReadNBytes(int64_t bytes_to_read, absl::Cord* result) override; +#endif + + int64_t Tell() const override; + + Status Reset() override; + + private: + // Decompress the next chunk of data and place the data into the cache. + Status Inflate(); + + // Attempt to read `bytes_to_read` from the decompressed data cache. Returns + // the actual number of bytes read. + size_t ReadBytesFromCache(size_t bytes_to_read, char* result); + + InputStreamInterface* input_stream_; + const size_t output_buffer_bytes_; + const bool owns_input_stream_; + + // Specifies the number of decompressed bytes currently read. + int64_t bytes_read_; + + // output_buffer_ contains decompressed data not yet read by the client. + std::unique_ptr output_buffer_; + + // next_out_ points to the position in the `output_buffer_` that contains the + // next unread byte. + char* next_out_; + + // avail_out_ specifies the number of bytes left in the output_buffers_ that + // is not yet read. + size_t avail_out_; + + SnappyInputStream(const SnappyInputStream&) = delete; + void operator=(const SnappyInputStream&) = delete; +}; + +} // namespace io +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_SNAPPY_SNAPPY_INPUTSTREAM_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/snappy/snappy_outputbuffer.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/snappy/snappy_outputbuffer.h new file mode 100644 index 0000000000000000000000000000000000000000..59b34d9cb4d98e0a21719fd73ebbf409569781d4 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/snappy/snappy_outputbuffer.h @@ -0,0 +1,158 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_IO_SNAPPY_SNAPPY_OUTPUTBUFFER_H_ +#define TENSORFLOW_TSL_LIB_IO_SNAPPY_SNAPPY_OUTPUTBUFFER_H_ + +#include +#include + +#include "tsl/platform/env.h" +#include "tsl/platform/macros.h" +#include "tsl/platform/platform.h" +#include "tsl/platform/snappy.h" +#include "tsl/platform/status.h" +#include "tsl/platform/types.h" + +namespace tsl { +namespace io { + +// Compresses input data using Snappy (https://github.com/google/snappy) and +// writes to `file`. +// +// The input data is cached in a buffer of size `input_buffer_bytes`. When the +// buffer does not have enough available space to fit new data (in the call to +// `Write`), the contents of the buffer are compressed and sent to the output +// buffer. +// +// The compressed output is buffered in a buffer of size `output_buffer_bytes` +// which gets flushed to file when full. +// +// Output file format: +// The output file consists of a sequence of compressed blocks. Each block +// starts with a 4 byte header which stores the length (in bytes) of the +// _compressed_ block _excluding_ this header. The compressed +// block (excluding the 4 byte header) is a valid snappy block and can directly +// be uncompressed using Snappy_Uncompress. +class SnappyOutputBuffer : public WritableFile { + public: + // Create an SnappyOutputBuffer for `file` with two buffers that cache the + // 1. input data to be deflated + // 2. the deflated output + // with sizes `input_buffer_bytes` and `output_buffer_bytes` respectively. + // Does not take ownership of `file`. + SnappyOutputBuffer(WritableFile* file, int32_t input_buffer_bytes, + int32_t output_buffer_bytes); + + // Per convention, the dtor does not call Flush() or Close(). We expect the + // caller to call those manually when done. + ~SnappyOutputBuffer() override; + + // Adds `data` to the compression pipeline. + // + // The input data is buffered internally and will be written to disk at a + // later time. To immediately write contents to file call `Flush()`. + Status Append(StringPiece data) override; + +#if defined(TF_CORD_SUPPORT) + Status Append(const absl::Cord& cord) override; +#endif + + // Compresses any buffered input and writes all output to file. This must be + // called before the destructor to avoid any data loss. + // + // Contrary to `Flush()` this informs snappy that it should not expect any + // further input. + // + // After calling this, any further calls to `Write()`, `Flush()` or `Close()` + // will fail. + Status Close() override; + + // Returns the name of the underlying file. + Status Name(StringPiece* result) const override; + + // Deflates any cached input, writes all output to file and syncs it. + Status Sync() override; + + // Returns the write position in the underlying file. The position does not + // reflect buffered, un-flushed data. + Status Tell(int64_t* position) override; + + // Adds `data` to the compression pipeline. + // + // The input data is buffered in `input_buffer_` and is compressed in bulk + // when the buffer gets full. The compressed output may not be immediately + // written to file but rather buffered in `output_buffer_` and gets written + // to file when the buffer is full. + // + // To immediately write contents to file call `Flush()`. + Status Write(StringPiece data); + + // Compresses any cached input and writes all output to file. This must be + // called before the destructor to avoid any data loss. + Status Flush() override; + + private: + // Appends `data` to `input_buffer_`. + // Throws if `data.size()` > AvailableInputSpace(). + void AddToInputBuffer(StringPiece data); + + // Appends `data` to `output_buffer_`. Flushes buffer contents to file when + // buffer gets full. + Status AddToOutputBuffer(const char* data, size_t length); + + // Returns the total space available in `input_buffer_`. + int32 AvailableInputSpace() const; + + // Deflate contents in input_buffer_ and store results in output_buffer_. + // The contents of output stream are written to file if more space is needed. + // + // Note: This method does not flush contents to file. + // Returns non-ok status if writing contents to file fails. + Status DeflateBuffered(); + + // Appends contents of `output_buffer_` to `file_`. + // Returns non-OK status if writing to file fails. + Status FlushOutputBufferToFile(); + + // Compresses `avail_in_` bytes at `next_in_` location in `input_buffer_` and + // writes the results to output using `AddToOutputBuffer`. + // Returns non-OK status if writing to file failed. + Status Deflate(); + + WritableFile* file_; // Not owned + + // Buffer for storing contents read from input `file_`. + // TODO(srbs): Consider using circular buffers. That would greatly simplify + // the implementation. + std::unique_ptr input_buffer_; + size_t input_buffer_capacity_; + char* next_in_; + size_t avail_in_ = 0; + + // Buffer for storing deflated contents of `file_`. + std::unique_ptr output_buffer_; + size_t output_buffer_capacity_; + char* next_out_; + size_t avail_out_; + + SnappyOutputBuffer(const SnappyOutputBuffer&) = delete; + void operator=(const SnappyOutputBuffer&) = delete; +}; + +} // namespace io +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_SNAPPY_SNAPPY_OUTPUTBUFFER_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/table.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/table.h new file mode 100644 index 0000000000000000000000000000000000000000..31ed1777122f2552e41c900b13f3e887f896405d --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/table.h @@ -0,0 +1,86 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_IO_TABLE_H_ +#define TENSORFLOW_TSL_LIB_IO_TABLE_H_ + +#include + +#include "tsl/lib/io/iterator.h" + +namespace tsl { + +class RandomAccessFile; + +namespace table { + +struct Options; + +// A Table is a sorted map from strings to strings. Tables are +// immutable and persistent. A Table may be safely accessed from +// multiple threads without external synchronization. +class Table { + public: + // Attempt to open the table that is stored in bytes [0..file_size) + // of "file", and read the metadata entries necessary to allow + // retrieving data from the table. + // + // If successful, returns ok and sets "*table" to the newly opened + // table. The client should delete "*table" when no longer needed. + // If there was an error while initializing the table, sets "*table" + // to NULL and returns a non-ok status. Does not take ownership of + // "*file", but the client must ensure that "file" remains live + // for the duration of the returned table's lifetime. + static Status Open(const Options& options, tsl::RandomAccessFile* file, + uint64 file_size, Table** table); + + ~Table(); + + // Returns a new iterator over the table contents. + // The result of NewIterator() is initially invalid (caller must + // call one of the Seek methods on the iterator before using it). + Iterator* NewIterator() const; + + // Given a key, return an approximate byte offset in the file where + // the data for that key begins (or would begin if the key were + // present in the file). The returned value is in terms of file + // bytes, and so includes effects like compression of the underlying data. + // E.g., the approximate offset of the last key in the table will + // be close to the file length. + uint64 ApproximateOffsetOf(const StringPiece& key) const; + + private: + struct Rep; + Rep* rep_; + + explicit Table(Rep* rep) { rep_ = rep; } + static Iterator* BlockReader(void*, const StringPiece&); + + // Calls (*handle_result)(arg, ...) with the entry found after a call + // to Seek(key). May not make such a call if filter policy says + // that key is not present. + Status InternalGet(const StringPiece& key, void* arg, + void (*handle_result)(void* arg, const StringPiece& k, + const StringPiece& v)); + + // No copying allowed + Table(const Table&); + void operator=(const Table&); +}; + +} // namespace table +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_TABLE_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/table_builder.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/table_builder.h new file mode 100644 index 0000000000000000000000000000000000000000..0740083bddc009d936c8353a361dbd0db36a8c1a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/table_builder.h @@ -0,0 +1,101 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +// TableBuilder provides the interface used to build a Table +// (an immutable and sorted map from keys to values). +// +// Multiple threads can invoke const methods on a TableBuilder without +// external synchronization, but if any of the threads may call a +// non-const method, all threads accessing the same TableBuilder must use +// external synchronization. + +#ifndef TENSORFLOW_TSL_LIB_IO_TABLE_BUILDER_H_ +#define TENSORFLOW_TSL_LIB_IO_TABLE_BUILDER_H_ + +#include + +#include "tsl/lib/io/table_options.h" +#include "tsl/platform/status.h" +#include "tsl/platform/stringpiece.h" + +namespace tsl { +class WritableFile; +namespace table { + +class BlockBuilder; +class BlockHandle; + +class TableBuilder { + public: + // Create a builder that will store the contents of the table it is + // building in *file. Does not close the file. It is up to the + // caller to close the file after calling Finish(). + TableBuilder(const Options& options, tsl::WritableFile* file); + + // REQUIRES: Either Finish() or Abandon() has been called. + ~TableBuilder(); + + // Add key,value to the table being constructed. + // REQUIRES: key is after any previously added key in lexicographic order. + // REQUIRES: Finish(), Abandon() have not been called + void Add(const StringPiece& key, const StringPiece& value); + + // Advanced operation: writes any buffered key/value pairs to file. + // Can be used to ensure that two adjacent entries never live in + // the same data block. Most clients should not need to use this method. + // Does not flush the file itself. + // REQUIRES: Finish(), Abandon() have not been called + void Flush(); + + // Return non-ok iff some error has been detected. + Status status() const; + + // Finish building the table. Stops using the file passed to the + // constructor after this function returns. + // REQUIRES: Finish(), Abandon() have not been called + Status Finish(); + + // Indicate that the contents of this builder should be abandoned. Stops + // using the file passed to the constructor after this function returns. + // If the caller is not going to call Finish(), it must call Abandon() + // before destroying this builder. + // REQUIRES: Finish(), Abandon() have not been called + void Abandon(); + + // Number of calls to Add() so far. + uint64 NumEntries() const; + + // Size of the file generated so far. If invoked after a successful + // Finish() call, returns the size of the final generated file. + uint64 FileSize() const; + + private: + bool ok() const { return status().ok(); } + void WriteBlock(BlockBuilder* block, BlockHandle* handle); + void WriteRawBlock(const StringPiece& data, CompressionType, + BlockHandle* handle); + + struct Rep; + Rep* rep_; + + // No copying allowed + TableBuilder(const TableBuilder&); + void operator=(const TableBuilder&); +}; + +} // namespace table +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_TABLE_BUILDER_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/table_options.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/table_options.h new file mode 100644 index 0000000000000000000000000000000000000000..c3ca3e1b2fe96daae9b42932943fc239c43862de --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/table_options.h @@ -0,0 +1,76 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_IO_TABLE_OPTIONS_H_ +#define TENSORFLOW_TSL_LIB_IO_TABLE_OPTIONS_H_ + +#include + +namespace tsl { +namespace table { + +class Cache; + +// DB contents are stored in a set of blocks, each of which holds a +// sequence of key,value pairs. Each block may be compressed before +// being stored in a file. The following enum describes which +// compression method (if any) is used to compress a block. +enum CompressionType { + // NOTE: do not change the values of existing entries, as these are + // part of the persistent format on disk. + kNoCompression = 0x0, + kSnappyCompression = 0x1 +}; + +// Options to control the behavior of a table (passed to Table::Open) +struct Options { + // Approximate size of user data packed per block. Note that the + // block size specified here corresponds to uncompressed data. The + // actual size of the unit read from disk may be smaller if + // compression is enabled. This parameter can be changed dynamically. + size_t block_size = 262144; + + // Number of keys between restart points for delta encoding of keys. + // This parameter can be changed dynamically. Most clients should + // leave this parameter alone. + int block_restart_interval = 16; + + // Compress blocks using the specified compression algorithm. This + // parameter can be changed dynamically. + // + // Default: kSnappyCompression, which gives lightweight but fast + // compression. + // + // Typical speeds of kSnappyCompression on an Intel(R) Core(TM)2 2.4GHz: + // ~200-500MB/s compression + // ~400-800MB/s decompression + // Note that these speeds are significantly faster than most + // persistent storage speeds, and therefore it is typically never + // worth switching to kNoCompression. Even if the input data is + // incompressible, the kSnappyCompression implementation will + // efficiently detect that and will switch to uncompressed mode. + CompressionType compression = kSnappyCompression; + + // Control over blocks (user data is stored in a set of blocks, and + // a block is the unit of reading from disk). + + // If non-null, use the specified cache for blocks. + Cache* block_cache = nullptr; +}; + +} // namespace table +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_TABLE_OPTIONS_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/two_level_iterator.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/two_level_iterator.h new file mode 100644 index 0000000000000000000000000000000000000000..3d6127dbde80e2335df55693ea2cffb57ea6db5e --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/two_level_iterator.h @@ -0,0 +1,41 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_IO_TWO_LEVEL_ITERATOR_H_ +#define TENSORFLOW_TSL_LIB_IO_TWO_LEVEL_ITERATOR_H_ + +#include "tsl/lib/io/iterator.h" + +namespace tsl { +namespace table { + +// Return a new two level iterator. A two-level iterator contains an +// index iterator whose values point to a sequence of blocks where +// each block is itself a sequence of key,value pairs. The returned +// two-level iterator yields the concatenation of all key/value pairs +// in the sequence of blocks. Takes ownership of "index_iter" and +// will delete it when no longer needed. +// +// Uses a supplied function to convert an index_iter value into +// an iterator over the contents of the corresponding block. +extern Iterator* NewTwoLevelIterator( + Iterator* index_iter, + Iterator* (*block_function)(void* arg, const StringPiece& index_value), + void* arg); + +} // namespace table +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_TWO_LEVEL_ITERATOR_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/zlib_compression_options.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/zlib_compression_options.h new file mode 100644 index 0000000000000000000000000000000000000000..612f32c507148d9f341b073100bae363f740d2c9 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/zlib_compression_options.h @@ -0,0 +1,141 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_IO_ZLIB_COMPRESSION_OPTIONS_H_ +#define TENSORFLOW_TSL_LIB_IO_ZLIB_COMPRESSION_OPTIONS_H_ + +#include "tsl/platform/types.h" + +namespace tsl { +namespace io { + +class ZlibCompressionOptions { + public: + ZlibCompressionOptions(); + + static ZlibCompressionOptions DEFAULT(); + static ZlibCompressionOptions RAW(); + static ZlibCompressionOptions GZIP(); + + // Defaults to Z_NO_FLUSH + int8 flush_mode; + + // Size of the buffer used for caching the data read from source file. + int64_t input_buffer_size = 256 << 10; + + // Size of the sink buffer where the compressed/decompressed data produced by + // zlib is cached. + int64_t output_buffer_size = 256 << 10; + + // The window_bits parameter is the base two logarithm of the window size + // (the size of the history buffer). Larger values of buffer size result in + // better compression at the expense of memory usage. + // + // Accepted values: + // + // 8..15: + // Normal deflate with zlib header and checksum. + // + // -8..-15: + // Negative values can be used for raw deflate/inflate. In this case, + // -window_bits determines the window size. deflate() will then generate raw + // deflate data with no zlib header or trailer, and will not compute an + // adler32 check value. inflate() will then process raw deflate data, not + // looking for a zlib or gzip header, not generating a check value, and not + // looking for any check values for comparison at the end of the stream. + // + // 16 + [8..15]: + // window_bits can also be greater than 15 for optional gzip encoding. Add 16 + // to window_bits to write a simple gzip header and trailer around the + // compressed data instead of a zlib wrapper. The gzip header will have no + // file name, no extra data, no comment, no modification time (set to zero), + // no header crc, and the operating system will be set to 255 (unknown). If a + // gzip stream is being written, strm->adler is a crc32 instead of an adler32. + // + // 0: + // window_bits can also be zero to request that inflate use the window size + // in the zlib header of the compressed stream. + // + // While inflating, window_bits must be greater than or equal to the + // window_bits value provided used while compressing. If a compressed stream + // with a larger window size is given as input, inflate() will return with the + // error code Z_DATA_ERROR instead of trying to allocate a larger window. + // + // Defaults to MAX_WBITS + int8 window_bits; + + // From the zlib manual (http://www.zlib.net/manual.html): + // The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + // 1 gives best speed, 9 gives best compression, 0 gives no compression at all + // (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION + // requests a default compromise between speed and compression (currently + // equivalent to level 6). + int8 compression_level; + + // Only Z_DEFLATED is supported at this time. + int8 compression_method; + + // From the zlib manual (http://www.zlib.net/manual.html): + // The mem_level parameter specifies how much memory should be allocated for + // the internal compression state. mem_level=1 uses minimum memory but is slow + // and reduces compression ratio; mem_level=9 uses maximum memory for optimal + // speed. The default value is 8. + int8 mem_level = 9; + + // From the zlib manual (http://www.zlib.net/manual.html): + // The strategy parameter is used to tune the compression algorithm. Use the + // value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by + // a filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only + // (no string match), or Z_RLE to limit match distances to one + // (run-length encoding). Filtered data consists mostly of small values with + // a somewhat random distribution. In this case, the compression algorithm is + // tuned to compress them better. The effect of Z_FILTERED is to force more + // Huffman coding and less string matching; it is somewhat intermediate + // between Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be + // almost as fast as Z_HUFFMAN_ONLY, but give better compression for + // PNG image data. The strategy parameter only affects the compression ratio + // but not the correctness of the compressed output even if it is not set + // appropriately. Z_FIXED prevents the use of dynamic Huffman codes, allowing + // for a simpler decoder for special applications. + int8 compression_strategy; + + // When this is set to true and we are unable to find the header to correctly + // decompress a file, we return an error when `ReadNBytes` is called instead + // of CHECK-failing. Defaults to false (i.e. CHECK-failing). + // + // This option is ignored for `ZlibOutputBuffer`. + bool soft_fail_on_error = false; // NOLINT +}; + +inline ZlibCompressionOptions ZlibCompressionOptions::DEFAULT() { + return ZlibCompressionOptions(); +} + +inline ZlibCompressionOptions ZlibCompressionOptions::RAW() { + ZlibCompressionOptions options = ZlibCompressionOptions(); + options.window_bits = -options.window_bits; + return options; +} + +inline ZlibCompressionOptions ZlibCompressionOptions::GZIP() { + ZlibCompressionOptions options = ZlibCompressionOptions(); + options.window_bits = options.window_bits + 16; + return options; +} + +} // namespace io +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_ZLIB_COMPRESSION_OPTIONS_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/zlib_inputstream.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/zlib_inputstream.h new file mode 100644 index 0000000000000000000000000000000000000000..e19843c812d350b28e74b885b555ca90e53e6b4e --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/zlib_inputstream.h @@ -0,0 +1,142 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_IO_ZLIB_INPUTSTREAM_H_ +#define TENSORFLOW_TSL_LIB_IO_ZLIB_INPUTSTREAM_H_ + +#include + +#include "tsl/lib/io/inputstream_interface.h" +#include "tsl/lib/io/zlib_compression_options.h" +#include "tsl/platform/env.h" +#include "tsl/platform/macros.h" +#include "tsl/platform/status.h" +#include "tsl/platform/types.h" + +namespace tsl { +namespace io { + +// Forward declare some members of zlib.h, which is only included in the +// .cc file. +struct ZStreamDef; + +// An ZlibInputStream provides support for reading from a stream compressed +// using zlib (http://www.zlib.net/). Buffers the contents of the file. +// +// A given instance of an ZlibInputStream is NOT safe for concurrent use +// by multiple threads +class ZlibInputStream : public InputStreamInterface { + public: + // Create a ZlibInputStream for `input_stream` with a buffer of size + // `input_buffer_bytes` bytes for reading contents from `input_stream` and + // another buffer with size `output_buffer_bytes` for caching decompressed + // contents. + // + // Takes ownership of `input_stream` iff `owns_input_stream` is true. + ZlibInputStream(InputStreamInterface* input_stream, size_t input_buffer_bytes, + size_t output_buffer_bytes, + const ZlibCompressionOptions& zlib_options, + bool owns_input_stream); + + // Equivalent to the previous constructor with owns_input_stream=false. + ZlibInputStream(InputStreamInterface* input_stream, size_t input_buffer_bytes, + size_t output_buffer_bytes, + const ZlibCompressionOptions& zlib_options); + + ~ZlibInputStream(); + + // Reads bytes_to_read bytes into *result, overwriting *result. + // + // Return Status codes: + // OK: If successful. + // OUT_OF_RANGE: If there are not enough bytes to read before + // the end of the stream. + // ABORTED: If inflate() fails, we return the error code with the + // error message in `z_stream_->msg`. + // others: If reading from stream failed. + Status ReadNBytes(int64_t bytes_to_read, tstring* result) override; + +#if defined(TF_CORD_SUPPORT) + Status ReadNBytes(int64_t bytes_to_read, absl::Cord* result) override; +#endif + + int64_t Tell() const override; + + Status Reset() override; + + private: + void InitZlibBuffer(); + + const bool owns_input_stream_; + InputStreamInterface* input_stream_; + size_t input_buffer_capacity_; // Size of z_stream_input_ + size_t output_buffer_capacity_; // Size of z_stream_output_ + char* next_unread_byte_; // Next unread byte in z_stream_output_ + bool init_error_ = false; // Whether we encountered an error in init. + + ZlibCompressionOptions const zlib_options_; + + std::unique_ptr z_stream_def_; + + // Reads data from `input_stream_` and tries to fill up `z_stream_input_` if + // enough unread data is left in `input_stream_`. + // + // Looks up z_stream_->next_in to check how much data in z_stream_input_ + // has already been read. The used data is removed and new data is added to + // after any unread data in z_stream_input_. + // After this call z_stream_->next_in points to the start of z_stream_input_ + // and z_stream_->avail_in stores the number of readable bytes in + // z_stream_input_. + // + // Returns OutOfRange error if NO data could be read from stream. Note that + // this won't return an OutOfRange if there wasn't sufficient data in stream + // to completely fill up z_stream_input_. + Status ReadFromStream(); + + // Calls `inflate()` and returns DataLoss Status if it failed. + Status Inflate(); + + // Starts reading bytes at `next_unread_byte_` till either `bytes_to_read` + // bytes have been read or `z_stream_->next_out` is reached. + // Returns the number of bytes read and advances the `next_unread_byte_` + // pointer to the next location to read from. + size_t ReadBytesFromCache(size_t bytes_to_read, tstring* result); + + // The number of unread bytes in z_stream_output_. + // + // z_stream_output_ --> + // + // [RRRRRRRRRRRRRRRRRRUUUUUUUUUUUUUU000000000000000000] + // ^ ^ + // next_unread_byte_ z_stream_->next_out + // + // R: Read bytes + // U: Unread bytes + // 0: garbage bytes where new output will be written + // + // Returns the size of [next_unread_byte_, z_stream_->next_out) + size_t NumUnreadBytes() const; + + // Number of *uncompressed* bytes that have been read from this stream. + int64_t bytes_read_; + + ZlibInputStream(const ZlibInputStream&) = delete; + void operator=(const ZlibInputStream&) = delete; +}; + +} // namespace io +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_ZLIB_INPUTSTREAM_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/zlib_outputbuffer.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/zlib_outputbuffer.h new file mode 100644 index 0000000000000000000000000000000000000000..3e4236ac1e44fd1b7b58a24058f1d8407114055e --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/io/zlib_outputbuffer.h @@ -0,0 +1,159 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_IO_ZLIB_OUTPUTBUFFER_H_ +#define TENSORFLOW_TSL_LIB_IO_ZLIB_OUTPUTBUFFER_H_ + +#include + +#include + +#include "tsl/lib/io/zlib_compression_options.h" +#include "tsl/platform/env.h" +#include "tsl/platform/file_system.h" +#include "tsl/platform/macros.h" +#include "tsl/platform/status.h" +#include "tsl/platform/stringpiece.h" +#include "tsl/platform/types.h" + +namespace tsl { +namespace io { + +// Provides support for writing compressed output to file using zlib +// (http://www.zlib.net/). +// A given instance of an ZlibOutputBuffer is NOT safe for concurrent use +// by multiple threads +class ZlibOutputBuffer : public WritableFile { + public: + // Create an ZlibOutputBuffer for `file` with two buffers that cache the + // 1. input data to be deflated + // 2. the deflated output + // with sizes `input_buffer_bytes` and `output_buffer_bytes` respectively. + // Does not take ownership of `file`. + // output_buffer_bytes should be greater than 1. + ZlibOutputBuffer( + WritableFile* file, + int32_t input_buffer_bytes, // size of z_stream.next_in buffer + int32_t output_buffer_bytes, // size of z_stream.next_out buffer + const ZlibCompressionOptions& zlib_options); + + ~ZlibOutputBuffer(); + + // Initializes some state necessary for the output buffer. This call is + // required before any other operation on the buffer. + Status Init(); + + // Adds `data` to the compression pipeline. + // + // The input data is buffered in `z_stream_input_` and is compressed in bulk + // when the buffer gets full. The compressed output is not immediately + // written to file but rather buffered in `z_stream_output_` and gets written + // to file when the buffer is full. + // + // To immediately write contents to file call `Flush()`. + Status Append(StringPiece data) override; + +#if defined(TF_CORD_SUPPORT) + Status Append(const absl::Cord& cord) override; +#endif + + // Deflates any cached input and writes all output to file. + Status Flush() override; + + // Compresses any cached input and writes all output to file. This must be + // called before the destructor to avoid any data loss. + // + // Contrary to `Flush()` this informs zlib that it should not expect any + // further input by using Z_FINISH flush mode. Also cleans up z_stream. + // + // After calling this, any further calls to `Write()`, `Flush()` or `Close()` + // will fail. + Status Close() override; + + // Returns the name of the underlying file. + Status Name(StringPiece* result) const override; + + // Deflates any cached input, writes all output to file and syncs it. + Status Sync() override; + + // Returns the write position in the underlying file. The position does not + // reflect buffered, un-flushed data. + Status Tell(int64_t* position) override; + + private: + WritableFile* file_; // Not owned + Status init_status_; + size_t input_buffer_capacity_; + size_t output_buffer_capacity_; + + // Buffer for storing contents read from input `file_`. + // TODO(srbs): Consider using circular buffers. That would greatly simplify + // the implementation. + std::unique_ptr z_stream_input_; + + // Buffer for storing deflated contents of `file_`. + std::unique_ptr z_stream_output_; + + ZlibCompressionOptions const zlib_options_; + + // Configuration passed to `deflate`. + // + // z_stream_->next_in: + // Next byte to compress. Points to some byte in z_stream_input_ buffer. + // z_stream_->avail_in: + // Number of bytes available to be compressed at this time. + // z_stream_->next_out: + // Next byte to write compressed data to. Points to some byte in + // z_stream_output_ buffer. + // z_stream_->avail_out: + // Number of free bytes available at write location. + std::unique_ptr z_stream_; + + // Adds `data` to `z_stream_input_`. + // Throws if `data.size()` > AvailableInputSpace(). + void AddToInputBuffer(StringPiece data); + + // Returns the total space available in z_input_stream_ buffer. + int32 AvailableInputSpace() const; + + // Deflate contents in z_stream_input_ and store results in z_stream_output_. + // The contents of output stream are written to file if more space is needed. + // On successful termination it is assured that: + // - z_stream_->avail_in == 0 + // - z_stream_->avail_out > 0 + // + // Note: This method does not flush contents to file. + // Returns non-ok status if writing contents to file fails. + Status DeflateBuffered(int flush_mode); + + // Appends contents of `z_stream_output_` to `file_`. + // Returns non-OK status if writing to file fails. + Status FlushOutputBufferToFile(); + + // Calls `deflate()` and returns DataLoss Status if it failed. + Status Deflate(int flush); + + static bool IsSyncOrFullFlush(uint8 flush_mode) { + return flush_mode == Z_SYNC_FLUSH || flush_mode == Z_FULL_FLUSH; + } + + ZlibOutputBuffer(const ZlibOutputBuffer&) = delete; + void operator=(const ZlibOutputBuffer&) = delete; +}; + +} // namespace io +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_IO_ZLIB_OUTPUTBUFFER_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/math/math_util.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/math/math_util.h new file mode 100644 index 0000000000000000000000000000000000000000..a1651a6c4e75ae7e74c7de02ebbc8d667cac230e --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/math/math_util.h @@ -0,0 +1,163 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_LIB_MATH_MATH_UTIL_H_ +#define TENSORFLOW_TSL_LIB_MATH_MATH_UTIL_H_ + +#include + +#include "tsl/platform/logging.h" +#include "tsl/platform/types.h" + +namespace tsl { + +class MathUtil { + public: + // ---------------------------------------------------------------------- + // CeilOfRatio + // FloorOfRatio + // Returns the ceil (resp. floor) of the ratio of two integers. + // + // * IntegralType: any integral type, whether signed or not. + // * numerator: any integer: positive, negative, or zero. + // * denominator: a non-zero integer, positive or negative. + // + // This implementation is correct, meaning there is never any precision loss, + // and there is never an overflow. However, if the type is signed, having + // numerator == MathLimits::kMin and denominator == -1 is not a + // valid input, because kMin has a greater absolute value than kMax. + // + // Input validity is DCHECKed. When not in debug mode, invalid inputs raise + // SIGFPE. + // + // This method has been designed and tested so that it should always be + // preferred to alternatives. Indeed, there exist popular recipes to compute + // the result, such as casting to double, but they are in general incorrect. + // In cases where an alternative technique is correct, performance measurement + // showed the provided implementation is faster. + template + static IntegralType CeilOfRatio(IntegralType numerator, + IntegralType denominator) { + return CeilOrFloorOfRatio(numerator, denominator); + } + template + static IntegralType FloorOfRatio(IntegralType numerator, + IntegralType denominator) { + return CeilOrFloorOfRatio(numerator, denominator); + } + + template + static IntegralType CeilOrFloorOfRatio(IntegralType numerator, + IntegralType denominator); + + template + static IntegralType GCD(IntegralType x, IntegralType y); + + // ---------------------------------------------------------------------- + // IPow + // Computes the result of raising a number to a non-negative integral power. + // + // * T: An integral type, floating-point type, or user-defined type for which + // operator*= is defined. + // * base: the base "v" of the operation + // * exp: the exponent "i" of the operation; must be non-negative. + // + // Computes v^i, in a way that is faster than std::pow (which supports + // arbitrary real exponents). + // + // When T is a floating point type, this has the same semantics as std::pow, + // but it is much faster. When T is an integral type, computations are + // performed in the value domain of T, and overflow semantics are those of T. + // + // Input validity is DCHECKed. + template + static T IPow(T base, int exp); +}; + +// ---- CeilOrFloorOfRatio ---- +// This is a branching-free, cast-to-double-free implementation. +// +// Casting to double is in general incorrect because of loss of precision +// when casting an int64 into a double. +// +// There's a bunch of 'recipes' to compute a integer ceil (or floor) on the web, +// and most of them are incorrect. +template +IntegralType MathUtil::CeilOrFloorOfRatio(IntegralType numerator, + IntegralType denominator) { + DCHECK_NE(0, denominator) << "Division by zero is not supported."; + + const IntegralType rounded_toward_zero = numerator / denominator; + const IntegralType intermediate_product = rounded_toward_zero * denominator; + + if (ceil) { // Compile-time condition: not an actual branching + // When rounded_toward_zero is negative, then an adjustment is never needed: + // the real ratio is negative, and so rounded toward zero is the ceil. + // When rounded_toward_zero is non-negative, an adjustment is needed if the + // sign of the difference numerator - intermediate_product is the same as + // the sign of the denominator. + // + // + // Using a bool and then a static_cast to IntegralType is not strictly + // necessary, but it makes the code clear, and anyway the compiler should + // get rid of it. + const bool needs_adjustment = + (rounded_toward_zero >= 0) && + ((denominator > 0 && numerator > intermediate_product) || + (denominator < 0 && numerator < intermediate_product)); + const IntegralType adjustment = static_cast(needs_adjustment); + const IntegralType ceil_of_ratio = rounded_toward_zero + adjustment; + return ceil_of_ratio; + } else { + // Floor case: symmetrical to the previous one + const bool needs_adjustment = + (rounded_toward_zero <= 0) && + ((denominator > 0 && numerator < intermediate_product) || + (denominator < 0 && numerator > intermediate_product)); + const IntegralType adjustment = static_cast(needs_adjustment); + const IntegralType floor_of_ratio = rounded_toward_zero - adjustment; + return floor_of_ratio; + } +} + +template +IntegralType MathUtil::GCD(IntegralType x, IntegralType y) { + static_assert(std::is_unsigned::value, + "signed GCD not supported!"); + while (y != 0) { + IntegralType r = x % y; + x = y; + y = r; + } + return x; +} + +// ---- IPow ---- +// Implemented with the squared exponentiation method (a.k.a. double-and-add). +// +// Note that "exp >>= 1" is faster than "exp /= 2" on at least one platform. +template +T MathUtil::IPow(T base, int exp) { + DCHECK_GE(exp, 0); + for (T result(1);; base *= base) { + if ((exp & 1) != 0) result *= base; + exp >>= 1; + if (exp == 0) return result; + } +} + +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_MATH_MATH_UTIL_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/monitoring/cell_reader.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/monitoring/cell_reader.h new file mode 100644 index 0000000000000000000000000000000000000000..76870f80abc4df9b153d7063de37c86d20350897 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/monitoring/cell_reader.h @@ -0,0 +1,166 @@ +/* Copyright 2022 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ +#ifndef TENSORFLOW_TSL_LIB_MONITORING_CELL_READER_H_ +#define TENSORFLOW_TSL_LIB_MONITORING_CELL_READER_H_ + +#include +#include +#include +#include + +#include "absl/container/flat_hash_map.h" +#include "tsl/lib/monitoring/cell_reader-inl.h" +#include "tsl/lib/monitoring/collected_metrics.h" +#include "tsl/lib/monitoring/metric_def.h" + +namespace tsl { +namespace monitoring { +namespace testing { + +// `CellReader` is a testing class which allows a user to read the current value +// of a tfstreamz cell. +// +// For tfstreamz metrics like the following: +// +// ``` +// auto* test_counter = monitoring::Counter<1>::New( +// "/tensorflow/monitoring/test/counter", "label", +// "Test tfstreamz counter."); +// auto* test_sampler = monitoring::Sampler<2>::New( +// "/tensorflow/monitoring/test/sampler", "label1", "label2", +// "Test tfstreamz sampler."); +// auto* test_string_gauge = monitoring::Gauge<2>::New( +// "/tensorflow/monitoring/test/gauge", "label1", "label2", +// "Test tfstreamz gauge."); +// auto* test_percentiles = monitoring::PercentileSampler<2>::New( +// {"/tensorflow/monitoring/test/percentiles", "Test percentiles.", +// "label1", "label2"}, +// /*percentiles=*/{25.0, 50.0, 80.0, 90.0, 95.0, 99.0}, +// /*max_samples=*/1024, +// monitoring::UnitOfMeasure::kNumber); +// ``` +// +// one could read the exported tfstreamz values using a `CellReader` like this: +// +// ``` +// using tensorflow::monitoring::testing::Histogram; +// using tensorflow::monitoring::testing::Percentiles; +// +// CellReader counter_reader("/tensorflow/monitoring/test/counter"); +// CellReader sampler_reader("/tensorflow/monitoring/test/sampler"); +// CellReader gauge_reader("/tensorflow/monitoring/test/gauge"); +// CellReader percentiles_reader( +// "/tensorflow/monitoring/test/percentiles"); +// EXPECT_EQ(counter_reader.Delta("label_value"), 0); +// EXPECT_FLOAT_EQ(sampler_reader.Delta("x", "y").num(), 0.0); +// EXPECT_EQ(gauge_reader.Delta("x", "y"), ""); +// EXPECT_EQ(percentiles_reader.Delta("x", "y").num(), 0); +// +// CodeThatUpdateMetrics(); +// EXPECT_EQ(counter_reader.Delta("label_value"), 5); +// Histogram histogram = sampler_reader.Delta("x", "y"); +// EXPECT_FLOAT_EQ(histogram.num(), 5.0); +// EXPECT_GT(histogram.sum(), 0.0); +// EXPECT_EQ(gauge_reader.Delta("x", "y"), "gauge value"); +// EXPECT_EQ(percentiles_reader.Delta("x", "y").num(), 5); +// ``` +template +class CellReader { + public: + // Constructs a `CellReader` that reads values exported for `metric_name`. + // + // REQUIRES: a tfstreamz with `metric_name` exists. Otherwise, the + // `CellReader` will construct without issue, but the `Read` and `Delta` calls + // will CHECK-fail. + explicit CellReader(const std::string& metric_name); + virtual ~CellReader() = default; + CellReader(const CellReader&) = delete; + CellReader& operator=(const CellReader&) = delete; + + // Returns the current value of the cell with the given `labels`. A metric can + // have zero or more labels, depending on its definition. If the metric has + // not been modified, it returns a default value appropriate for `ValueType`. + // + // REQUIRES: The tfstreamz exists, and `labels` contains a correct number of + // labels per tfstreamz definition. Otherwise, it will CHECK-fail. + template + ValueType Read(const LabelType&... labels); + + // Returns the difference in the value of this cell since the last time + // `Delta()` was called for this cell, or when the `CellReader` was created, + // whichever was most recent. If the metric has not been modified, it returns + // a default value appropriate for `ValueType`. `Delta` is not supported for + // string and bool gauges. + // + // REQUIRES: The tfstreamz exists, `labels` contains a correct number of + // labels per tfstreamz definition, and the ValueType is not string or bool. + // Otherwise, it will CHECK-fail. + template + ValueType Delta(const LabelType&... labels); + + private: + const std::string metric_name_; + + // Metrics collected at the time of construction. It is needed because data + // may have been collected when this object is constructed. The initial values + // need to be subtracted from the result of the `Read()` call to compute the + // correct values. + std::unique_ptr initial_metrics_; + + // Records the value of the cells since the last time `Delta()` was called. + // This is used to compute the next delta value. + absl::flat_hash_map, ValueType> delta_map_; +}; + +template +CellReader::CellReader(const std::string& metric_name) + : metric_name_(metric_name), initial_metrics_(internal::CollectMetrics()) {} + +template +template +ValueType CellReader::Read(const LabelType&... labels) { + std::vector labels_list{labels...}; + std::unique_ptr metrics = internal::CollectMetrics(); + ValueType value = internal::GetLatestValueOrDefault( + *metrics, metric_name_, labels_list); + if (internal::GetMetricKind(*metrics, metric_name_) == MetricKind::kGauge) { + return value; + } + ValueType initial_value = internal::GetLatestValueOrDefault( + *initial_metrics_, metric_name_, labels_list); + return internal::GetDelta(value, initial_value); +} + +template +template +ValueType CellReader::Delta(const LabelType&... labels) { + std::vector labels_list{labels...}; + std::unique_ptr metrics = internal::CollectMetrics(); + ValueType value = internal::GetLatestValueOrDefault( + *metrics, metric_name_, labels_list); + ValueType initial_value = internal::GetLatestValueOrDefault( + *initial_metrics_, metric_name_, labels_list); + if (delta_map_.contains(labels_list)) { + initial_value = delta_map_[labels_list]; + } + delta_map_[labels_list] = value; + return internal::GetDelta(value, initial_value); +} + +} // namespace testing +} // namespace monitoring +} // namespace tsl + +#endif // TENSORFLOW_TSL_LIB_MONITORING_CELL_READER_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/monitoring/collected_metrics.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/monitoring/collected_metrics.h new file mode 100644 index 0000000000000000000000000000000000000000..8582594922adf23e52f7f6c83ed853dc2a721402 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tsl/lib/monitoring/collected_metrics.h @@ -0,0 +1,156 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +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. +==============================================================================*/ + +// Standard format in which the metrics are collected, before being exported. +// These are to be used only by the CollectionRegistry and exporters which +// collect metrics using the CollectionRegistry. + +#ifndef TENSORFLOW_TSL_LIB_MONITORING_COLLECTED_METRICS_H_ +#define TENSORFLOW_TSL_LIB_MONITORING_COLLECTED_METRICS_H_ + +#include +#include +#include +#include + +#include "tsl/lib/monitoring/metric_def.h" +#include "tsl/lib/monitoring/types.h" +#include "tsl/protobuf/histogram.pb.h" + +namespace tsl { +namespace monitoring { + +// A metric is a statistic about a monitorable entity. +// +// Metrics are named with path-like strings, which must conform to the regular +// expression (/[a-zA-Z0-9_-]+)+. For example: +// +// /proc/cpu_usage +// /rpc/client/count +// +// Metrics may optionally have labels, which are additional dimensions used to +// identify the metric's values. For example, the metric /rpc/client/count +// might have two labels named "rpc_service" and "rpc_method". +// +// A label name must be an identifier, which conform to the regular expression +// [a-zA-Z_][a-zA-Z_0-9]*, and is only unique within the context of the metric +// it is a label for. +// +// MetricDescriptor defines the structure of the metric (e.g. the fact that it's +// a counter and that it has two labels named "rpc_service" and "rpc_method"). +// Individual points will provide a value for the metric (e.g. the counter +// value) and specific values for each of the labels. +// +// There's no scoping relationship between metrics and monitorable entities: the +// metric /rpc/client/count should be defined the same way no matter which +// monitorable entity is exporting it. +struct MetricDescriptor { + // Metric names are path-like. E.g., "/mycomponent/mymetric". + string name; + + // A human-readable description of what this metric measures. + string description; + + // Label names for the metric. + // See the example in the top level comment for MetricDescriptor. + std::vector label_names; + + MetricKind metric_kind; + + ValueType value_type; +}; + +struct Point { + // Usually a Point should provide a |label| field for each of the labels + // defined in the corresponding MetricDescriptor. During transitions in + // metric definitions, however, there may be times when a Point provides more + // or fewer labels than those that appear in the MetricDescriptor. + struct Label { + // The |name| field must match the |label_name| field in the + // MetricDescriptor for this Point. + string name; + string value; + }; + std::vector