109 references to RangeUtil
Microsoft.ML.TorchSharp (109)
AutoFormerV2\Anchors.cs (11)
106
anchors[
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(2..)] = baseSize * torch.tile(scales, new long[] { 2, ratios.Length }).transpose(1, 0);
109
var areas = torch.mul(anchors[
RangeUtil
.ToTensorIndex(..), 2], anchors[
RangeUtil
.ToTensorIndex(..), 3]);
112
anchors[
RangeUtil
.ToTensorIndex(..), 2] = torch.sqrt(areas / torch.repeat_interleave(ratios, new long[] { scales.Length }));
113
anchors[
RangeUtil
.ToTensorIndex(..), 3] = torch.mul(anchors[
RangeUtil
.ToTensorIndex(..), 2], torch.repeat_interleave(ratios, new long[] { scales.Length }));
116
anchors[
RangeUtil
.ToTensorIndex(..), torch.TensorIndex.Tensor(torch.tensor(new long[] { 0, 2 }, dtype: torch.int64))] -= torch.tile(anchors[
RangeUtil
.ToTensorIndex(..), 2] * 0.5, new long[] { 2, 1 }).T;
117
anchors[
RangeUtil
.ToTensorIndex(..), torch.TensorIndex.Tensor(torch.tensor(new long[] { 1, 3 }, dtype: torch.int64))] -= torch.tile(anchors[
RangeUtil
.ToTensorIndex(..), 3] * 0.5, new long[] { 2, 1 }).T;
AutoFormerV2\Attention.cs (1)
116
var attn = (torch.matmul(q, k.transpose(-2, -1)) * this.scale) + this.attention_biases[
RangeUtil
.ToTensorIndex(..), this.attention_bias_idxs];
AutoFormerV2\AutoFormerV2Block.cs (3)
130
x = x[
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..h),
RangeUtil
.ToTensorIndex(..w)].contiguous();
AutoFormerV2\ObjectDetectionTrainer.cs (13)
387
transMidTensor[
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..image.Height),
RangeUtil
.ToTensorIndex(..image.Width)] = reMidTensor / 255.0;
410
labelTensor[
RangeUtil
.ToTensorIndex(..), i, 0] = x0;
411
labelTensor[
RangeUtil
.ToTensorIndex(..), i, 1] = y0;
412
labelTensor[
RangeUtil
.ToTensorIndex(..), i, 2] = x1;
413
labelTensor[
RangeUtil
.ToTensorIndex(..), i, 3] = y1;
414
labelTensor[
RangeUtil
.ToTensorIndex(..), i, 4] = cl;
922
transMidTensor[
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..image.Height),
RangeUtil
.ToTensorIndex(..image.Width)] = reMidTensor / 255.0;
Loss\FocalLoss.cs (41)
43
var anchor = anchors[0,
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..)];
45
var anchorWidths = anchor[
RangeUtil
.ToTensorIndex(..), 2] - anchor[
RangeUtil
.ToTensorIndex(..), 0];
46
var anchorHeights = anchor[
RangeUtil
.ToTensorIndex(..), 3] - anchor[
RangeUtil
.ToTensorIndex(..), 1];
47
var anchorCtrX = anchor[
RangeUtil
.ToTensorIndex(..), 0] + (0.5 * anchorWidths);
48
var anchorCtrY = anchor[
RangeUtil
.ToTensorIndex(..), 1] + (0.5 * anchorHeights);
52
var classification = classifications[j,
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..)];
53
var regression = regressions[j,
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..)];
55
var bboxAnnotation = annotations[j,
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..)];
56
bboxAnnotation = bboxAnnotation[bboxAnnotation[
RangeUtil
.ToTensorIndex(..), 4] != -1];
76
var iou = CalcIou(anchors[0,
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..)], bboxAnnotation[
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..4)]); // num_anchors x num_annotations
128
var gtWidths = assignedAnnotations[
RangeUtil
.ToTensorIndex(..), 2] - assignedAnnotations[
RangeUtil
.ToTensorIndex(..), 0];
129
var gtHeights = assignedAnnotations[
RangeUtil
.ToTensorIndex(..), 3] - assignedAnnotations[
RangeUtil
.ToTensorIndex(..), 1];
130
var gtCtrX = assignedAnnotations[
RangeUtil
.ToTensorIndex(..), 0] + (0.5 * gtWidths);
131
var gtCtrY = assignedAnnotations[
RangeUtil
.ToTensorIndex(..), 1] + (0.5 * gtHeights);
181
var area = (b[
RangeUtil
.ToTensorIndex(..), 2] - b[
RangeUtil
.ToTensorIndex(..), 0]) * (b[
RangeUtil
.ToTensorIndex(..), 3] - b[
RangeUtil
.ToTensorIndex(..), 1]);
183
var iw = torch.minimum(input: torch.unsqueeze(a[
RangeUtil
.ToTensorIndex(..), 2], dim: 1), b[
RangeUtil
.ToTensorIndex(..), 2]) -
184
torch.maximum(input: torch.unsqueeze(a[
RangeUtil
.ToTensorIndex(..), 0], 1), b[
RangeUtil
.ToTensorIndex(..), 0]);
185
var ih = torch.minimum(input: torch.unsqueeze(a[
RangeUtil
.ToTensorIndex(..), 3], dim: 1), b[
RangeUtil
.ToTensorIndex(..), 3]) -
186
torch.maximum(input: torch.unsqueeze(a[
RangeUtil
.ToTensorIndex(..), 1], 1), b[
RangeUtil
.ToTensorIndex(..), 1]);
191
var ua = torch.unsqueeze((a[
RangeUtil
.ToTensorIndex(..), 2] - a[
RangeUtil
.ToTensorIndex(..), 0]) * (a[
RangeUtil
.ToTensorIndex(..), 3] - a[
RangeUtil
.ToTensorIndex(..), 1]), dim: 1) + area - (iw * ih);
Utils\ImageUtils.cs (40)
53
var scores1 = torch.squeeze(classification[
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..), i], null);
111
var x1 = boxes[
RangeUtil
.ToTensorIndex(..), 0];
112
var y1 = boxes[
RangeUtil
.ToTensorIndex(..), 1];
113
var x2 = boxes[
RangeUtil
.ToTensorIndex(..), 2];
114
var y2 = boxes[
RangeUtil
.ToTensorIndex(..), 3];
120
var order = _order[
RangeUtil
.ToTensorIndex(..)];
136
var xx1 = x1[order[
RangeUtil
.ToTensorIndex(1..)]].clamp(min: x1[i]); // [N - 1,]
137
var yy1 = y1[order[
RangeUtil
.ToTensorIndex(1..)]].clamp(min: y1[i]);
138
var xx2 = x2[order[
RangeUtil
.ToTensorIndex(1..)]].clamp(max: x2[i]);
139
var yy2 = y2[order[
RangeUtil
.ToTensorIndex(1..)]].clamp(max: y2[i]);
142
var iou = inter / (areas[i] + areas[order[
RangeUtil
.ToTensorIndex(1..)]] - inter); // [N-1, ]
170
var widths = boxes[
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..), 2] - boxes[
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..), 0];
171
var heights = boxes[
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..), 3] - boxes[
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..), 1];
172
var ctrX = boxes[
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..), 0] + (0.5 * widths);
173
var ctrY = boxes[
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..), 1] + (0.5 * heights);
175
var dx = (deltas[
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..), 0] * std[0]) + mean[0];
176
var dy = (deltas[
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..), 1] * std[1]) + mean[1];
177
var dw = (deltas[
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..), 2] * std[2]) + mean[2];
178
var dh = (deltas[
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..), 3] * std[3]) + mean[3];
213
var clippedBoxesX0 = torch.clamp(boxes[
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..), 0], min: 0);
214
var clippedBoxesY0 = torch.clamp(boxes[
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..), 1], min: 0);
216
var clippedBoxesX1 = torch.clamp(boxes[
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..), 2], max: width);
217
var clippedBoxesY1 = torch.clamp(boxes[
RangeUtil
.ToTensorIndex(..),
RangeUtil
.ToTensorIndex(..), 3], max: height);