MCPcopy Create free account
hub / github.com/NVIDIA/DALI / ConvertTFRecordDefaultValue

Function ConvertTFRecordDefaultValue

dali/python/backend_impl.cc:2176–2199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2174using TFValue = TFFeature::Value;
2175
2176TFValue ConvertTFRecordDefaultValue(TFFeatureType type, py::object val) {
2177 PyObject *ptr = val.ptr();
2178 TFValue ret = {};
2179 switch (type) {
2180 case TFFeatureType::int64:
2181 DALI_ENFORCE(PyInt_Check(ptr) || PyLong_Check(ptr),
2182 "Invalid type for default value, expected int.");
2183 ret.int64 = PyInt_AsLong(ptr);
2184 break;
2185 case TFFeatureType::string:
2186 DALI_ENFORCE(PyStr_Check(ptr),
2187 "Invalid type for default value, expected string.");
2188 ret.str = PyStr_AsString(ptr);
2189 break;
2190 case TFFeatureType::float32:
2191 DALI_ENFORCE(PyFloat_Check(ptr),
2192 "Invalid type for default value, expected float.");
2193 ret.float32 = PyFloat_AsDouble(ptr);
2194 break;
2195 default:
2196 DALI_FAIL("Invalid type for default value, expected string, int or float.");
2197 }
2198 return ret;
2199}
2200#endif // DALI_BUILD_PROTO3
2201
2202void ExposeBufferPolicyFunctions(py::module &m) {

Callers 1

PYBIND11_MODULEFunction · 0.85

Calls 1

ptrMethod · 0.45

Tested by

no test coverage detected