Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/auto-assign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: Auto Assign
on:
issues:
types: [opened]
pull_request:
types: [opened]
jobs:
run:
runs-on: ubuntu-latest
Expand All @@ -16,4 +14,3 @@ jobs:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
assignees: Ra4ster
numOfAssignee: 1
25 changes: 25 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,31 @@ if(DEEPITY_USE_ONEDNN)
)
FetchContent_MakeAvailable(onednn)
set(DEEPITY_DNNL_TARGET dnnl)

# Silence warnings from oneDNN's own source -- it's a vendored
# dependency we don't maintain, its warnings aren't actionable
# here, and they'd otherwise show up next to this project's own
# in every build log. oneDNN's own CMakeLists.txt spreads its
# library across several targets (dnnl, dnnl_common, dnnl_cpu,
# dnnl_cpu_x64, ...) defined in nested subdirectories, so this
# walks every directory FetchContent pulled in rather than
# naming targets by hand -- new oneDNN versions can rename or
# add targets without silently losing this suppression.
function(deepity_silence_warnings_recursive dir)
get_property(targets DIRECTORY "${dir}" PROPERTY BUILDSYSTEM_TARGETS)
foreach(target ${targets})
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(${target} PRIVATE -w)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_options(${target} PRIVATE /w)
endif()
endforeach()
get_property(subdirs DIRECTORY "${dir}" PROPERTY SUBDIRECTORIES)
foreach(subdir ${subdirs})
deepity_silence_warnings_recursive("${subdir}")
endforeach()
endfunction()
deepity_silence_warnings_recursive("${onednn_SOURCE_DIR}")
endif()
endif()

