MCPcopy Create free account
hub / github.com/LBANN/lbann / set

Method set

src/utils/miopen.cpp:211–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209}
210
211void TensorDescriptor::set(miopenDataType_t data_type,
212 std::vector<int> dims_in,
213 std::vector<int> strides_in)
214{
215
216 // Check that arguments are valid
217 if (dims_in.empty()) {
218 LBANN_ERROR("attempted to set MIOpen tensor descriptor with no dimensions");
219 }
220 if (!strides_in.empty() && dims_in.size() != strides_in.size()) {
221 LBANN_ERROR("attempted to set MIOpen tensor descriptor ",
222 "with mismatched dimensions (",
223 dims_in.size(),
224 ") ",
225 "and strides (",
226 strides_in.size(),
227 ")");
228 }
229
230 std::vector<int> dims = std::move(dims_in), strides = std::move(strides_in);
231 if (dims.size() < 4) {
232 switch (dims.size()) {
233 case 2:
234 dims = {dims[0], 1, dims[1], 1};
235 strides = {};
236 break;
237 case 3:
238 dims = {dims[0], 1, dims[1], dims[2]};
239 strides = {};
240 break;
241 default:
242 LBANN_ERROR("Dims of size 1. Don't know what to do.");
243 break;
244 }
245 }
246
247 // Assume data is contiguous if no strides are provided
248 // Note (trb 12/29/2020): MIOpen only accepts contiguous strides.
249 if (strides.empty()) {
250 strides.resize(dims.size(), 1);
251 for (int i = strides.size() - 1; i > 0; --i) {
252 strides[i - 1] = strides[i] * dims[i];
253 }
254 }
255
256 // Set MIOpen object
257 create();
258 CHECK_MIOPEN(miopenSetTensorDescriptor(desc_,
259 data_type,
260 dims.size(),
261 dims.data(),
262 strides.data()));
263}
264
265// -----------------------------
266// DropoutDescriptor

Callers 5

ConvolutionDescriptorMethod · 0.45
PoolingDescriptorMethod · 0.45
LRNDescriptorMethod · 0.45

Calls 5

to_miopenFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected