{"id":16819579,"url":"https://github.com/slowli/ocl-convolution","last_synced_at":"2025-03-22T03:31:34.218Z","repository":{"id":48185923,"uuid":"184795427","full_name":"slowli/ocl-convolution","owner":"slowli","description":"OpenCL-accelerated 2D convolutions","archived":false,"fork":false,"pushed_at":"2024-03-28T03:27:00.000Z","size":1173,"stargazers_count":8,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-18T07:43:15.054Z","etag":null,"topics":["convolutional-neural-networks","deep-learning","opencl"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slowli.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-03T17:32:23.000Z","updated_at":"2023-09-30T14:33:41.000Z","dependencies_parsed_at":"2023-01-31T12:10:14.037Z","dependency_job_id":"f99e05ba-7d19-4af9-b813-6472af9d62e7","html_url":"https://github.com/slowli/ocl-convolution","commit_stats":{"total_commits":109,"total_committers":4,"mean_commits":27.25,"dds":0.07339449541284404,"last_synced_commit":"2e6fda9beaa4055f71504336e1011887dab6183d"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slowli%2Focl-convolution","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slowli%2Focl-convolution/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slowli%2Focl-convolution/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slowli%2Focl-convolution/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slowli","download_url":"https://codeload.github.com/slowli/ocl-convolution/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244902929,"owners_count":20529114,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["convolutional-neural-networks","deep-learning","opencl"],"created_at":"2024-10-13T10:53:54.150Z","updated_at":"2025-03-22T03:31:33.730Z","avatar_url":"https://github.com/slowli.png","language":"Rust","readme":"# OpenCL-accelerated 2D convolutions for Rust\n\n[![Build Status](https://github.com/slowli/ocl-convolution/workflows/CI/badge.svg?branch=master)](https://github.com/slowli/ocl-convolution/actions) \n[![License: MIT OR Apache-2.0](https://img.shields.io/badge/License-MIT%2FApache--2.0-blue)](https://github.com/slowli/ocl-convolution#license)\n![rust 1.65+ required](https://img.shields.io/badge/rust-1.65+-blue.svg?label=Required%20Rust) \n\n**Documentation:** [![Docs.rs](https://docs.rs/ocl-convolution/badge.svg)](https://docs.rs/ocl-convolution/)\n[![crate docs (master)](https://img.shields.io/badge/master-yellow.svg?label=docs)](https://slowli.github.io/ocl-convolution/ocl_convolution/) \n\nThis library provides 2D [convolutions] accelerated with [OpenCL]. Convolutions\nare particularly useful for deep learning tasks, such as image recognition;\nthey are a basic building block for [convolutional neural networks][cnn].\n\nThe library is intended mostly for quick-and-dirty hacking in deep learning research,\nin which one needs a separate spatial convolution primitive. Full-scale\nDL frameworks (TensorFlow, PyTorch, etc.) will most probably be a more robust and scalable\ntool for more high-level tasks.\n\n## Usage\n\nAdd this to your `Crate.toml`:\n\n```toml\n[dependencies]\nocl-convolution = \"0.3.0\"\n``` \n\nBasic floating-point convolution can be implemented as follows:\n\n```rust\nuse ndarray::Array4;\nuse rand::{Rng, thread_rng};\nuse ocl_convolution::{Convolution, FeatureMap, Params};\n\nlet convolution = Convolution::f32(3)?.build(Params {\n    strides: [1, 1],\n    pads: [0; 4],\n    dilation: [1, 1],\n    groups: 1,\n})?;\n\n// Generate random signal with 6x6 spatial dims and 3 channels.\nlet mut rng = thread_rng();\nlet signal = Array4::from_shape_fn([1, 6, 6, 3], |_| rng.gen_range(-1.0..=1.0));\n// Construct two 3x3 spatial filters.\nlet filters = Array4::from_shape_fn([2, 3, 3, 3], |_| rng.gen_range(-1.0..=1.0));\n// Perform the convolution. The output must have 4x4 spatial dims\n// and contain 2 channels (1 per each filter). The output layout will\n// be the same as in the signal.\nlet output = convolution.compute(\n    // `FeatureMap` wraps `ArrayView4` with information about\n    // memory layout (which is \"channels-last\" / NHWC in this case).\n    FeatureMap::nhwc(\u0026signal),\n    \u0026filters,\n)?;\nassert_eq!(output.shape(), [1, 4, 4, 2]);\n\nOk::\u003c_, ocl::Error\u003e(())\n```\n\nSee crate docs for more examples of usage.\n\n### Installing OpenCL\n\nOpenCL has [a variety of implementations](https://www.khronos.org/opencl/resources).\nFor quick testing, one may use [POCL](https://github.com/pocl/pocl); it is open source\nand not tied to hardware (at the cost of being CPU-based, i.e., orders of magnitude\nslower than OpenCL implementations by GPU vendors).\nPOCL [can be installed from sources](http://portablecl.org/docs/html/install.html)\nwith the commands like in the [installation script](install-pocl.sh)\n(tested on Ubuntu 22.04).\n\n## Contributing\n\nAll contributions are welcome! See [the contributing guide](CONTRIBUTING.md) to help\nyou get involved.\n\n## License\n\nLicensed under either of [Apache License, Version 2.0](LICENSE-APACHE)\nor [MIT license](LICENSE-MIT) at your option.\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in `ocl-convolution` by you, as defined in the Apache-2.0 license,\nshall be dual licensed as above, without any additional terms or conditions.\n\n[convolutions]: https://en.wikipedia.org/wiki/Convolution\n[opencl]: https://www.khronos.org/opencl/\n[cnn]: https://en.wikipedia.org/wiki/Convolutional_neural_network\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslowli%2Focl-convolution","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslowli%2Focl-convolution","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslowli%2Focl-convolution/lists"}