Expand Down
66 changes: 44 additions & 22 deletions bindings/QuantFormatBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ void BindQuantType(nb::module_& m, const char* className, const char* formatDoc)
nb::arg("value"),
"Rounds value to the nearest representable grid point (saturating at the "
"format's max magnitude).")
.def_rw("bits", &QuantT::bits, "Raw packed bit pattern (bit 3 = sign, bits 2:0 = "
"magnitude index).")
.def_rw("bits",
&QuantT::bits,
"Raw packed bit pattern (bit 3 = sign, bits 2:0 = "
"magnitude index).")
.def("__float__", [](const QuantT& self) { return (float)self; })
.def("__repr__",
[className](const QuantT& self)
Expand All @@ -45,38 +47,58 @@ void BindQuantType(nb::module_& m, const char* className, const char* formatDoc)
void bind_quant_formats(nb::module_& m)
{
BindQuantType<Deep::Fp4E2M1Value>(
m, "Fp4E2M1Value",
m,
"Fp4E2M1Value",
"FP4 E2M1 (1 sign + 2 exponent + 1 mantissa bit) quantization grid value.");
BindQuantType<Deep::Posit4_0Value>(m, "Posit4_0Value", "Posit<4,0> (es=0) quantization grid value.");
BindQuantType<Deep::Posit4_1Value>(m, "Posit4_1Value", "Posit<4,1> (es=1) quantization grid value.");
BindQuantType<Deep::Posit4_2Value>(m, "Posit4_2Value", "Posit<4,2> (es=2) quantization grid value.");
BindQuantType<Deep::Posit4_0Value>(
m, "Posit4_0Value", "Posit<4,0> (es=0) quantization grid value.");
BindQuantType<Deep::Posit4_1Value>(
m, "Posit4_1Value", "Posit<4,1> (es=1) quantization grid value.");
BindQuantType<Deep::Posit4_2Value>(
m, "Posit4_2Value", "Posit<4,2> (es=2) quantization grid value.");

m.def("decode_fp4_e2m1", &Deep::DecodeFp4E2M1, nb::arg("bits"),
m.def("decode_fp4_e2m1",
&Deep::DecodeFp4E2M1,
nb::arg("bits"),
"Decodes a raw Fp4E2M1Value bit pattern (0-15) to its real value.");
m.def("encode_fp4_e2m1", &Deep::EncodeFp4E2M1, nb::arg("value"),
m.def("encode_fp4_e2m1",
&Deep::EncodeFp4E2M1,
nb::arg("value"),
"Encodes a float to its nearest Fp4E2M1Value bit pattern.");
m.def("decode_posit4_0", &Deep::DecodePosit4_0, nb::arg("bits"),
m.def("decode_posit4_0",
&Deep::DecodePosit4_0,
nb::arg("bits"),
"Decodes a raw Posit4_0Value bit pattern (0-15) to its real value.");
m.def("encode_posit4_0", &Deep::EncodePosit4_0, nb::arg("value"),
m.def("encode_posit4_0",
&Deep::EncodePosit4_0,
nb::arg("value"),
"Encodes a float to its nearest Posit4_0Value bit pattern.");
m.def("decode_posit4_1", &Deep::DecodePosit4_1, nb::arg("bits"),
m.def("decode_posit4_1",
&Deep::DecodePosit4_1,
nb::arg("bits"),
"Decodes a raw Posit4_1Value bit pattern (0-15) to its real value.");
m.def("encode_posit4_1", &Deep::EncodePosit4_1, nb::arg("value"),
m.def("encode_posit4_1",
&Deep::EncodePosit4_1,
nb::arg("value"),
"Encodes a float to its nearest Posit4_1Value bit pattern.");
m.def("decode_posit4_2", &Deep::DecodePosit4_2, nb::arg("bits"),
m.def("decode_posit4_2",
&Deep::DecodePosit4_2,
nb::arg("bits"),
"Decodes a raw Posit4_2Value bit pattern (0-15) to its real value.");
m.def("encode_posit4_2", &Deep::EncodePosit4_2, nb::arg("value"),
m.def("encode_posit4_2",
&Deep::EncodePosit4_2,
nb::arg("value"),
"Encodes a float to its nearest Posit4_2Value bit pattern.");

// The grids themselves, for introspection -- each format's 8
// non-negative magnitude levels (index 0 is always 0), mirroring
// QuantFormat.h's own kFp4E2M1Magnitudes/kPosit4_*Magnitudes tables.
m.attr("FP4_E2M1_MAGNITUDES") = std::vector<float>(
std::begin(Deep::detail::kFp4E2M1Magnitudes), std::end(Deep::detail::kFp4E2M1Magnitudes));
m.attr("POSIT4_0_MAGNITUDES") = std::vector<float>(
std::begin(Deep::detail::kPosit4_0Magnitudes), std::end(Deep::detail::kPosit4_0Magnitudes));
m.attr("POSIT4_1_MAGNITUDES") = std::vector<float>(
std::begin(Deep::detail::kPosit4_1Magnitudes), std::end(Deep::detail::kPosit4_1Magnitudes));
m.attr("POSIT4_2_MAGNITUDES") = std::vector<float>(
std::begin(Deep::detail::kPosit4_2Magnitudes), std::end(Deep::detail::kPosit4_2Magnitudes));
m.attr("FP4_E2M1_MAGNITUDES") = std::vector<float>(std::begin(Deep::detail::kFp4E2M1Magnitudes),
std::end(Deep::detail::kFp4E2M1Magnitudes));
m.attr("POSIT4_0_MAGNITUDES") = std::vector<float>(std::begin(Deep::detail::kPosit4_0Magnitudes),
std::end(Deep::detail::kPosit4_0Magnitudes));
m.attr("POSIT4_1_MAGNITUDES") = std::vector<float>(std::begin(Deep::detail::kPosit4_1Magnitudes),
std::end(Deep::detail::kPosit4_1Magnitudes));
m.attr("POSIT4_2_MAGNITUDES") = std::vector<float>(std::begin(Deep::detail::kPosit4_2Magnitudes),
std::end(Deep::detail::kPosit4_2Magnitudes));
}
7 changes: 5 additions & 2 deletions include/deepity/backend/CPUBackendT.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include <deepity/backend/IComputeBackend.h>
#include <deepity/backend/Tensor.h>
#include <deepity/utils/activations/ActivationMacros.h> // RESTRICT
#include <stdexcept>

namespace Deep
Expand Down Expand Up @@ -136,8 +137,10 @@ class CPUBackendT : public IComputeBackendT<T, AccumT>
"SimplePCLayer stays on the non-templated CPUBackend in this templating pass.");
}

AccumT ComputeErrorAndEnergy(T* e, const T* z, const T* mu, size_t n) noexcept override;
void ComputeError(T* e, const T* z, const T* mu, size_t n) noexcept override;
AccumT ComputeErrorAndEnergy(T* RESTRICT e, const T* RESTRICT z, const T* RESTRICT mu,
size_t n) noexcept override;
void ComputeError(T* RESTRICT e, const T* RESTRICT z, const T* RESTRICT mu,
size_t n) noexcept override;

bool TryComputeErrorAndActivation(ActivationType, T*, T*, const T*, const T*,
size_t) noexcept override
Expand Down
3 changes: 2 additions & 1 deletion include/deepity/utils/ModelIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ class ModelIO
const char* expectedDtype = DTypeTag<ElementType>::Name();
if (!fileDtype.empty() && fileDtype != expectedDtype)
{
throw std::runtime_error("ModelIO::Load: dtype mismatch for '" + key + "' -- file "
throw std::runtime_error("ModelIO::Load: dtype mismatch for '" + key +
"' -- file "
"has " +
fileDtype + ", network expects " + expectedDtype + ".");
}
Expand Down
Loading
Loading